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>
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;
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)
{
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,
}
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);