*: Refactor if_get_by_name to be VRF aware

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-03-11 07:30:52 -05:00
parent 1306c09a1b
commit 92a57eb206
5 changed files with 8 additions and 16 deletions

View File

@ -427,7 +427,7 @@ if_lookup_prefix (struct prefix *prefix, vrf_id_t vrf_id)
/* Get interface by name if given name interface doesn't exist create /* Get interface by name if given name interface doesn't exist create
one. */ one. */
struct interface * struct interface *
if_get_by_name_vrf (const char *name, vrf_id_t vrf_id) if_get_by_name (const char *name, vrf_id_t vrf_id)
{ {
struct interface *ifp; struct interface *ifp;
@ -435,12 +435,6 @@ if_get_by_name_vrf (const char *name, vrf_id_t vrf_id)
if_create (name, strlen(name), vrf_id); if_create (name, strlen(name), vrf_id);
} }
struct interface *
if_get_by_name (const char *name)
{
return if_get_by_name_vrf (name, VRF_DEFAULT);
}
struct interface * struct interface *
if_get_by_name_len_vrf (const char *name, size_t namelen, vrf_id_t vrf_id, int vty) if_get_by_name_len_vrf (const char *name, size_t namelen, vrf_id_t vrf_id, int vty)
{ {

View File

@ -402,14 +402,12 @@ extern struct connected *if_lookup_address (void *matchaddr, int family,
extern struct interface *if_lookup_prefix (struct prefix *prefix, extern struct interface *if_lookup_prefix (struct prefix *prefix,
vrf_id_t vrf_id); vrf_id_t vrf_id);
/* These 2 functions are to be used when the ifname argument is terminated /* These 3 functions are to be used when the ifname argument is terminated
by a '\0' character: */ by a '\0' character: */
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_all_vrf (const char *ifname);
extern struct interface *if_lookup_by_name (const char *ifname, extern struct interface *if_lookup_by_name (const char *ifname,
vrf_id_t vrf_id); vrf_id_t vrf_id);
extern struct interface *if_get_by_name_vrf (const char *ifname, extern struct interface *if_get_by_name (const char *ifname,
vrf_id_t vrf_id); vrf_id_t vrf_id);
/* For these 2 functions, the namelen argument should be the precise length /* For these 2 functions, the namelen argument should be the precise length

View File

@ -668,7 +668,7 @@ DEFUN (ospf6_interface_area,
u_int32_t area_id; u_int32_t area_id;
/* find/create ospf6 interface */ /* find/create ospf6 interface */
ifp = if_get_by_name (argv[idx_ifname]->arg); ifp = if_get_by_name (argv[idx_ifname]->arg, VRF_DEFAULT);
oi = (struct ospf6_interface *) ifp->info; oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL) if (oi == NULL)
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);

View File

@ -387,7 +387,7 @@ DEFUN (ospf_passive_interface,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
ifp = if_get_by_name (argv[1]->arg); ifp = if_get_by_name (argv[1]->arg, VRF_DEFAULT);
params = IF_DEF_PARAMS (ifp); params = IF_DEF_PARAMS (ifp);
@ -457,7 +457,7 @@ DEFUN (no_ospf_passive_interface,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
ifp = if_get_by_name (argv[2]->arg); ifp = if_get_by_name (argv[2]->arg, VRF_DEFAULT);
params = IF_DEF_PARAMS (ifp); params = IF_DEF_PARAMS (ifp);

View File

@ -375,7 +375,7 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h,
} }
/* Add interface. */ /* Add interface. */
ifp = if_get_by_name_vrf (name, vrf_id); ifp = if_get_by_name (name, vrf_id);
set_ifindex(ifp, ifi->ifi_index, zns); set_ifindex(ifp, ifi->ifi_index, zns);
ifp->flags = ifi->ifi_flags & 0x0000fffff; ifp->flags = ifi->ifi_flags & 0x0000fffff;
if (vrf_device) if (vrf_device)
@ -722,7 +722,7 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
if (ifp == NULL) if (ifp == NULL)
{ {
/* unknown interface */ /* unknown interface */
ifp = if_get_by_name_vrf (name, vrf_id); ifp = if_get_by_name (name, vrf_id);
} }
else else
{ {