* [PATCH] iproute2: Ignore EADDRNOTAVAIL errors during address flush operation
@ 2015-11-05 19:54 Neil Horman
2015-11-23 23:59 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Neil Horman @ 2015-11-05 19:54 UTC (permalink / raw)
To: netdev; +Cc: Neil Horman, Stephen Hemminger, Alexey Kuznetsov
I found recently that, if I disabled address promotion in the kernel, that
ip addr flush dev <dev>
would fail with an EADDRNOTAVAIL errno (though the flush operation would in fact
flush all addresses from an interface properly)
Whats happening is that, if I add a primary and multiple secondary addresses to
an interface, the flush operation first ennumerates them all with a GETADDR |
DUMP operation, then sends a delete request for each address. But the kernel,
having promotion disabled, deletes all secondary addresses when the primary is
removed. That means, that several delete requests may still be pending in the
netlink request for addresses that have been removed on our behalf, resulting in
EADDRNOTAVAIL return codes.
It seems the simplest thing to do is to understand that EADDRUNAVAIL isn't a
fatal outcome on a flush operation, as it just indicates that an address which
you want to remove is already removed, so it can safely be ignored.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Stephen Hemminger <stephen@networkplumber.org>
CC: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
---
ip/ipaddress.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index f290205..05358c9 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -893,7 +893,17 @@ int print_linkinfo(const struct sockaddr_nl *who,
static int flush_update(void)
{
- if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
+
+ /*
+ * Note that the kernel may delete multiple addresses for one
+ * delete request (e.g. if ipv4 address promotion is disabled).
+ * Since a flush operation is really a series of delete requests
+ * its possible that we may request an address delete that has
+ * already been done by the kernel. Therefore, ignore EADDRNOTAVAIL
+ * errors returned from a flush request
+ */
+ if ((rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) &&
+ (errno != EADDRNOTAVAIL)) {
perror("Failed to send flush request");
return -1;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iproute2: Ignore EADDRNOTAVAIL errors during address flush operation
2015-11-05 19:54 [PATCH] iproute2: Ignore EADDRNOTAVAIL errors during address flush operation Neil Horman
@ 2015-11-23 23:59 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2015-11-23 23:59 UTC (permalink / raw)
To: Neil Horman; +Cc: netdev, Alexey Kuznetsov
On Thu, 5 Nov 2015 14:54:17 -0500
Neil Horman <nhorman@tuxdriver.com> wrote:
> I found recently that, if I disabled address promotion in the kernel, that
> ip addr flush dev <dev>
>
> would fail with an EADDRNOTAVAIL errno (though the flush operation would in fact
> flush all addresses from an interface properly)
>
> Whats happening is that, if I add a primary and multiple secondary addresses to
> an interface, the flush operation first ennumerates them all with a GETADDR |
> DUMP operation, then sends a delete request for each address. But the kernel,
> having promotion disabled, deletes all secondary addresses when the primary is
> removed. That means, that several delete requests may still be pending in the
> netlink request for addresses that have been removed on our behalf, resulting in
> EADDRNOTAVAIL return codes.
>
> It seems the simplest thing to do is to understand that EADDRUNAVAIL isn't a
> fatal outcome on a flush operation, as it just indicates that an address which
> you want to remove is already removed, so it can safely be ignored.
>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: Stephen Hemminger <stephen@networkplumber.org>
> CC: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-23 23:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-05 19:54 [PATCH] iproute2: Ignore EADDRNOTAVAIL errors during address flush operation Neil Horman
2015-11-23 23:59 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).