}
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",
/* "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. */
}
/* 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;
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)) {
/* 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 */
/* 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 */
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);
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);