summaryrefslogtreecommitdiffstats
path: root/src/if-bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2018-03-19 15:39:05 +0000
committerRoy Marples <roy@marples.name>2018-03-19 15:39:05 +0000
commit1437db1d25f09c5235ed792bd278ee3f0f17dd65 (patch)
treedecb2c14336f00dff8f505e394e099ec8a2c40ba /src/if-bsd.c
parent81edfe77f1ab8c5e9d5761fda73506d2a28710fb (diff)
downloaddhcpcd-1437db1d25f09c5235ed792bd278ee3f0f17dd65.tar.xz
link: detect buffer overflow / desync and relearn interface state
It's possible for the internal kernel buffer that reports network events to overflow. On Linux and NetBSD* this is handled by ENOBUFS being returned by recv(2). On OpenBSD there is a special route(4) message RTM_DESYNC. All other OS's don't seem to report this error, so dhcpcd cannot detect it. * I will commit a patch to NetBSD soon for this and will request a pullup to NetBSD-8.
Diffstat (limited to 'src/if-bsd.c')
-rw-r--r--src/if-bsd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/if-bsd.c b/src/if-bsd.c
index f259e821..fcb81001 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -1210,6 +1210,11 @@ if_dispatch(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm)
case RTM_NEWADDR:
if_ifa(ctx, (const void *)rtm);
break;
+#ifdef RTM_DESYNC
+ case RTM_DESYNC:
+ dhcpcd_linkoverflow(ctx);
+ break;
+#endif
}
}
@@ -1223,7 +1228,8 @@ if_handlelink(struct dhcpcd_ctx *ctx)
msg.msg_iov = ctx->iov;
msg.msg_iovlen = 1;
- if ((len = recvmsg_realloc(ctx->link_fd, &msg, 0)) == -1)
+ len = recvmsg_realloc(ctx->link_fd, &msg, 0);
+ if (len == -1)
return -1;
if (len != 0)
if_dispatch(ctx, ctx->iov[0].iov_base);
@@ -1480,9 +1486,11 @@ if_setup_inet6(const struct interface *ifp)
char ifname[IFNAMSIZ + 8];
strlcpy(ifname, ifp->name, sizeof(ifname));
- if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&ifname) == -1)
+ if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&ifname) == -1 &&
+ errno != ENOTSUP)
logwarn("SIOCSRTRFLUSH_IN6");
- if (ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&ifname) == -1)
+ if (ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&ifname) == -1 &&
+ errno != ENOTSUP)
logwarn("SIOCSPFXFLUSH_IN6");
}
#endif