aboutsummaryrefslogtreecommitdiffstats
path: root/src/libhydra/plugins
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-04-19 16:55:38 +0200
committerMartin Willi <martin@revosec.ch>2013-05-06 17:00:55 +0200
commit77b6f19694e4705db56e6ee18c4e22a16f4910f7 (patch)
tree8684e7637c8d41825faead7d30ff87825ea34a51 /src/libhydra/plugins
parent2a2d7a4dc8d11cc5695ed6c0f25bc20830282eaf (diff)
downloadstrongswan-77b6f19694e4705db56e6ee18c4e22a16f4910f7.tar.bz2
strongswan-77b6f19694e4705db56e6ee18c4e22a16f4910f7.tar.xz
kernel-pfroute: mark IPs installed on tun device as virtual
Diffstat (limited to 'src/libhydra/plugins')
-rw-r--r--src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
index 44f31080d..62664023a 100644
--- a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
+++ b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
@@ -823,8 +823,11 @@ METHOD(kernel_net_t, get_source_addr, host_t*,
METHOD(kernel_net_t, add_ip, status_t,
private_kernel_pfroute_net_t *this, host_t *vip, int prefix,
- char *iface)
+ char *ifname)
{
+ enumerator_t *ifaces, *addrs;
+ iface_entry_t *iface;
+ addr_entry_t *addr;
tun_device_t *tun;
bool timeout = FALSE;
@@ -860,6 +863,26 @@ METHOD(kernel_net_t, add_ip, status_t,
this->lock->write_lock(this->lock);
this->tuns->insert_last(this->tuns, tun);
+
+ ifaces = this->ifaces->create_enumerator(this->ifaces);
+ while (ifaces->enumerate(ifaces, &iface))
+ {
+ if (streq(iface->ifname, tun->get_name(tun)))
+ {
+ addrs = iface->addrs->create_enumerator(iface->addrs);
+ while (addrs->enumerate(addrs, &addr))
+ {
+ if (addr->ip->ip_equals(addr->ip, vip))
+ {
+ addr->virtual = TRUE;
+ addr->refcount = 1;
+ }
+ }
+ addrs->destroy(addrs);
+ }
+ }
+ ifaces->destroy(ifaces);
+
this->lock->unlock(this->lock);
return SUCCESS;