netlink: fixup regression in RTM_GETADDR
authorArthur Gautier <[email protected]>
Mon, 31 Dec 2018 02:10:58 +0000 (02:10 +0000)
committerDavid S. Miller <[email protected]>
Fri, 4 Jan 2019 20:47:06 +0000 (12:47 -0800)
This commit fixes a regression in AF_INET/RTM_GETADDR and
AF_INET6/RTM_GETADDR.

Before this commit, the kernel would stop dumping addresses once the first
skb was full and end the stream with NLMSG_DONE(-EMSGSIZE). The error
shouldn't be sent back to netlink_dump so the callback is kept alive. The
userspace is expected to call back with a new empty skb.

Changes from V1:
 - The error is not handled in netlink_dump anymore but rather in
   inet_dump_ifaddr and inet6_dump_addr directly as suggested by
   David Ahern.

Fixes: d7e38611b81e ("net/ipv4: Put target net when address dump fails due to bad attributes")
Fixes: 242afaa6968c ("net/ipv6: Put target net when address dump fails due to bad attributes")
Cc: David Ahern <[email protected]>
Cc: "David S . Miller" <[email protected]>
Cc: [email protected]
Signed-off-by: Arthur Gautier <[email protected]>
Reviewed-by: David Ahern <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/ipv4/devinet.c
net/ipv6/addrconf.c

index 04ba321ae5cee0cf9bb2a6d3e47c8df4f1c11976..e258a00b4a3d6c11df57bf951213795b14f792d6 100644 (file)
@@ -1826,7 +1826,7 @@ put_tgt_net:
        if (fillargs.netnsid >= 0)
                put_net(tgt_net);
 
-       return err < 0 ? err : skb->len;
+       return skb->len ? : err;
 }
 
 static void rtmsg_ifa(int event, struct in_ifaddr *ifa, struct nlmsghdr *nlh,
index 8eeec6eb2bd3730a7445eabffb06ffb03e82e78f..93d5ad2b1a69790384bd9cefa8e0b024e1714c97 100644 (file)
@@ -5154,7 +5154,7 @@ put_tgt_net:
        if (fillargs.netnsid >= 0)
                put_net(tgt_net);
 
-       return err < 0 ? err : skb->len;
+       return skb->len ? : err;
 }
 
 static int inet6_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)