diff options
author | Martin Willi <martin@strongswan.org> | 2008-11-05 07:38:55 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-11-05 07:38:55 +0000 |
commit | 31537fd970e666cd1605d2eb0bf5b3280834b416 (patch) | |
tree | 5162b6aa75223f731562f2daed09b0c6274ce270 /src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c | |
parent | 746115a0bebb64f9529b42c8adf2a8ac8b92cc1f (diff) | |
download | strongswan-31537fd970e666cd1605d2eb0bf5b3280834b416.tar.bz2 strongswan-31537fd970e666cd1605d2eb0bf5b3280834b416.tar.xz |
do not install route if interface lookup failed
Diffstat (limited to 'src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c')
-rw-r--r-- | src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c b/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c index 9fd624a7f..4d6211b8b 100644 --- a/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c +++ b/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c @@ -1506,22 +1506,30 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this, memcpy(route->dst_net.ptr, &policy->sel.saddr, route->dst_net.len); route->prefixlen = policy->sel.prefixlen_s; - switch (charon->kernel_interface->add_route(charon->kernel_interface, - route->dst_net, route->prefixlen, route->gateway, - route->src_ip, route->if_name)) + if (route->if_name) + { + switch (charon->kernel_interface->add_route( + charon->kernel_interface, route->dst_net, + route->prefixlen, route->gateway, + route->src_ip, route->if_name)) + { + default: + DBG1(DBG_KNL, "unable to install source route for %H", + route->src_ip); + /* FALL */ + case ALREADY_DONE: + /* route exists, do not uninstall */ + route_entry_destroy(route); + break; + case SUCCESS: + /* cache the installed route */ + policy->route = route; + break; + } + } + else { - default: - DBG1(DBG_KNL, "unable to install source route for %H", - route->src_ip); - /* FALL */ - case ALREADY_DONE: - /* route exists, do not uninstall */ - route_entry_destroy(route); - break; - case SUCCESS: - /* cache the installed route */ - policy->route = route; - break; + route_entry_destroy(route); } } else @@ -1529,7 +1537,6 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this, free(route); } } - return SUCCESS; } |