bgpd, lib, zebra: Refactor ifname2ifindex to be VRF aware

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-03-11 07:52:59 -05:00
parent baaea325e6
commit 128c2be2a1
5 changed files with 5 additions and 12 deletions

View file

@ -617,7 +617,7 @@ bgp_connect (struct peer *peer)
}
if (peer->conf_if || peer->ifname)
ifindex = ifname2ifindex (peer->conf_if ? peer->conf_if : peer->ifname);
ifindex = ifname2ifindex (peer->conf_if ? peer->conf_if : peer->ifname, peer->bgp->vrf_id);
if (bgp_debug_neighbor_events(peer))
zlog_debug ("%s [Event] Connect start to %s fd %d",

View file

@ -1509,7 +1509,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp,
if (!ifindex)
{
if (mpinfo->peer->conf_if || mpinfo->peer->ifname)
ifindex = ifname2ifindex (mpinfo->peer->conf_if ? mpinfo->peer->conf_if : mpinfo->peer->ifname);
ifindex = ifname2ifindex (mpinfo->peer->conf_if ? mpinfo->peer->conf_if : mpinfo->peer->ifname, bgp->vrf_id);
else if (mpinfo->peer->nexthop.ifp)
ifindex = mpinfo->peer->nexthop.ifp->ifindex;
}

View file

@ -256,7 +256,7 @@ ifindex2ifname (ifindex_t ifindex, vrf_id_t vrf_id)
}
ifindex_t
ifname2ifindex_vrf (const char *name, vrf_id_t vrf_id)
ifname2ifindex (const char *name, vrf_id_t vrf_id)
{
struct interface *ifp;
@ -264,12 +264,6 @@ ifname2ifindex_vrf (const char *name, vrf_id_t vrf_id)
: IFINDEX_INTERNAL;
}
ifindex_t
ifname2ifindex (const char *name)
{
return ifname2ifindex_vrf (name, VRF_DEFAULT);
}
/* Interface existance check by interface name. */
struct interface *
if_lookup_by_name (const char *name, vrf_id_t vrf_id)

View file

@ -452,8 +452,7 @@ extern const char *ifindex2ifname (ifindex_t, vrf_id_t vrf_id);
/* Please use ifname2ifindex instead of if_nametoindex where possible;
ifname2ifindex uses internal interface info, whereas if_nametoindex must
make a system call. */
extern ifindex_t ifname2ifindex(const char *ifname);
extern ifindex_t ifname2ifindex_vrf(const char *ifname, vrf_id_t vrf_id);
extern ifindex_t ifname2ifindex(const char *ifname, vrf_id_t vrf_id);
/* Connected address functions. */
extern struct connected *connected_new (void);

View file

@ -189,7 +189,7 @@ route_match_interface (void *rule, struct prefix *prefix,
nh_data = object;
if (!nh_data || !nh_data->nexthop)
return RMAP_NOMATCH;
ifindex = ifname2ifindex_vrf (ifname, nh_data->vrf_id);
ifindex = ifname2ifindex (ifname, nh_data->vrf_id);
if (ifindex == 0)
return RMAP_NOMATCH;
if (nh_data->nexthop->ifindex == ifindex)