diff --git a/bgpd/bgp_errors.c b/bgpd/bgp_errors.c index 8a33ce6789..0f9d5fc73a 100644 --- a/bgpd/bgp_errors.c +++ b/bgpd/bgp_errors.c @@ -462,6 +462,18 @@ static struct log_ref ferr_bgp_err[] = { .description = "As part of normal collision detection for opening a connection to a peer, BGP has detected that the remote peer's router-id is the same as ours", .suggestion = "Change one of the two router-id's", }, + { + .code = EC_BGP_INVALID_BGP_INSTANCE, + .title = "BGP instance for the specifc vrf is invalid", + .description = "Indicates that specified bgp instance is NULL", + .suggestion = "Get log files from router and open an issue", + }, + { + .code = EC_BGP_INVALID_ROUTE, + .title = "BGP route node is invalid", + .description = "BGP route for the specified AFI/SAFI is NULL", + .suggestion = "Get log files from router and open an issue", + }, { .code = END_FERR, } diff --git a/bgpd/bgp_errors.h b/bgpd/bgp_errors.h index 49c58ae6b0..20056d382a 100644 --- a/bgpd/bgp_errors.h +++ b/bgpd/bgp_errors.h @@ -99,6 +99,8 @@ enum bgp_log_refs { EC_BGP_INVALID_NEXTHOP_LENGTH, EC_BGP_DOPPELGANGER_CONFIG, EC_BGP_ROUTER_ID_SAME, + EC_BGP_INVALID_BGP_INSTANCE, + EC_BGP_INVALID_ROUTE, }; extern void bgp_error_init(void); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index fb4fae833d..b12a36fa69 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1514,6 +1514,20 @@ void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode, vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL)); } +DEFPY (bgp_suppress_fib_pending, + bgp_suppress_fib_pending_cmd, + "[no] bgp suppress-fib-pending", + NO_STR + BGP_STR + "Advertise only routes that are programmed in kernel to peers\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + + bgp_suppress_fib_pending_set(bgp, !no); + return CMD_SUCCESS; +} + + /* BGP Cluster ID. */ DEFUN_YANG(bgp_cluster_id, bgp_cluster_id_cmd, @@ -16856,6 +16870,10 @@ int bgp_config_write(struct vty *vty) vty_out(vty, " bgp router-id %pI4\n", &bgp->router_id_static); + /* Suppress fib pending */ + if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) + vty_out(vty, " bgp suppress-fib-pending\n"); + /* BGP log-neighbor-changes. */ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) != SAVE_BGP_LOG_NEIGHBOR_CHANGES) @@ -17371,6 +17389,9 @@ void bgp_vty_init(void) install_element(BGP_NODE, &bgp_router_id_cmd); install_element(BGP_NODE, &no_bgp_router_id_cmd); + /* "bgp suppress-fib-pending" command */ + install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); + /* "bgp cluster-id" commands. */ install_element(BGP_NODE, &bgp_cluster_id_cmd); install_element(BGP_NODE, &no_bgp_cluster_id_cmd); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index df453dd993..2e779fddce 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -109,6 +109,9 @@ struct community_list_handler *bgp_clist; unsigned int multipath_num = MULTIPATH_NUM; +/* Number of bgp instances configured for suppress fib config */ +unsigned int bgp_suppress_fib_count; + static void bgp_if_finish(struct bgp *bgp); static void peer_drop_dynamic_neighbor(struct peer *peer); @@ -390,6 +393,43 @@ void bgp_router_id_static_set(struct bgp *bgp, struct in_addr id) true /* is config */); } +/* Set the suppress fib pending for the bgp configuration */ +void bgp_suppress_fib_pending_set(struct bgp *bgp, bool set) +{ + bool send_msg = false; + + if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) + return; + + if (set) { + SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING); + /* Send msg to zebra for the first instance of bgp enabled + * with suppress fib + */ + if (bgp_suppress_fib_count == 0) + send_msg = true; + bgp_suppress_fib_count++; + } else { + UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING); + bgp_suppress_fib_count--; + + /* Send msg to zebra if there are no instances enabled + * with suppress fib + */ + if (bgp_suppress_fib_count == 0) + send_msg = true; + } + /* Send route notify request to RIB */ + if (send_msg) { + if (BGP_DEBUG(zebra, ZEBRA)) + zlog_debug("Sending ZEBRA_ROUTE_NOTIFY_REQUEST"); + + if (zclient) + zebra_route_notify_send(ZEBRA_ROUTE_NOTIFY_REQUEST, + zclient, set); + } +} + /* BGP's cluster-id control. */ int bgp_cluster_id_set(struct bgp *bgp, struct in_addr *cluster_id) { diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 287aeca143..e7d46f3e13 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -455,11 +455,12 @@ struct bgp { #define BGP_FLAG_DELETE_IN_PROGRESS (1 << 22) #define BGP_FLAG_SELECT_DEFER_DISABLE (1 << 23) #define BGP_FLAG_GR_DISABLE_EOR (1 << 24) -#define BGP_FLAG_EBGP_REQUIRES_POLICY (1 << 25) -#define BGP_FLAG_SHOW_NEXTHOP_HOSTNAME (1 << 26) +#define BGP_FLAG_EBGP_REQUIRES_POLICY (1 << 25) +#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) +#define BGP_FLAG_SUPPRESS_FIB_PENDING (1 << 28) enum global_mode GLOBAL_GR_FSM[BGP_GLOBAL_GR_MODE] [BGP_GLOBAL_GR_EVENT_CMD]; @@ -712,6 +713,9 @@ struct afi_safi_info { #define BGP_SELECT_DEFER_DISABLE(bgp) \ (CHECK_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE)) +#define BGP_SUPPRESS_FIB_ENABLED(bgp) \ + (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) + /* BGP peer-group support. */ struct peer_group { /* Name of the peer-group. */ @@ -1507,6 +1511,9 @@ DECLARE_QOBJ_TYPE(peer) || CHECK_FLAG((P)->sflags, PEER_STATUS_PREFIX_OVERFLOW) \ || CHECK_FLAG((P)->bgp->flags, BGP_FLAG_SHUTDOWN)) +#define PEER_ROUTE_ADV_DELAY(peer) \ + CHECK_FLAG(peer->thread_flags, PEER_THREAD_SUBGRP_ADV_DELAY) + #define PEER_PASSWORD_MINLEN (1) #define PEER_PASSWORD_MAXLEN (80) @@ -1677,6 +1684,7 @@ struct bgp_nlri { #define BGP_DEFAULT_STALEPATH_TIME 360 #define BGP_DEFAULT_SELECT_DEFERRAL_TIME 360 #define BGP_DEFAULT_RIB_STALE_TIME 500 +#define BGP_DEFAULT_UPDATE_ADVERTISEMENT_TIME 1 /* BGP uptime string length. */ #define BGP_UPTIME_LEN 25 @@ -1853,6 +1861,7 @@ extern int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, extern void bgp_router_id_zebra_bump(vrf_id_t, const struct prefix *); extern void bgp_router_id_static_set(struct bgp *, struct in_addr); +extern void bgp_suppress_fib_pending_set(struct bgp *bgp, bool set); extern int bgp_cluster_id_set(struct bgp *, struct in_addr *); extern int bgp_cluster_id_unset(struct bgp *);