diff options
| -rw-r--r-- | bgpd/bgp_main.c | 10 | ||||
| -rw-r--r-- | bgpd/bgp_network.c | 4 | ||||
| -rw-r--r-- | bgpd/bgpd.c | 4 | ||||
| -rw-r--r-- | bgpd/bgpd.h | 1 | ||||
| -rw-r--r-- | doc/user/zebra.rst | 2 | ||||
| -rw-r--r-- | lib/id_alloc.c | 8 | ||||
| -rw-r--r-- | lib/vrf.c | 7 | ||||
| -rw-r--r-- | lib/vrf.h | 1 |
8 files changed, 29 insertions, 8 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index bee885cff2..f8ff4f2f07 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -375,6 +375,7 @@ int main(int argc, char **argv) int bgp_port = BGP_PORT_DEFAULT; char *bgp_address = NULL; int no_fib_flag = 0; + int no_zebra_flag = 0; int skip_runas = 0; int instance = 0; @@ -384,6 +385,7 @@ int main(int argc, char **argv) " -p, --bgp_port Set BGP listen port number (0 means do not listen).\n" " -l, --listenon Listen on specified address (implies -n)\n" " -n, --no_kernel Do not install route to kernel.\n" + " -Z, --no_zebra Do not communicate with Zebra.\n" " -S, --skip_runas Skip capabilities checks, and changing user and group IDs.\n" " -e, --ecmp Specify ECMP to use.\n" " -I, --int_num Set instance number (label-manager)\n"); @@ -430,6 +432,9 @@ int main(int argc, char **argv) case 'n': no_fib_flag = 1; break; + case 'Z': + no_zebra_flag = 1; + break; case 'S': skip_runas = 1; break; @@ -453,9 +458,10 @@ int main(int argc, char **argv) if (bgp_port == 0) bgp_option_set(BGP_OPT_NO_LISTEN); bm->address = bgp_address; - if (no_fib_flag) + if (no_fib_flag || no_zebra_flag) bgp_option_set(BGP_OPT_NO_FIB); - + if (no_zebra_flag) + bgp_option_set(BGP_OPT_NO_ZEBRA); bgp_error_init(); /* Initializations. */ bgp_vrf_init(); diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 191b1641b2..a310b7ba74 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -708,7 +708,9 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address) gai_strerror(ret)); return -1; } - + if (bgp_option_check(BGP_OPT_NO_ZEBRA) && + bgp->vrf_id != VRF_DEFAULT) + return -1; count = 0; for (ainfo = ainfo_save; ainfo; ainfo = ainfo->ai_next) { int sock; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 32bbb78ef3..a078c4f587 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -171,6 +171,7 @@ int bgp_option_set(int flag) case BGP_OPT_MULTIPLE_INSTANCE: case BGP_OPT_CONFIG_CISCO: case BGP_OPT_NO_LISTEN: + case BGP_OPT_NO_ZEBRA: SET_FLAG(bm->options, flag); break; default: @@ -186,6 +187,7 @@ int bgp_option_unset(int flag) if (listcount(bm->bgp) > 1) return BGP_ERR_MULTIPLE_INSTANCE_USED; /* Fall through. */ + case BGP_OPT_NO_ZEBRA: case BGP_OPT_NO_FIB: case BGP_OPT_CONFIG_CISCO: UNSET_FLAG(bm->options, flag); @@ -3095,6 +3097,8 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name, } bgp = bgp_create(as, name, inst_type); + if (bgp_option_check(BGP_OPT_NO_ZEBRA) && name) + bgp->vrf_id = vrf_generate_id(); bgp_router_id_set(bgp, &bgp->router_id_zebra); bgp_address_init(bgp); bgp_tip_hash_init(bgp); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 5ee54e3c70..70193104b4 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -131,6 +131,7 @@ struct bgp_master { #define BGP_OPT_MULTIPLE_INSTANCE (1 << 1) #define BGP_OPT_CONFIG_CISCO (1 << 2) #define BGP_OPT_NO_LISTEN (1 << 3) +#define BGP_OPT_NO_ZEBRA (1 << 4) uint64_t updgrp_idspace; uint64_t subgrp_idspace; diff --git a/doc/user/zebra.rst b/doc/user/zebra.rst index 14b78f8776..c509eb8583 100644 --- a/doc/user/zebra.rst +++ b/doc/user/zebra.rst @@ -383,7 +383,7 @@ alternate name for default VRF. Then, the default VRF naming will automatically be updated with the new name. To illustrate, if you want to recompile with `global` value, use the following command: -.. code-block:: linux +.. code-block:: shell ./configure --with-defaultvrfname=global diff --git a/lib/id_alloc.c b/lib/id_alloc.c index b4d37dbdcf..222ba651b4 100644 --- a/lib/id_alloc.c +++ b/lib/id_alloc.c @@ -42,7 +42,7 @@ DEFINE_MTYPE_STATIC(LIB, IDALLOC_POOL, "ID Number temporary holding pool entry") #define DIR_MASK ((1<<IDALLOC_DIR_BITS)-1) #define SUBDIR_MASK ((1<<IDALLOC_SUBDIR_BITS)-1) -#define PAGE_MASK ((1<<IDALLOC_PAGE_BITS)-1) +#define FRR_ID_PAGE_MASK ((1<<IDALLOC_PAGE_BITS)-1) #define WORD_MASK ((1<<IDALLOC_WORD_BITS)-1) #define OFFSET_MASK ((1<<IDALLOC_OFFSET_BITS)-1) @@ -50,13 +50,13 @@ DEFINE_MTYPE_STATIC(LIB, IDALLOC_POOL, "ID Number temporary holding pool entry") IDALLOC_PAGE_BITS + IDALLOC_SUBDIR_BITS) #define SUBDIR_SHIFT (IDALLOC_OFFSET_BITS + IDALLOC_WORD_BITS + \ IDALLOC_PAGE_BITS) -#define PAGE_SHIFT (IDALLOC_OFFSET_BITS + IDALLOC_WORD_BITS) +#define FRR_ID_PAGE_SHIFT (IDALLOC_OFFSET_BITS + IDALLOC_WORD_BITS) #define WORD_SHIFT (IDALLOC_OFFSET_BITS) #define OFFSET_SHIFT (0) #define ID_DIR(id) ((id >> DIR_SHIFT) & DIR_MASK) #define ID_SUBDIR(id) ((id >> SUBDIR_SHIFT) & SUBDIR_MASK) -#define ID_PAGE(id) ((id >> PAGE_SHIFT) & PAGE_MASK) +#define ID_PAGE(id) ((id >> FRR_ID_PAGE_SHIFT) & FRR_ID_PAGE_MASK) #define ID_WORD(id) ((id >> WORD_SHIFT) & WORD_MASK) #define ID_OFFSET(id) ((id >> OFFSET_SHIFT) & OFFSET_MASK) @@ -98,7 +98,7 @@ static struct id_alloc_page *find_or_create_page(struct id_alloc *alloc, page->base_value = id; subdir->sublevels[ID_PAGE(id)] = page; - alloc->capacity += 1 << PAGE_SHIFT; + alloc->capacity += 1 << FRR_ID_PAGE_SHIFT; page->next_has_free = alloc->has_free; alloc->has_free = page; } else if (page != NULL && create) { @@ -1022,3 +1022,10 @@ int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id, } return ret; } + +vrf_id_t vrf_generate_id(void) +{ + static int vrf_id_local; + + return ++vrf_id_local; +} @@ -293,5 +293,6 @@ extern int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, extern void vrf_disable(struct vrf *vrf); extern int vrf_enable(struct vrf *vrf); extern void vrf_delete(struct vrf *vrf); +extern vrf_id_t vrf_generate_id(void); #endif /*_ZEBRA_VRF_H*/ |
