bgpd: minor fix and code style compliance

* Applied style suggestions by automated compliance check.
* Fixed function bgp_shutdown_enable to use immutable message string.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
This commit is contained in:
David Schweizer 2020-08-20 16:50:21 +02:00
parent df465afea8
commit 736b68f33a
No known key found for this signature in database
GPG Key ID: A07D97BEEE79EF7F
3 changed files with 26 additions and 30 deletions

View File

@ -3600,15 +3600,13 @@ DEFUN (bgp_default_shutdown,
return CMD_SUCCESS;
}
DEFPY (bgp_shutdown_msg,
bgp_shutdown_msg_cmd,
"bgp shutdown message MSG...",
BGP_STR
"Enable administrative shutdown of the BGP instance\n"
"Add a shutdown message (RFC 8203)\n"
"Shutdown message\n")
DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...",
BGP_STR
"Enable administrative shutdown of the BGP instance\n"
"Add a shutdown message (RFC 8203)\n"
"Shutdown message\n")
{
char* msgstr = NULL;
char *msgstr = NULL;
VTY_DECLVAR_CONTEXT(bgp, bgp);
@ -3621,10 +3619,8 @@ DEFPY (bgp_shutdown_msg,
return CMD_SUCCESS;
}
DEFPY (bgp_shutdown, bgp_shutdown_cmd,
"bgp shutdown",
BGP_STR
"Enable administrative shutdown of the BGP instance\n")
DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown",
BGP_STR "Enable administrative shutdown of the BGP instance\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
@ -3633,12 +3629,8 @@ DEFPY (bgp_shutdown, bgp_shutdown_cmd,
return CMD_SUCCESS;
}
DEFPY (no_bgp_shutdown,
no_bgp_shutdown_cmd,
"no bgp shutdown",
NO_STR
BGP_STR
"Disable administrative shutdown of the BGP instance\n")
DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown",
NO_STR BGP_STR "Disable administrative shutdown of the BGP instance\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
@ -9376,7 +9368,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
"pfxSnt",
(PAF_SUBGRP(paf))->scount);
if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)
|| CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN))
|| CHECK_FLAG(peer->bgp->flags,
BGP_FLAG_SHUTDOWN))
json_object_string_add(json_peer, "state",
"Idle (Admin)");
else if (peer->afc_recv[afi][safi])
@ -9495,8 +9488,10 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
->scount);
}
} else {
if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)
|| CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN))
if (CHECK_FLAG(peer->flags,
PEER_FLAG_SHUTDOWN)
|| CHECK_FLAG(peer->bgp->flags,
BGP_FLAG_SHUTDOWN))
vty_out(vty, " Idle (Admin)");
else if (CHECK_FLAG(
peer->sflags,

View 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, char *msg)
void bgp_shutdown_enable(struct bgp *bgp, const char *msg)
{
struct peer *peer;
struct listnode *node;
@ -4046,13 +4046,14 @@ void bgp_shutdown_enable(struct bgp *bgp, char *msg)
/* send a RFC 4486 notification message if necessary */
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
if (msg)
bgp_notify_send_with_data(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN,
(uint8_t *)(msg),
strlen(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);
bgp_notify_send(
peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
}
/* reset start timer to initial value */

View File

@ -453,7 +453,7 @@ struct bgp {
#define BGP_FLAG_SHOW_NEXTHOP_HOSTNAME (1 << 26)
/* This flag is set if the instance is in administrative shutdown */
#define BGP_FLAG_SHUTDOWN (1 << 27)
#define BGP_FLAG_SHUTDOWN (1 << 27)
enum global_mode GLOBAL_GR_FSM[BGP_GLOBAL_GR_MODE]
[BGP_GLOBAL_GR_EVENT_CMD];
@ -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, char *msg);
extern void bgp_shutdown_enable(struct bgp *bgp, const char *msg);
extern void bgp_shutdown_disable(struct bgp *bgp);
extern void bgp_close(void);