From: Martin Willi Date: Wed, 16 Jul 2008 12:30:47 +0000 (-0000) Subject: do not complain about existing routes X-Git-Tag: 4.2.5~37 X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=commitdiff_plain;h=7b9e1ff0fdad9f045fde24a7bbe0b416f35bd1f5 do not complain about existing routes --- diff --git a/src/charon/kernel/kernel_interface.c b/src/charon/kernel/kernel_interface.c index 8e16ba1..b32b198 100644 --- a/src/charon/kernel/kernel_interface.c +++ b/src/charon/kernel/kernel_interface.c @@ -1090,6 +1090,11 @@ static status_t netlink_send_ack(private_kernel_interface_t *this, if (err->error) { + if (-err->error == EEXIST) + { /* do not report existing routes */ + free(out); + return ALREADY_DONE; + } DBG1(DBG_KNL, "received netlink error: %s (%d)", strerror(-err->error), -err->error); free(out); @@ -2737,17 +2742,26 @@ static status_t add_policy(private_kernel_interface_t *this, /* get the nexthop to src (src as we are in POLICY_FWD).*/ policy->route->gateway = get_route(this, src, TRUE); policy->route->if_index = get_interface_index(this, dst); - policy->route->dst_net = chunk_alloc(policy->sel.family == AF_INET ? 4 : 16); - memcpy(policy->route->dst_net.ptr, &policy->sel.saddr, policy->route->dst_net.len); + policy->route->dst_net = chunk_alloc( + policy->sel.family == AF_INET ? 4 : 16); + memcpy(policy->route->dst_net.ptr, &policy->sel.saddr, + policy->route->dst_net.len); policy->route->prefixlen = policy->sel.prefixlen_s; - if (manage_srcroute(this, RTM_NEWROUTE, NLM_F_CREATE | NLM_F_EXCL, - policy->route) != SUCCESS) + switch (manage_srcroute(this, RTM_NEWROUTE, + NLM_F_CREATE | NLM_F_EXCL, policy->route)) { - DBG1(DBG_KNL, "unable to install source route for %H", - policy->route->src_ip); - route_entry_destroy(policy->route); - policy->route = NULL; + default: + DBG1(DBG_KNL, "unable to install source route for %H", + policy->route->src_ip); + /* FALL */ + case ALREADY_DONE: + /* route exists, do not uninstall */ + route_entry_destroy(policy->route); + policy->route = NULL; + break; + case SUCCESS: + break; } } else