From 0a3874a2dc344c7b40592951a726bfdd81283487 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Fri, 4 Oct 2013 08:26:38 +0200 Subject: [PATCH] Check for local addr more often --- src/ra.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ra.c b/src/ra.c index 431bcd1..83f1758 100644 --- a/src/ra.c +++ b/src/ra.c @@ -79,21 +79,6 @@ int ra_init(const char *ifname, const struct in6_addr *ifid) fcntl(sock, F_SETOWN, ourpid); fcntl(sock, F_SETFL, fcntl(sock, F_GETFL) | O_ASYNC); - if (IN6_IS_ADDR_UNSPECIFIED(&lladdr)) { - // Autodetect interface-id if not specified - FILE *fp = fopen("/proc/net/if_inet6", "r"); - if (fp) { - char addrbuf[33], ifbuf[16]; - while (fscanf(fp, "%32s %*x %*x %*x %*x %15s", addrbuf, ifbuf) == 2) { - if (!strcmp(ifbuf, if_name)) { - script_unhexlify((uint8_t*)&lladdr, sizeof(lladdr), addrbuf); - break; - } - } - fclose(fp); - } - } - // Send RS signal(SIGALRM, ra_send_rs); ra_send_rs(SIGALRM); @@ -140,6 +125,21 @@ bool ra_process(void) struct odhcp6c_entry entry = {IN6ADDR_ANY_INIT, 0, 0, IN6ADDR_ANY_INIT, 0, 0, 0}; const struct in6_addr any = IN6ADDR_ANY_INIT; + if (IN6_IS_ADDR_UNSPECIFIED(&lladdr)) { + // Autodetect interface-id if not specified + FILE *fp = fopen("/proc/net/if_inet6", "r"); + if (fp) { + char addrbuf[33], ifbuf[16]; + while (fscanf(fp, "%32s %*x %*x %*x %*x %15s", addrbuf, ifbuf) == 2) { + if (!strcmp(ifbuf, if_name)) { + script_unhexlify((uint8_t*)&lladdr, sizeof(lladdr), addrbuf); + break; + } + } + fclose(fp); + } + } + while (true) { struct sockaddr_in6 from; struct iovec iov = {buf, sizeof(buf)}; -- 2.39.5