config: recheck have_link_local on interface reload if already init
authorChristian Marangi <ansuelsmth@gmail.com>
Thu, 23 Mar 2023 23:29:15 +0000 (00:29 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 24 Mar 2023 00:57:58 +0000 (01:57 +0100)
If an interface is already init in the odhcpd avl tables, have_link_local
is not set to true with a link local addr set as get ipv6 addr is skipped.

Move checking for have_link_local outside get_addr to better track when
an interface is ready and have a link local addr for interface already
init in odhcpd avl tables.

Fixes: #197
Fixes: 7c0f603abc14 ("router: skip RA and wait for LINK-LOCAL to be assigned")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
src/config.c

index ee7219fa9a2724867f82f9ad83b638599bf4e5eb..27e7f0375adf30a29388215f1fd142f6da4d4b47 100644 (file)
@@ -594,21 +594,21 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                if (len > 0)
                        iface->addr6_len = len;
 
-               for (size_t i = 0; i < iface->addr6_len; i++) {
-                       struct odhcpd_ipaddr *addr = &iface->addr6[i];
-
-                       if (!addr->tentative) {
-                               iface->have_link_local = true;
-                               break;
-                       }
-               }
-
                len = netlink_get_interface_addrs(iface->ifindex,
                                                false, &iface->addr4);
                if (len > 0)
                        iface->addr4_len = len;
        }
 
+       for (size_t i = 0; i < iface->addr6_len; i++) {
+               struct odhcpd_ipaddr *addr = &iface->addr6[i];
+
+               if (!addr->tentative) {
+                       iface->have_link_local = true;
+                       break;
+               }
+       }
+
        iface->inuse = true;
 
        if ((c = tb[IFACE_ATTR_DYNAMICDHCP]))