aboutsummaryrefslogtreecommitdiffstats
path: root/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c')
-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;