]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
BSD: Improve RTM_NEWADDR/RTM_DELADDR validaton some more
authorRoy Marples <roy@marples.name>
Tue, 21 Jan 2020 12:01:02 +0000 (12:01 +0000)
committerRoy Marples <roy@marples.name>
Wed, 22 Jan 2020 12:25:14 +0000 (12:25 +0000)
src/if-bsd.c

index 49f98d5f2ccc8dc92262c0cc2398231d5e5e2e64..396dfb744c2159083f5c8423a8ed5567011ddf12 100644 (file)
@@ -1267,11 +1267,13 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                                logerr("%s: SIOCGIFALIAS", __func__);
                        if (ifam->ifam_type != RTM_DELADDR)
                                break;
-               }
+               } else {
+                       if (ifam->ifam_type == RTM_DELADDR)
+                               break;
 #if defined(__NetBSD_Version__) && __NetBSD_Version__ < 800000000
-               else
                        bcast = ifra.ifra_broadaddr.sin_addr;
 #endif
+               }
 #else
 #warning No SIOCGIFALIAS support
                /*
@@ -1330,16 +1332,15 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                 * dhcpcd to drop any lease to which it belongs.
                 * Also check an added address was really added.
                 */
-               if (ifam->ifam_type == RTM_DELADDR) {
-                       flags = if_addrflags6(ifp, &addr6, NULL);
-                       if (flags != -1)
-                               break;
-                       flags = 0;
-               } else if ((flags = if_addrflags6(ifp, &addr6, NULL)) == -1) {
+               flags = if_addrflags6(ifp, &addr6, NULL);
+               if (flags == -1) {
                        if (errno != EADDRNOTAVAIL)
                                logerr("%s: if_addrflags6", __func__);
+                       if (ifam->ifam_type != RTM_DELADDR)
+                               break;
+                       flags = 0;
+               } else if (ifam->ifam_type == RTM_DELADDR)
                        break;
-               }
 
 #ifdef __KAME__
                if (IN6_IS_ADDR_LINKLOCAL(&addr6))