From 42e99ad77396e4e9b02d67daf46349e215e99a0f Mon Sep 17 00:00:00 2001 From: willcl-ark Date: Wed, 2 Apr 2025 09:47:27 +0100 Subject: [PATCH] net: skip non-route netlink responses This shouldn't usually be hit, but is a good belt-and-braces. --- src/common/netif.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/netif.cpp b/src/common/netif.cpp index dbdd3ddde97..ef0485b8a2d 100644 --- a/src/common/netif.cpp +++ b/src/common/netif.cpp @@ -97,6 +97,10 @@ std::optional QueryDefaultGatewayImpl(sa_family_t family) rtmsg* r = (rtmsg*)NLMSG_DATA(hdr); int remaining_len = RTM_PAYLOAD(hdr); + if (hdr->nlmsg_type != RTM_NEWROUTE) { + continue; // Skip non-route messages + } + // Only consider default routes (destination prefix length of 0). if (r->rtm_dst_len != 0) { continue;