aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2017-01-19 11:23:45 +0100
committerMartin Willi <martin@strongswan.org>2017-02-13 15:11:20 +0100
commit395500b8c1be03a3f2201f7d66e595d13ffcc299 (patch)
tree34caefe77101b092e2d08ad3b367d3e4f1ee7b58 /src/libcharon
parent558691b3b04b82db56a1522360e62bbd6547aa26 (diff)
downloadstrongswan-395500b8c1be03a3f2201f7d66e595d13ffcc299.tar.bz2
strongswan-395500b8c1be03a3f2201f7d66e595d13ffcc299.tar.xz
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.
Diffstat (limited to 'src/libcharon')
-rw-r--r--src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
index 330695600..2dc76d941 100644
--- a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
+++ b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
@@ -1883,7 +1883,14 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
if (candidate)
{
chunk = candidate->get_address(candidate);
- netlink_add_attribute(hdr, RTA_PREFSRC, chunk, sizeof(request));
+ 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);