From: Hangbin Liu <liuhangbin@gmail.com>
To: thinker.li@gmail.com
Cc: netdev@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev,
kernel-team@meta.com, davem@davemloft.net, dsahern@kernel.org,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
sinquersw@gmail.com, kuifeng@meta.com
Subject: Re: [PATCH net-next v3 1/5] net/ipv6: set expires in rt6_add_dflt_router().
Date: Fri, 2 Feb 2024 19:52:11 +0800 [thread overview]
Message-ID: <ZbzXa3ECxEBdjOJu@Laptop-X1> (raw)
In-Reply-To: <20240202082200.227031-2-thinker.li@gmail.com>
On Fri, Feb 02, 2024 at 12:21:56AM -0800, thinker.li@gmail.com wrote:
> From: Kui-Feng Lee <thinker.li@gmail.com>
>
> Pass the duration of a lifetime (in seconds) to the function
> rt6_add_dflt_router() so that it can properly set the expiration time.
>
> The function ndisc_router_discovery() is the only one that calls
> rt6_add_dflt_router(), and it will later set the expiration time for the
> route created by rt6_add_dflt_router(). However, there is a gap of time
> between calling rt6_add_dflt_router() and setting the expiration time in
> ndisc_router_discovery(). During this period, there is a possibility that a
> new route may be removed from the routing table. By setting the correct
> expiration time in rt6_add_dflt_router(), we can prevent this from
> happening. The reason for setting RTF_EXPIRES in rt6_add_dflt_router() is
> to start the Garbage Collection (GC) timer, as it only activates when a
> route with RTF_EXPIRES is added to a table.
>
> Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
> ---
> include/net/ip6_route.h | 3 ++-
> net/ipv6/ndisc.c | 3 ++-
> net/ipv6/route.c | 4 +++-
> 3 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
> index 28b065790261..52a51c69aa9d 100644
> --- a/include/net/ip6_route.h
> +++ b/include/net/ip6_route.h
> @@ -170,7 +170,8 @@ struct fib6_info *rt6_get_dflt_router(struct net *net,
> struct fib6_info *rt6_add_dflt_router(struct net *net,
> const struct in6_addr *gwaddr,
> struct net_device *dev, unsigned int pref,
> - u32 defrtr_usr_metric);
> + u32 defrtr_usr_metric,
> + int lifetime);
>
> void rt6_purge_dflt_routers(struct net *net);
>
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
> index a19999b30bc0..a68462668158 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -1382,7 +1382,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb)
> neigh_release(neigh);
>
> rt = rt6_add_dflt_router(net, &ipv6_hdr(skb)->saddr,
> - skb->dev, pref, defrtr_usr_metric);
> + skb->dev, pref, defrtr_usr_metric,
> + lifetime);
> if (!rt) {
> ND_PRINTK(0, err,
> "RA: %s failed to add default route\n",
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 63b4c6056582..98abba8f15cd 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -4355,7 +4355,8 @@ struct fib6_info *rt6_add_dflt_router(struct net *net,
> const struct in6_addr *gwaddr,
> struct net_device *dev,
> unsigned int pref,
> - u32 defrtr_usr_metric)
> + u32 defrtr_usr_metric,
> + int lifetime)
> {
> struct fib6_config cfg = {
> .fc_table = l3mdev_fib_table(dev) ? : RT6_TABLE_DFLT,
> @@ -4368,6 +4369,7 @@ struct fib6_info *rt6_add_dflt_router(struct net *net,
> .fc_nlinfo.portid = 0,
> .fc_nlinfo.nlh = NULL,
> .fc_nlinfo.nl_net = net,
> + .fc_expires = jiffies_to_clock_t(lifetime * HZ),
> };
>
> cfg.fc_gateway = *gwaddr;
> --
> 2.34.1
>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
next prev parent reply other threads:[~2024-02-02 11:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 8:21 [PATCH net-next v3 0/5] Remove expired routes with a separated list of routes thinker.li
2024-02-02 8:21 ` [PATCH net-next v3 1/5] net/ipv6: set expires in rt6_add_dflt_router() thinker.li
2024-02-02 11:52 ` Hangbin Liu [this message]
2024-02-05 4:42 ` David Ahern
2024-02-02 8:21 ` [PATCH net-next v3 2/5] net/ipv6: Remove unnecessary clean thinker.li
2024-02-05 4:42 ` David Ahern
2024-02-02 8:21 ` [PATCH net-next v3 3/5] net/ipv6: Remove expired routes with a separated list of routes thinker.li
2024-02-04 10:29 ` Hangbin Liu
2024-02-04 16:10 ` David Ahern
2024-02-05 4:45 ` David Ahern
2024-02-05 15:24 ` David Ahern
2024-02-02 8:21 ` [PATCH net-next v3 4/5] net/ipv6: set expires in modify_prefix_route() if RTF_EXPIRES is set thinker.li
2024-02-02 12:16 ` Hangbin Liu
2024-02-02 17:57 ` Kui-Feng Lee
2024-02-04 10:17 ` Hangbin Liu
2024-02-05 18:59 ` Kui-Feng Lee
2024-02-02 8:22 ` [PATCH net-next v3 5/5] selftests/net: Adding test cases of replacing routes and route advertisements thinker.li
2024-02-02 12:37 ` Hangbin Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZbzXa3ECxEBdjOJu@Laptop-X1 \
--to=liuhangbin@gmail.com \
--cc=ast@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=kuifeng@meta.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sinquersw@gmail.com \
--cc=thinker.li@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).