free_options(ifo);
free_globals(&ctx);
- if_rarestore(&ctx);
ipv4_ctxfree(&ctx);
ipv6_ctxfree(&ctx);
dev_stop(&ctx, !(ctx.options & DHCPCD_FORKED));
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 */
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)
{
#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) {
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;
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
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";
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;
}
#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);
#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);