]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Adding BGP GR change mode config apply on notification sent & received.
authorbisdhdh <biswajit.sadhu@gmail.com>
Wed, 23 Oct 2019 19:12:10 +0000 (00:42 +0530)
committerbisdhdh <biswajit.sadhu@gmail.com>
Thu, 23 Jan 2020 04:04:25 +0000 (09:34 +0530)
* Changing GR mode on a router needs a session reset from the
SAME router to negotiate new GR capability.
* The present GR implementation needs a session reset after every
new BGP GR mode change.
* When BGP session reset happens due to sending or receiving BGP
notification after changing BGP GR mode, there is no need of
explicit session reset.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
bgpd/bgp_fsm.c
bgpd/bgp_packet.c
bgpd/bgp_vty.c

index bafba62029ced2663f5608718036db1b87531ca0..5e5ac636ed4473b5b36b8220247bcc82cdc36e7a 100644 (file)
@@ -1308,7 +1308,6 @@ int bgp_stop(struct peer *peer)
        } else {
                bgp_peer_conf_if_to_su_update(peer);
        }
-
        return ret;
 }
 
index 0c52585a1025a7803b3eac105c3a85c794cbdfe5..49b6f2f27916986958a0c5b0122715457e2fa67f 100644 (file)
@@ -759,6 +759,8 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
        /* Add packet to peer's output queue */
        stream_fifo_push(peer->obuf, s);
 
+       bgp_peer_gr_flags_update(peer);
+
        bgp_write_notify(peer);
 }
 
@@ -1796,6 +1798,8 @@ static int bgp_notify_receive(struct peer *peer, bgp_size_t size)
            && bgp_notify.subcode == BGP_NOTIFY_OPEN_UNSUP_PARAM)
                UNSET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN);
 
+       bgp_peer_gr_flags_update(peer);
+
        return Receive_NOTIFICATION_message;
 }
 
index b1bef993061ef74606246db81de19ec6bc66e661..896d1f0e896ab2b6a27932901160b2ea4225a9c6 100644 (file)
@@ -843,6 +843,8 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
 
                        if (ret < 0)
                                bgp_clear_vty_error(vty, peer, afi, safi, ret);
+
+                       bgp_peer_gr_flags_update(peer);
                }
 
                /* This is to apply read-only mode on this clear. */
@@ -2145,6 +2147,9 @@ DEFUN (bgp_graceful_restart,
       )
 {
        int ret = BGP_GR_FAILURE;
+       struct peer *peer;
+       struct listnode *node = {0};
+       struct listnode *nnode = {0};
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug("BGP_GR:: bgp_graceful_restart_cmd : START ");
@@ -2152,6 +2157,11 @@ DEFUN (bgp_graceful_restart,
 
        ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD);
 
+       for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
+               if (peer->bgp->t_startup)
+                       bgp_peer_gr_flags_update(peer);
+       }
+
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug("BGP_GR:: bgp_graceful_restart_cmd : END ");
        return bgp_vty_return(vty, ret);
@@ -2166,6 +2176,9 @@ DEFUN (no_bgp_graceful_restart,
       )
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
+       struct peer *peer;
+       struct listnode *node = {0};
+       struct listnode *nnode = {0};
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug("BGP_GR:: no_bgp_graceful_restart_cmd : START ");
@@ -2174,6 +2187,11 @@ DEFUN (no_bgp_graceful_restart,
 
        ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD);
 
+       for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
+               if (peer->bgp->t_startup)
+                       bgp_peer_gr_flags_update(peer);
+       }
+
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug("BGP_GR:: no_bgp_graceful_restart_cmd : END ");
 
@@ -2315,6 +2333,9 @@ DEFUN (bgp_graceful_restart_disable,
                GR_DISABLE)
 {
        int ret = BGP_GR_FAILURE;
+       struct peer *peer;
+       struct listnode *node = {0};
+       struct listnode *nnode = {0};
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
@@ -2323,6 +2344,11 @@ DEFUN (bgp_graceful_restart_disable,
 
        ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD);
 
+       for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
+               if (peer->bgp->t_startup)
+                       bgp_peer_gr_flags_update(peer);
+       }
+
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
                                "BGP_GR:: bgp_graceful_restart_disable_cmd : END ");
@@ -2338,6 +2364,9 @@ DEFUN (no_bgp_graceful_restart_disable,
       )
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
+       struct peer *peer;
+       struct listnode *node = {0};
+       struct listnode *nnode = {0};
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
@@ -2347,6 +2376,11 @@ DEFUN (no_bgp_graceful_restart_disable,
 
        ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD);
 
+       for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
+               if (peer->bgp->t_startup)
+                       bgp_peer_gr_flags_update(peer);
+       }
+
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
                                "BGP_GR:: no_bgp_graceful_restart_disable_cmd : END ");
@@ -2413,7 +2447,7 @@ DEFUN (no_bgp_neighbor_graceful_restart,
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
-                               "BGP_GR:: no_bgp_neighbor_graceful_restart_set_cmd : END ");
+                               "BGP_GR:: no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
 
        return bgp_vty_return(vty, ret);
 }
@@ -2432,17 +2466,18 @@ DEFUN (bgp_neighbor_graceful_restart_helper_set,
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
-                               "BGP_GR:: bgp_neighbor_graceful_restart_set_helper_cmd : START ");
+                               "BGP_GR:: bgp_neighbor_graceful_restart_helper_set_cmd : START ");
        peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg);
 
-       if (peer->bgp->t_startup)
-               bgp_peer_gr_flags_update(peer);
-
        if (!peer)
                return CMD_WARNING_CONFIG_FAILED;
 
 
        ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD);
+
+       if (peer->bgp->t_startup)
+               bgp_peer_gr_flags_update(peer);
+
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
                                "BGP_GR:: bgp_neighbor_graceful_restart_helper_set_cmd : END ");
@@ -2479,7 +2514,7 @@ DEFUN (no_bgp_neighbor_graceful_restart_helper,
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
-                               "BGP_GR:: no_bgp_neighbor_graceful_restart_set_cmd : END ");
+                               "BGP_GR:: no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
 
        return bgp_vty_return(vty, ret);
 }
@@ -2506,7 +2541,7 @@ DEFUN (bgp_neighbor_graceful_restart_disable_set,
 
 
        ret = bgp_neighbor_graceful_restart(peer,
-                       PEER_DISABLE_cmd);
+                               PEER_DISABLE_cmd);
 
        if (peer->bgp->t_startup)
                bgp_peer_gr_flags_update(peer);