summaryrefslogtreecommitdiffstats
path: root/src/if-bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-11-10 15:15:16 +0000
committerRoy Marples <roy@marples.name>2019-11-10 15:15:16 +0000
commit7857a08e7c28cb16368501da110ec6f2a8e36e46 (patch)
treec71b8bcf6e579af8aab92dc7761308081c6bba63 /src/if-bsd.c
parent7499c22baaa7263e581798619aee2bbb4600bcf6 (diff)
downloaddhcpcd-7857a08e7c28cb16368501da110ec6f2a8e36e46.tar.xz
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.
Diffstat (limited to 'src/if-bsd.c')
-rw-r--r--src/if-bsd.c16
1 files changed, 15 insertions, 1 deletions
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);