All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Poirier <bpoirier@nvidia.com>
To: Nikolay Aleksandrov <nikolay@nvidia.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, bridge@lists.linux-foundation.org,
	"David S. Miller" <davem@davemloft.net>,
	Roopa Prabhu <roopa@nvidia.com>
Subject: Re: [Bridge] [PATCH net] net: bridge: vlan: Fix dumping with ifindex
Date: Wed, 26 Jan 2022 11:54:37 +0900	[thread overview]
Message-ID: <YfC37T23elbsAD0R@d3> (raw)
In-Reply-To: <25ec6925-8ebf-d2fa-7d73-708ba72cec0a@nvidia.com>

On 2022-01-25 11:51 +0200, Nikolay Aleksandrov wrote:
> On 25/01/2022 10:24, Nikolay Aleksandrov wrote:
> > On 25/01/2022 08:19, Benjamin Poirier wrote:
> >> Specifying ifindex in a RTM_GETVLAN dump leads to an infinite repetition
> >> of the same entries. netlink_dump() normally calls the dump function
> >> repeatedly until it returns 0 which br_vlan_rtm_dump() never does in
> >> that case.
> >>
> >> Fixes: 8dcea187088b ("net: bridge: vlan: add rtm definitions and dump support")
> >> Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
> >> ---
> >>  net/bridge/br_vlan.c | 6 ++++--
> >>  1 file changed, 4 insertions(+), 2 deletions(-)
> >>
> > [snip]
> >>
> >> diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> >> index 84ba456a78cc..2e606f2b9a4d 100644
> >> --- a/net/bridge/br_vlan.c
> >> +++ b/net/bridge/br_vlan.c
> >> @@ -2013,7 +2013,7 @@ static int br_vlan_rtm_dump(struct sk_buff *skb, struct netlink_callback *cb)
> >>  		dump_flags = nla_get_u32(dtb[BRIDGE_VLANDB_DUMP_FLAGS]);
> >>  
> >>  	rcu_read_lock();
> >> -	if (bvm->ifindex) {
> >> +	if (bvm->ifindex && !s_idx) {
> >>  		dev = dev_get_by_index_rcu(net, bvm->ifindex);
> >>  		if (!dev) {
> >>  			err = -ENODEV;
> >> @@ -2022,7 +2022,9 @@ static int br_vlan_rtm_dump(struct sk_buff *skb, struct netlink_callback *cb)
> >>  		err = br_vlan_dump_dev(dev, skb, cb, dump_flags);
> >>  		if (err && err != -EMSGSIZE)
> >>  			goto out_err;
> >> -	} else {
> >> +		else if (!err)
> >> +			idx++;
> >> +	} else if (!bvm->ifindex) {
> >>  		for_each_netdev_rcu(net, dev) {
> >>  			if (idx < s_idx)
> >>  				goto skip;
> > 
> > Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
> 
> Actually I'd prefer an alternative that would encapsulate handling the single
> device dump in its block, avoid all the "else if"s and is simpler (untested):
> 
> diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> index 84ba456a78cc..43201260e37b 100644
> --- a/net/bridge/br_vlan.c
> +++ b/net/bridge/br_vlan.c
> @@ -2020,7 +2020,8 @@ static int br_vlan_rtm_dump(struct sk_buff *skb, struct netlink_callback *cb)
>                         goto out_err;
>                 }
>                 err = br_vlan_dump_dev(dev, skb, cb, dump_flags);
> -               if (err && err != -EMSGSIZE)
> +               /* if the dump completed without an error we return 0 here */
> +               if (err != -EMSGSIZE)
>                         goto out_err;
>         } else {
>                 for_each_netdev_rcu(net, dev) {

LGTM, thank you.

  reply	other threads:[~2022-01-26  2:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25  6:19 [Bridge] [PATCH net] net: bridge: vlan: Fix dumping with ifindex Benjamin Poirier
2022-01-25  8:24 ` Nikolay Aleksandrov
2022-01-25  9:51   ` Nikolay Aleksandrov
2022-01-26  2:54     ` Benjamin Poirier [this message]
2022-01-26 13:10       ` [Bridge] [PATCH net] net: bridge: vlan: fix single net device option dumping Nikolay Aleksandrov
2022-01-27 14:00         ` 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=YfC37T23elbsAD0R@d3 \
    --to=bpoirier@nvidia.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=roopa@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.