]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
Check for local addr more often
authorSteven Barth <steven@midlink.org>
Fri, 4 Oct 2013 06:26:38 +0000 (08:26 +0200)
committerSteven Barth <steven@midlink.org>
Fri, 4 Oct 2013 06:26:38 +0000 (08:26 +0200)
src/ra.c

index 431bcd113031f54e79830c6af17b7a7bbc5b8b22..83f17584cbe93f9a4587a0e095432fa295b91de1 100644 (file)
--- 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)};