From 128c2be2a1b1592e4641b79d897c8ceebc0e8bf5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 11 Mar 2017 07:52:59 -0500 Subject: [PATCH] bgpd, lib, zebra: Refactor ifname2ifindex to be VRF aware Signed-off-by: Donald Sharp --- bgpd/bgp_network.c | 2 +- bgpd/bgp_zebra.c | 2 +- lib/if.c | 8 +------- lib/if.h | 3 +-- zebra/zebra_routemap.c | 2 +- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index b85dcf6c4..46ae882b2 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -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", diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 32ad87cb7..64c20f318 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -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; } diff --git a/lib/if.c b/lib/if.c index f4f7ad774..6dbadb868 100644 --- a/lib/if.c +++ b/lib/if.c @@ -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) diff --git a/lib/if.h b/lib/if.h index bee783d93..7d88a9edf 100644 --- a/lib/if.h +++ b/lib/if.h @@ -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); diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 6b81f66a2..847da5295 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -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) -- 2.39.5