Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:43 +0200
committerJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:48 +0200
commit60eb94bc0e35fecc2e52f4436798a8a1ae58d11d (patch)
tree6819174f2ec6e8afe560d965313bb2ca8b628e3c
parenta19202faf578a9440ba4c2300e5a47bef80917d1 (diff)
fib_rules: return 0 directly if an exactly same rule exists
when NLM_F_EXCL not supplied (bnc#1012628).
-rw-r--r--patches.kernel.org/5.1.3-017-fib_rules-return-0-directly-if-an-exactly-same-.patch55
-rw-r--r--series.conf1
2 files changed, 56 insertions, 0 deletions
diff --git a/patches.kernel.org/5.1.3-017-fib_rules-return-0-directly-if-an-exactly-same-.patch b/patches.kernel.org/5.1.3-017-fib_rules-return-0-directly-if-an-exactly-same-.patch
new file mode 100644
index 0000000000..e8d00eeeb3
--- /dev/null
+++ b/patches.kernel.org/5.1.3-017-fib_rules-return-0-directly-if-an-exactly-same-.patch
@@ -0,0 +1,55 @@
+From: Hangbin Liu <liuhangbin@gmail.com>
+Date: Tue, 7 May 2019 17:11:18 +0800
+Subject: [PATCH] fib_rules: return 0 directly if an exactly same rule exists
+ when NLM_F_EXCL not supplied
+References: bnc#1012628
+Patch-mainline: 5.1.3
+Git-commit: e9919a24d3022f72bcadc407e73a6ef17093a849
+
+[ Upstream commit e9919a24d3022f72bcadc407e73a6ef17093a849 ]
+
+With commit 153380ec4b9 ("fib_rules: Added NLM_F_EXCL support to
+fib_nl_newrule") we now able to check if a rule already exists. But this
+only works with iproute2. For other tools like libnl, NetworkManager,
+it still could add duplicate rules with only NLM_F_CREATE flag, like
+
+[localhost ~ ]# ip rule
+0: from all lookup local
+32766: from all lookup main
+32767: from all lookup default
+100000: from 192.168.7.5 lookup 5
+100000: from 192.168.7.5 lookup 5
+
+As it doesn't make sense to create two duplicate rules, let's just return
+0 if the rule exists.
+
+Fixes: 153380ec4b9 ("fib_rules: Added NLM_F_EXCL support to fib_nl_newrule")
+Reported-by: Thomas Haller <thaller@redhat.com>
+Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ net/core/fib_rules.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
+index ffbb827723a2..c49b752ea7eb 100644
+--- a/net/core/fib_rules.c
++++ b/net/core/fib_rules.c
+@@ -756,9 +756,9 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
+ if (err)
+ goto errout;
+
+- if ((nlh->nlmsg_flags & NLM_F_EXCL) &&
+- rule_exists(ops, frh, tb, rule)) {
+- err = -EEXIST;
++ if (rule_exists(ops, frh, tb, rule)) {
++ if (nlh->nlmsg_flags & NLM_F_EXCL)
++ err = -EEXIST;
+ goto errout_free;
+ }
+
+--
+2.21.0
+
diff --git a/series.conf b/series.conf
index 492117899f..18fd2bbf51 100644
--- a/series.conf
+++ b/series.conf
@@ -102,6 +102,7 @@
patches.kernel.org/5.1.3-014-bonding-fix-arp_validate-toggling-in-active-bac.patch
patches.kernel.org/5.1.3-015-bridge-Fix-error-path-for-kobject_init_and_add.patch
patches.kernel.org/5.1.3-016-dpaa_eth-fix-SG-frame-cleanup.patch
+ patches.kernel.org/5.1.3-017-fib_rules-return-0-directly-if-an-exactly-same-.patch
########################################################
# Build fixes that apply to the vanilla kernel too.