Mercurial > hg > dhcpcd
changeset 4343:6aaf514ac20d draft
BSD: Turn on SO_RERROR for all sockets
So we can detect IPv6ND or DHCPv6 overflow as well as route(4)
overflow.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Tue, 22 Jan 2019 14:51:42 +0000 |
| parents | 3c30f2eb43a4 |
| children | b1963fd13968 |
| files | src/if-bsd.c src/if.c |
| diffstat | 2 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if-bsd.c Thu Jan 17 11:49:52 2019 +0000 +++ b/src/if-bsd.c Tue Jan 22 14:51:42 2019 +0000 @@ -170,16 +170,6 @@ &n, sizeof(n)) == -1) logerr("%s: SO_USELOOPBACK", __func__); -#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. */ - n = 1; - if (setsockopt(ctx->link_fd, SOL_SOCKET, SO_RERROR, - &n, sizeof(n)) == -1) - logerr("%s: SO_RERROR", __func__); -#endif - #if defined(RO_MSGFILTER) if (setsockopt(ctx->link_fd, PF_ROUTE, RO_MSGFILTER, &msgfilter, sizeof(msgfilter)) == -1)
--- a/src/if.c Thu Jan 17 11:49:52 2019 +0000 +++ b/src/if.c Tue Jan 22 14:51:42 2019 +0000 @@ -790,6 +790,9 @@ #if !defined(HAVE_SOCK_CLOEXEC) || !defined(HAVE_SOCK_NONBLOCK) int xflags, xtype = type; #endif +#ifdef SO_RERROR + int on; +#endif #ifndef HAVE_SOCK_CLOEXEC if (xtype & SOCK_CLOEXEC) @@ -814,6 +817,13 @@ goto out; #endif +#ifdef SO_RERROR + /* Tell recvmsg(2) to return ENOBUFS if the receiving socket overflows. */ + on = 1; + if (setsockopt(s, SOL_SOCKET, SO_RERROR, &on, sizeof(on)) == -1) + logerr("%s: SO_RERROR", __func__); +#endif + return s; #if !defined(HAVE_SOCK_CLOEXEC) || !defined(HAVE_SOCK_NONBLOCK)
