* [PATCH] Net:cache didn't flush when ipv6 rule changed @ 2024-02-26 13:11 Lena Wang (王娜) 2024-02-27 15:06 ` David Ahern 2024-02-28 8:24 ` [PATCH net v2] " Lena Wang (王娜) 0 siblings, 2 replies; 6+ messages in thread From: Lena Wang (王娜) @ 2024-02-26 13:11 UTC (permalink / raw) To: davem, kuba, pabeni, dsahern, edumazet Cc: linux-kernel, Shiming Cheng (成诗明) From a415abaf4fc90a27dd86357ea8be62d32956f7d8 Mon Sep 17 00:00:00 2001 From: shiming cheng <shiming.cheng@mediatek.com> Date: Mon, 26 Feb 2024 20:17:58 +0800 Subject: [PATCH] Net:cache didn't flush when ipv6 rule changed When changed from old rule&route configure to new one as below, ipv6 cache dst_entry did not change to new route table as no cache flush callback function, then forward to wrong out interface. When fib6_check dst_entry, the fib6_node version[fn_sernm] is always the same with socket dst_cookie, old cache dst_entry is always used and no chance to update. So we need to update fib6_node version when rule changed and flush cache to avoid dispatching a wrong interface. Signed-off-by: shiming cheng <shiming.cheng@mediatek.com> --- net/ipv6/fib6_rules.c | 10 ++++++++++ 1 files changed, 10 insertions(+) diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 7523c4baef35..bec2cf4436e1 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -449,6 +449,15 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule) + nla_total_size(16); /* src */ } +static void fib6_rule_flush_cache(struct fib_rules_ops *ops) +{ + struct net *net = ops->fro_net; + if (!net) + return; + rt_genid_bump_ipv6(net); + return; +} + static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .family = AF_INET6, .rule_size = sizeof(struct fib6_rule), @@ -461,6 +470,7 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .compare = fib6_rule_compare, .fill = fib6_rule_fill, .nlmsg_payload = fib6_rule_nlmsg_payload, + .flush_cache = fib6_rule_flush_cache, .nlgroup = RTNLGRP_IPV6_RULE, .owner = THIS_MODULE, .fro_net = &init_net, -- 2.18.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Net:cache didn't flush when ipv6 rule changed 2024-02-26 13:11 [PATCH] Net:cache didn't flush when ipv6 rule changed Lena Wang (王娜) @ 2024-02-27 15:06 ` David Ahern 2024-02-28 7:28 ` Lena Wang (王娜) 2024-02-28 8:24 ` [PATCH net v2] " Lena Wang (王娜) 1 sibling, 1 reply; 6+ messages in thread From: David Ahern @ 2024-02-27 15:06 UTC (permalink / raw) To: Lena Wang (王娜), davem, kuba, pabeni, edumazet Cc: linux-kernel, Shiming Cheng (成诗明) On 2/26/24 6:11 AM, Lena Wang (王娜) wrote: > diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c > index 7523c4baef35..bec2cf4436e1 100644 > --- a/net/ipv6/fib6_rules.c > +++ b/net/ipv6/fib6_rules.c > @@ -449,6 +449,15 @@ static size_t fib6_rule_nlmsg_payload(struct > fib_rule *rule) > + nla_total_size(16); /* src */ > } > > +static void fib6_rule_flush_cache(struct fib_rules_ops *ops) > +{ > + struct net *net = ops->fro_net; > + if (!net) > + return; > + rt_genid_bump_ipv6(net); > + return; > +} This can be written as a 1-liner - the same way as the IPv4 flush cache: static void fib6_rule_flush_cache(struct fib_rules_ops *ops) { rt_genid_bump_ipv6(ops->fro_net); } > + > static const struct fib_rules_ops __net_initconst > fib6_rules_ops_template = { > .family = AF_INET6, > .rule_size = sizeof(struct fib6_rule), > @@ -461,6 +470,7 @@ static const struct fib_rules_ops __net_initconst > fib6_rules_ops_template = { > .compare = fib6_rule_compare, > .fill = fib6_rule_fill, > .nlmsg_payload = fib6_rule_nlmsg_payload, > + .flush_cache = fib6_rule_flush_cache, this should be tabs and the columns should align with existing code. > .nlgroup = RTNLGRP_IPV6_RULE, > .owner = THIS_MODULE, > .fro_net = &init_net, > -- > 2.18.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Net:cache didn't flush when ipv6 rule changed 2024-02-27 15:06 ` David Ahern @ 2024-02-28 7:28 ` Lena Wang (王娜) 2024-02-28 7:34 ` Paolo Abeni 0 siblings, 1 reply; 6+ messages in thread From: Lena Wang (王娜) @ 2024-02-28 7:28 UTC (permalink / raw) To: davem, kuba, pabeni, dsahern, edumazet Cc: linux-kernel, Shiming Cheng (成诗明) On Tue, 2024-02-27 at 08:06 -0700, David Ahern wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > On 2/26/24 6:11 AM, Lena Wang (王娜) wrote: > > > diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c > > index 7523c4baef35..bec2cf4436e1 100644 > > --- a/net/ipv6/fib6_rules.c > > +++ b/net/ipv6/fib6_rules.c > > @@ -449,6 +449,15 @@ static size_t fib6_rule_nlmsg_payload(struct > > fib_rule *rule) > > + nla_total_size(16); /* src */ > > } > > > > +static void fib6_rule_flush_cache(struct fib_rules_ops *ops) > > +{ > > + struct net *net = ops->fro_net; > > + if (!net) > > + return; > > + rt_genid_bump_ipv6(net); > > + return; > > +} > > This can be written as a 1-liner - the same way as the IPv4 flush > cache: > > static void fib6_rule_flush_cache(struct fib_rules_ops *ops) > { > rt_genid_bump_ipv6(ops->fro_net); > } > > > > + > > static const struct fib_rules_ops __net_initconst > > fib6_rules_ops_template = { > > .family = AF_INET6, > > .rule_size = sizeof(struct fib6_rule), > > @@ -461,6 +470,7 @@ static const struct fib_rules_ops > __net_initconst > > fib6_rules_ops_template = { > > .compare = fib6_rule_compare, > > .fill = fib6_rule_fill, > > .nlmsg_payload = fib6_rule_nlmsg_payload, > > + .flush_cache = fib6_rule_flush_cache, > > this should be tabs and the columns should align with existing code. > > > > > .nlgroup = RTNLGRP_IPV6_RULE, > > .owner = THIS_MODULE, > > .fro_net = &init_net, > > -- > > 2.18.0 > Dear David, Update the patch as below, thanks. From db01a40e45f51d00cb19e45a41507c97363d6ed8 Mon Sep 17 00:00:00 2001 From: shiming cheng <shiming.cheng@mediatek.com> Date: Mon, 26 Feb 2024 20:17:58 +0800 Subject: [PATCH] Net:cache didn't flush when ipv6 rule changed When changed from old rule&route configure to new one as below, ipv6 cache dst_entry did not change to new route table as no cache flush callback function, then forward to wrong out interface. When fib6_check dst_entry, the fib6_node version[fn_sernm] is always the same with socket dst_cookie, old cache dst_entry is always used and no chance to update. So we need to update fib6_node version when rule changed and flush cache to avoid dispatching a wrong interface. Signed-off-by: shiming cheng <shiming.cheng@mediatek.com> --- net/ipv6/fib6_rules.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 7523c4baef35..31d6183221a2 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -449,6 +449,11 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule) + nla_total_size(16); /* src */ } +static void fib6_rule_flush_cache(struct fib_rules_ops *ops) +{ + rt_genid_bump_ipv6(net); +} + static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .family = AF_INET6, .rule_size = sizeof(struct fib6_rule), @@ -461,6 +466,7 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .compare = fib6_rule_compare, .fill = fib6_rule_fill, .nlmsg_payload = fib6_rule_nlmsg_payload, + .flush_cache = fib6_rule_flush_cache, .nlgroup = RTNLGRP_IPV6_RULE, .owner = THIS_MODULE, .fro_net = &init_net, -- 2.18.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Net:cache didn't flush when ipv6 rule changed 2024-02-28 7:28 ` Lena Wang (王娜) @ 2024-02-28 7:34 ` Paolo Abeni 0 siblings, 0 replies; 6+ messages in thread From: Paolo Abeni @ 2024-02-28 7:34 UTC (permalink / raw) To: Lena Wang (王娜), davem, kuba, dsahern, edumazet Cc: linux-kernel, Shiming Cheng (成诗明) Hi, On Wed, 2024-02-28 at 07:28 +0000, Lena Wang (王娜) wrote: > Dear David, > Update the patch as below, thanks. > > > From db01a40e45f51d00cb19e45a41507c97363d6ed8 Mon Sep 17 00:00:00 2001 > From: shiming cheng <shiming.cheng@mediatek.com> > Date: Mon, 26 Feb 2024 20:17:58 +0800 > Subject: [PATCH] Net:cache didn't flush when ipv6 rule changed > > When changed from old rule&route configure to new one as below, > ipv6 cache dst_entry did not change to new route table as no > cache flush callback function, then forward to wrong out interface. > When fib6_check dst_entry, the fib6_node version[fn_sernm] is > always the same with socket dst_cookie, old cache dst_entry is > always used and no chance to update. > > So we need to update fib6_node version when rule changed and > flush cache to avoid dispatching a wrong interface. > > Signed-off-by: shiming cheng <shiming.cheng@mediatek.com> You need to cc the netdev mailing list to allow up processing the patch. Please also include the target tree in the subject prefix ('net' in this case), a suitable fixes tag and avoid sending patches in reply to existing threads as it confuses our bot. @David (out of sheer ignorace) could this the root cause for the fib6 self-tests sporadic failures? Thanks, Paolo ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net v2] Net:cache didn't flush when ipv6 rule changed 2024-02-26 13:11 [PATCH] Net:cache didn't flush when ipv6 rule changed Lena Wang (王娜) 2024-02-27 15:06 ` David Ahern @ 2024-02-28 8:24 ` Lena Wang (王娜) 2024-02-28 12:30 ` Jiri Pirko 1 sibling, 1 reply; 6+ messages in thread From: Lena Wang (王娜) @ 2024-02-28 8:24 UTC (permalink / raw) To: davem, kuba, pabeni, dsahern, edumazet Cc: linux-kernel, netdev, Shiming Cheng (成诗明) From bf53859b379a653eec8a14fbb3f29286f9f888fb Mon Sep 17 00:00:00 2001 From: shiming cheng <shiming.cheng@mediatek.com> Date: Mon, 26 Feb 2024 20:17:58 +0800 Subject: [PATCH net v2] Net:cache didn't flush when ipv6 rule changed When changed from old rule&route configure to new one as below, ipv6 cache dst_entry did not change to new route table as no cache flush callback function, then forward to wrong out interface. When fib6_check dst_entry, the fib6_node version[fn_sernm] is always the same with socket dst_cookie, old cache dst_entry is always used and no chance to update. So we need to update fib6_node version when rule changed and flush cache to avoid dispatching a wrong interface. Signed-off-by: shiming cheng <shiming.cheng@mediatek.com> --- v2: 1. Add the fix tag. 2. Changes according to David Ahern's suggestions, modify flush functions same way as ipv4 flush cache and use tabs to aligh with existing code. --- --- net/ipv6/fib6_rules.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 7523c4baef35..52c04f0ac498 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -449,6 +449,11 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule) + nla_total_size(16); /* src */ } +static void fib6_rule_flush_cache(struct fib_rules_ops *ops) +{ + rt_genid_bump_ipv6(ops->fro_net); +} + static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .family = AF_INET6, .rule_size = sizeof(struct fib6_rule), @@ -461,6 +466,7 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .compare = fib6_rule_compare, .fill = fib6_rule_fill, .nlmsg_payload = fib6_rule_nlmsg_payload, + .flush_cache = fib6_rule_flush_cache, .nlgroup = RTNLGRP_IPV6_RULE, .owner = THIS_MODULE, .fro_net = &init_net, -- 2.18.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v2] Net:cache didn't flush when ipv6 rule changed 2024-02-28 8:24 ` [PATCH net v2] " Lena Wang (王娜) @ 2024-02-28 12:30 ` Jiri Pirko 0 siblings, 0 replies; 6+ messages in thread From: Jiri Pirko @ 2024-02-28 12:30 UTC (permalink / raw) To: Lena Wang (王娜) Cc: davem, kuba, pabeni, dsahern, edumazet, linux-kernel, netdev, Shiming Cheng (成诗明) [PATCH net v2] Net:cache didn't flush when ipv6 rule changed Please make sure your patch subject is aligned with the rest: $ git log --no-merges --pretty=format:"%s" net/ipv6/fib6_rules.c | head -n30 fib: remove unnecessary input parameters in fib_default_rule_add ipv6: change fib6_rules_net_exit() to batch mode ipv6: Define dscp_t and stop taking ECN bits into account in fib6-rules fib: rules: remove duplicated nla policies ipv6: fix memory leak in fib6_rule_suppress ipv6: fib6: remove redundant initialization of variable err fib: use indirect call wrappers in the most common fib_rules_ops ipv6: fib6: avoid indirect calls from fib6_rule_lookup net: fib_notifier: propagate extack down to the notifier block callback ipv6: do not free rt if FIB_LOOKUP_NOREF is set on suppress rule ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 372 ipv6: Use result arg in fib_lookup_arg consistently ipv6: fib6_rule_action_alt needs to return -EAGAIN ipv6: Pass fib6_result to fib lookups net/ipv6: Add fib6_lookup net/ipv6: Refactor fib6_rule_action net: fib_rules: add extack support net: Drop pernet_operations::async net/ipv6: Pass skb to route lookup ipv6: route: dissect flow in input path if fib rules need it ipv6: fib6_rules: support for match on sport, dport and ip proto net: Convert fib6_rules_net_ops net: ipv6: avoid overhead when no custom FIB rules are installed ipv6: fib_rules: Dump rules during registration to FIB chain ipv6: fib_rules: Check if rule is a default rule ipv6: Do not leak throw route references net: flow: Add l3mdev flow update net: Add l3mdev rule ipv6: fix the incorrect return value of throw route Use imperative mood as other subjects do, tell the codebase what do do. Wed, Feb 28, 2024 at 09:24:55AM CET, Lena.Wang@mediatek.com wrote: >From bf53859b379a653eec8a14fbb3f29286f9f888fb Mon Sep 17 00:00:00 2001 >From: shiming cheng <shiming.cheng@mediatek.com> Names start with capital letters. >Date: Mon, 26 Feb 2024 20:17:58 +0800 >Subject: [PATCH net v2] Net:cache didn't flush when ipv6 rule changed I don't understand why you put these "headers" here. Only one "from" is enough in this case (you are submitting the patch in stead of another person). If you are not, I suggest to use git-send-email for submissions. > >When changed from old rule&route configure to new one as below, "as below" where? >ipv6 cache dst_entry did not change to new route table as no >cache flush callback function, then forward to wrong out interface. I don't understand this sentence :/ >When fib6_check dst_entry, the fib6_node version[fn_sernm] is >always the same with socket dst_cookie, old cache dst_entry is >always used and no chance to update. Sorry, this is too cryptic for me to understand :/ > >So we need to update fib6_node version when rule changed and >flush cache to avoid dispatching a wrong interface. Be imperative in the patch description too, tell the codebase what do do. https://www.kernel.org/doc/html/v6.6/process/submitting-patches.html#describe-your-changes > >Signed-off-by: shiming cheng <shiming.cheng@mediatek.com> Names start with capital letters. Also, when you submit the patch, your signed-off-by tag should be here as well. >--- >v2: > 1. Add the fix tag. And there, there is none... pw-bot: cr > 2. Changes according to David Ahern's suggestions, modify flush >functions same way as ipv4 flush cache and use tabs to aligh with >existing code. >--- >--- > net/ipv6/fib6_rules.c | 6 ++++++ > 1 file changed, 6 insertions(+) > >diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c >index 7523c4baef35..52c04f0ac498 100644 >--- a/net/ipv6/fib6_rules.c >+++ b/net/ipv6/fib6_rules.c >@@ -449,6 +449,11 @@ static size_t fib6_rule_nlmsg_payload(struct >fib_rule *rule) > + nla_total_size(16); /* src */ > } > >+static void fib6_rule_flush_cache(struct fib_rules_ops *ops) >+{ >+ rt_genid_bump_ipv6(ops->fro_net); >+} >+ > static const struct fib_rules_ops __net_initconst >fib6_rules_ops_template = { > .family = AF_INET6, > .rule_size = sizeof(struct fib6_rule), >@@ -461,6 +466,7 @@ static const struct fib_rules_ops __net_initconst >fib6_rules_ops_template = { > .compare = fib6_rule_compare, > .fill = fib6_rule_fill, > .nlmsg_payload = fib6_rule_nlmsg_payload, >+ .flush_cache = fib6_rule_flush_cache, > .nlgroup = RTNLGRP_IPV6_RULE, > .owner = THIS_MODULE, > .fro_net = &init_net, >-- >2.18.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-28 12:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-02-26 13:11 [PATCH] Net:cache didn't flush when ipv6 rule changed Lena Wang (王娜) 2024-02-27 15:06 ` David Ahern 2024-02-28 7:28 ` Lena Wang (王娜) 2024-02-28 7:34 ` Paolo Abeni 2024-02-28 8:24 ` [PATCH net v2] " Lena Wang (王娜) 2024-02-28 12:30 ` Jiri Pirko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®