zebra: Use zebra_vrf_lookup_by_id when we can

Let's make this as consistent as is possible.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-03-28 15:49:50 -04:00
parent 9b00c0a165
commit 9a7d1e7427
11 changed files with 38 additions and 38 deletions

View file

@ -1023,7 +1023,7 @@ static int fpm_lsp_send_cb(struct hash_bucket *bucket, void *arg)
static void fpm_lsp_send(struct event *t)
{
struct fpm_nl_ctx *fnc = EVENT_ARG(t);
struct zebra_vrf *zvrf = vrf_info_lookup(VRF_DEFAULT);
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
struct fpm_lsp_arg fla;
fla.fnc = fnc;
@ -1263,7 +1263,7 @@ static void fpm_lsp_reset_cb(struct hash_bucket *bucket, void *arg)
static void fpm_lsp_reset(struct event *t)
{
struct fpm_nl_ctx *fnc = EVENT_ARG(t);
struct zebra_vrf *zvrf = vrf_info_lookup(VRF_DEFAULT);
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
hash_iterate(zvrf->lsp_table, fpm_lsp_reset_cb, NULL);

View file

@ -145,7 +145,7 @@ static bool zebra_redistribute_check(const struct route_node *rn,
return false;
afi = family2afi(rn->p.family);
zvrf = vrf_info_lookup(re->vrf_id);
zvrf = zebra_vrf_lookup_by_id(re->vrf_id);
if (re->vrf_id == VRF_DEFAULT && zvrf->table_id != re->table)
return false;

View file

@ -284,7 +284,7 @@ DEFUN (ip_router_id,
argv_find(argv, argc, "NAME", &idx);
VRF_GET_ID(vrf_id, argv[idx]->arg, false);
zvrf = vrf_info_lookup(vrf_id);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
router_id_set(AFI_IP, &rid, zvrf);
return CMD_SUCCESS;
@ -321,7 +321,7 @@ DEFUN (ipv6_router_id,
argv_find(argv, argc, "NAME", &idx);
VRF_GET_ID(vrf_id, argv[idx]->arg, false);
zvrf = vrf_info_lookup(vrf_id);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
router_id_set(AFI_IP6, &rid, zvrf);
return CMD_SUCCESS;
@ -403,7 +403,7 @@ DEFUN (no_ip_router_id,
if (argv_find(argv, argc, "NAME", &idx))
VRF_GET_ID(vrf_id, argv[idx]->arg, false);
zvrf = vrf_info_lookup(vrf_id);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
router_id_set(AFI_IP, &rid, zvrf);
return CMD_SUCCESS;
@ -437,7 +437,7 @@ DEFUN (no_ipv6_router_id,
if (argv_find(argv, argc, "NAME", &idx))
VRF_GET_ID(vrf_id, argv[idx]->arg, false);
zvrf = vrf_info_lookup(vrf_id);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
router_id_set(AFI_IP6, &rid, zvrf);
return CMD_SUCCESS;
@ -514,7 +514,7 @@ DEFUN (show_ip_router_id,
vrf_name = argv[idx]->arg;
}
zvrf = vrf_info_lookup(vrf_id);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
if (zvrf != NULL) {
if (is_ipv6) {

View file

@ -1330,7 +1330,7 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS)
uint32_t label_index = MPLS_INVALID_LABEL_INDEX;
s = msg;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return;
@ -1393,7 +1393,7 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS)
uint16_t flags;
s = msg;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return;
@ -2337,7 +2337,7 @@ void zsend_capabilities_all_clients(void)
struct zebra_vrf *zvrf;
struct zserv *client;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
/* Do not send unsolicited messages to synchronous clients. */
if (client->synchronous)

View file

@ -389,7 +389,7 @@ static void zebra_evpn_dad_mac_auto_recovery_exp(struct event *t)
mac = EVENT_ARG(t);
/* since this is asynchronous we need sanity checks*/
zvrf = vrf_info_lookup(mac->zevpn->vrf_id);
zvrf = zebra_vrf_lookup_by_id(mac->zevpn->vrf_id);
if (!zvrf)
return;

View file

@ -887,7 +887,7 @@ static wq_item_status lsp_process(struct work_queue *wq, void *data)
struct zebra_lsp *lsp;
struct zebra_nhlfe *oldbest, *newbest;
char buf[BUFSIZ], buf2[BUFSIZ];
struct zebra_vrf *zvrf = vrf_info_lookup(VRF_DEFAULT);
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
enum zebra_dplane_result res;
lsp = (struct zebra_lsp *)data;
@ -1028,7 +1028,7 @@ static void lsp_processq_del(struct work_queue *wq, void *data)
if (zebra_router_in_shutdown())
return;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
assert(zvrf);
lsp_table = zvrf->lsp_table;
@ -1776,7 +1776,7 @@ void zebra_mpls_lsp_dplane_result(struct zebra_dplane_ctx *ctx)
case DPLANE_OP_LSP_INSTALL:
case DPLANE_OP_LSP_UPDATE:
/* Look for zebra LSP object */
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (zvrf == NULL)
break;
@ -2092,7 +2092,7 @@ void zebra_mpls_process_dplane_notify(struct zebra_dplane_ctx *ctx)
dplane_ctx_get_in_label(ctx));
/* Look for zebra LSP object */
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (zvrf == NULL)
return;
@ -2467,7 +2467,7 @@ int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p,
*/
static int zebra_mpls_cleanup_fecs_for_client(struct zserv *client)
{
struct zebra_vrf *zvrf = vrf_info_lookup(VRF_DEFAULT);
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
struct route_node *rn;
struct zebra_fec *fec;
struct listnode *node;

View file

@ -41,7 +41,7 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
return CMD_WARNING_CONFIG_FAILED;
}
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf) {
vty_out(vty, "%% Default VRF does not exist\n");
return CMD_WARNING_CONFIG_FAILED;
@ -185,7 +185,7 @@ static int zebra_mpls_bind(struct vty *vty, int add_cmd, const char *prefix,
uint32_t label;
int ret;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf) {
vty_out(vty, "%% Default VRF does not exist\n");
return CMD_WARNING_CONFIG_FAILED;
@ -273,7 +273,7 @@ static int zebra_mpls_config(struct vty *vty)
int write = 0;
struct zebra_vrf *zvrf;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return 0;
@ -296,7 +296,7 @@ DEFUN (show_mpls_fec,
struct prefix p;
int ret;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return 0;
@ -326,7 +326,7 @@ DEFUN (show_mpls_table,
struct zebra_vrf *zvrf;
bool uj = use_json(argc, argv);
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
zebra_mpls_print_lsp_table(vty, zvrf, uj);
return CMD_SUCCESS;
}
@ -344,7 +344,7 @@ DEFUN (show_mpls_table_lsp,
struct zebra_vrf *zvrf;
bool uj = use_json(argc, argv);
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
label = atoi(argv[3]->arg);
zebra_mpls_print_lsp(vty, zvrf, label, uj);
return CMD_SUCCESS;

View file

@ -407,7 +407,7 @@ DEFUN_NOSH (pseudowire_if,
const char *ifname;
int idx = 0;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return CMD_WARNING;
@ -439,7 +439,7 @@ DEFUN (no_pseudowire_if,
const char *ifname;
int idx = 0;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return CMD_WARNING;
@ -563,7 +563,7 @@ DEFUN (show_pseudowires,
struct zebra_vrf *zvrf;
struct zebra_pw *pw;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return 0;
@ -602,7 +602,7 @@ static void vty_show_mpls_pseudowire_detail(struct vty *vty)
struct nexthop *nexthop;
struct nexthop_group *nhg;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return;
@ -758,7 +758,7 @@ static void vty_show_mpls_pseudowire_detail_json(struct vty *vty)
struct zebra_vrf *zvrf;
struct zebra_pw *pw;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return;
@ -794,7 +794,7 @@ static int zebra_pw_config(struct vty *vty)
struct zebra_vrf *zvrf;
struct zebra_pw *pw;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return 0;

View file

@ -632,7 +632,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,
{
struct nexthop *nexthop;
struct rib_table_info *info = srcdest_rnode_table_info(rn);
struct zebra_vrf *zvrf = vrf_info_lookup(re->vrf_id);
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(re->vrf_id);
const struct prefix *p, *src_p;
enum zebra_dplane_result ret;
@ -715,7 +715,7 @@ void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re)
{
struct nexthop *nexthop;
struct rib_table_info *info = srcdest_rnode_table_info(rn);
struct zebra_vrf *zvrf = vrf_info_lookup(re->vrf_id);
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(re->vrf_id);
if (info->safi != SAFI_UNICAST) {
UNSET_FLAG(re->status, ROUTE_ENTRY_INSTALLED);
@ -1410,7 +1410,7 @@ static void rib_process(struct route_node *rn)
static void zebra_rib_evaluate_mpls(struct route_node *rn)
{
rib_dest_t *dest = rib_dest_from_rnode(rn);
struct zebra_vrf *zvrf = vrf_info_lookup(VRF_DEFAULT);
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!dest)
return;
@ -1898,7 +1898,7 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
struct rib_table_info *info;
bool rt_delete = false;
zvrf = vrf_info_lookup(dplane_ctx_get_vrf(ctx));
zvrf = zebra_vrf_lookup_by_id(dplane_ctx_get_vrf(ctx));
vrf = vrf_lookup_by_id(dplane_ctx_get_vrf(ctx));
/* Locate rn and re(s) from ctx */
@ -2566,7 +2566,7 @@ static void process_subq_early_label(struct listnode *lnode)
if (!w)
return;
zvrf = vrf_info_lookup(w->vrf_id);
zvrf = zebra_vrf_lookup_by_id(w->vrf_id);
if (!zvrf) {
XFREE(MTYPE_WQ_WRAPPER, w);
return;

View file

@ -326,7 +326,7 @@ void zebra_register_rnh_pseudowire(vrf_id_t vrf_id, struct zebra_pw *pw,
*nht_exists = false;
zvrf = vrf_info_lookup(vrf_id);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
if (!zvrf)
return;

View file

@ -566,7 +566,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
if (re->mtu)
vty_out(vty, ", mtu %u", re->mtu);
if (re->vrf_id != VRF_DEFAULT) {
zvrf = vrf_info_lookup(re->vrf_id);
zvrf = zebra_vrf_lookup_by_id(re->vrf_id);
vty_out(vty, ", vrf %s", zvrf_name(zvrf));
}
if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED))
@ -2706,7 +2706,7 @@ DEFUN (default_vrf_vni_mapping,
struct zebra_vrf *zvrf = NULL;
int filter = 0;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return CMD_WARNING;
@ -2745,7 +2745,7 @@ DEFUN (no_default_vrf_vni_mapping,
vni_t vni = strtoul(argv[2]->arg, NULL, 10);
struct zebra_vrf *zvrf = NULL;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf)
return CMD_WARNING;