All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aaron Conole <aconole@redhat.com>
To: Krister Johansen <kjlx@templeofstupid.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Mahesh Bandewar <maheshb@google.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH] Ipvlan should return an error when an address is already in use.
Date: Tue, 03 Jan 2017 10:50:00 -0500	[thread overview]
Message-ID: <f7td1g49m8n.fsf@redhat.com> (raw)
In-Reply-To: <20161231041058.GC2448@templeofstupid.com> (Krister Johansen's message of "Fri, 30 Dec 2016 20:10:58 -0800")

Hi Krister,

Krister Johansen <kjlx@templeofstupid.com> writes:

> The ipvlan code already knows how to detect when a duplicate address is
> about to be assigned to an ipvlan device.  However, that failure is not
> propogated outward and leads to a silent failure.  This teaches the ip
> address addition functions how to report this error to the user
> applications so that a notifier chain failure during ip address addition
> will not appear to succeed when it actually has not.
>
> This can be especially useful if it is necessary to provision many
> ipvlans in containers.  The provisioning software (or operator) can use
> this to detect situations where an ip address is unexpectedly in use.
>
> Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
> ---

...

> @@ -489,7 +490,12 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh,
>  	   Notifier will trigger FIB update, so that
>  	   listeners of netlink will know about new ifaddr */
>  	rtmsg_ifa(RTM_NEWADDR, ifa, nlh, portid);
> -	blocking_notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa);
> +	ret = blocking_notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa);

Why are you doing this assignment if you aren't using the result?

> +	ret = notifier_to_errno(ret);
> +	if (ret) {
> +		__inet_del_ifa(in_dev, ifap, 1, NULL, portid);
> +		return ret;
> +	}
>  
>  	return 0;
>  }

<<snip>>

> @@ -1031,9 +1032,15 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
>  out2:
>  	rcu_read_unlock_bh();
>  
> -	if (likely(err == 0))
> -		inet6addr_notifier_call_chain(NETDEV_UP, ifa);
> -	else {
> +	if (likely(err == 0)) {
> +		err = inet6addr_notifier_call_chain(NETDEV_UP, ifa);

Same here...

> +		err = notifier_to_errno(err);
> +		if (err) {
> +			__ipv6_del_addr(ifa, false);
> +			ifa = ERR_PTR(err);
> +			return ifa;
> +		}
> +	} else {
>  		kfree(ifa);
>  		ifa = ERR_PTR(err);
>  	}

  parent reply	other threads:[~2017-01-03 15:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-31  4:10 [PATCH] Ipvlan should return an error when an address is already in use Krister Johansen
2017-01-02  3:26 ` David Miller
2017-01-04 10:04   ` Krister Johansen
2017-06-08 20:12   ` [PATCH v2 net-next] " Krister Johansen
2017-06-09 16:26     ` David Miller
2017-06-09 17:13       ` Krister Johansen
2017-06-09 17:15         ` David Miller
2017-06-09 17:25           ` Krister Johansen
2017-01-03 15:50 ` Aaron Conole [this message]
2017-01-03 15:55   ` [PATCH] " David Miller
2017-01-03 19:24     ` Aaron Conole
2017-01-04 10:09       ` Krister Johansen

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=f7td1g49m8n.fsf@redhat.com \
    --to=aconole@redhat.com \
    --cc=davem@davemloft.net \
    --cc=kjlx@templeofstupid.com \
    --cc=maheshb@google.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.