mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 02:46:26 +00:00
zebra: support yielding between oper state routes query
Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
ef91d34f01
commit
d266b1cc9c
14
lib/vrf.c
14
lib/vrf.c
@ -987,6 +987,19 @@ static const void *lib_vrf_lookup_entry(struct nb_cb_lookup_entry_args *args)
|
||||
return vrf;
|
||||
}
|
||||
|
||||
static const void *lib_vrf_lookup_next(struct nb_cb_lookup_entry_args *args)
|
||||
{
|
||||
const char *vrfname = args->keys->key[0];
|
||||
struct vrf vrfkey, *vrf;
|
||||
|
||||
strlcpy(vrfkey.name, vrfname, sizeof(vrfkey.name));
|
||||
vrf = RB_FIND(vrf_name_head, &vrfs_by_name, &vrfkey);
|
||||
if (!strcmp(vrf->name, vrfname))
|
||||
vrf = RB_NEXT(vrf_name_head, vrf);
|
||||
|
||||
return vrf;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-vrf:lib/vrf/id
|
||||
*/
|
||||
@ -1024,6 +1037,7 @@ const struct frr_yang_module_info frr_vrf_info = {
|
||||
.get_next = lib_vrf_get_next,
|
||||
.get_keys = lib_vrf_get_keys,
|
||||
.lookup_entry = lib_vrf_lookup_entry,
|
||||
.lookup_next = lib_vrf_lookup_next,
|
||||
},
|
||||
.priority = NB_DFLT_PRIORITY - 2,
|
||||
},
|
||||
|
@ -434,6 +434,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
||||
.get_next = lib_vrf_zebra_ribs_rib_get_next,
|
||||
.get_keys = lib_vrf_zebra_ribs_rib_get_keys,
|
||||
.lookup_entry = lib_vrf_zebra_ribs_rib_lookup_entry,
|
||||
.lookup_next = lib_vrf_zebra_ribs_rib_lookup_next,
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -454,6 +455,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
||||
.get_next = lib_vrf_zebra_ribs_rib_route_get_next,
|
||||
.get_keys = lib_vrf_zebra_ribs_rib_route_get_keys,
|
||||
.lookup_entry = lib_vrf_zebra_ribs_rib_route_lookup_entry,
|
||||
.lookup_next = lib_vrf_zebra_ribs_rib_route_lookup_next,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -125,6 +125,8 @@ const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args);
|
||||
int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args);
|
||||
const void *
|
||||
lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args);
|
||||
const void *
|
||||
lib_vrf_zebra_ribs_rib_lookup_next(struct nb_cb_lookup_entry_args *args);
|
||||
struct yang_data *
|
||||
lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem(struct nb_cb_get_elem_args *args);
|
||||
struct yang_data *
|
||||
@ -134,6 +136,8 @@ lib_vrf_zebra_ribs_rib_route_get_next(struct nb_cb_get_next_args *args);
|
||||
int lib_vrf_zebra_ribs_rib_route_get_keys(struct nb_cb_get_keys_args *args);
|
||||
const void *
|
||||
lib_vrf_zebra_ribs_rib_route_lookup_entry(struct nb_cb_lookup_entry_args *args);
|
||||
const void *
|
||||
lib_vrf_zebra_ribs_rib_route_lookup_next(struct nb_cb_lookup_entry_args *args);
|
||||
struct yang_data *
|
||||
lib_vrf_zebra_ribs_rib_route_prefix_get_elem(struct nb_cb_get_elem_args *args);
|
||||
struct yang_data *lib_vrf_zebra_ribs_rib_route_protocol_get_elem(
|
||||
|
@ -212,6 +212,28 @@ lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args)
|
||||
return zebra_router_find_zrt(zvrf, table_id, afi, safi);
|
||||
}
|
||||
|
||||
const void *
|
||||
lib_vrf_zebra_ribs_rib_lookup_next(struct nb_cb_lookup_entry_args *args)
|
||||
{
|
||||
struct vrf *vrf = (struct vrf *)args->parent_list_entry;
|
||||
struct zebra_vrf *zvrf;
|
||||
afi_t afi;
|
||||
safi_t safi;
|
||||
uint32_t table_id = 0;
|
||||
|
||||
zvrf = zebra_vrf_lookup_by_id(vrf->vrf_id);
|
||||
if (!zvrf)
|
||||
return NULL;
|
||||
|
||||
yang_afi_safi_identity2value(args->keys->key[0], &afi, &safi);
|
||||
table_id = yang_str2uint32(args->keys->key[1]);
|
||||
/* table_id 0 assume vrf's table_id. */
|
||||
if (!table_id)
|
||||
table_id = zvrf->table_id;
|
||||
|
||||
return zebra_router_find_next_zrt(zvrf, table_id, afi, safi);
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/afi-safi-name
|
||||
*/
|
||||
@ -289,6 +311,25 @@ lib_vrf_zebra_ribs_rib_route_lookup_entry(struct nb_cb_lookup_entry_args *args)
|
||||
return rn;
|
||||
}
|
||||
|
||||
const void *
|
||||
lib_vrf_zebra_ribs_rib_route_lookup_next(struct nb_cb_lookup_entry_args *args)
|
||||
{
|
||||
const struct zebra_router_table *zrt = args->parent_list_entry;
|
||||
struct prefix p;
|
||||
struct route_node *rn;
|
||||
|
||||
yang_str2prefix(args->keys->key[0], &p);
|
||||
|
||||
rn = route_table_get_next(zrt->table, &p);
|
||||
|
||||
if (!rn)
|
||||
return NULL;
|
||||
|
||||
route_unlock_node(rn);
|
||||
|
||||
return rn;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/prefix
|
||||
*/
|
||||
|
@ -70,6 +70,26 @@ struct zebra_router_table *zebra_router_find_zrt(struct zebra_vrf *zvrf,
|
||||
return zrt;
|
||||
}
|
||||
|
||||
struct zebra_router_table *zebra_router_find_next_zrt(struct zebra_vrf *zvrf,
|
||||
uint32_t tableid,
|
||||
afi_t afi, safi_t safi)
|
||||
{
|
||||
struct zebra_router_table finder;
|
||||
struct zebra_router_table *zrt;
|
||||
|
||||
memset(&finder, 0, sizeof(finder));
|
||||
finder.afi = afi;
|
||||
finder.safi = safi;
|
||||
finder.tableid = tableid;
|
||||
finder.ns_id = zvrf->zns->ns_id;
|
||||
zrt = RB_NFIND(zebra_router_table_head, &zrouter.tables, &finder);
|
||||
if (zrt->afi == afi && zrt->safi == safi && zrt->tableid == tableid &&
|
||||
zrt->ns_id == finder.ns_id)
|
||||
zrt = RB_NEXT(zebra_router_table_head, zrt);
|
||||
|
||||
return zrt;
|
||||
}
|
||||
|
||||
struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
|
||||
uint32_t tableid, afi_t afi,
|
||||
safi_t safi)
|
||||
|
@ -250,6 +250,9 @@ extern void zebra_router_terminate(void);
|
||||
extern struct zebra_router_table *zebra_router_find_zrt(struct zebra_vrf *zvrf,
|
||||
uint32_t tableid,
|
||||
afi_t afi, safi_t safi);
|
||||
extern struct zebra_router_table *
|
||||
zebra_router_find_next_zrt(struct zebra_vrf *zvrf, uint32_t tableid, afi_t afi,
|
||||
safi_t safi);
|
||||
extern struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
|
||||
uint32_t tableid, afi_t afi,
|
||||
safi_t safi);
|
||||
|
Loading…
Reference in New Issue
Block a user