net: skip non-route netlink responses

This shouldn't usually be hit, but is a good belt-and-braces.
This commit is contained in:
willcl-ark
2025-04-02 09:47:27 +01:00
parent 57ce645f05
commit 42e99ad773

View File

@@ -97,6 +97,10 @@ std::optional<CNetAddr> 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;