From: Roy Marples Date: Sun, 10 Nov 2019 15:15:16 +0000 (+0000) Subject: BSD: Try and set linkmtu for the interface just to be nice. X-Git-Tag: v8.1.2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd0849c7e299def8aed3f82a7543bc1d19408cb5;p=thirdparty%2Fdhcpcd.git BSD: Try and set linkmtu for the interface just to be nice. If it fails, zero it out and try again - only the linkmtu should fail really. This is fine as we fix it against the route itself. --- diff --git a/src/if-bsd.c b/src/if-bsd.c index c629a7dd..a0870b92 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -1490,15 +1490,29 @@ if_applyra(const struct ra *rap) #ifdef SIOCSIFINFO_IN6 struct in6_ndireq ndi = { .ndi.chlim = 0 }; struct priv *priv = rap->iface->ctx->priv; + int error; strlcpy(ndi.ifname, rap->iface->name, sizeof(ndi.ifname)); if (ioctl(priv->pf_inet6_fd, SIOCGIFINFO_IN6, &ndi) == -1) return -1; + ndi.ndi.linkmtu = rap->mtu; ndi.ndi.chlim = rap->hoplimit; ndi.ndi.retrans = rap->retrans; ndi.ndi.basereachable = rap->reachable; - return ioctl(priv->pf_inet6_fd, SIOCSIFINFO_IN6, &ndi); + error = ioctl(priv->pf_inet6_fd, SIOCSIFINFO_IN6, &ndi); + if (error == -1 && errno == EINVAL) { + /* + * Very likely that this is caused by a dodgy MTU + * setting specific to the interface. + * Let's set it to "unspecified" and try again. + * Doesn't really matter as we fix the MTU against the + * routes we add as not all OS support SIOCSIFINFO_IN6. + */ + ndi.ndi.linkmtu = 0; + error = ioctl(priv->pf_inet6_fd, SIOCSIFINFO_IN6, &ndi); + } + return error; #else #warning OS does not allow setting of RA bits hoplimit, retrans or reachable UNUSED(rap);