]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: cleanup properly if rtr mgr cannot add a cache
authorMarcel Röthke <marcel.roethke@haw-hamburg.de>
Thu, 22 Aug 2019 13:49:58 +0000 (15:49 +0200)
committerMarcel Röthke <marcel.roethke@haw-hamburg.de>
Thu, 22 Aug 2019 15:31:09 +0000 (17:31 +0200)
Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
bgpd/bgp_rpki.c

index 32f599745fe74755589680c3b9cea1f5765c681a..28d14ccb8c1269b87104ec3b4ef4ac466ae027ef 100644 (file)
@@ -756,8 +756,6 @@ static int add_cache(struct cache *cache)
        group.sockets_len = 1;
        group.sockets = &cache->rtr_socket;
 
-       listnode_add(cache_list, cache);
-
        if (rtr_is_running) {
                init_tr_socket(cache);
 
@@ -767,6 +765,8 @@ static int add_cache(struct cache *cache)
                }
        }
 
+       listnode_add(cache_list, cache);
+
        return SUCCESS;
 }
 
@@ -793,7 +793,12 @@ static int add_tcp_cache(const char *host, const char *port,
        cache->rtr_socket = rtr_socket;
        cache->preference = preference;
 
-       return add_cache(cache);
+       int ret = add_cache(cache);
+       if (ret != SUCCESS) {
+               free_cache(cache);
+       }
+
+       return ret;
 }
 
 #if defined(FOUND_SSH)
@@ -829,7 +834,12 @@ static int add_ssh_cache(const char *host, const unsigned int port,
        cache->rtr_socket = rtr_socket;
        cache->preference = preference;
 
-       return add_cache(cache);
+       int ret = add_cache(cache);
+       if (ret != SUCCESS) {
+               free_cache(cache);
+       }
+
+       return ret;
 }
 #endif