Skip to content

Commit 42e99ad

Browse files
committed
net: skip non-route netlink responses
This shouldn't usually be hit, but is a good belt-and-braces.
1 parent 57ce645 commit 42e99ad

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/common/netif.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
9797
rtmsg* r = (rtmsg*)NLMSG_DATA(hdr);
9898
int remaining_len = RTM_PAYLOAD(hdr);
9999

100+
if (hdr->nlmsg_type != RTM_NEWROUTE) {
101+
continue; // Skip non-route messages
102+
}
103+
100104
// Only consider default routes (destination prefix length of 0).
101105
if (r->rtm_dst_len != 0) {
102106
continue;

0 commit comments

Comments
 (0)