Message ID | 20190122214033.3803-1-jakub.kicinski@netronome.com |
---|---|
State | Superseded |
Delegated to: | David Miller |
Headers | show |
Series | [net] net/ipv6: don't return positive numbers when nothing was dumped | expand |
On 1/22/19 2:40 PM, Jakub Kicinski wrote: > in6_dump_addrs() returns a positive 1 if there was nothing to dump. > This return value can not be passed as return from inet6_dump_addr() > as is, because it will confuse rtnetlink, resulting in NLMSG_DONE > never getting set: > > $ ip addr list dev lo > EOF on netlink > Dump terminated > > Fixes: 7c1e8a3817c5 ("netlink: fixup regression in RTM_GETADDR") > Reported-by: Brendan Galloway <brendan.galloway@netronome.com> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> > --- > net/ipv6/addrconf.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c > index 93d5ad2b1a69..87c98f7fe997 100644 > --- a/net/ipv6/addrconf.c > +++ b/net/ipv6/addrconf.c > @@ -5120,6 +5120,9 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, > if (idev) { > err = in6_dump_addrs(idev, skb, cb, s_ip_idx, > &fillargs); > + if (err < 0) > + goto put_tgt_net; > + err = 0; Rather than have 2 goto's to the same target why not just: if (err > 0) err = 0; > } > goto put_tgt_net; > } > Thanks for the path.
On Tue, 22 Jan 2019 15:38:20 -0700, David Ahern wrote: > > @@ -5120,6 +5120,9 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, > > if (idev) { > > err = in6_dump_addrs(idev, skb, cb, s_ip_idx, > > &fillargs); > > + if (err < 0) > > + goto put_tgt_net; > > + err = 0; > > Rather than have 2 goto's to the same target why not just: > > if (err > 0) > err = 0; My default is to keep success path less indented and to minimize dependencies between code blocks. v2 coming in 3.. 2.. 1.. > > } > > goto put_tgt_net; > > } > >
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 93d5ad2b1a69..87c98f7fe997 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -5120,6 +5120,9 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, if (idev) { err = in6_dump_addrs(idev, skb, cb, s_ip_idx, &fillargs); + if (err < 0) + goto put_tgt_net; + err = 0; } goto put_tgt_net; }
in6_dump_addrs() returns a positive 1 if there was nothing to dump. This return value can not be passed as return from inet6_dump_addr() as is, because it will confuse rtnetlink, resulting in NLMSG_DONE never getting set: $ ip addr list dev lo EOF on netlink Dump terminated Fixes: 7c1e8a3817c5 ("netlink: fixup regression in RTM_GETADDR") Reported-by: Brendan Galloway <brendan.galloway@netronome.com> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> --- net/ipv6/addrconf.c | 3 +++ 1 file changed, 3 insertions(+)