From 40ab806bf4c8698ac925d094ce11ce1d57ae2e46 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 3 Apr 2023 20:12:13 +0200 Subject: config: use dedicated link local function to check interface Use netlink_get_interface_addrs is wrong and doesn't actually work. The function checks only for UNIVERSE address and is not suitable for dumping linklocal address of an interface. Use the new and dedicated function to get interface linklocal address to correctly check if the interface can receive message. Fixes: #197 Fixes: 7c0f603abc14 ("router: skip RA and wait for LINK-LOCAL to be assigned") Signed-off-by: Christian Marangi --- src/config.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/config.c b/src/config.c index 6122fb1..30fdc30 100644 --- a/src/config.c +++ b/src/config.c @@ -518,8 +518,10 @@ static int parse_ntp_fqdn(uint16_t *dhcpv6_ntp_len, char *fqdn, uint8_t **dhcpv6 int config_parse_interface(void *data, size_t len, const char *name, bool overwrite) { + struct odhcpd_ipaddr *addrs = NULL; struct interface *iface; struct blob_attr *tb[IFACE_ATTR_MAX], *c; + ssize_t addrs_len; bool get_addrs = false; int mode; const char *ifname = NULL; @@ -588,25 +590,28 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr } if (get_addrs) { - ssize_t len = netlink_get_interface_addrs(iface->ifindex, + addrs_len = netlink_get_interface_addrs(iface->ifindex, true, &iface->addr6); - if (len > 0) - iface->addr6_len = len; + if (addrs_len > 0) + iface->addr6_len = addrs_len; - for (size_t i = 0; i < iface->addr6_len; i++) { - struct odhcpd_ipaddr *addr = &iface->addr6[i]; + addrs_len = netlink_get_interface_addrs(iface->ifindex, + false, &iface->addr4); + if (addrs_len > 0) + iface->addr4_len = addrs_len; + } + + addrs_len = netlink_get_interface_linklocal(iface->ifindex, &addrs); + if (addrs_len > 0) { + for (ssize_t i = 0; i < addrs_len; i++) { + struct odhcpd_ipaddr *addr = &addrs[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; } iface->inuse = true; -- cgit v1.2.3