summaryrefslogtreecommitdiffstats
path: root/src/if-bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-04-29 14:55:23 +0100
committerRoy Marples <roy@marples.name>2020-04-29 14:55:23 +0100
commit04718f4885340118f67cd2655907bb86a0ccace1 (patch)
treea9539aa822e6909d00f0aaf01dbbcc2ddbe1771d /src/if-bsd.c
parent3e72861dd03bd8ffb428fe937f2aa1615b8aadb0 (diff)
downloaddhcpcd-04718f4885340118f67cd2655907bb86a0ccace1.tar.xz
NetBSD: Gear up for kernel RA removal.
linkmtu will vanish from nd_ifinfo along with other things. Also, there is not need to pre-fetch ifinfo because flags are no longer updated when setting ifinfo back again.
Diffstat (limited to 'src/if-bsd.c')
-rw-r--r--src/if-bsd.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/if-bsd.c b/src/if-bsd.c
index 42bf7480..9a491b31 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -1649,18 +1649,30 @@ if_applyra(const struct ra *rap)
#ifdef SIOCSIFINFO_IN6
struct in6_ndireq nd = { .ndi.chlim = 0 };
struct dhcpcd_ctx *ctx = rap->iface->ctx;
- struct priv *priv = ctx->priv;
int error;
strlcpy(nd.ifname, rap->iface->name, sizeof(nd.ifname));
+
+#ifdef IPV6CTL_ACCEPT_RTADV
+ struct priv *priv = ctx->priv;
+
+ /*
+ * NetBSD changed SIOCSIFINFO_IN6 to NOT set flags when kernel
+ * RA was removed, however both FreeBSD and DragonFlyBSD still do.
+ * linkmtu was also removed.
+ * Hopefully this guard will still work if either remove kernel RA.
+ */
if (ioctl(priv->pf_inet6_fd, SIOCGIFINFO_IN6, &nd, sizeof(nd)) == -1)
return -1;
nd.ndi.linkmtu = rap->mtu;
+#endif
+
nd.ndi.chlim = rap->hoplimit;
nd.ndi.retrans = rap->retrans;
nd.ndi.basereachable = rap->reachable;
error = if_ioctl6(ctx, SIOCSIFINFO_IN6, &nd, sizeof(nd));
+#ifdef IPV6CTL_ACCEPT_RTADV
if (error == -1 && errno == EINVAL) {
/*
* Very likely that this is caused by a dodgy MTU
@@ -1672,6 +1684,7 @@ if_applyra(const struct ra *rap)
nd.ndi.linkmtu = 0;
error = if_ioctl6(ctx, SIOCSIFINFO_IN6, &nd, sizeof(nd));
}
+#endif
return error;
#else
#warning OS does not allow setting of RA bits hoplimit, retrans or reachable