diff options
35 files changed, 114 insertions, 81 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index b84bc39cd..45b10ebd7 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -241,7 +241,7 @@ babel_enable_if_add (const char *ifname) vector_set (babel_enable_if, strdup (ifname)); - ifp = if_lookup_by_name(ifname, VRF_DEFAULT); + ifp = if_lookup_by_name(ifname, vrf_lookup_by_id(VRF_DEFAULT)); if (ifp != NULL) interface_recalculate(ifp); @@ -264,7 +264,7 @@ babel_enable_if_delete (const char *ifname) free (str); vector_unset (babel_enable_if, babel_enable_if_index); - ifp = if_lookup_by_name(ifname, VRF_DEFAULT); + ifp = if_lookup_by_name(ifname, vrf_lookup_by_id(VRF_DEFAULT)); if (ifp != NULL) interface_reset(ifp); @@ -907,7 +907,8 @@ DEFUN (show_babel_interface, show_babel_interface_sub (vty, ifp); return CMD_SUCCESS; } - if ((ifp = if_lookup_by_name (argv[3]->arg, VRF_DEFAULT)) == NULL) + if ((ifp = if_lookup_by_name (argv[3]->arg, + vrf_lookup_by_id(VRF_DEFAULT))) == NULL) { vty_out (vty, "No such interface name\n"); return CMD_WARNING; @@ -949,7 +950,8 @@ DEFUN (show_babel_neighbour, } return CMD_SUCCESS; } - if ((ifp = if_lookup_by_name (argv[3]->arg, VRF_DEFAULT)) == NULL) + if ((ifp = if_lookup_by_name (argv[3]->arg, + vrf_lookup_by_id(VRF_DEFAULT))) == NULL) { vty_out (vty, "No such interface name\n"); return CMD_WARNING; diff --git a/babeld/babeld.c b/babeld/babeld.c index 39451b435..298903f50 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -555,7 +555,7 @@ babel_distribute_update (struct distribute_ctx *ctx, struct distribute *dist) if (! dist->ifname) return; - ifp = if_lookup_by_name (dist->ifname, VRF_DEFAULT); + ifp = if_lookup_by_name (dist->ifname, vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) return; diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 8e18ed752..ca88a38df 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -310,7 +310,8 @@ static int bgp_get_instance_for_inc_conn(int sock, struct bgp **bgp_inst) if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) continue; - ifp = if_lookup_by_name(name, bgp->vrf_id); + ifp = if_lookup_by_name(name, + vrf_lookup_by_id(bgp->vrf_id)); if (ifp) { *bgp_inst = bgp; return 0; @@ -570,7 +571,8 @@ static int bgp_update_source(struct peer *peer) /* Source is specified with interface name. */ if (peer->update_if) { - ifp = if_lookup_by_name(peer->update_if, peer->bgp->vrf_id); + ifp = if_lookup_by_name(peer->update_if, + vrf_lookup_by_id(peer->bgp->vrf_id)); if (!ifp) return -1; diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 5e9fc57f5..252eb8814 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -787,7 +787,7 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, nexthop->v4 = local->sin.sin_addr; if (peer->update_if) ifp = if_lookup_by_name(peer->update_if, - peer->bgp->vrf_id); + vrf_lookup_by_id(peer->bgp->vrf_id)); else ifp = if_lookup_by_ipv4_exact(&local->sin.sin_addr, peer->bgp->vrf_id); @@ -798,10 +798,11 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, ifp = if_lookup_by_name(peer->conf_if ? peer->conf_if : peer->ifname, - peer->bgp->vrf_id); + vrf_lookup_by_id( + peer->bgp->vrf_id)); } else if (peer->update_if) ifp = if_lookup_by_name(peer->update_if, - peer->bgp->vrf_id); + vrf_lookup_by_id(peer->bgp->vrf_id)); else ifp = if_lookup_by_ipv6_exact(&local->sin6.sin6_addr, local->sin6.sin6_scope_id, @@ -2882,7 +2883,8 @@ static void bgp_encode_pbr_interface_list(struct bgp *bgp, struct stream *s) head = &(bgp_pbr_cfg->ifaces_by_name_ipv4); RB_FOREACH (pbr_if, bgp_pbr_interface_head, head) { - ifp = if_lookup_by_name(pbr_if->name, bgp->vrf_id); + ifp = if_lookup_by_name(pbr_if->name, + vrf_lookup_by_id(bgp->vrf_id)); if (ifp) stream_putl(s, ifp->ifindex); } @@ -2900,7 +2902,8 @@ static int bgp_pbr_get_ifnumber(struct bgp *bgp) head = &(bgp_pbr_cfg->ifaces_by_name_ipv4); RB_FOREACH (pbr_if, bgp_pbr_interface_head, head) { - if (if_lookup_by_name(pbr_if->name, bgp->vrf_id)) + if (if_lookup_by_name(pbr_if->name, + vrf_lookup_by_id(bgp->vrf_id))) cnt++; } return cnt; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 02eda7a43..b61363aa0 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1436,7 +1436,8 @@ void bgp_peer_conf_if_to_su_update(struct peer *peer) hash_release(peer->bgp->peerhash, peer); prev_family = peer->su.sa.sa_family; - if ((ifp = if_lookup_by_name(peer->conf_if, peer->bgp->vrf_id))) { + if ((ifp = if_lookup_by_name(peer->conf_if, + vrf_lookup_by_id(peer->bgp->vrf_id)))) { peer->ifp = ifp; /* If BGP unnumbered is not "v6only", we first see if we can * derive the diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c index 93eed9452..7727fd96c 100644 --- a/eigrpd/eigrp_filter.c +++ b/eigrpd/eigrp_filter.c @@ -174,7 +174,8 @@ void eigrp_distribute_update(struct distribute_ctx *ctx, return; } - ifp = if_lookup_by_name(dist->ifname, VRF_DEFAULT); + ifp = if_lookup_by_name(dist->ifname, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) return; diff --git a/eigrpd/eigrp_routemap.c b/eigrpd/eigrp_routemap.c index f080ba487..10f8df6f1 100644 --- a/eigrpd/eigrp_routemap.c +++ b/eigrpd/eigrp_routemap.c @@ -62,7 +62,7 @@ void eigrp_if_rmap_update(struct if_rmap *if_rmap) struct route_map *rmap; struct eigrp *e; - ifp = if_lookup_by_name(if_rmap->ifname); + ifp = if_lookup_by_name(if_rmap->ifname, vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) return; diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 0a74e8626..5040386e8 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -336,7 +336,8 @@ static struct interface *zebra_interface_if_lookup(struct stream *s) stream_get(ifname_tmp, s, INTERFACE_NAMSIZ); /* And look it up. */ - return if_lookup_by_name(ifname_tmp, VRF_DEFAULT); + return if_lookup_by_name(ifname_tmp, + vrf_lookup_by_id(VRF_DEFAULT)); } void eigrp_zebra_route_add(struct prefix *p, struct list *successors, diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c index d5cdec154..62618e3be 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -1597,7 +1597,7 @@ static int lib_interface_isis_area_tag_modify(enum nb_event event, vrfname = yang_dnode_get_string(dnode->parent->parent, "./vrf"); vrf = vrf_lookup_by_name(vrfname); assert(vrf); - ifp = if_lookup_by_name(ifname, vrf->vrf_id); + ifp = if_lookup_by_name(ifname, vrf); if (!ifp) return NB_OK; circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); @@ -1635,7 +1635,7 @@ static int lib_interface_isis_circuit_type_modify(enum nb_event event, vrfname = yang_dnode_get_string(dnode->parent->parent, "./vrf"); vrf = vrf_lookup_by_name(vrfname); assert(vrf); - ifp = if_lookup_by_name(ifname, vrf->vrf_id); + ifp = if_lookup_by_name(ifname, vrf); if (!ifp) break; circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 4ea6c2c60..a56c2836d 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -1175,7 +1175,8 @@ DEFUN (show_isis_mpls_te_interface, } } else { /* Interface name is specified. */ - ifp = if_lookup_by_name(argv[idx_interface]->arg, VRF_DEFAULT); + ifp = if_lookup_by_name(argv[idx_interface]->arg, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) vty_out(vty, "No such interface name\n"); else { @@ -264,16 +264,16 @@ const char *ifindex2ifname(ifindex_t ifindex, vrf_id_t vrf_id) ifindex_t ifname2ifindex(const char *name, vrf_id_t vrf_id) { struct interface *ifp; + struct vrf *vrf = vrf_lookup_by_id(vrf_id); - return ((ifp = if_lookup_by_name(name, vrf_id)) != NULL) + return ((ifp = if_lookup_by_name(name, vrf)) != NULL) ? ifp->ifindex : IFINDEX_INTERNAL; } /* Interface existance check by interface name. */ -struct interface *if_lookup_by_name(const char *name, vrf_id_t vrf_id) +struct interface *if_lookup_by_name(const char *name, struct vrf *vrf) { - struct vrf *vrf = vrf_lookup_by_id(vrf_id); struct interface if_tmp; if (!vrf || !name @@ -293,7 +293,7 @@ struct interface *if_lookup_by_name_all_vrf(const char *name) return NULL; RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) { - ifp = if_lookup_by_name(name, vrf->vrf_id); + ifp = if_lookup_by_name(name, vrf); if (ifp) return ifp; } @@ -425,7 +425,7 @@ struct interface *if_get_by_name(const char *name, struct vrf *vrf) switch (vrf_get_backend()) { case VRF_BACKEND_UNKNOWN: case VRF_BACKEND_NETNS: - ifp = if_lookup_by_name(name, vrf->vrf_id); + ifp = if_lookup_by_name(name, vrf); if (ifp) return ifp; return if_create(name, vrf); @@ -635,7 +635,7 @@ static struct interface *if_sunwzebra_get(const char *name, struct vrf *vrf) struct interface *ifp; char *cp; - if ((ifp = if_lookup_by_name(name, vrf->vrf_id)) != NULL) + if ((ifp = if_lookup_by_name(name, vrf)) != NULL) return ifp; /* hunt the primary interface name... */ @@ -1128,6 +1128,7 @@ DEFPY_NOSH (interface, vrf_id_t vrf_id; struct interface *ifp; int ret; + struct vrf *vrf; if (!vrfname) vrfname = VRF_DEFAULT_NAME; @@ -1142,8 +1143,6 @@ DEFPY_NOSH (interface, VRF_GET_ID(vrf_id, vrfname, false); ifp = if_lookup_by_name_all_vrf(ifname); if (ifp && ifp->vrf_id != vrf_id) { - struct vrf *vrf; - /* * Special case 1: a VRF name was specified, but the found * interface is associated to different VRF. Reject the command. @@ -1161,9 +1160,9 @@ DEFPY_NOSH (interface, */ vrf = vrf_lookup_by_id(ifp->vrf_id); assert(vrf); - vrf_id = ifp->vrf_id; vrfname = vrf->name; - } + } else + vrf = vrf_lookup_by_id(vrf_id); snprintf(xpath_list, sizeof(xpath_list), "/frr-interface:lib/interface[name='%s'][vrf='%s']", ifname, @@ -1180,7 +1179,7 @@ DEFPY_NOSH (interface, * all interface-level commands are converted to the new * northbound model. */ - ifp = if_lookup_by_name(ifname, vrf_id); + ifp = if_lookup_by_name(ifname, vrf); if (ifp) VTY_PUSH_CONTEXT(INTERFACE_NODE, ifp); } @@ -494,7 +494,7 @@ size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz, /* These 3 functions are to be used when the ifname argument is terminated by a '\0' character: */ extern struct interface *if_lookup_by_name_all_vrf(const char *ifname); -extern struct interface *if_lookup_by_name(const char *ifname, vrf_id_t vrf_id); +extern struct interface *if_lookup_by_name(const char *ifname, struct vrf *vrf); extern struct interface *if_get_by_name(const char *ifname, struct vrf *vrf); extern void if_set_index(struct interface *ifp, ifindex_t ifindex); diff --git a/lib/zclient.c b/lib/zclient.c index c5d4e0daf..da8dc4e90 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1490,7 +1490,8 @@ struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id) stream_get(ifname_tmp, s, INTERFACE_NAMSIZ); /* Lookup this by interface index. */ - ifp = if_lookup_by_name(ifname_tmp, vrf_id); + ifp = if_lookup_by_name(ifname_tmp, + vrf_lookup_by_id(vrf_id)); if (ifp == NULL) { flog_err(EC_LIB_ZAPI_ENCODE, "INTERFACE_STATE: Cannot find IF %s in VRF %d", @@ -1550,7 +1551,8 @@ struct interface *zebra_interface_link_params_read(struct stream *s, ifindex = stream_getl(s); - struct interface *ifp = if_lookup_by_index(ifindex, vrf_id); + struct interface *ifp = if_lookup_by_index(ifindex, + vrf_id); if (ifp == NULL) { flog_err(EC_LIB_ZAPI_ENCODE, @@ -1846,7 +1848,8 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s, stream_get(ifname, s, INTERFACE_NAMSIZ); /* Lookup interface. */ - ifp = if_lookup_by_name(ifname, vrf_id); + ifp = if_lookup_by_name(ifname, + vrf_lookup_by_id(vrf_id)); if (ifp == NULL) { flog_err(EC_LIB_ZAPI_ENCODE, "INTERFACE_VRF_UPDATE: Cannot find IF %s in VRF %d", diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c index 8f1ba14fe..a01911ca4 100644 --- a/nhrpd/nhrp_interface.c +++ b/nhrpd/nhrp_interface.c @@ -126,7 +126,8 @@ static void nhrp_interface_update_nbma(struct interface *ifp) sockunion_family(&nbma) = AF_UNSPEC; if (nifp->source) - nbmaifp = if_lookup_by_name(nifp->source, VRF_DEFAULT); + nbmaifp = if_lookup_by_name(nifp->source, + vrf_lookup_by_id(VRF_DEFAULT)); switch (ifp->ll_type) { case ZEBRA_LLT_IPGRE: { diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 946bbf8cc..91a28eaa4 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1404,7 +1404,8 @@ ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix, if (type == RMAP_OSPF6) { ei = ((struct ospf6_route *)object)->route_option; - ifp = if_lookup_by_name((char *)rule, VRF_DEFAULT); + ifp = if_lookup_by_name((char *)rule, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp != NULL && ei->ifindex == ifp->ifindex) return RMAP_MATCH; diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 692c84ad0..114a56c95 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -996,7 +996,8 @@ DEFUN (show_ipv6_ospf6_interface, struct interface *ifp; if (argc == 5) { - ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); + ifp = if_lookup_by_name(argv[idx_ifname]->arg, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) { vty_out(vty, "No such Interface: %s\n", argv[idx_ifname]->arg); @@ -1081,7 +1082,8 @@ DEFUN (show_ipv6_ospf6_interface_traffic, if (argv_find(argv, argc, "IFNAME", &idx_ifname)) { intf_name = argv[idx_ifname]->arg; - ifp = if_lookup_by_name(intf_name, VRF_DEFAULT); + ifp = if_lookup_by_name(intf_name, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) { vty_out(vty, "No such Interface: %s\n", intf_name); return CMD_WARNING; @@ -1125,7 +1127,8 @@ DEFUN (show_ipv6_ospf6_interface_ifname_prefix, struct interface *ifp; struct ospf6_interface *oi; - ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); + ifp = if_lookup_by_name(argv[idx_ifname]->arg, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) { vty_out(vty, "No such Interface: %s\n", argv[idx_ifname]->arg); return CMD_WARNING; @@ -2026,7 +2029,7 @@ DEFUN (clear_ipv6_ospf6_interface, } else /* Interface name is specified. */ { if ((ifp = if_lookup_by_name(argv[idx_ifname]->arg, - VRF_DEFAULT)) + vrf_lookup_by_id(VRF_DEFAULT))) == NULL) { vty_out(vty, "No such Interface: %s\n", argv[idx_ifname]->arg); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 5cd657259..bbc9247b0 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -715,7 +715,8 @@ DEFUN (no_ospf6_interface_area, struct interface *ifp; uint32_t area_id; - ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); + ifp = if_lookup_by_name(argv[idx_ifname]->arg, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) { vty_out(vty, "No such interface %s\n", argv[idx_ifname]->arg); return CMD_SUCCESS; diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index e68363663..52ec97e34 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -2569,7 +2569,7 @@ DEFUN (show_ip_ospf_mpls_te_link, if (idx_interface) { ifp = if_lookup_by_name( argv[idx_interface]->arg, - ospf->vrf_id); + vrf_lookup_by_id(ospf->vrf_id)); if (ifp == NULL) { vty_out(vty, "No such interface name in vrf %s\n", vrf->name); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index a2444c9ea..e2ddf36a3 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3741,7 +3741,8 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf, json_interface); } else { /* Interface name is specified. */ - ifp = if_lookup_by_name(intf_name, ospf->vrf_id); + ifp = if_lookup_by_name(intf_name, + vrf_lookup_by_id(ospf->vrf_id)); if (ifp == NULL) { if (use_json) json_object_boolean_true_add(json_vrf, @@ -3881,7 +3882,8 @@ static int show_ip_ospf_interface_traffic_common( } } else { /* Interface name is specified. */ - ifp = if_lookup_by_name(intf_name, ospf->vrf_id); + ifp = if_lookup_by_name(intf_name, + vrf_lookup_by_id(ospf->vrf_id)); if (ifp != NULL) { struct route_node *rn; struct ospf_interface *oi; @@ -4691,7 +4693,8 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, json, use_vrf); - ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id); + ifp = if_lookup_by_name(argv[arg_base]->arg, + vrf_lookup_by_id(ospf->vrf_id)); if (!ifp) { if (use_json) json_object_boolean_true_add(json, "noSuchIface"); @@ -4759,7 +4762,8 @@ DEFUN (show_ip_ospf_neighbor_int, argv_find(argv, argc, "IFNAME", &idx_ifname); - ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id); + ifp = if_lookup_by_name(argv[idx_ifname]->arg, + vrf_lookup_by_id(vrf_id)); if (!ifp) return ret; @@ -5576,7 +5580,8 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty, vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); } - ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id); + ifp = if_lookup_by_name(argv[arg_base]->arg, + vrf_lookup_by_id(ospf->vrf_id)); if (!ifp) { if (!use_json) vty_out(vty, "No such interface.\n"); @@ -10684,7 +10689,8 @@ DEFUN (clear_ip_ospf_interface, } } else { /* Interface name is specified. */ - ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id); + ifp = if_lookup_by_name(argv[idx_ifname]->arg, + vrf_lookup_by_id(vrf_id)); if (ifp == NULL) vty_out(vty, "No such interface name\n"); else diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index c178e367d..9db89faa9 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -175,7 +175,8 @@ static struct interface *zebra_interface_if_lookup(struct stream *s, stream_get(ifname_tmp, s, INTERFACE_NAMSIZ); /* And look it up. */ - return if_lookup_by_name(ifname_tmp, vrf_id); + return if_lookup_by_name(ifname_tmp, + vrf_lookup_by_id(vrf_id)); } static int ospf_interface_state_up(ZAPI_CALLBACK_ARGS) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 18e84fef2..cb30b2b7f 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -7655,7 +7655,7 @@ DEFUN (interface_ip_mroute, pim = pim_ifp->pim; oifname = argv[idx_interface]->arg; - oif = if_lookup_by_name(oifname, pim->vrf_id); + oif = if_lookup_by_name(oifname, pim->vrf); if (!oif) { vty_out(vty, "No such interface name %s\n", oifname); return CMD_WARNING; @@ -7706,7 +7706,7 @@ DEFUN (interface_ip_mroute_source, pim = pim_ifp->pim; oifname = argv[idx_interface]->arg; - oif = if_lookup_by_name(oifname, pim->vrf_id); + oif = if_lookup_by_name(oifname, pim->vrf); if (!oif) { vty_out(vty, "No such interface name %s\n", oifname); return CMD_WARNING; @@ -7761,7 +7761,7 @@ DEFUN (interface_no_ip_mroute, pim = pim_ifp->pim; oifname = argv[idx_interface]->arg; - oif = if_lookup_by_name(oifname, pim->vrf_id); + oif = if_lookup_by_name(oifname, pim->vrf); if (!oif) { vty_out(vty, "No such interface name %s\n", oifname); return CMD_WARNING; @@ -7813,7 +7813,7 @@ DEFUN (interface_no_ip_mroute_source, pim = pim_ifp->pim; oifname = argv[idx_interface]->arg; - oif = if_lookup_by_name(oifname, pim->vrf_id); + oif = if_lookup_by_name(oifname, pim->vrf); if (!oif) { vty_out(vty, "No such interface name %s\n", oifname); return CMD_WARNING; @@ -10127,7 +10127,7 @@ DEFUN_HIDDEN (ip_pim_mlag, idx = 3; peerlink = argv[idx]->arg; - ifp = if_lookup_by_name(peerlink, VRF_DEFAULT); + ifp = if_lookup_by_name(peerlink, vrf_lookup_by_id(VRF_DEFAULT)); if (!ifp) { vty_out(vty, "No such interface name %s\n", peerlink); return CMD_WARNING; diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 6a1b835ca..4d6af1b51 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -895,9 +895,9 @@ struct in_addr pim_find_primary_addr(struct interface *ifp) struct interface *lo_ifp; // DBS - Come back and check here if (ifp->vrf_id == VRF_DEFAULT) - lo_ifp = if_lookup_by_name("lo", vrf->vrf_id); + lo_ifp = if_lookup_by_name("lo", vrf); else - lo_ifp = if_lookup_by_name(vrf->name, vrf->vrf_id); + lo_ifp = if_lookup_by_name(vrf->name, vrf); if (lo_ifp) return pim_find_primary_addr(lo_ifp); diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c index b1f7cfd2c..954b5dee7 100644 --- a/pimd/pim_msdp_socket.c +++ b/pimd/pim_msdp_socket.c @@ -158,7 +158,7 @@ int pim_msdp_sock_listen(struct pim_instance *pim) if (pim->vrf_id != VRF_DEFAULT) { struct interface *ifp = - if_lookup_by_name(pim->vrf->name, pim->vrf_id); + if_lookup_by_name(pim->vrf->name, pim->vrf); if (!ifp) { flog_err(EC_LIB_INTERFACE, "%s: Unable to lookup vrf interface: %s", @@ -239,7 +239,7 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp) if (mp->pim->vrf_id != VRF_DEFAULT) { struct interface *ifp = - if_lookup_by_name(mp->pim->vrf->name, mp->pim->vrf_id); + if_lookup_by_name(mp->pim->vrf->name, mp->pim->vrf); if (!ifp) { flog_err(EC_LIB_INTERFACE, "%s: Unable to lookup vrf interface: %s", diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 25ac307ac..2a772639f 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -211,11 +211,12 @@ static int pim_zebra_if_state_up(ZAPI_CALLBACK_ARGS) */ if (sscanf(ifp->name, "pimreg%" SCNu32, &table_id) == 1) { struct vrf *vrf; + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { if ((table_id == vrf->data.l.table_id) && (ifp->vrf_id != vrf->vrf_id)) { struct interface *master = if_lookup_by_name( - vrf->name, vrf->vrf_id); + vrf->name, vrf); if (!master) { zlog_debug( diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index 3216b8f89..3f8b9cb76 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -106,7 +106,8 @@ static route_map_result_t route_match_interface(void *rule, if (type == RMAP_RIP) { ifname = rule; - ifp = if_lookup_by_name(ifname, VRF_DEFAULT); + ifp = if_lookup_by_name(ifname, + vrf_lookup_by_id(VRF_DEFAULT)); if (!ifp) return RMAP_NOMATCH; diff --git a/ripd/ripd.c b/ripd/ripd.c index 3a1ffd17a..72af5326b 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3299,7 +3299,7 @@ static void rip_distribute_update(struct distribute_ctx *ctx, if (!ctx->vrf || !dist->ifname) return; - ifp = if_lookup_by_name(dist->ifname, ctx->vrf->vrf_id); + ifp = if_lookup_by_name(dist->ifname, ctx->vrf); if (ifp == NULL) return; @@ -3418,7 +3418,7 @@ static void rip_if_rmap_update(struct if_rmap_ctx *ctx, if (ctx->name) vrf = vrf_lookup_by_name(ctx->name); if (vrf) - ifp = if_lookup_by_name(if_rmap->ifname, vrf->vrf_id); + ifp = if_lookup_by_name(if_rmap->ifname, vrf); if (ifp == NULL) return; diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index 0604e272c..874d81516 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -97,7 +97,8 @@ static route_map_result_t route_match_interface(void *rule, if (type == RMAP_RIPNG) { ifname = rule; - ifp = if_lookup_by_name(ifname, VRF_DEFAULT); + ifp = if_lookup_by_name(ifname, + vrf_lookup_by_id(VRF_DEFAULT)); if (!ifp) return RMAP_NOMATCH; diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 71bc43049..67a52e9f0 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2454,7 +2454,7 @@ static void ripng_distribute_update(struct distribute_ctx *ctx, if (!ctx->vrf || !dist->ifname) return; - ifp = if_lookup_by_name(dist->ifname, ctx->vrf->vrf_id); + ifp = if_lookup_by_name(dist->ifname, ctx->vrf); if (ifp == NULL) return; @@ -2571,7 +2571,7 @@ static void ripng_if_rmap_update(struct if_rmap_ctx *ctx, if (ctx->name) vrf = vrf_lookup_by_name(ctx->name); if (vrf) - ifp = if_lookup_by_name(if_rmap->ifname, vrf->vrf_id); + ifp = if_lookup_by_name(if_rmap->ifname, vrf); if (ifp == NULL) return; diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index cd6f95658..01d6db078 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -46,7 +46,7 @@ struct zclient *zclient = NULL; /* For registering threads. */ extern struct thread_master *master; -static struct interface *zebra_interface_if_lookup(struct stream *s) +static struct interface *zebra_interface_if_lookup(struct stream *s, vrf_id_t vrf_id) { char ifname_tmp[INTERFACE_NAMSIZ]; @@ -54,7 +54,8 @@ static struct interface *zebra_interface_if_lookup(struct stream *s) stream_get(ifname_tmp, s, INTERFACE_NAMSIZ); /* And look it up. */ - return if_lookup_by_name(ifname_tmp, VRF_DEFAULT); + return if_lookup_by_name(ifname_tmp, + vrf_lookup_by_id(vrf_id)); } /* Inteface addition message from zebra. */ @@ -112,7 +113,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS) static int interface_state_up(ZAPI_CALLBACK_ARGS) { - zebra_interface_if_lookup(zclient->ibuf); + zebra_interface_if_lookup(zclient->ibuf, vrf_id); return 0; } diff --git a/staticd/static_routes.c b/staticd/static_routes.c index 5f9ecad69..9c012c475 100644 --- a/staticd/static_routes.c +++ b/staticd/static_routes.c @@ -187,7 +187,7 @@ int static_add_route(afi_t afi, safi_t safi, uint8_t type, struct prefix *p, else { struct interface *ifp; - ifp = if_lookup_by_name(ifname, nh_svrf->vrf->vrf_id); + ifp = if_lookup_by_name(ifname, nh_svrf->vrf); if (ifp && ifp->ifindex != IFINDEX_INTERNAL) { si->ifindex = ifp->ifindex; static_install_route(rn, si, safi); @@ -331,8 +331,7 @@ static void static_fixup_vrf(struct static_vrf *svrf, si->nh_vrf_id = svrf->vrf->vrf_id; si->nh_registered = false; if (si->ifindex) { - ifp = if_lookup_by_name(si->ifname, - si->nh_vrf_id); + ifp = if_lookup_by_name(si->ifname, svrf->vrf); if (ifp) si->ifindex = ifp->ifindex; else @@ -367,7 +366,8 @@ static void static_enable_vrf(struct static_vrf *svrf, si->vrf_id = vrf->vrf_id; if (si->ifindex) { ifp = if_lookup_by_name(si->ifname, - si->nh_vrf_id); + vrf_lookup_by_id( + si->nh_vrf_id)); if (ifp) si->ifindex = ifp->ifindex; else diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index c6da00418..6ffeb2ca4 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -47,7 +47,7 @@ struct zclient *zclient; static struct hash *static_nht_hash; -static struct interface *zebra_interface_if_lookup(struct stream *s) +static struct interface *zebra_interface_if_lookup(struct stream *s, vrf_id_t vrf_id) { char ifname_tmp[INTERFACE_NAMSIZ]; @@ -55,7 +55,8 @@ static struct interface *zebra_interface_if_lookup(struct stream *s) stream_get(ifname_tmp, s, INTERFACE_NAMSIZ); /* And look it up. */ - return if_lookup_by_name(ifname_tmp, VRF_DEFAULT); + return if_lookup_by_name(ifname_tmp, + vrf_lookup_by_id(vrf_id)); } /* Inteface addition message from zebra. */ @@ -115,7 +116,7 @@ static int interface_state_up(ZAPI_CALLBACK_ARGS) { struct interface *ifp; - ifp = zebra_interface_if_lookup(zclient->ibuf); + ifp = zebra_interface_if_lookup(zclient->ibuf, vrf_id); if (ifp) { if (if_is_vrf(ifp)) { diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 6f664601e..a5a18a10f 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -196,7 +196,8 @@ static int if_getaddrs(void) continue; } - ifp = if_lookup_by_name(ifap->ifa_name, VRF_DEFAULT); + ifp = if_lookup_by_name(ifap->ifa_name, + vrf_lookup_by_id(VRF_DEFAULT)); if (ifp == NULL) { flog_err(EC_LIB_INTERFACE, "if_getaddrs(): Can't lookup interface %s\n", diff --git a/zebra/interface.c b/zebra/interface.c index 13582008a..6939c8c61 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1653,7 +1653,8 @@ DEFUN (show_interface_name_vrf, VRF_GET_ID(vrf_id, argv[idx_name]->arg, false); /* Specified interface print. */ - ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id); + ifp = if_lookup_by_name(argv[idx_ifname]->arg, + vrf_lookup_by_id(vrf_id)); if (ifp == NULL) { vty_out(vty, "%% Can't find interface %s\n", argv[idx_ifname]->arg); @@ -1683,7 +1684,7 @@ DEFUN (show_interface_name_vrf_all, /* All interface print. */ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { /* Specified interface print. */ - ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf->vrf_id); + ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf); if (ifp) { if_dump_vty(vty, ifp); found++; diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 88bcc0e45..be1191bac 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -616,7 +616,7 @@ int ifm_read(struct if_msghdr *ifm) * be filled in. */ if ((ifp == NULL) && ifnlen) - ifp = if_lookup_by_name(ifname, VRF_DEFAULT); + ifp = if_lookup_by_name(ifname, vrf); /* * If ifp still does not exist or has an invalid index diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 61200806b..f4347e5ac 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -2207,9 +2207,9 @@ static void zread_vrf_label(ZAPI_HANDLER_ARGS) STREAM_GETC(s, ltype); if (zvrf->vrf->vrf_id != VRF_DEFAULT) - ifp = if_lookup_by_name(zvrf->vrf->name, zvrf->vrf->vrf_id); + ifp = if_lookup_by_name(zvrf->vrf->name, zvrf->vrf); else - ifp = if_lookup_by_name("lo", VRF_DEFAULT); + ifp = if_lookup_by_name("lo", vrf_lookup_by_id(VRF_DEFAULT)); if (!ifp) { zlog_debug("Unable to find specified Interface for %s", |