*: change if_lookup_by_name() api with vrf

the vrf_id parameter is replaced by struct vrf * parameter.
this impacts most of the daemons that look for an interface based on the
name and the vrf identifier.
Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was
ignored until now.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
Philippe Guibert 2019-02-11 15:46:48 +01:00
parent e9c199a6c1
commit f11e98eca3
35 changed files with 114 additions and 81 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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,

View file

@ -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);

View file

@ -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 {

View file

@ -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);
}

View file

@ -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);

View file

@ -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",

View file

@ -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: {

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -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);

View file

@ -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",

View file

@ -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(

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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

View file

@ -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)) {

View file

@ -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",

View file

@ -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++;

View file

@ -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

View file

@ -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",