]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Stop restoring kernel flags to their state before dhcpcd ran.
authorRoy Marples <roy@marples.name>
Wed, 2 Jul 2014 13:15:18 +0000 (13:15 +0000)
committerRoy Marples <roy@marples.name>
Wed, 2 Jul 2014 13:15:18 +0000 (13:15 +0000)
As multiple dhcpcd daemons could be in use to facilitate separate sessions
per DHCPv6 IA resetting them at exist could break the others.

dhcpcd.c
dhcpcd.h
if-bsd.c
if-linux.c
if.h

index 46a7b8c9cd6828251a831f241860a6a1d2ffc221..47481ded607d2849e0372703aa1dc249cc39e8be 100644 (file)
--- 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));
index 105da431c1307c2e792f2cc7c8058d597033166f..7371b602d150c597c02d7d2fd55ce2edb804b052 100644 (file)
--- 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 */
 
index fd5ac0eaf99106840aeff20b6e6b9ea606071cf5..a0b82f122a785c26c6e7b4ad6c93ef6715d803ed 100644 (file)
--- 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
index c00304dc3f277a9c9bbeee7be607f05e6c5da11c..be9abb6b6edbb8ccda51abe2a87b4103417642b9 100644 (file)
@@ -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 f2616de7e85d5c734884d1742d5e3dc06049a6c4..2f6e25b536eca2a5b5f1312558f160e7c3a98caa 100644 (file)
--- 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);