]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
dhcpcd: When route socket overflows, report how large it is.
authorRoy Marples <roy@marples.name>
Sun, 26 Jan 2020 15:46:41 +0000 (15:46 +0000)
committerRoy Marples <roy@marples.name>
Sun, 26 Jan 2020 15:46:41 +0000 (15:46 +0000)
Of course Linux likes to double it, so cater for this.

src/dhcpcd.c

index 20ade526865bcc3faad3755d81b8c9038919a94c..b6c531d61814ad18b9f012f752f7066b3667eca7 100644 (file)
@@ -1116,11 +1116,23 @@ dhcpcd_setlinkrcvbuf(struct dhcpcd_ctx *ctx)
 void
 dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx)
 {
+       socklen_t socklen;
+       int rcvbuflen;
        struct if_head *ifaces;
        struct ifaddrs *ifaddrs;
        struct interface *ifp, *ifn, *ifp1;
 
-       logerrx("route socket overflowed - learning interface state");
+       socklen = sizeof(rcvbuflen);
+       if (getsockopt(ctx->link_fd, SOL_SOCKET,
+           SO_RCVBUF, &rcvbuflen, &socklen) == -1)
+               rcvbuflen = 0;
+#ifdef __linux__
+       else
+               rcvbuflen /= 2;
+#endif
+
+       logerrx("route socket overflowed (rcvbuflen %d)"
+           " - learning interface state", rcvbuflen);
 
        /* Close the existing socket and open a new one.
         * This is easier than draining the kernel buffer of an