]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: change if_lookup_by_name() api with vrf
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 11 Feb 2019 14:46:48 +0000 (15:46 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 12 Jun 2019 06:37:54 +0000 (08:37 +0200)
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>
35 files changed:
babeld/babel_interface.c
babeld/babeld.c
bgpd/bgp_network.c
bgpd/bgp_zebra.c
bgpd/bgpd.c
eigrpd/eigrp_filter.c
eigrpd/eigrp_routemap.c
eigrpd/eigrp_zebra.c
isisd/isis_northbound.c
isisd/isis_te.c
lib/if.c
lib/if.h
lib/zclient.c
nhrpd/nhrp_interface.c
ospf6d/ospf6_asbr.c
ospf6d/ospf6_interface.c
ospf6d/ospf6_top.c
ospfd/ospf_te.c
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
pimd/pim_cmd.c
pimd/pim_iface.c
pimd/pim_msdp_socket.c
pimd/pim_zebra.c
ripd/rip_routemap.c
ripd/ripd.c
ripngd/ripng_routemap.c
ripngd/ripngd.c
sharpd/sharp_zebra.c
staticd/static_routes.c
staticd/static_zebra.c
zebra/if_ioctl.c
zebra/interface.c
zebra/kernel_socket.c
zebra/zapi_msg.c

index b84bc39cd8dfb58b1e6662f3b87440d2492d7bf6..45b10ebd7955bb92ef94ff995cfae3db84b583a6 100644 (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;
index 39451b435a44ec59b7876dafcb2dbdf39cc0ac42..298903f50fffeb52cf8e192b7bca611dccfc7946 100644 (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;
 
index 8e18ed75295c9a3a0886a113d04bdf8d7bd353ab..ca88a38df2f6f2f85702519dfbc935b668d5b21c 100644 (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;
 
index 5e9fc57f59aeeb5edab641a4b3e8f839d31b1c1c..252eb881432c090d198a93b8b9cb23a2b4544643 100644 (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;
index 02eda7a430c4086168be691f4fbedf479bc923e3..b61363aa086bf445dc8a98247000cbf6cb4f1764 100644 (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
index 93eed9452ccbb6ab4ad9174b45f4f4f2b90a0908..7727fd96c8ab4c8ae24bf2da9269530ca1ef40e5 100644 (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;
 
index f080ba48769f78c369431e57e5c1f283da3c5b99..10f8df6f1d1906be0faf87335afe1b63d6c9b8d0 100644 (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;
 
index 0a74e86263a320f1b65ec76a23cef07e9e186409..5040386e886f8e2a0f581bbe6a1222635bf5e190 100644 (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,
index d5cdec154b4d3c5817a8fc776016ea881f378abb..62618e3be9594b4fc1ebace7b4ba4a770cc988a5 100644 (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);
index 4ea6c2c60d657901cb6c8f9a8ea1252348ea1baa..a56c2836d0fda385cc57b45215a2622cdf4d7f66 100644 (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 {
index 22f83bb675f04612876d153bcc93aed3e4cdc74a..1a51e3ee8d6baf3dcd1c205a79fc46c0c6d9afec 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -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);
        }
index 196c77c7828c5087167ebded899eb956c51fa123..794952897d06bc19f90756a058e7383682fe3c75 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -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);
 
index c5d4e0daff37b94fab797c0bd2593be758d60ac9..da8dc4e906409fff4e9628d2f041a297d8dd5433 100644 (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",
index 8f1ba14fe4f200636ae85fcb9eedc505bf94539a..a01911ca4b8dd1ea5e929781aa64cc8343da4356 100644 (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: {
index 946bbf8cc9423f8fb9a5309f2c79203b4f3f6a16..91a28eaa4f489c9bf5df0dbf615dca0d2ca7b802 100644 (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;
index 692c84ad08e7f7f82c144f4a4f3ce631fe222782..114a56c952b7933f239f17ceda3f9c79334014e2 100644 (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);
index 5cd657259b3fd6039196088d79afee6758f0c72a..bbc9247b07627bba88119e319c5b0b1005d1cc77 100644 (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;
index e68363663949b8d7c34965fcd2afc11b59d629cf..52ec97e345f812ce65ef1e3c4cd570c78327af6c 100644 (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);
index a2444c9ea39ea6a258e75c70cf855f2617cf2d8a..e2ddf36a3695bf6947ca4a0ac5e0b6d03bcc13c5 100644 (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
index c178e367d390a032fcc37df14163950328d8ce69..9db89faa93397c877567bf4382b886dfea4f0bb6 100644 (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)
index 18e84fef23c7b7863abc02888e8da120c5853540..cb30b2b7fdb9bec4c608579d8ee85be59afa6f9a 100644 (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;
index 6a1b835cac01bb4170f9de370fc6e7a71ace211c..4d6af1b51e657dfb7b5b1f8cc8e6b1003f3c60fb 100644 (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);
index b1f7cfd2c66b57b05e170b2f06735138308c2e40..954b5dee7e8d8d2400d00be51afefe42e88ff919 100644 (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",
index 25ac307ac43defc1b51e27ba89d169df7da729db..2a772639fb3fd4549e8b7c1444b39b21ca7cf003 100644 (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(
index 3216b8f89fda9417eba84d1980cdc033d8e43378..3f8b9cb76bad816f1d20dcd911cf4873171cc3e6 100644 (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;
index 3a1ffd17a6f47561d7b54a1e40f4c71e77509602..72af5326b52df15b6292ea8101209c4360e0bebd 100644 (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;
 
index 0604e272cdfd6800b6318f3746841616de5c6c61..874d815167c84fc3057d41de0021b371d850df32 100644 (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;
index 71bc43049ab039b3a565fb766718b8cb7d2cd37a..67a52e9f018b83df6005bb91b6579babfe2f8b6c 100644 (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;
 
index cd6f9565802dca1f2e19fcdafbc4c99e90ffebd1..01d6db07842badf4f31aca951157ac83aa00f91e 100644 (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;
 }
index 5f9ecad6946229f8c3db99da2def2165552f7163..9c012c47518b6623b9aaf810900e9eca8e43deba 100644 (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
index c6da00418b4ab9408b056c07c17871ac6560f76b..6ffeb2ca4bea033c92db60ac8840757224ddd295 100644 (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)) {
index 6f664601e526b21066e82281d28d057634537632..a5a18a10fa499848a286cf36ea35d4e69934afd7 100644 (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",
index 13582008a702641ff9a56907525532de9e1b463e..6939c8c61f46040192c361246e2f11e84951e368 100644 (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++;
index 88bcc0e45eb1cc1a901a977d096fc8f4b4d76baf..be1191bac11b82630728206df435a0e643f194d1 100644 (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
index 61200806ba84ca81b9077771dd0be3963b51b25e..f4347e5ac529a66c9fbc9cc59f8fbf95c9ccb2a0 100644 (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",