From: David Ahern <dsahern@kernel.org>
To: xu.xin16@zte.com.cn, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
dsahern@gmail.com, fan.yu9@zte.com.cn, yang.yang29@zte.com.cn,
si.hao@zte.com.cn, zhang.yunkai@zte.com.cn, he.peilin@zte.com.cn
Subject: Re: [PATCH] net/ipv6: Fix route deleting failure when metric equals 0
Date: Tue, 14 May 2024 09:13:41 -0600 [thread overview]
Message-ID: <3e9595ec-f233-4d93-84ff-77e0183c73a7@kernel.org> (raw)
In-Reply-To: <20240514201102055dD2Ba45qKbLlUMxu_DTHP@zte.com.cn>
On 5/14/24 6:11 AM, xu.xin16@zte.com.cn wrote:
> From: xu xin <xu.xin16@zte.com.cn>
>
> Problem
> =========
> After commit 67f695134703 ("ipv6: Move setting default metric for routes"),
> we noticed that the logic of assigning the default value of fc_metirc
> changed in the ioctl process. That is, when users use ioctl(fd, SIOCADDRT,
> rt) with a non-zero metric to add a route, then they may fail to delete a
> route with passing in a metric value of 0 to the kernel by ioctl(fd,
> SIOCDELRT, rt). But iproute can succeed in deleting it.
>
> As a reference, when using iproute tools by netlink to delete routes with
> a metric parameter equals 0, like the command as follows:
>
> ip -6 route del fe80::/64 via fe81::5054:ff:fe11:3451 dev eth0 metric 0
>
> the user can still succeed in deleting the route entry with the smallest
> metric.
>
> Root Reason
> ===========
> After commit 67f695134703 ("ipv6: Move setting default metric for routes"),
> When ioctl() pass in SIOCDELRT with a zero metric, rtmsg_to_fib6_config()
> will set a defalut value (1024) to cfg->fc_metric in kernel, and in
> ip6_route_del() and the line 4074 at net/ipv3/route.c, it will check by
>
> if (cfg->fc_metric && cfg->fc_metric != rt->fib6_metric)
> continue;
>
> and the condition is true and skip the later procedure (deleting route)
> because cfg->fc_metric != rt->fib6_metric. But before that commit,
> cfg->fc_metric is still zero there, so the condition is false and it
> will do the following procedure (deleting).
>
> Solution
> ========
> In order to keep a consistent behaviour across netlink() and ioctl(), we
> should allow to delete a route with a metric value of 0. So we only do
> the default setting of fc_metric in route adding.
>
> CC: stable@vger.kernel.org # 5.4+
> Fixes: 67f695134703 ("ipv6: Move setting default metric for routes")
> Co-developed-by: Fan Yu <fan.yu9@zte.com.cn>
> Signed-off-by: Fan Yu <fan.yu9@zte.com.cn>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> ---
> net/ipv6/route.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
next prev parent reply other threads:[~2024-05-14 15:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 12:11 [PATCH] net/ipv6: Fix route deleting failure when metric equals 0 xu.xin16
2024-05-14 15:13 ` David Ahern [this message]
2024-05-17 2:40 ` patchwork-bot+netdevbpf
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=3e9595ec-f233-4d93-84ff-77e0183c73a7@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=edumazet@google.com \
--cc=fan.yu9@zte.com.cn \
--cc=he.peilin@zte.com.cn \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=si.hao@zte.com.cn \
--cc=xu.xin16@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
--cc=zhang.yunkai@zte.com.cn \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).