Use source address in get_nexthop() call
Otherwise the nexthop returned might belong to a different route than the one actually used with the current source address.
This commit is contained in:
@@ -2174,7 +2174,7 @@ METHOD(kernel_ipsec_t, add_policy, status_t,
|
||||
|
||||
/* get the nexthop to dst */
|
||||
route->gateway = hydra->kernel_interface->get_nexthop(
|
||||
hydra->kernel_interface, dst);
|
||||
hydra->kernel_interface, dst, route->src_ip);
|
||||
route->dst_net = chunk_clone(policy->dst.net->get_address(policy->dst.net));
|
||||
route->prefixlen = policy->dst.mask;
|
||||
|
||||
|
||||
@@ -2167,7 +2167,8 @@ static status_t add_policy_internal(private_kernel_netlink_ipsec_t *this,
|
||||
{
|
||||
/* get the nexthop to src (src as we are in POLICY_FWD) */
|
||||
route->gateway = hydra->kernel_interface->get_nexthop(
|
||||
hydra->kernel_interface, ipsec->src);
|
||||
hydra->kernel_interface, ipsec->src,
|
||||
ipsec->dst);
|
||||
/* install route via outgoing interface */
|
||||
route->if_name = hydra->kernel_interface->get_interface(
|
||||
hydra->kernel_interface, ipsec->dst);
|
||||
|
||||
@@ -1443,9 +1443,9 @@ METHOD(kernel_net_t, get_source_addr, host_t*,
|
||||
}
|
||||
|
||||
METHOD(kernel_net_t, get_nexthop, host_t*,
|
||||
private_kernel_netlink_net_t *this, host_t *dest)
|
||||
private_kernel_netlink_net_t *this, host_t *dest, host_t *src)
|
||||
{
|
||||
return get_route(this, dest, TRUE, NULL);
|
||||
return get_route(this, dest, TRUE, src);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2026,7 +2026,8 @@ static status_t add_policy_internal(private_kernel_pfkey_ipsec_t *this,
|
||||
{
|
||||
/* get the nexthop to src (src as we are in POLICY_FWD).*/
|
||||
route->gateway = hydra->kernel_interface->get_nexthop(
|
||||
hydra->kernel_interface, ipsec->src);
|
||||
hydra->kernel_interface, ipsec->src,
|
||||
ipsec->dst);
|
||||
/* install route via outgoing interface */
|
||||
route->if_name = hydra->kernel_interface->get_interface(
|
||||
hydra->kernel_interface, ipsec->dst);
|
||||
|
||||
@@ -520,7 +520,7 @@ METHOD(kernel_net_t, get_source_addr, host_t*,
|
||||
}
|
||||
|
||||
METHOD(kernel_net_t, get_nexthop, host_t*,
|
||||
private_kernel_pfroute_net_t *this, host_t *dest)
|
||||
private_kernel_pfroute_net_t *this, host_t *dest, host_t *src)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user