mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Lu Wei <luwei32@huawei.com>
Cc: <davem@davemloft.net>, <dsahern@kernel.org>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] ipv6: Add lwtunnel encap size of all siblings in nexthop calculation
Date: Tue, 14 Feb 2023 18:39:35 +0100	[thread overview]
Message-ID: <d5f2c46c-cf68-3ec9-ec87-f6748ede1d1f@intel.com> (raw)
In-Reply-To: <20230214092933.3817533-1-luwei32@huawei.com>

From: Lu Wei <luwei32@huawei.com>
Date: Tue, 14 Feb 2023 17:29:33 +0800

> In function rt6_nlmsg_size(), the length of nexthop is calculated
> by multipling the nexthop length of fib6_info and the number of
> siblings. However if the fib6_info has no lwtunnel but the siblings
> have lwtunnels, the nexthop length is less than it should be, and
> it will trigger a warning in inet6_rt_notify() as follows:

[...]

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index e74e0361fd92..a6983a13dd20 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -5540,16 +5540,17 @@ static size_t rt6_nlmsg_size(struct fib6_info *f6i)
>  		nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_nlmsg_size,
>  					 &nexthop_len);
>  	} else {
> +		struct fib6_info *sibling, *next_sibling;
>  		struct fib6_nh *nh = f6i->fib6_nh;
>  
>  		nexthop_len = 0;
>  		if (f6i->fib6_nsiblings) {
> -			nexthop_len = nla_total_size(0)	 /* RTA_MULTIPATH */
> -				    + NLA_ALIGN(sizeof(struct rtnexthop))
> -				    + nla_total_size(16) /* RTA_GATEWAY */
> -				    + lwtunnel_get_encap_size(nh->fib_nh_lws);
> +			rt6_nh_nlmsg_size(nh, &nexthop_len);
>  
> -			nexthop_len *= f6i->fib6_nsiblings;
> +			list_for_each_entry_safe(sibling, next_sibling,
> +						 &f6i->fib6_siblings, fib6_siblings) {
> +				rt6_nh_nlmsg_size(sibling->fib6_nh, &nexthop_len);
> +			}

Just a random nitpick that you shouldn't put braces {} around oneliners :D

>  		}
>  		nexthop_len += lwtunnel_get_encap_size(nh->fib_nh_lws);
>  	}
Thanks,
Olek

  parent reply	other threads:[~2023-02-14 17:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14  9:29 Lu Wei
2023-02-14 15:45 ` David Ahern
2023-02-15  6:28   ` luwei (O)
2023-02-14 17:39 ` Alexander Lobakin [this message]
2023-02-14 18:11   ` David Ahern
2023-02-15 15:58     ` Alexander Lobakin

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=d5f2c46c-cf68-3ec9-ec87-f6748ede1d1f@intel.com \
    --to=alexandr.lobakin@intel.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luwei32@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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

all inboxes | Powered by JetHome®