From 7cf6ba7ec3d5759a2cfea9823f2ecea6461d0e04 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 30 Apr 2014 14:13:22 +0000 Subject: [PATCH] Support ND6_IFF_OVERRIDE_RTADV --- dhcpcd.c | 1 + if-bsd.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/dhcpcd.c b/dhcpcd.c index 2927dfc0..8d2ed326 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -350,6 +350,7 @@ configure_interface1(struct interface *ifp) ifp->ctx->options & DHCPCD_IPV6RA_OWN ? 1 : 0); ra_iface = if_checkipv6(ifp->ctx, ifp->name, ifp->options->options & DHCPCD_IPV6RA_OWN ? 1 : 0); + printf ("ra global %d ifp %d\n", ra_global, ra_iface); if (ra_global == -1 || ra_iface == -1) ifo->options &= ~DHCPCD_IPV6RS; else if (ra_iface == 0) diff --git a/if-bsd.c b/if-bsd.c index 08910d01..b36ccfd9 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -1000,15 +1000,24 @@ if_rarestore(struct dhcpcd_ctx *ctx) return; for (; ctx->ra_restore_len > 0; ctx->ra_restore_len--) { +#ifdef ND6_IFF_ACCEPT_RTADV if (!(ctx->options & DHCPCD_FORKED)) { syslog(LOG_INFO, "%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) + 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) 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); @@ -1045,6 +1054,9 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) int ra; if (ifname) { +#ifdef ND6_IFF_OVERRIDE_RTADV + int override; +#endif #ifdef ND6_IFF_ACCEPT_RTADV size_t i; char *p, **nrest; @@ -1064,6 +1076,14 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) } #endif +#ifdef ND6_IFF_OVERRIDE_RTADV + override = get_if_nd6_flag(ifname, ND6_IFF_OVERRIDE_RTADV); + if (override == -1) + syslog(LOG_ERR, "%s: get_if_nd6_flag: %m", ifname); + else if (override == 0 && !own) + return 0; +#endif + #ifdef ND6_IFF_ACCEPT_RTADV ra = get_if_nd6_flag(ifname, ND6_IFF_ACCEPT_RTADV); if (ra == -1) @@ -1079,6 +1099,16 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) ifname); return ra; } +#ifdef ND6_IFF_OVERRIDE_RTADV + if (override == 0 && ctx->ra_kernel_set == 0 && + set_if_nd6_flag(ifname, ND6_IFF_OVERRIDE_RTADV) + == -1) + { + syslog(LOG_ERR, "%s: set_if_nd6_flag: %m", + ifname); + return ra; + } +#endif for (i = 0; i < ctx->ra_restore_len; i++) if (strcmp(ctx->ra_restore[i], ifname) == 0) break; -- 2.47.3