From: Roy Marples Date: Wed, 7 Nov 2018 18:57:20 +0000 (+0000) Subject: BSD: Use SO_RERROR on the route(4) socket. X-Git-Tag: v7.1.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=776fa23a7589f63377a10bcaf50a26eebe17f329;p=thirdparty%2Fdhcpcd.git BSD: Use SO_RERROR on the route(4) socket. This allows NetBSD to receive ENOBUFS again so it can detect route(4) overflow. This was recently defaulted to off globably, but is now settable per socket. --- diff --git a/src/if-bsd.c b/src/if-bsd.c index c1a6be86..e9ebfdce 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -125,6 +125,9 @@ int if_opensockets_os(struct dhcpcd_ctx *ctx) { struct priv *priv; +#ifdef SO_RERROR + int on = 1; +#endif #if defined(RO_MSGFILTER) || defined(ROUTE_MSGFILTER) unsigned char msgfilter[] = { RTM_IFINFO, @@ -161,6 +164,15 @@ if_opensockets_os(struct dhcpcd_ctx *ctx) if (ctx->link_fd == -1) return -1; +#ifdef SO_RERROR + /* Tell recvmsg(2) to return ENOBUFS if the receiving socket overflows + * from too many route(4) messages so we can re-sync our state + * with reality. */ + if (setsockopt(ctx->link_fd, SOL_SOCKET, SO_RERROR, + &on, sizeof(on)) == -1) + logerr("%s: SO_RERROR", __func__); +#endif + #if defined(RO_MSGFILTER) if (setsockopt(ctx->link_fd, PF_ROUTE, RO_MSGFILTER, &msgfilter, sizeof(msgfilter)) == -1)