From: Roy Marples Date: Fri, 13 Jul 2012 08:22:04 +0000 (+0000) Subject: Disable kernel interface RA as early as possible on Linux. X-Git-Tag: v5.6.2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bde566f574065f5212f7977c43bf9104077a7059;p=thirdparty%2Fdhcpcd.git Disable kernel interface RA as early as possible on Linux. Don't add duplicate interfaces to the restore kernel RA on Linux. --- diff --git a/dhcpcd.c b/dhcpcd.c index 4b318cac..06026c48 100644 --- 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); diff --git a/platform-linux.c b/platform-linux.c index 393e5198..3ac2db9e 100644 --- a/platform-linux.c +++ b/platform-linux.c @@ -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); }