public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: Ido Schimmel <idosch@idosch.org>
Cc: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Beniamino Galvani <bgalvani@redhat.com>
Subject: Re: [PATCHv2 net-next] IPv6: add extack info for inet6_addr_add/del
Date: Mon, 24 Jul 2023 11:59:28 +0800	[thread overview]
Message-ID: <ZL33IPUcU3bmpO82@Laptop-X1> (raw)
In-Reply-To: <ZLkL3eNVNfzZbaBv@shredder>

On Thu, Jul 20, 2023 at 01:26:37PM +0300, Ido Schimmel wrote:
> > -static int ipv6_add_addr_hash(struct net_device *dev, struct inet6_ifaddr *ifa)
> > +static int ipv6_add_addr_hash(struct net_device *dev, struct inet6_ifaddr *ifa,
> > +			      struct netlink_ext_ack *extack)
> >  {
> >  	struct net *net = dev_net(dev);
> >  	unsigned int hash = inet6_addr_hash(net, &ifa->addr);
> > @@ -1037,7 +1038,7 @@ static int ipv6_add_addr_hash(struct net_device *dev, struct inet6_ifaddr *ifa)
> >  
> >  	/* Ignore adding duplicate addresses on an interface */
> >  	if (ipv6_chk_same_addr(net, &ifa->addr, dev, hash)) {
> > -		netdev_dbg(dev, "ipv6_add_addr: already assigned\n");
> > +		NL_SET_ERR_MSG(extack, "ipv6_add_addr: already assigned");
> 
> How do you trigger it?
> 
> # ip link add name dummy10 up type dummy
> # ip address add 2001:db8:1::1/64 dev dummy10
> # ip address add 2001:db8:1::1/64 dev dummy10
> RTNETLINK answers: File exists
> 
> Better to add extack in inet6_rtm_newaddr():
> 
> if (nlh->nlmsg_flags & NLM_F_EXCL || 
>     !(nlh->nlmsg_flags & NLM_F_REPLACE))
> 	err = -EEXIST;
> else
> 	err = inet6_addr_modify(net, ifa, &cfg)

Thanks. Since the dup addr checking will be done on inet6_rtm_newaddr(). I
will remove the extack msg in ipv6_add_addr_hash().

> > @@ -1103,6 +1108,7 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
> >  
> >  	f6i = addrconf_f6i_alloc(net, idev, cfg->pfx, false, gfp_flags);
> >  	if (IS_ERR(f6i)) {
> > +		NL_SET_ERR_MSG(extack, "Dest allocate failed");
> 
> The only thing that can fail in this function is ip6_route_info_create()
> which already has an extack argument. Better to pass extack to
> addrconf_f6i_alloc() and get a more accurate error message.

OK, I will update the patch.

> > -	if (cfg->plen > 128)
> > +	if (cfg->plen > 128) {
> > +		NL_SET_ERR_MSG(extack, "IPv6 address prefix length larger than 128");
> 
> For RTM_NEWROUTE IPv6 code just says "Invalid prefix length", so might
> as well be consistent with it. Also, I see IPv4 doesn't have such
> messages for its RTM_{NEW,DEL}ADDR messages. If you think it's useful
> for IPv6, then I suggest also adding it to IPv4.

OK. But since this patch is for IPv6. I will post another patch for IPv4
specifically.

Thanks
Hangbin

      reply	other threads:[~2023-07-24  3:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 13:56 [PATCHv2 net-next] IPv6: add extack info for inet6_addr_add/del Hangbin Liu
2023-07-20 10:26 ` Ido Schimmel
2023-07-24  3:59   ` Hangbin Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZL33IPUcU3bmpO82@Laptop-X1 \
    --to=liuhangbin@gmail.com \
    --cc=bgalvani@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=idosch@idosch.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox