Stop BGP session even when we are master
authorBenjamin Cama <benoar@dolka.fr>
Sun, 24 Jul 2011 00:26:32 +0000 (02:26 +0200)
committerBenjamin Cama <benoar@dolka.fr>
Fri, 29 Jul 2011 10:54:00 +0000 (12:54 +0200)
Probably a bug; introduced by a patch that made only slaves stop their BGP
session.

Signed-off-by: Benjamin Cama <benoar@dolka.fr>
l2tpns.c

index 7f94d24..9947bd5 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -3395,35 +3395,36 @@ static int still_busy(void)
        static clockt last_talked = 0;
        static clockt start_busy_wait = 0;
 
-       if (!config->cluster_iam_master)
-       {
 #ifdef BGP
-               static time_t stopped_bgp = 0;
-               if (bgp_configured)
+       static time_t stopped_bgp = 0;
+       if (bgp_configured)
+       {
+               if (!stopped_bgp)
                {
-                       if (!stopped_bgp)
-                       {
-                               LOG(1, 0, 0, "Shutting down in %d seconds, stopping BGP...\n", QUIT_DELAY);
+                       LOG(1, 0, 0, "Shutting down in %d seconds, stopping BGP...\n", QUIT_DELAY);
 
-                               for (i = 0; i < BGP_NUM_PEERS; i++)
-                                       if (bgp_peers[i].state == Established)
-                                               bgp_stop(&bgp_peers[i]);
+                       for (i = 0; i < BGP_NUM_PEERS; i++)
+                               if (bgp_peers[i].state == Established)
+                                       bgp_stop(&bgp_peers[i]);
 
-                               stopped_bgp = time_now;
+                       stopped_bgp = time_now;
 
+                       if (!config->cluster_iam_master)
+                       {
                                // we don't want to become master
                                cluster_send_ping(0);
 
                                return 1;
                        }
-
-                       if (time_now < (stopped_bgp + QUIT_DELAY))
-                               return 1;
                }
+
+               if (!config->cluster_iam_master && time_now < (stopped_bgp + QUIT_DELAY))
+                       return 1;
+       }
 #endif /* BGP */
 
+       if (!config->cluster_iam_master)
                return 0;
-       }
 
        if (main_quit == QUIT_SHUTDOWN)
        {