From 907f92c8fcbd212a1bcb7b2b421ba9a8faa3f4af Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 May 2015 18:03:49 -0700 Subject: [PATCH] bgpd: Disable connected check for next hop on eBGP peers In the data center, in conjunction with next hop propagation for features such as announcing VIP routes to load balancers and such, it is desired to disable the connected route check even on ebgp peers with TTL of 1. This patch is used to disable the check for all peers instead of the peer by peer check that is currently supported. Furthermore, the existing disable-connected-check is different from how Cisco implements this feature. So, we add this new flag to avoid reliance on the existing flag. Signed-off-by: Dinesh G Dutt Reviewed-by: Vivek Venkatraman --- bgpd/bgp_route.c | 6 ++++-- bgpd/bgp_vty.c | 32 ++++++++++++++++++++++++++++++++ bgpd/bgp_zebra.c | 7 +++++-- bgpd/bgpd.c | 4 ++++ bgpd/bgpd.h | 1 + 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4ea5ad841f..f37f3179ae 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3046,7 +3046,8 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id, if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) { if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && - ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) + ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) + && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) connected = 1; else connected = 0; @@ -3102,7 +3103,8 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id, if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) { if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && - ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) + ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) + && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) connected = 1; else connected = 0; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index d294781bc5..e2a5707e07 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -2086,6 +2086,34 @@ bgp_config_write_listen (struct vty *vty, struct bgp *bgp) } +DEFUN (bgp_disable_connected_route_check, + bgp_disable_connected_route_check_cmd, + "bgp disable-ebgp-connected-route-check", + "BGP specific commands\n" + "Disable checking if nexthop is connected on ebgp sessions\n") +{ + struct bgp *bgp; + + bgp = vty->index; + bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); + return CMD_SUCCESS; +} + +DEFUN (no_bgp_disable_connected_route_check, + no_bgp_disable_connected_route_check_cmd, + "no bgp disable-ebgp-connected-route-check", + NO_STR + "BGP specific commands\n" + "Disable checking if nexthop is connected on ebgp sessions\n") +{ + struct bgp *bgp; + + bgp = vty->index; + bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); + return CMD_SUCCESS; +} + + static int peer_remote_as_vty (struct vty *vty, const char *peer_str, const char *as_str, afi_t afi, safi_t safi) @@ -11297,6 +11325,10 @@ bgp_vty_init (void) install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd); + /* bgp disable-ebgp-connected-nh-check */ + install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); + install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); + /* bgp update-delay command */ install_element (BGP_NODE, &bgp_update_delay_cmd); install_element (BGP_NODE, &no_bgp_update_delay_cmd); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 4c3f3dbb21..c78b4fc30e 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -967,7 +967,9 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, } if ((peer->sort == BGP_PEER_EBGP && peer->ttl != 1) - || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) + || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) + || bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) + SET_FLAG (flags, ZEBRA_FLAG_INTERNAL); nhcount = 1 + bgp_info_mpath_count (info); @@ -1304,7 +1306,8 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi) } if ((peer->sort == BGP_PEER_EBGP && peer->ttl != 1) - || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) + || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) + || bgp_flag_check(peer->bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) SET_FLAG (flags, ZEBRA_FLAG_INTERNAL); if (p->family == AF_INET) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index cbe8580f3a..4c18772d0e 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6310,6 +6310,10 @@ bgp_config_write (struct vty *vty) vty_out (vty, " bgp cluster-id %s%s", inet_ntoa (bgp->cluster_id), VTY_NEWLINE); + /* Disable ebgp connected nexthop check */ + if (bgp_flag_check (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) + vty_out (vty, " bgp disable-ebgp-connected-route-check%s", VTY_NEWLINE); + /* Confederation identifier*/ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)) vty_out (vty, " bgp confederation identifier %i%s", bgp->confed_id, diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 8b046e597c..68e8f10d5e 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -237,6 +237,7 @@ struct bgp #define BGP_FLAG_ASPATH_CONFED (1 << 13) #define BGP_FLAG_ASPATH_MULTIPATH_RELAX (1 << 14) #define BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY (1 << 15) +#define BGP_FLAG_DISABLE_NH_CONNECTED_CHK (1 << 16) /* BGP Per AF flags */ u_int16_t af_flags[AFI_MAX][SAFI_MAX]; -- 2.39.5