mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 02:37:21 +00:00
bgpd: get table identifier from table manager
A table chunk of 100000 is allocated from zebra, and when needed in flowspec, the table identifier is extracted from that chunk. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
f7df19076a
commit
31c28cd708
@ -805,16 +805,13 @@ static void bgp_pbr_policyroute_add_to_zebra(struct bgp *bgp,
|
|||||||
bgp_pbr_action_alloc_intern);
|
bgp_pbr_action_alloc_intern);
|
||||||
|
|
||||||
if (bpa->fwmark == 0) {
|
if (bpa->fwmark == 0) {
|
||||||
/* TODO: allocate new table ID using zebra */
|
|
||||||
static int fwmark_id;
|
|
||||||
|
|
||||||
/* drop is handled by iptable */
|
/* drop is handled by iptable */
|
||||||
if (nh && nh->type == NEXTHOP_TYPE_BLACKHOLE) {
|
if (nh && nh->type == NEXTHOP_TYPE_BLACKHOLE) {
|
||||||
bpa->table_id = 0;
|
bpa->table_id = 0;
|
||||||
bpa->installed = true;
|
bpa->installed = true;
|
||||||
} else {
|
} else {
|
||||||
bpa->fwmark = ++fwmark_id;
|
bpa->fwmark = bgp_zebra_tm_get_id();
|
||||||
bpa->table_id = fwmark_id;
|
bpa->table_id = bpa->fwmark;
|
||||||
bpa->installed = false;
|
bpa->installed = false;
|
||||||
}
|
}
|
||||||
bpa->unique = ++bgp_pbr_action_counter_unique;
|
bpa->unique = ++bgp_pbr_action_counter_unique;
|
||||||
|
@ -998,6 +998,9 @@ static int bgp_table_map_apply(struct route_map *map, struct prefix *p,
|
|||||||
|
|
||||||
static struct thread *bgp_tm_thread_connect;
|
static struct thread *bgp_tm_thread_connect;
|
||||||
static bool bgp_tm_status_connected;
|
static bool bgp_tm_status_connected;
|
||||||
|
static bool bgp_tm_chunk_obtained;
|
||||||
|
#define BGP_FLOWSPEC_TABLE_CHUNK 100000
|
||||||
|
static uint32_t bgp_tm_min, bgp_tm_max, bgp_tm_chunk_size;
|
||||||
|
|
||||||
static int bgp_zebra_tm_connect(struct thread *t)
|
static int bgp_zebra_tm_connect(struct thread *t)
|
||||||
{
|
{
|
||||||
@ -1018,12 +1021,27 @@ static int bgp_zebra_tm_connect(struct thread *t)
|
|||||||
if (!bgp_tm_status_connected)
|
if (!bgp_tm_status_connected)
|
||||||
zlog_debug("Connecting to table manager. Success");
|
zlog_debug("Connecting to table manager. Success");
|
||||||
bgp_tm_status_connected = true;
|
bgp_tm_status_connected = true;
|
||||||
|
if (!bgp_tm_chunk_obtained) {
|
||||||
|
if (bgp_zebra_get_table_range(bgp_tm_chunk_size,
|
||||||
|
&bgp_tm_min,
|
||||||
|
&bgp_tm_max) >= 0)
|
||||||
|
bgp_tm_chunk_obtained = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
|
thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
|
||||||
&bgp_tm_thread_connect);
|
&bgp_tm_thread_connect);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t bgp_zebra_tm_get_id(void)
|
||||||
|
{
|
||||||
|
static int table_id;
|
||||||
|
|
||||||
|
if (!bgp_tm_chunk_obtained)
|
||||||
|
return ++table_id;
|
||||||
|
return bgp_tm_min++;
|
||||||
|
}
|
||||||
|
|
||||||
void bgp_zebra_init_tm_connect(void)
|
void bgp_zebra_init_tm_connect(void)
|
||||||
{
|
{
|
||||||
int delay = 1;
|
int delay = 1;
|
||||||
@ -1033,6 +1051,9 @@ void bgp_zebra_init_tm_connect(void)
|
|||||||
if (bgp_tm_thread_connect != NULL)
|
if (bgp_tm_thread_connect != NULL)
|
||||||
return;
|
return;
|
||||||
bgp_tm_status_connected = false;
|
bgp_tm_status_connected = false;
|
||||||
|
bgp_tm_chunk_obtained = false;
|
||||||
|
bgp_tm_min = bgp_tm_max = 0;
|
||||||
|
bgp_tm_chunk_size = BGP_FLOWSPEC_TABLE_CHUNK;
|
||||||
thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
|
thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
|
||||||
&bgp_tm_thread_connect);
|
&bgp_tm_thread_connect);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
extern void bgp_zebra_init(struct thread_master *master);
|
extern void bgp_zebra_init(struct thread_master *master);
|
||||||
extern void bgp_zebra_init_tm_connect(void);
|
extern void bgp_zebra_init_tm_connect(void);
|
||||||
|
extern uint32_t bgp_zebra_tm_get_id(void);
|
||||||
extern void bgp_zebra_destroy(void);
|
extern void bgp_zebra_destroy(void);
|
||||||
extern int bgp_zebra_get_table_range(uint32_t chunk_size,
|
extern int bgp_zebra_get_table_range(uint32_t chunk_size,
|
||||||
uint32_t *start, uint32_t *end);
|
uint32_t *start, uint32_t *end);
|
||||||
|
Loading…
Reference in New Issue
Block a user