kernel-netlink: Use RTA_SRC to specify route source in kernel-based lookups

For table dumps the kernel accepts RTA_PREFSRC to filter the routes, which is
what we do when doing userspace route calculations. For kernel-based route
lookups, however, the RTA_PREFSRC attribute is ignored and we must specify
RTA_SRC for policy based route lookups.
This commit is contained in:
Martin Willi 2017-01-19 11:23:45 +01:00
parent 558691b3b0
commit 395500b8c1

View File

@ -1883,8 +1883,15 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
if (candidate)
{
chunk = candidate->get_address(candidate);
if (hdr->nlmsg_flags & NLM_F_DUMP)
{
netlink_add_attribute(hdr, RTA_PREFSRC, chunk, sizeof(request));
}
else
{
netlink_add_attribute(hdr, RTA_SRC, chunk, sizeof(request));
}
}
/* we use this below to match against the routes */
chunk = dest->get_address(dest);
if (!match_net)