summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoman K S <somanks@gmail.com>2020-11-06 08:46:04 +0530
committerSoman K S <somanks@gmail.com>2020-11-06 08:46:04 +0530
commitc208c58670a3de2078fce343fed9a70e5b014690 (patch)
treee2885d295894d71213e329a08b0927862e975431
parent77b38a4a7dc1dde3a8c24a650884f956fae11157 (diff)
bgpd: Advertise FIB installed routes to bgp peers (Part 2)
* Added CLI command "[no] bgp suppress-fib-pending" to enable and disable suppress-fib-pending * Send ZEBRA_ROUTE_NOTIFY_REQUEST to zebra when "bgp suppress-fib-pending" is enabled or disabled * Define BGP_DEFAULT_UPDATE_ADVERTISEMENT_TIME which is the delay added to update group timer. * Added error codes Signed-off-by: kssoman <somanks@gmail.com>
-rw-r--r--bgpd/bgp_errors.c12
-rw-r--r--bgpd/bgp_errors.h2
-rw-r--r--bgpd/bgp_vty.c21
-rw-r--r--bgpd/bgpd.c40
-rw-r--r--bgpd/bgpd.h15
5 files changed, 87 insertions, 3 deletions
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
@@ -463,6 +463,18 @@ static struct log_ref ferr_bgp_err[] = {
.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 *);