Don't wait while removing external IPs used for load testing
authorMartin Willi <martin@revosec.ch>
Mon, 12 Nov 2012 10:14:03 +0000 (11:14 +0100)
committerMartin Willi <martin@revosec.ch>
Thu, 29 Nov 2012 09:22:51 +0000 (10:22 +0100)
src/libcharon/plugins/load_tester/load_tester_config.c
src/libcharon/sa/child_sa.c
src/libcharon/sa/ike_sa.c
src/libhydra/kernel/kernel_interface.c
src/libhydra/kernel/kernel_interface.h
src/libhydra/kernel/kernel_net.h
src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c
src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c

index 7dc90c1..6024dd9 100644 (file)
@@ -539,7 +539,7 @@ METHOD(load_tester_config_t, delete_ip, void,
                        if (pool->release_address(pool, ip, found))
                        {
                                hydra->kernel_interface->del_ip(hydra->kernel_interface,
-                                                                                               ip, this->prefix);
+                                                                                               ip, this->prefix, FALSE);
                        }
                        found->destroy(found);
                        break;
index 7083eb4..f02d836 100644 (file)
@@ -829,7 +829,7 @@ static void reinstall_vip(host_t *vip, host_t *me)
        if (hydra->kernel_interface->get_interface(hydra->kernel_interface,
                                                                                           me, &iface))
        {
-               hydra->kernel_interface->del_ip(hydra->kernel_interface, vip, -1);
+               hydra->kernel_interface->del_ip(hydra->kernel_interface, vip, -1, TRUE);
                hydra->kernel_interface->add_ip(hydra->kernel_interface, vip, -1, iface);
                free(iface);
        }
index 8585745..4862111 100644 (file)
@@ -780,7 +780,8 @@ METHOD(ike_sa_t, clear_virtual_ips, void,
        {
                if (local)
                {
-                       hydra->kernel_interface->del_ip(hydra->kernel_interface, vip, -1);
+                       hydra->kernel_interface->del_ip(hydra->kernel_interface,
+                                                                                       vip, -1, TRUE);
                }
                vip->destroy(vip);
        }
@@ -2087,7 +2088,7 @@ METHOD(ike_sa_t, destroy, void,
 
        while (this->my_vips->remove_last(this->my_vips, (void**)&vip) == SUCCESS)
        {
-               hydra->kernel_interface->del_ip(hydra->kernel_interface, vip, -1);
+               hydra->kernel_interface->del_ip(hydra->kernel_interface, vip, -1, TRUE);
                vip->destroy(vip);
        }
        this->my_vips->destroy(this->my_vips);
index 733aced..8948e05 100644 (file)
@@ -323,13 +323,13 @@ METHOD(kernel_interface_t, add_ip, status_t,
 }
 
 METHOD(kernel_interface_t, del_ip, status_t,
-       private_kernel_interface_t *this, host_t *virtual_ip, int prefix)
+       private_kernel_interface_t *this, host_t *virtual_ip, int prefix, bool wait)
 {
        if (!this->net)
        {
                return NOT_SUPPORTED;
        }
-       return this->net->del_ip(this->net, virtual_ip, prefix);
+       return this->net->del_ip(this->net, virtual_ip, prefix, wait);
 }
 
 METHOD(kernel_interface_t, add_route, status_t,
index a5ee0b5..8d8ef2e 100644 (file)
@@ -349,9 +349,11 @@ struct kernel_interface_t {
         *
         * @param virtual_ip    virtual ip address to assign
         * @param prefix                prefix length of the IP to uninstall, -1 for auto
+        * @param wait                  TRUE to wait untily IP is gone
         * @return                              SUCCESS if operation completed
         */
-       status_t (*del_ip) (kernel_interface_t *this, host_t *virtual_ip, int prefix);
+       status_t (*del_ip) (kernel_interface_t *this, host_t *virtual_ip,
+                                               int prefix, bool wait);
 
        /**
         * Add a route.
index a6b7686..6a3b2ce 100644 (file)
@@ -128,9 +128,11 @@ struct kernel_net_t {
         *
         * @param virtual_ip    virtual ip address to assign
         * @param prefix                prefix length of the IP to uninstall, -1 for auto
+        * @param wait                  TRUE to wait until IP is gone
         * @return                              SUCCESS if operation completed
         */
-       status_t (*del_ip) (kernel_net_t *this, host_t *virtual_ip, int prefix);
+       status_t (*del_ip) (kernel_net_t *this, host_t *virtual_ip, int prefix,
+                                               bool wait);
 
        /**
         * Add a route.
index c00fa88..23a354d 100644 (file)
@@ -1758,7 +1758,8 @@ METHOD(kernel_net_t, add_ip, status_t,
 }
 
 METHOD(kernel_net_t, del_ip, status_t,
-       private_kernel_netlink_net_t *this, host_t *virtual_ip, int prefix)
+       private_kernel_netlink_net_t *this, host_t *virtual_ip, int prefix,
+       bool wait)
 {
        addr_map_entry_t *entry, lookup = {
                .ip = virtual_ip,
@@ -1798,7 +1799,7 @@ METHOD(kernel_net_t, del_ip, status_t,
                entry->addr->installed = FALSE;
                status = manage_ipaddr(this, RTM_DELADDR, 0, entry->iface->ifindex,
                                                           virtual_ip, prefix);
-               if (status == SUCCESS)
+               if (status == SUCCESS && wait)
                {       /* wait until the address is really gone */
                        while (is_known_vip(this, virtual_ip))
                        {
index 7311ded..7ac3e8a 100644 (file)
@@ -647,7 +647,8 @@ METHOD(kernel_net_t, add_ip, status_t,
 }
 
 METHOD(kernel_net_t, del_ip, status_t,
-       private_kernel_pfroute_net_t *this, host_t *virtual_ip, int prefix)
+       private_kernel_pfroute_net_t *this, host_t *virtual_ip, int prefix,
+       bool wait)
 {
        return FAILED;
 }