]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Disable kernel interface RA as early as possible on Linux.
authorRoy Marples <roy@marples.name>
Fri, 13 Jul 2012 08:22:04 +0000 (08:22 +0000)
committerRoy Marples <roy@marples.name>
Fri, 13 Jul 2012 08:22:04 +0000 (08:22 +0000)
Don't add duplicate interfaces to the restore kernel RA on Linux.

dhcpcd.c
platform-linux.c

index 4b318caca80bf3cae9ca9e18c30584983cfe77c4..06026c484705eeb75650702961ffe9d73ef96ea8 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -785,6 +785,12 @@ configure_interface1(struct interface *iface)
        if (ifo->metric != -1)
                iface->metric = ifo->metric;
 
+       /* We want to disable kernel interface RA as early as possible. */
+       if (options & DHCPCD_IPV6RS && ifo->options & DHCPCD_IPV6RS) {
+               if (check_ipv6(iface->name) != 1)
+                       ifo->options &= ~DHCPCD_IPV6RS;
+       }
+
        /* If we haven't specified a ClientID and our hardware address
         * length is greater than DHCP_CHADDR_LEN then we enforce a ClientID
         * of the hardware address family and the hardware address. */
@@ -1167,12 +1173,8 @@ start_interface(void *arg)
        free(iface->state->offer);
        iface->state->offer = NULL;
 
-       if (options & DHCPCD_IPV6RS && ifo->options & DHCPCD_IPV6RS) {
-               if (check_ipv6(iface->name) == 1)
-                       ipv6rs_start(iface);
-               else
-                       ifo->options &= ~DHCPCD_IPV6RS;
-       }
+       if (options & DHCPCD_IPV6RS && ifo->options & DHCPCD_IPV6RS)
+               ipv6rs_start(iface);
 
        if (iface->state->arping_index < ifo->arping_len) {
                start_arping(iface);
index 393e51987c602523d9b4587ed44d9093ffa0c0b3..3ac2db9e5b422f1d0b8f168ac2e400d46a3e3def 100644 (file)
@@ -174,7 +174,7 @@ restore_kernel_ra(void)
 int
 check_ipv6(const char *ifname)
 {
-       int r, ex;
+       int r, ex, i;
        char path[256];
 
        if (ifname == NULL) {
@@ -194,12 +194,18 @@ check_ipv6(const char *ifname)
                        syslog(LOG_ERR, "write_path: %s: %m", path);
                        return 0;
                }
-               restore = realloc(restore, (nrestore + 1) * sizeof(char *));
-               if (restore == NULL) {
-                       syslog(LOG_ERR, "realloc: %m");
-                       exit(EXIT_FAILURE);
+               for (i = 0; i < nrestore; i++)
+                       if (strcmp(restore[i], ifname) == 0)
+                               break;
+               if (i == nrestore) {
+                       restore = realloc(restore,
+                           (nrestore + 1) * sizeof(char *));
+                       if (restore == NULL) {
+                               syslog(LOG_ERR, "realloc: %m");
+                               exit(EXIT_FAILURE);
+                       }
+                       restore[nrestore++] = xstrdup(ifname);
                }
-               restore[nrestore++] = xstrdup(ifname);
                if (ex)
                        atexit(restore_kernel_ra);
        }