1 From foo@baz Sun 09 Jun 2019 09:24:16 AM CEST
2 From: Hangbin Liu <liuhangbin@gmail.com>
3 Date: Wed, 5 Jun 2019 12:27:14 +0800
4 Subject: Revert "fib_rules: return 0 directly if an exactly same rule exists when NLM_F_EXCL not supplied"
6 From: Hangbin Liu <liuhangbin@gmail.com>
8 [ Upstream commit 4970b42d5c362bf873982db7d93245c5281e58f4 ]
10 This reverts commit e9919a24d3022f72bcadc407e73a6ef17093a849.
12 Nathan reported the new behaviour breaks Android, as Android just add
13 new rules and delete old ones.
15 If we return 0 without adding dup rules, Android will remove the new
16 added rules and causing system to soft-reboot.
18 Fixes: e9919a24d302 ("fib_rules: return 0 directly if an exactly same rule exists when NLM_F_EXCL not supplied")
19 Reported-by: Nathan Chancellor <natechancellor@gmail.com>
20 Reported-by: Yaro Slav <yaro330@gmail.com>
21 Reported-by: Maciej Żenczykowski <zenczykowski@gmail.com>
22 Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
23 Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
24 Tested-by: Nathan Chancellor <natechancellor@gmail.com>
25 Signed-off-by: David S. Miller <davem@davemloft.net>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 net/core/fib_rules.c | 6 +++---
29 1 file changed, 3 insertions(+), 3 deletions(-)
31 --- a/net/core/fib_rules.c
32 +++ b/net/core/fib_rules.c
33 @@ -756,9 +756,9 @@ int fib_nl_newrule(struct sk_buff *skb,
37 - if (rule_exists(ops, frh, tb, rule)) {
38 - if (nlh->nlmsg_flags & NLM_F_EXCL)
40 + if ((nlh->nlmsg_flags & NLM_F_EXCL) &&
41 + rule_exists(ops, frh, tb, rule)) {