diff mbox series

[net] ipv6: Fix address dump when IPv6 is disabled on an interface

Message ID 20240321173042.2151756-1-idosch@nvidia.com (mailing list archive)
State Accepted
Commit c04f7dfe6ec2a3a20a8578d5f67a436ae36e2a2a
Delegated to: Netdev Maintainers
Headers show
Series [net] ipv6: Fix address dump when IPv6 is disabled on an interface | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 939 this patch: 939
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 956 this patch: 956
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 956 this patch: 956
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-23--00-00 (tests: 943)

Commit Message

Ido Schimmel March 21, 2024, 5:30 p.m. UTC
Cited commit started returning an error when user space requests to dump
the interface's IPv6 addresses and IPv6 is disabled on the interface.
Restore the previous behavior and do not return an error.

Before cited commit:

 # ip address show dev dummy1
 2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
     link/ether 1a:52:02:5a:c2:6e brd ff:ff:ff:ff:ff:ff
     inet6 fe80::1852:2ff:fe5a:c26e/64 scope link proto kernel_ll
        valid_lft forever preferred_lft forever
 # ip link set dev dummy1 mtu 1000
 # ip address show dev dummy1
 2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
     link/ether 1a:52:02:5a:c2:6e brd ff:ff:ff:ff:ff:ff

After cited commit:

 # ip address show dev dummy1
 2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
     link/ether 1e:9b:94:00:ac:e8 brd ff:ff:ff:ff:ff:ff
     inet6 fe80::1c9b:94ff:fe00:ace8/64 scope link proto kernel_ll
        valid_lft forever preferred_lft forever
 # ip link set dev dummy1 mtu 1000
 # ip address show dev dummy1
 RTNETLINK answers: No such device
 Dump terminated

With this patch:

 # ip address show dev dummy1
 2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
     link/ether 42:35:fc:53:66:cf brd ff:ff:ff:ff:ff:ff
     inet6 fe80::4035:fcff:fe53:66cf/64 scope link proto kernel_ll
        valid_lft forever preferred_lft forever
 # ip link set dev dummy1 mtu 1000
 # ip address show dev dummy1
 2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
     link/ether 42:35:fc:53:66:cf brd ff:ff:ff:ff:ff:ff

Fixes: 9cc4cc329d30 ("ipv6: use xa_array iterator to implement inet6_dump_addr()")
Reported-by: Gal Pressman <gal@nvidia.com>
Closes: https://lore.kernel.org/netdev/7e261328-42eb-411d-b1b4-ad884eeaae4d@linux.dev/
Tested-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
A similar change was done for IPv4 in commit cdb2f80f1c10 ("inet: use
xa_array iterator to implement inet_dump_ifaddr()"), but I'm not aware
of a way to disable IPv4 other than unregistering the interface, so I
don't see a reason to change the IPv4 code.
---
 net/ipv6/addrconf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Eric Dumazet March 21, 2024, 5:47 p.m. UTC | #1
On Thu, Mar 21, 2024 at 6:31 PM Ido Schimmel <idosch@nvidia.com> wrote:
>
> Cited commit started returning an error when user space requests to dump
> the interface's IPv6 addresses and IPv6 is disabled on the interface.
> Restore the previous behavior and do not return an error.
>
> Before cited commit:
>
>  # ip address show dev dummy1
>  2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
>      link/ether 1a:52:02:5a:c2:6e brd ff:ff:ff:ff:ff:ff
>      inet6 fe80::1852:2ff:fe5a:c26e/64 scope link proto kernel_ll
>         valid_lft forever preferred_lft forever
>  # ip link set dev dummy1 mtu 1000
>  # ip address show dev dummy1
>  2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
>      link/ether 1a:52:02:5a:c2:6e brd ff:ff:ff:ff:ff:ff
>
> After cited commit:
>
>  # ip address show dev dummy1
>  2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
>      link/ether 1e:9b:94:00:ac:e8 brd ff:ff:ff:ff:ff:ff
>      inet6 fe80::1c9b:94ff:fe00:ace8/64 scope link proto kernel_ll
>         valid_lft forever preferred_lft forever
>  # ip link set dev dummy1 mtu 1000
>  # ip address show dev dummy1
>  RTNETLINK answers: No such device
>  Dump terminated
>
> With this patch:
>
>  # ip address show dev dummy1
>  2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
>      link/ether 42:35:fc:53:66:cf brd ff:ff:ff:ff:ff:ff
>      inet6 fe80::4035:fcff:fe53:66cf/64 scope link proto kernel_ll
>         valid_lft forever preferred_lft forever
>  # ip link set dev dummy1 mtu 1000
>  # ip address show dev dummy1
>  2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
>      link/ether 42:35:fc:53:66:cf brd ff:ff:ff:ff:ff:ff
>
> Fixes: 9cc4cc329d30 ("ipv6: use xa_array iterator to implement inet6_dump_addr()")
> Reported-by: Gal Pressman <gal@nvidia.com>
> Closes: https://lore.kernel.org/netdev/7e261328-42eb-411d-b1b4-ad884eeaae4d@linux.dev/
> Tested-by: Gal Pressman <gal@nvidia.com>
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
> A similar change was done for IPv4 in commit cdb2f80f1c10 ("inet: use
> xa_array iterator to implement inet_dump_ifaddr()"), but I'm not aware
> of a way to disable IPv4 other than unregistering the interface, so I
> don't see a reason to change the IPv4 code.
> ---

Thanks for the fix.

Reviewed-by: Eric Dumazet <edumazet@google.com>
patchwork-bot+netdevbpf@kernel.org March 23, 2024, 1:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 21 Mar 2024 19:30:42 +0200 you wrote:
> Cited commit started returning an error when user space requests to dump
> the interface's IPv6 addresses and IPv6 is disabled on the interface.
> Restore the previous behavior and do not return an error.
> 
> Before cited commit:
> 
>  # ip address show dev dummy1
>  2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
>      link/ether 1a:52:02:5a:c2:6e brd ff:ff:ff:ff:ff:ff
>      inet6 fe80::1852:2ff:fe5a:c26e/64 scope link proto kernel_ll
>         valid_lft forever preferred_lft forever
>  # ip link set dev dummy1 mtu 1000
>  # ip address show dev dummy1
>  2: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
>      link/ether 1a:52:02:5a:c2:6e brd ff:ff:ff:ff:ff:ff
> 
> [...]

Here is the summary with links:
  - [net] ipv6: Fix address dump when IPv6 is disabled on an interface
    https://git.kernel.org/netdev/net/c/c04f7dfe6ec2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 247bd4d8ee45..92db9b474f2b 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5416,10 +5416,11 @@  static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
 
 		err = 0;
 		if (fillargs.ifindex) {
-			err = -ENODEV;
 			dev = dev_get_by_index_rcu(tgt_net, fillargs.ifindex);
-			if (!dev)
+			if (!dev) {
+				err = -ENODEV;
 				goto done;
+			}
 			idev = __in6_dev_get(dev);
 			if (idev)
 				err = in6_dump_addrs(idev, skb, cb,