summaryrefslogtreecommitdiffstats
path: root/src/if.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-01-22 14:51:42 +0000
committerRoy Marples <roy@marples.name>2019-01-22 14:51:42 +0000
commit3250805123f455a7aa1477ccf5d69598dd9f0935 (patch)
tree67ecbc6db3f33341e86a4bb7b4750cbe68c46cc5 /src/if.c
parent57d586821dd9ffcccce8adb3b6302eaf5efd70e6 (diff)
downloaddhcpcd-3250805123f455a7aa1477ccf5d69598dd9f0935.tar.xz
BSD: Turn on SO_RERROR for all sockets
So we can detect IPv6ND or DHCPv6 overflow as well as route(4) overflow.
Diffstat (limited to 'src/if.c')
-rw-r--r--src/if.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/if.c b/src/if.c
index 7807d89b..2aa28190 100644
--- a/src/if.c
+++ b/src/if.c
@@ -790,6 +790,9 @@ xsocket(int domain, int type, int protocol)
#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 @@ xsocket(int domain, int type, int protocol)
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)