]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: enhancement of bgp administrative shutdown
authorDavid Schweizer <dschweizer@opensourcerouting.org>
Mon, 17 Aug 2020 09:45:02 +0000 (11:45 +0200)
committerDavid Schweizer <dschweizer@opensourcerouting.org>
Mon, 17 Aug 2020 09:45:02 +0000 (11:45 +0200)
* Added message to RFC 8203 peer notification about BGP instance
  shutdown.
* Added informational log message to instance shutdown enable/disable
  functions.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index f9d030e08cf93c0443b501d7f6d6506d045c1e48..79a9a80f4f9f79c8a628c7f12e219d589322fbc8 100644 (file)
@@ -3601,18 +3601,31 @@ DEFUN (bgp_default_shutdown,
 }
 
 DEFPY (bgp_shutdown,
-       bgp_shutdown_cmd,
-       "bgp shutdown",
+       bgp_shutdown_msg_cmd,
+       "bgp shutdown message MSG...",
        BGP_STR
-       "Enable administrative shutdown of the BGP instance\n")
+       "Enable administrative shutdown of the BGP instance\n"
+       "Add a shutdown message (RFC 8203)\n"
+       "Shutdown message\n")
 {
+       char* msgstr = NULL;
+
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       bgp_shutdown_enable(bgp);
+       if (argc > 3)
+               msgstr = argv_concat(argv, argc, 4);
+
+       bgp_shutdown_enable(bgp, msgstr);
+       XFREE(MTYPE_TMP, msgstr);
 
        return CMD_SUCCESS;
 }
 
+ALIAS(bgp_shutdown, bgp_shutdown_cmd,
+      "bgp shutdown",
+      BGP_STR
+      "Enable administrative shutdown of the BGP instance\n")
+
 DEFPY (no_bgp_shutdown,
        no_bgp_shutdown_cmd,
        "no bgp shutdown",
@@ -16064,6 +16077,7 @@ void bgp_vty_init(void)
 
        /* "bgp shutdown" commands */
        install_element(BGP_NODE, &bgp_shutdown_cmd);
+       install_element(BGP_NODE, &bgp_shutdown_msg_cmd);
        install_element(BGP_NODE, &no_bgp_shutdown_cmd);
 
        /* "neighbor remote-as" commands. */
index aa3aba6856b9621faa133a1f18be2e96d5cb44e3..7a52727a43356699f9f7d04896fc29238dca1785 100644 (file)
@@ -4024,7 +4024,7 @@ static void peer_flag_modify_action(struct peer *peer, uint32_t flag)
 }
 
 /* Enable global administrative shutdown of all peers of BGP instance */
-void bgp_shutdown_enable(struct bgp *bgp)
+void bgp_shutdown_enable(struct bgp *bgp, char *msg)
 {
        struct peer *peer;
        struct listnode *node;
@@ -4033,9 +4033,9 @@ void bgp_shutdown_enable(struct bgp *bgp)
        if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN))
                return;
 
-       /* TODO: log message
-       zlog_info("Enabled administrative shutdown on BGP instance %s",
-                 bgp->name); */
+       /* informational log message */
+       zlog_info("Enabled administrative shutdown on BGP instance AS %u",
+                 bgp->as);
 
        /* iterate through peers of BGP instance */
        for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
@@ -4045,8 +4045,14 @@ void bgp_shutdown_enable(struct bgp *bgp)
 
                /* send a RFC 4486 notification message if necessary */
                if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
-                       bgp_notify_send(peer, BGP_NOTIFY_CEASE,
-                                       BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
+                       if (msg)
+                               bgp_notify_send_with_data(peer, BGP_NOTIFY_CEASE,
+                                                         BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN,
+                                                         (uint8_t *)(msg),
+                                                         strlen(msg));
+                       else
+                               bgp_notify_send(peer, BGP_NOTIFY_CEASE,
+                                               BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
                }
 
                /* reset start timer to initial value */
@@ -4054,11 +4060,6 @@ void bgp_shutdown_enable(struct bgp *bgp)
 
                /* trigger a RFC 4271 ManualStop event */
                BGP_EVENT_ADD(peer, BGP_Stop);
-
-               /* TODO: log message per peer?
-               if (bgp_debug_neighbor_events(peer))
-                       zlog_debug("Neighbor %s is now in administrative shutdown.",
-                                  peer->host); */
        }
 
        /* set the BGP instances shutdown flag */
@@ -4072,9 +4073,9 @@ void bgp_shutdown_disable(struct bgp *bgp)
        if (!CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN))
                return;
 
-       /* TODO: log message
-       zlog_info("Disabled administrative shutdown on BGP instance %s",
-                 bgp->name); */
+       /* informational log message */
+       zlog_info("Disabled administrative shutdown on BGP instance AS %u",
+                 bgp->as);
 
        /* clear the BGP instances shutdown flag */
        UNSET_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN);
index 43a800326d2d9a2fe67df493ff2b5ae674ac9249..4e5ccf59dcd7f1c0655483cfc1e5681d7d2e516a 100644 (file)
@@ -1951,7 +1951,7 @@ extern struct peer_af *peer_af_create(struct peer *, afi_t, safi_t);
 extern struct peer_af *peer_af_find(struct peer *, afi_t, safi_t);
 extern int peer_af_delete(struct peer *, afi_t, safi_t);
 
-extern void bgp_shutdown_enable(struct bgp *bgp);
+extern void bgp_shutdown_enable(struct bgp *bgp, char *msg);
 extern void bgp_shutdown_disable(struct bgp *bgp);
 
 extern void bgp_close(void);