From: Roy Marples Date: Wed, 2 Jul 2014 13:15:18 +0000 (+0000) Subject: Stop restoring kernel flags to their state before dhcpcd ran. X-Git-Tag: v6.4.1~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e17496222ac347191a66defd35d2266d56240f9b;p=thirdparty%2Fdhcpcd.git Stop restoring kernel flags to their state before dhcpcd ran. As multiple dhcpcd daemons could be in use to facilitate separate sessions per DHCPv6 IA resetting them at exist could break the others. --- diff --git a/dhcpcd.c b/dhcpcd.c index 46a7b8c9..47481ded 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1666,7 +1666,6 @@ exit1: free_options(ifo); free_globals(&ctx); - if_rarestore(&ctx); ipv4_ctxfree(&ctx); ipv6_ctxfree(&ctx); dev_stop(&ctx, !(ctx.options & DHCPCD_FORKED)); diff --git a/dhcpcd.h b/dhcpcd.h index 105da431..7371b602 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -123,11 +123,8 @@ struct dhcpcd_ctx { struct dhcp_opt *dhcp6_opts; size_t dhcp6_opts_len; struct ipv6_ctx *ipv6; - char **ra_restore; - size_t ra_restore_len; #ifndef __linux__ int ra_global; - int ra_kernel_set; #endif #endif /* INET6 */ diff --git a/if-bsd.c b/if-bsd.c index fd5ac0ea..a0b82f12 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -1019,47 +1019,6 @@ if_nd6reachable(const char *ifname, struct in6_addr *addr) return flags; } -void -if_rarestore(struct dhcpcd_ctx *ctx) -{ - - if (ctx->options & DHCPCD_FORKED) - return; - - for (; ctx->ra_restore_len > 0; ctx->ra_restore_len--) { -#ifdef ND6_IFF_ACCEPT_RTADV - if (!(ctx->options & DHCPCD_FORKED)) { - syslog(LOG_DEBUG, - "%s: restoring kernel IPv6 RA support", - ctx->ra_restore[ctx->ra_restore_len - 1]); - if (set_if_nd6_flag( - ctx->ra_restore[ctx->ra_restore_len -1], - ND6_IFF_ACCEPT_RTADV) == -1 && - errno != ENXIO) - syslog(LOG_ERR, "%s: set_if_nd6_flag: %m", - ctx->ra_restore[ctx->ra_restore_len - 1]); -#ifdef ND6_IFF_OVERRIDE_RTADV - if (ctx->ra_kernel_set == 0 && del_if_nd6_flag( - ctx->ra_restore[ctx->ra_restore_len -1], - ND6_IFF_OVERRIDE_RTADV) == -1 && - errno != ENXIO) - syslog(LOG_ERR, "%s: del_if_nd6_flag: %m", - ctx->ra_restore[ctx->ra_restore_len - 1]); -#endif - } -#endif - free(ctx->ra_restore[ctx->ra_restore_len - 1]); - } - free(ctx->ra_restore); - ctx->ra_restore = NULL; - - if (ctx->ra_kernel_set) { - syslog(LOG_DEBUG, "restoring kernel IPv6 RA support"); - if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 1) == -1) - syslog(LOG_ERR, "IPV6CTL_ACCEPT_RTADV: %m"); - } -} - static int if_raflush(void) { @@ -1087,10 +1046,6 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) #ifdef ND6_IFF_OVERRIDE_RTADV int override; #endif -#ifdef ND6_IFF_ACCEPT_RTADV - size_t i; - char *p, **nrest; -#endif #ifdef ND6_IFF_IFDISABLED if (del_if_nd6_flag(ifname, ND6_IFF_IFDISABLED) == -1) { @@ -1179,25 +1134,6 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) return ra; } #endif - for (i = 0; i < ctx->ra_restore_len; i++) - if (strcmp(ctx->ra_restore[i], ifname) == 0) - break; - if (i == ctx->ra_restore_len) { - p = strdup(ifname); - if (p == NULL) { - syslog(LOG_ERR, "%s: %m", __func__); - return 0; - } - nrest = realloc(ctx->ra_restore, - (ctx->ra_restore_len + 1) * sizeof(char *)); - if (nrest == NULL) { - syslog(LOG_ERR, "%s: %m", __func__); - free(p); - return 0; - } - ctx->ra_restore = nrest; - ctx->ra_restore[ctx->ra_restore_len++] = p; - } return 0; } return ra; @@ -1219,7 +1155,6 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) return ra; } ra = 0; - ctx->ra_kernel_set = 1; /* Flush the kernel knowledge of advertised routers * and prefixes so the kernel does not expire prefixes diff --git a/if-linux.c b/if-linux.c index c00304dc..be9abb6b 100644 --- a/if-linux.c +++ b/if-linux.c @@ -1223,33 +1223,11 @@ if_addrflags6(const char *ifname, const struct in6_addr *addr) static const char *prefix = "/proc/sys/net/ipv6/conf"; -void -if_rarestore(struct dhcpcd_ctx *ctx) -{ - char path[256]; - - for (; ctx->ra_restore_len > 0; ctx->ra_restore_len--) { - if (!(ctx->options & DHCPCD_FORKED)) { - syslog(LOG_DEBUG, - "%s: restoring kernel IPv6 RA support", - ctx->ra_restore[ctx->ra_restore_len - 1]); - snprintf(path, sizeof(path), "%s/%s/accept_ra", - prefix, ctx->ra_restore[ctx->ra_restore_len - 1]); - if (write_path(path, "1") == -1 && errno != ENOENT) - syslog(LOG_ERR, "write_path: %s: %m", path); - } - free(ctx->ra_restore[ctx->ra_restore_len - 1]); - } - free(ctx->ra_restore); - ctx->ra_restore = NULL; -} - int -if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) +if_checkipv6(__unused struct dhcpcd_ctx *ctx, const char *ifname, int own) { int ra; - size_t i; - char path[256], *p, **nrest; + char path[256]; if (ifname == NULL) ifname = "all"; @@ -1283,25 +1261,6 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) syslog(LOG_ERR, "write_path: %s: %m", path); return ra; } - for (i = 0; i < ctx->ra_restore_len; i++) - if (strcmp(ctx->ra_restore[i], ifname) == 0) - break; - if (i == ctx->ra_restore_len) { - p = strdup(ifname); - if (p == NULL) { - syslog(LOG_ERR, "%s: %m", __func__); - return 0; - } - nrest = realloc(ctx->ra_restore, - (ctx->ra_restore_len + 1) * sizeof(char *)); - if (nrest == NULL) { - syslog(LOG_ERR, "%s: %m", __func__); - free(p); - return 0; - } - ctx->ra_restore = nrest; - ctx->ra_restore[ctx->ra_restore_len++] = p; - } return 0; } diff --git a/if.h b/if.h index f2616de7..2f6e25b5 100644 --- a/if.h +++ b/if.h @@ -132,7 +132,6 @@ int if_route(const struct rt *rt, int); #ifdef INET6 int if_checkipv6(struct dhcpcd_ctx *ctx, const char *, int); -void if_rarestore(struct dhcpcd_ctx *); int if_nd6reachable(const char *ifname, struct in6_addr *addr); int if_address6(const struct ipv6_addr *, int); @@ -146,7 +145,6 @@ int if_route6(const struct rt6 *rt, int); #define if_delroute6(rt) if_route6(rt, -1) #else #define if_checkipv6(a, b, c) (-1) -#define if_rarestore(a) #endif int if_machinearch(char *, size_t);