IPv6: add extack info for IPv6 address add/delete
Subsystems (3)
PATCH v3 1/1 IPv6: add extack info for IPv6 address add/delete
Add extack info for IPv6 address add/delete, which would be useful for users to understand the problem without having to read kernel code.
---
v3: * Update extack message. Pass extack to addrconf_f6i_alloc().
* Return "IPv6 is disabled" for addrconf_add_dev(), as the same with ndisc_allow_add() does.
* Set dup addr extack message in inet6_rtm_newaddr() instead of ipv6_add_addr_hash().
v2: Update extack msg for dead dev. Remove msg for NOBUFS error.
Add extack for ipv6_add_addr_hash()
--- include/net/ip6_route.h | 2 +- net/ipv6/addrconf.c | 63 +++++++++++++++++++++++++++++------------ net/ipv6/anycast.c | 2 +- net/ipv6/route.c | 5 ++-- 4 files changed, 50 insertions(+), 22 deletions(-)
include/net/ip6_route.h +1 -1
@@ -156,7 +156,7 @@ void fib6_force_start_gc(struct net *net);struct fib6_info *addrconf_f6i_alloc (struct net *net,struct inet6_dev *idev,const struct in6_addr *addr,bool anycast, -gfp_t gfp_flags); +gfp_t gfp_flags,struct netlink_ext_ack *extack);struct rt6_info *ip6_dst_alloc (struct net *net,struct net_device *dev,int flags);
net/ipv6/addrconf.c +45 -18
164 lines not on this page · raw message
net/ipv6/anycast.c +1 -1
@@ -305,7 +305,7 @@ int __ipv6_dev_ac_inc(struct inet6_dev *idev, const struct in6_addr *addr) } net =dev_net (idev->dev); - f6i =addrconf_f6i_alloc (net, idev, addr, true,GFP_ATOMIC ); + f6i =addrconf_f6i_alloc (net, idev, addr, true,GFP_ATOMIC ,NULL );if (IS_ERR (f6i)) { err =PTR_ERR (f6i); goto out;
net/ipv6/route.c +3 -2
@@ -4543,7 +4543,8 @@ static int ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buffstruct fib6_info *addrconf_f6i_alloc (struct net *net,struct inet6_dev *idev,const struct in6_addr *addr, -bool anycast,gfp_t gfp_flags) +bool anycast,gfp_t gfp_flags, +struct netlink_ext_ack *extack) {struct fib6_config cfg = { .fc_table =l3mdev_fib_table (idev->dev) ? :RT6_TABLE_LOCAL ,
@@ -4565,7 +4566,7 @@ struct fib6_info *addrconf_f6i_alloc(struct net *net, cfg.fc_flags |=RTF_LOCAL ; } - f6i =ip6_route_info_create (&cfg, gfp_flags,NULL ); + f6i =ip6_route_info_create (&cfg, gfp_flags, extack);if (!IS_ERR (f6i)) { f6i->dst_nocount = true;
Signature · 1 line
2.38.1
Quoted 13 lines · Hangbin Liu
Add extack info for IPv6 address add/delete, which would be useful for users to understand the problem without having to read kernel code.
Suggested-by Beniamino Galvani <[email protected]>Signed-off-by Hangbin Liu <[email protected]>---
v3: * Update extack message. Pass extack toaddrconf_f6i_alloc().
* Return "IPv6 is disabled" foraddrconf_add_dev(), as the same withndisc_allow_add()does.
* Set dup addr extack message ininet6_rtm_newaddr()instead ofipv6_add_addr_hash().
v2: Update extack msg for dead dev. Remove msg for NOBUFS error.
Add extack foripv6_add_addr_hash()
Quoted 7 lines
--- include/net/ip6_route.h | 2 +- net/ipv6/addrconf.c | 63 +++++++++++++++++++++++++++++------------ net/ipv6/anycast.c | 2 +- net/ipv6/route.c | 5 ++-- 4 files changed, 50 insertions(+), 22 deletions(-)
This patch is getting long enough, so:
Followup requests below. Thanks,
net/ipv6/addrconf.c ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg, · line 1074
Quoted 13 lines
net/ipv6/addrconf.c +3
-1@@ -1068,15 +1068,19 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg, !(cfg->ifa_flags & IFA_F_MCAUTOJOIN)) || (!(idev->dev->flags & IFF_LOOPBACK) && !netif_is_l3_master(idev->dev) && - addr_type & IPV6_ADDR_LOOPBACK)) + addr_type & IPV6_ADDR_LOOPBACK)) { +NL_SET_ERR_MSG (extack,"Cannot assign requested address" );return ERR_PTR (-EADDRNOTAVAIL ); + }
It would be good to split the above checks into separate ones with more specific messages.
Quoted 13 lines
net/ipv6/addrconf.c +3
-1if (idev->dead) { - err = -ENODEV ;/*XXX*/ +NL_SET_ERR_MSG (extack,"IPv6 device is going away" ); + err = -ENODEV ; goto out; }if (idev->cnf.disable_ipv6) { +NL_SET_ERR_MSG (extack,"IPv6 is disabled on this device" ); err = -EACCES ; goto out; }
...
net/ipv6/addrconf.c static int inet6_addr_add(struct net *net, int ifindex, · line 2956
Quoted 4 lines
net/ipv6/addrconf.c +0
-0if (cfg->ifa_flags &IFA_F_MCAUTOJOIN ) {int ret =ipv6_mc_config (net->ipv6.mc_autojoin_sk, true, cfg->pfx, ifindex);
and pass extack to this one for better message as well.
Quoted 9 lines
net/ipv6/addrconf.c +3
-1-if (ret <0 ) +if (ret <0 ) { +NL_SET_ERR_MSG (extack,"Multicast auto join failed" );return ret; + } } cfg->scope =ipv6_addr_scope (cfg->pfx);
Quoted 22 lines · David Ahern
Quoted 13 lines · Hangbin Liu
Add extack info for IPv6 address add/delete, which would be useful for users to understand the problem without having to read kernel code.
Suggested-by Beniamino Galvani <[email protected]>Signed-off-by Hangbin Liu <[email protected]>---
v3: * Update extack message. Pass extack toaddrconf_f6i_alloc().
* Return "IPv6 is disabled" foraddrconf_add_dev(), as the same withndisc_allow_add()does.
* Set dup addr extack message ininet6_rtm_newaddr()instead ofipv6_add_addr_hash().
v2: Update extack msg for dead dev. Remove msg for NOBUFS error.
Add extack foripv6_add_addr_hash()Quoted 7 lines
--- include/net/ip6_route.h | 2 +- net/ipv6/addrconf.c | 63 +++++++++++++++++++++++++++++------------ net/ipv6/anycast.c | 2 +- net/ipv6/route.c | 5 ++-- 4 files changed, 50 insertions(+), 22 deletions(-)
Quoted 3 lines
This patch is getting long enough, so:
Reviewed-by David Ahern <[email protected]>
Thanks a lot for your review.
Quoted 19 lines
Followup requests below. Thanks,
net/ipv6/addrconf.c ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg, · line 1074
Quoted 13 lines
net/ipv6/addrconf.c +3
-1@@ -1068,15 +1068,19 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg, !(cfg->ifa_flags & IFA_F_MCAUTOJOIN)) || (!(idev->dev->flags & IFF_LOOPBACK) && !netif_is_l3_master(idev->dev) && - addr_type & IPV6_ADDR_LOOPBACK)) + addr_type & IPV6_ADDR_LOOPBACK)) { +NL_SET_ERR_MSG (extack,"Cannot assign requested address" );return ERR_PTR (-EADDRNOTAVAIL ); + }It would be good to split the above checks into separate ones with more specific messages.
How about this.
net/ipv6/addrconf.c +11 -7
@@ -1063,13 +1063,17 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,struct fib6_info *f6i =NULL ;int err =0 ; -if (addr_type ==IPV6_ADDR_ANY || - (addr_type &IPV6_ADDR_MULTICAST && - !(cfg->ifa_flags &IFA_F_MCAUTOJOIN )) || - (!(idev->dev->flags &IFF_LOOPBACK ) && - !netif_is_l3_master (idev->dev) && - addr_type &IPV6_ADDR_LOOPBACK )) { -NL_SET_ERR_MSG (extack,"Cannot assign requested address" ); +if (addr_type ==IPV6_ADDR_ANY ) { +NL_SET_ERR_MSG (extack,"IPv6: Cannot assign unspecified address" ); +return ERR_PTR (-EADDRNOTAVAIL ); + }else if (addr_type &IPV6_ADDR_MULTICAST && + !(cfg->ifa_flags &IFA_F_MCAUTOJOIN )) { +NL_SET_ERR_MSG (extack,"IPv6: Cannot assign multicast address without \"IFA_F_MCAUTOJOIN\" flag" ); +return ERR_PTR (-EADDRNOTAVAIL ); + }else if (!(idev->dev->flags &IFF_LOOPBACK ) && + !netif_is_l3_master (idev->dev) && + addr_type &IPV6_ADDR_LOOPBACK ) { +NL_SET_ERR_MSG (extack,"IPv6: Cannot assign loopback address on this device" );return ERR_PTR (-EADDRNOTAVAIL ); }
Quoted 8 lines
...
net/ipv6/addrconf.c
Quoted 4 lines
net/ipv6/addrconf.c +0
-0if (cfg->ifa_flags &IFA_F_MCAUTOJOIN ) {int ret =ipv6_mc_config (net->ipv6.mc_autojoin_sk, true, cfg->pfx, ifindex);and pass extack to this one for better message as well.
This one looks a little deep. We need pass extack to
- ipv6_mc_config
- ipv6_sock_mc_join
- __ipv6_sock_mc_join
- __ipv6_dev_mc_inc maybe also this one??
to get more detailed message. And all these are "Join multicast group failed". Do you still want to do this?
Thanks
Hangbin
Quoted 12 lines
Quoted 10 lines
net/ipv6/addrconf.c +3
-1-if (ret <0 ) +if (ret <0 ) { +NL_SET_ERR_MSG (extack,"Multicast auto join failed" );return ret; + } } cfg->scope =ipv6_addr_scope (cfg->pfx);
Quoted 5 lines · Hangbin Liu
Add extack info for IPv6 address add/delete, which would be useful for users to understand the problem without having to read kernel code.
Suggested-by Beniamino Galvani <[email protected]>Signed-off-by Hangbin Liu <[email protected]>
David Ahern
maintainerQuoted 26 lines · Hangbin Liu
Quoted 8 lines
Quoted 8 lines
net/ipv6/addrconf.c +0
-0@@ -1068,15 +1068,19 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg, !(cfg->ifa_flags & IFA_F_MCAUTOJOIN)) || (!(idev->dev->flags & IFF_LOOPBACK) && !netif_is_l3_master(idev->dev) &&Quoted 8 lines
net/ipv6/addrconf.c ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg, · line 1074
Quoted 5 lines
net/ipv6/addrconf.c +3
-1- addr_type & IPV6_ADDR_LOOPBACK)) + addr_type & IPV6_ADDR_LOOPBACK)) { +NL_SET_ERR_MSG (extack,"Cannot assign requested address" );return ERR_PTR (-EADDRNOTAVAIL ); + }It would be good to split the above checks into separate ones with more specific messages.
How about this.
net/ipv6/addrconf.c +0
-0@@ -1063,13 +1063,17 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,struct fib6_info *f6i =NULL ;int err =0 ;
net/ipv6/addrconf.c ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg, · line 1067
Quoted 10 lines
net/ipv6/addrconf.c +2
-7-if (addr_type ==IPV6_ADDR_ANY || - (addr_type &IPV6_ADDR_MULTICAST && - !(cfg->ifa_flags &IFA_F_MCAUTOJOIN )) || - (!(idev->dev->flags &IFF_LOOPBACK ) && - !netif_is_l3_master (idev->dev) && - addr_type &IPV6_ADDR_LOOPBACK )) { -NL_SET_ERR_MSG (extack,"Cannot assign requested address" ); +if (addr_type ==IPV6_ADDR_ANY ) { +NL_SET_ERR_MSG (extack,"IPv6: Cannot assign unspecified address" );
Maybe just "IPv6: Invalid address".
Also, that reminds me that IPv6 should be using NL_SET_ERR_MSG_MOD which will add the IPv6 part.
Quoted 21 lines
net/ipv6/addrconf.c +9
-0+return ERR_PTR (-EADDRNOTAVAIL ); + }else if (addr_type &IPV6_ADDR_MULTICAST && + !(cfg->ifa_flags &IFA_F_MCAUTOJOIN )) { +NL_SET_ERR_MSG (extack,"IPv6: Cannot assign multicast address without \"IFA_F_MCAUTOJOIN\" flag" ); +return ERR_PTR (-EADDRNOTAVAIL ); + }else if (!(idev->dev->flags &IFF_LOOPBACK ) && + !netif_is_l3_master (idev->dev) && + addr_type &IPV6_ADDR_LOOPBACK ) { +NL_SET_ERR_MSG (extack,"IPv6: Cannot assign loopback address on this device" );return ERR_PTR (-EADDRNOTAVAIL ); }Quoted 8 lines
...
net/ipv6/addrconf.c
Quoted 4 lines
net/ipv6/addrconf.c +0
-0if (cfg->ifa_flags &IFA_F_MCAUTOJOIN ) {int ret =ipv6_mc_config (net->ipv6.mc_autojoin_sk, true, cfg->pfx, ifindex);and pass extack to this one for better message as well.
Quoted 8 lines
This one looks a little deep. We need pass extack to
-ipv6_mc_config
-ipv6_sock_mc_join
-__ipv6_sock_mc_join
-__ipv6_dev_mc_incmaybe also this one??to get more detailed message. And all these are "Join multicast group failed". Do you still want to do this?
ok, staring at the errors for that stack, not much value I guess.