summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_zebra.c58
-rw-r--r--bgpd/bgp_zebra.h3
-rw-r--r--bgpd/bgpd.c4
-rw-r--r--lib/zebra.h3
-rw-r--r--zebra/zserv.c3
5 files changed, 69 insertions, 2 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 77416e3cf..269dcc7cb 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -970,6 +970,64 @@ static int bgp_table_map_apply(struct route_map *map, struct prefix *p,
return 0;
}
+static struct thread *bgp_tm_thread_connect;
+static bool bgp_tm_status_connected;
+
+static int bgp_zebra_tm_connect(struct thread *t)
+{
+ struct zclient *zclient;
+ int delay = 10, ret = 0;
+
+ zclient = THREAD_ARG(t);
+ if (bgp_tm_status_connected && zclient->sock > 0)
+ delay = 60;
+ else {
+ bgp_tm_status_connected = false;
+ ret = tm_table_manager_connect(zclient);
+ }
+ if (ret < 0) {
+ zlog_warn("Error connecting to table manager!");
+ bgp_tm_status_connected = false;
+ } else {
+ if (!bgp_tm_status_connected)
+ zlog_debug("Connecting to table manager. Success");
+ bgp_tm_status_connected = true;
+ }
+ thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
+ &bgp_tm_thread_connect);
+ return 0;
+}
+
+void bgp_zebra_init_tm_connect(void)
+{
+ int delay = 1;
+
+ /* if already set, do nothing
+ */
+ if (bgp_tm_thread_connect != NULL)
+ return;
+ bgp_tm_status_connected = false;
+ thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
+ &bgp_tm_thread_connect);
+}
+
+int bgp_zebra_get_table_range(uint32_t chunk_size,
+ uint32_t *start, uint32_t *end)
+{
+ int ret;
+
+ if (!bgp_tm_status_connected)
+ return -1;
+ ret = tm_get_table_chunk(zclient, chunk_size, start, end);
+ if (ret < 0) {
+ zlog_err("BGP: Error getting table chunk %u", chunk_size);
+ return -1;
+ }
+ zlog_info("BGP: Table Manager returns range from chunk %u is [%u %u]",
+ chunk_size, *start, *end);
+ return 0;
+}
+
void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
struct bgp_info *info, struct bgp *bgp, afi_t afi,
safi_t safi)
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index 68c495cf8..7263317b6 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -24,7 +24,10 @@
#include "vxlan.h"
extern void bgp_zebra_init(struct thread_master *master);
+extern void bgp_zebra_init_tm_connect(void);
extern void bgp_zebra_destroy(void);
+extern int bgp_zebra_get_table_range(uint32_t chunk_size,
+ uint32_t *start, uint32_t *end);
extern int bgp_if_update_all(void);
extern void bgp_config_write_maxpaths(struct vty *, struct bgp *, afi_t,
safi_t);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 515d90e04..97f0ffcf2 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1973,6 +1973,10 @@ int peer_activate(struct peer *peer, afi_t afi, safi_t safi)
bgp_recalculate_afi_safi_bestpaths(bgp, afi, SAFI_UNICAST);
}
+ if (safi == SAFI_FLOWSPEC) {
+ /* connect to table manager */
+ bgp_zebra_init_tm_connect();
+ }
return ret;
}
diff --git a/lib/zebra.h b/lib/zebra.h
index ec530397b..388760223 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -433,7 +433,8 @@ typedef enum {
SAFI_ENCAP = 4,
SAFI_EVPN = 5,
SAFI_LABELED_UNICAST = 6,
- SAFI_MAX = 7
+ SAFI_FLOWSPEC = 7,
+ SAFI_MAX = 8
} safi_t;
/*
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 76e5ea2f0..645deac27 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -2203,7 +2203,8 @@ static int zsend_table_manager_connect_response(struct zserv *client,
}
/* Send response to a table manager connect request to client */
-static void zread_table_manager_connect(struct zserv *client, struct stream *msg,
+static void zread_table_manager_connect(struct zserv *client,
+ struct stream *msg,
vrf_id_t vrf_id)
{
struct stream *s;