]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd, lib, zebra: Add ability to retrieve ifp without specifying a vrf
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 23 Mar 2016 19:38:30 +0000 (12:38 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 23 Mar 2016 19:38:30 +0000 (12:38 -0700)
There are cases where we get an interface name but do not have a
corresponding vrf.  We care about getting an interface pointer
so just provide a function that searches all vrf's for the ifp.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Radhicak Mahankali <radhika@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
bgpd/bgp_routemap.c
lib/if.c
lib/if.h
zebra/zebra_ptm.c

index 311ebb3635082b952e85503e378fd8d10e76f21f..9833e4e86b314dd5fe5a26c892a62409c5bac639 100644 (file)
@@ -949,7 +949,7 @@ route_match_interface (void *rule, struct prefix *prefix,
       if (!info || !info->attr)
        return RMAP_NOMATCH;
 
-      ifp = if_lookup_by_name ((char *)rule);
+      ifp = if_lookup_by_name_all_vrf ((char *)rule);
 
       if (ifp == NULL || ifp->ifindex != info->attr->nh_ifindex)
        return RMAP_NOMATCH;
index cf88b031b3c7fae51ec118cd0eedc4768526336b..443cd419bedfab01a540c7e0af97846f9dd62feb 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -290,6 +290,24 @@ if_lookup_by_name_vrf (const char *name, vrf_id_t vrf_id)
   return NULL;
 }
 
+struct interface *
+if_lookup_by_name_all_vrf (const char *name)
+{
+  struct interface *ifp;
+  struct vrf *vrf = NULL;
+  vrf_iter_t iter;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      vrf = vrf_iter2vrf (iter);
+      ifp = if_lookup_by_name_vrf (name, vrf->vrf_id);
+      if (ifp)
+       return ifp;
+    }
+
+  return NULL;
+}
+
 struct interface *
 if_lookup_by_name (const char *name)
 {
index 797a68bf8281e37bbd753a6b155955096df75f57..f9c4cd5063b926008062060f2f5db38db88116d0 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -287,6 +287,7 @@ extern struct interface *if_lookup_prefix_vrf (struct prefix *prefix,
 extern struct interface *if_lookup_by_name (const char *ifname);
 extern struct interface *if_get_by_name (const char *ifname);
 
+extern struct interface *if_lookup_by_name_all_vrf (const char *ifname);
 extern struct interface *if_lookup_by_name_vrf (const char *ifname,
                                 vrf_id_t vrf_id);
 extern struct interface *if_get_by_name_vrf (const char *ifname,
index f32fedd9f602e680ff6d92271a852168b2ee37cd..bd4c03d1d1f0f1c97592bdd43f20aeb70f60495f 100644 (file)
@@ -492,7 +492,7 @@ zebra_ptm_handle_msg_cb(void *arg, void *in_ctxt)
   }
 
   if (strcmp(ZEBRA_PTM_INVALID_PORT_NAME, port_str)) {
-    ifp = if_lookup_by_name(port_str);
+    ifp = if_lookup_by_name_all_vrf(port_str);
 
     if (!ifp) {
       zlog_err("%s: %s not found in interface list", __func__, port_str);