From f697e5fb21a1cdb9feab1ca2dcb977f2f87e0f3a Mon Sep 17 00:00:00 2001 From: Pascal Mathis Date: Sat, 7 Jul 2018 13:14:55 +0200 Subject: [PATCH] bgpd: Fix bgp auto-shutdown behavior The current behavior of the `bgp default shutdown` command is to set the state of all newly configured peers to shutdown. This leads to a problem when restarting bgpd, because all peers will then be seen as newly configured, which leads to all peers being set to shutdown after each restart. This behavior is undesired and not common when comparing the implementation against other vendors. This commit moves the `bgp default shutdown` configuration underneath the peer-group and peer configuration, to ensure that existing peers will not be set to shutdown after a daemon restart. Signed-off-by: Pascal Mathis --- bgpd/bgpd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3d7a0f32c0..8e25463e87 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -7589,10 +7589,6 @@ int bgp_config_write(struct vty *vty) vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", bgp->default_subgroup_pkt_queue_max); - /* BGP default autoshutdown neighbors */ - if (bgp->autoshutdown) - vty_out(vty, " bgp default shutdown\n"); - /* BGP client-to-client reflection. */ if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) vty_out(vty, " no bgp client-to-client reflection\n"); @@ -7746,6 +7742,16 @@ int bgp_config_write(struct vty *vty) /* listen range and limit for dynamic BGP neighbors */ bgp_config_write_listen(vty, bgp); + /* + * BGP default autoshutdown neighbors + * + * This must be placed after any peer and peer-group + * configuration, to avoid setting all peers to shutdown after + * a daemon restart, which is undesired behavior. (see #2286) + */ + if (bgp->autoshutdown) + vty_out(vty, " bgp default shutdown\n"); + /* No auto-summary */ if (bgp_option_check(BGP_OPT_CONFIG_CISCO)) vty_out(vty, " no auto-summary\n"); -- 2.39.5