netlink: let core handle error cases in dump operations
Subsystems (3)
PATCH 1/1 netlink: let core handle error cases in dump operations
After commit b5a899154aa9 ("netlink: handle EMSGSIZE errors in the core"), we can remove some code that was not 100 % correct anyway.
--- net/core/rtnetlink.c | 5 +---- net/ipv4/devinet.c | 4 ---- net/ipv4/fib_frontend.c | 7 +------ net/ipv6/addrconf.c | 7 +------ 4 files changed, 3 insertions(+), 20 deletions(-)
net/core/rtnetlink.c +1 -4
@@ -2267,11 +2267,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) nlh->nlmsg_seq,0 , flags, ext_filter_mask,0 ,NULL ,0 , netnsid, GFP_KERNEL); -if (err <0 ) { -if (likely (skb->len)) - err = skb->len; +if (err <0 )break ; - } } cb->seq = tgt_net->dev_base_seq;nl_dump_check_consistent (cb,nlmsg_hdr (skb));
net/ipv4/devinet.c +0 -4
@@ -1900,8 +1900,6 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) goto done; } done: -if (err <0 &&likely (skb->len)) - err = skb->len;if (fillargs.netnsid >=0 )put_net (tgt_net);rcu_read_unlock ();
@@ -2312,8 +2310,6 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb, ctx->all_default++; } done: -if (err <0 &&likely (skb->len)) - err = skb->len;rcu_read_unlock ();return err; }
net/ipv4/fib_frontend.c +1 -6
@@ -1026,8 +1026,6 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) goto unlock; } err =fib_table_dump (tb, skb, cb, &filter); -if (err <0 && skb->len) - err = skb->len; goto unlock; }
@@ -1045,11 +1043,8 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)memset (&cb->args[2 ],0 ,sizeof (cb->args) -2 *sizeof (cb->args[0 ])); err =fib_table_dump (tb, skb, cb, &filter); -if (err <0 ) { -if (likely (skb->len)) - err = skb->len; +if (err <0 ) goto out; - } dumped =1 ; next: e++;
net/ipv6/addrconf.c +1 -6
@@ -793,8 +793,6 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, ctx->all_default++; } done: -if (err <0 &&likely (skb->len)) - err = skb->len;rcu_read_unlock ();return err; }
@@ -6158,11 +6156,8 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI); -if (err <0 ) { -if (likely (skb->len)) - err = skb->len; +if (err <0 )break ; - } }rcu_read_unlock ();
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
+ Ido Schimmel, David Ahern
Quoted 5 lines · Eric Dumazet
After commit
b5a899154aa9("netlink: handle EMSGSIZE errors in the core"), we can remove some code that was not 100 % correct anyway.Signed-off-by Eric Dumazet <[email protected]>
Thanks Eric,
this looks like a nice clean-up in combination with the cited commit.
Quoted 102 lines
--- net/core/rtnetlink.c | 5 +---- net/ipv4/devinet.c | 4 ---- net/ipv4/fib_frontend.c | 7 +------ net/ipv6/addrconf.c | 7 +------ 4 files changed, 3 insertions(+), 20 deletions(-)net/core/rtnetlink.c +1
-4@@ -2267,11 +2267,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) nlh->nlmsg_seq,0 , flags, ext_filter_mask,0 ,NULL ,0 , netnsid, GFP_KERNEL); -if (err <0 ) { -if (likely (skb->len)) - err = skb->len; +if (err <0 )break ; - } } cb->seq = tgt_net->dev_base_seq;nl_dump_check_consistent (cb,nlmsg_hdr (skb));net/ipv4/devinet.c +0
-4@@ -1900,8 +1900,6 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) goto done; } done: -if (err <0 &&likely (skb->len)) - err = skb->len;if (fillargs.netnsid >=0 )put_net (tgt_net);rcu_read_unlock ();@@ -2312,8 +2310,6 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb, ctx->all_default++; } done: -if (err <0 &&likely (skb->len)) - err = skb->len;rcu_read_unlock ();return err; }net/ipv4/fib_frontend.c +1
-6@@ -1026,8 +1026,6 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) goto unlock; } err =fib_table_dump (tb, skb, cb, &filter); -if (err <0 && skb->len) - err = skb->len; goto unlock; }@@ -1045,11 +1043,8 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)memset (&cb->args[2 ],0 ,sizeof (cb->args) -2 *sizeof (cb->args[0 ])); err =fib_table_dump (tb, skb, cb, &filter); -if (err <0 ) { -if (likely (skb->len)) - err = skb->len; +if (err <0 ) goto out; - } dumped =1 ; next: e++;net/ipv6/addrconf.c +1
-6@@ -793,8 +793,6 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, ctx->all_default++; } done: -if (err <0 &&likely (skb->len)) - err = skb->len;rcu_read_unlock ();return err; }@@ -6158,11 +6156,8 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI); -if (err <0 ) { -if (likely (skb->len)) - err = skb->len; +if (err <0 )break ; - } }rcu_read_unlock ();Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Quoted 8 lines · Simon Horman
+ Ido Schimmel, David Ahern
Quoted 5 lines · Eric Dumazet
After commit
b5a899154aa9("netlink: handle EMSGSIZE errors in the core"), we can remove some code that was not 100 % correct anyway.Signed-off-by Eric Dumazet <[email protected]>
Quoted 7 lines · Simon Horman
+ Ido Schimmel, David Ahern
Quoted 4 lines · Eric Dumazet
After commit
b5a899154aa9("netlink: handle EMSGSIZE errors in the core"), we can remove some code that was not 100 % correct anyway.
Quoted 5 lines
Quoted 1 line
Signed-off-by Eric Dumazet <[email protected]>Thanks Eric,
this looks like a nice clean-up in combination with the cited commit.
+1
Quoted 3 lines
Reviewed-by Simon Horman <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Wed, 6 Mar 2024 10:24:26 +0000 you wrote:
After commit
b5a899154aa9("netlink: handle EMSGSIZE errors in the core"), we can remove some code that was not 100 % correct anyway.Signed-off-by Eric Dumazet <[email protected]>--- net/core/rtnetlink.c | 5 +---- net/ipv4/devinet.c | 4 ---- net/ipv4/fib_frontend.c | 7 +------ net/ipv6/addrconf.c | 7 +------ 4 files changed, 3 insertions(+), 20 deletions(-)
Here is the summary with links:
- [net-next] netlink: let core handle error cases in dump operations
https://git.kernel.org/netdev/net-next/c/02e24903e5a4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html