kernel-pfroute: Don't cache route entries if installation fails
authorTobias Brunner <tobias@strongswan.org>
Fri, 7 Feb 2014 10:37:58 +0000 (11:37 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 12 Feb 2014 12:52:25 +0000 (13:52 +0100)
src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c

index bc10610..844d7c4 100644 (file)
@@ -1420,9 +1420,12 @@ METHOD(kernel_net_t, add_route, status_t,
                this->routes_lock->unlock(this->routes_lock);
                return ALREADY_DONE;
        }
-       found = route_entry_clone(&route);
-       this->routes->put(this->routes, found, found);
        status = manage_route(this, RTM_ADD, dst_net, prefixlen, gateway, if_name);
+       if (status == SUCCESS)
+       {
+               found = route_entry_clone(&route);
+               this->routes->put(this->routes, found, found);
+       }
        this->routes_lock->unlock(this->routes_lock);
        return status;
 }