kernel-netlinks get_interface() considers virtual IPs, too
authorMartin Willi <martin@revosec.ch>
Mon, 17 Dec 2012 13:23:44 +0000 (14:23 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 17 Dec 2012 13:23:44 +0000 (14:23 +0100)
When using load-tester, we can install tunnel outer addresses on
demand. As these are installed as "virtual", we have to consider
virtual IPs in the get_interface() lookup to install "real" virtual
IPs to these dynamic external addresses.

src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c

index 23a354d..e478878 100644 (file)
@@ -1229,6 +1229,19 @@ METHOD(kernel_net_t, get_interface_name, bool,
                this->lock->unlock(this->lock);
                return TRUE;
        }
                this->lock->unlock(this->lock);
                return TRUE;
        }
+       /* in a second step, consider virtual IPs installed by us */
+       entry = this->vips->get_match(this->vips, &lookup,
+                                                                 (void*)addr_map_entry_match_up_and_usable);
+       if (entry)
+       {
+               if (name)
+               {
+                       *name = strdup(entry->iface->ifname);
+                       DBG2(DBG_KNL, "virtual %H is on interface %s", ip, *name);
+               }
+               this->lock->unlock(this->lock);
+               return TRUE;
+       }
        /* maybe it is installed on an ignored interface */
        entry = this->addrs->get_match(this->addrs, &lookup,
                                                                  (void*)addr_map_entry_match_up);
        /* maybe it is installed on an ignored interface */
        entry = this->addrs->get_match(this->addrs, &lookup,
                                                                  (void*)addr_map_entry_match_up);