Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: if_addrflags6: Can't assign requested address



On 17/08/2018 09:04, Masanobu SAITOH wrote:
wm2: carrier lost
wm2: executing `/libexec/dhcpcd-run-hooks' NOCARRIER
wm2: deleting address fe80::1392:4012:56d8:a7a2
wm2: if_addrflags6: Can't assign requested address
wm2: if_addrflags6: Can't assign requested address
wm2: if_addrflags6: Can't assign requested address
wm2: if_addrflags6: Can't assign requested address
wm2: carrier acquired
wm2: executing `/libexec/dhcpcd-run-hooks' CARRIER

This helps.
I never saw this because on NetBSD-8, we have addrflags available in ifa_msghdr when sent over route(4). This does not exist on NetBSD-7 so we need to make an ioctl per address to work out the flags. Sadly, this is racy and this is what happens:

Something adds an address.
Kernel annnounces new address to route(4).
Something deletes this address.
Kernel announces the address deleted to route(4).

dhcpcd reads the address added message from route(4) *after* the address has been deleted from the kernel. Because dhcpcd needs the address flags at this point, an ioctl is made to the deleted address and boom, error.

Luckily dhcpcd handles it correctly and it's just noise.
Please test the attached patch to silence it.
If you can verify it works, let me know and I'll push a new version out.

Thanks

Roy
diff --git a/src/if-bsd.c b/src/if-bsd.c
index c3c95ba6..c03e4f6d 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -1134,8 +1134,8 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
 		if (ifam->ifam_type == RTM_DELADDR)
 			addrflags = 0 ;
 		else if ((addrflags = if_addrflags(ifp, &addr, NULL)) == -1) {
-			logerr("%s: if_addrflags: %s",
-			    ifp->name, inet_ntoa(addr));
+			if (errno != EADDRNOTAVAIL)
+				logerr("%s: if_addrflags", __func__);
 			break;
 		}
 #endif
@@ -1160,7 +1160,8 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
 		if (ifam->ifam_type == RTM_DELADDR)
 		    addrflags = 0;
 		else if ((addrflags = if_addrflags6(ifp, &addr6, NULL)) == -1) {
-			logerr("%s: if_addrflags6", ifp->name);
+			if (errno != EADDRNOTAVAIL)
+				logerr("%s: if_addrflags6", __func__);
 			break;
 		}
 #endif
diff --git a/src/if.c b/src/if.c
index eaebefa5..c1c81eb6 100644
--- a/src/if.c
+++ b/src/if.c
@@ -240,7 +240,7 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
 			addrflags = if_addrflags(ifp, &addr->sin_addr,
 			    ifa->ifa_name);
 			if (addrflags == -1) {
-				if (errno != EEXIST)
+				if (errno != EEXIST && errno != EADDRNOTAVAIL)
 					logerr("%s: if_addrflags: %s",
 					    __func__,
 					    inet_ntoa(addr->sin_addr));
@@ -266,7 +266,7 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
 			addrflags = if_addrflags6(ifp, &sin6->sin6_addr,
 			    ifa->ifa_name);
 			if (addrflags == -1) {
-				if (errno != EEXIST)
+				if (errno != EEXIST || errno == EADDRNOTAVAIL)
 					logerr("%s: if_addrflags6", __func__);
 				continue;
 			}


Home | Main Index | Thread Index | Old Index