]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Linux: Use NETLINK_BROADCAST_ERROR
authorRoy Marples <roy@marples.name>
Sun, 4 Nov 2018 13:01:15 +0000 (13:01 +0000)
committerRoy Marples <roy@marples.name>
Sun, 4 Nov 2018 13:01:15 +0000 (13:01 +0000)
This should allow dhcpcd to detect overflow on netlink, just
like NetBSD and OpenBSD.

src/if-linux.c

index abd4cd526570062153ea49e28873b7bdd614053d..b5f7983d6b6bae4edfce88a17dde954974244ab7 100644 (file)
@@ -294,6 +294,9 @@ if_opensockets_os(struct dhcpcd_ctx *ctx)
        struct priv *priv;
        struct sockaddr_nl snl;
        socklen_t len;
+#ifdef NETLINK_BROADCAST_ERROR
+       int on = 1;
+#endif
 
        /* Open the link socket first so it gets pid() for the socket.
         * Then open our persistent route socket so we get a unique
@@ -311,6 +314,10 @@ if_opensockets_os(struct dhcpcd_ctx *ctx)
        ctx->link_fd = _open_link_socket(&snl, NETLINK_ROUTE);
        if (ctx->link_fd == -1)
                return -1;
+#ifdef NETLINK_BROADCAST_ERROR
+       setsockopt(ctx->link_fd, SOL_NETLINK, NETLINK_BROADCAST_ERROR,
+           &on, sizeof(on));
+#endif
 
        if ((priv = calloc(1, sizeof(*priv))) == NULL)
                return -1;