mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
net: filter for default routes in netlink responses
Filter netlink responses to only consider default routes by checking the destination prefix length (rtm_dst_len == 0). Previously, we selected the first route with an RTA_GATEWAY attribute, which for IPv6 often resulted in choosing a non-default route instead of the actual default. This caused occasional PCP port mapping failures because a gateway for a non-default route was selected.
This commit is contained in:
parent
74d9598bfb
commit
57ce645f05
1 changed files with 5 additions and 0 deletions
|
@ -97,6 +97,11 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
|
|||
rtmsg* r = (rtmsg*)NLMSG_DATA(hdr);
|
||||
int remaining_len = RTM_PAYLOAD(hdr);
|
||||
|
||||
// Only consider default routes (destination prefix length of 0).
|
||||
if (r->rtm_dst_len != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Iterate over the attributes.
|
||||
rtattr *rta_gateway = nullptr;
|
||||
int scope_id = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue