From: Martin Willi Date: Fri, 19 Apr 2013 14:55:38 +0000 (+0200) Subject: kernel-pfroute: mark IPs installed on tun device as virtual X-Git-Tag: 5.1.0dr1~153^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77b6f19694e4705db56e6ee18c4e22a16f4910f7;p=thirdparty%2Fstrongswan.git kernel-pfroute: mark IPs installed on tun device as virtual --- diff --git a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c index 44f31080df..62664023af 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;