mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 11:02:33 +00:00
ospf6d, bgpd: avoid calling if_nametoindex
As the comments in if.h, it is better to call ifname2ifindex() instead of if_nametoindex(). And ifname2ifindex() can work for VRF by appending a parameter while if_nametoindex() can not. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 395828eea809e8b2b8c5824d3639cefedd7aa9f0)
This commit is contained in:
parent
35d921cc20
commit
322e59645d
@ -619,7 +619,7 @@ bgp_connect (struct peer *peer)
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (peer->conf_if || peer->ifname)
|
||||
ifindex = if_nametoindex (peer->conf_if ? peer->conf_if : peer->ifname);
|
||||
ifindex = ifname2ifindex (peer->conf_if ? peer->conf_if : peer->ifname);
|
||||
#endif /* HAVE_IPV6 */
|
||||
|
||||
if (bgp_debug_neighbor_events(peer))
|
||||
|
@ -1038,7 +1038,7 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote,
|
||||
if (IN6_IS_ADDR_LINKLOCAL (&local->sin6.sin6_addr))
|
||||
{
|
||||
if (peer->conf_if || peer->ifname)
|
||||
ifp = if_lookup_by_index_vrf (if_nametoindex (peer->conf_if ? peer->conf_if : peer->ifname), peer->bgp->vrf_id);
|
||||
ifp = if_lookup_by_name_vrf (peer->conf_if ? peer->conf_if : peer->ifname, peer->bgp->vrf_id);
|
||||
}
|
||||
else if (peer->update_if)
|
||||
ifp = if_lookup_by_name_vrf (peer->update_if, peer->bgp->vrf_id);
|
||||
@ -1513,7 +1513,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 = if_nametoindex (mpinfo->peer->conf_if ? mpinfo->peer->conf_if : mpinfo->peer->ifname);
|
||||
ifindex = ifname2ifindex (mpinfo->peer->conf_if ? mpinfo->peer->conf_if : mpinfo->peer->ifname);
|
||||
else if (mpinfo->peer->nexthop.ifp)
|
||||
ifindex = mpinfo->peer->nexthop.ifp->ifindex;
|
||||
}
|
||||
@ -1705,7 +1705,7 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
|
||||
struct zapi_ipv6 api;
|
||||
|
||||
assert (info->attr->extra);
|
||||
|
||||
|
||||
api.vrf_id = peer->bgp->vrf_id;
|
||||
api.flags = flags;
|
||||
api.type = ZEBRA_ROUTE_BGP;
|
||||
|
@ -347,10 +347,9 @@ ospf6_route_zebra_copy_nexthops (struct ospf6_route *route,
|
||||
{
|
||||
if (IS_OSPF6_DEBUG_ZEBRA (SEND))
|
||||
{
|
||||
char ifname[IFNAMSIZ];
|
||||
const char *ifname;
|
||||
inet_ntop (AF_INET6, &nh->address, buf, sizeof (buf));
|
||||
if (!if_indextoname(nh->ifindex, ifname))
|
||||
strlcpy(ifname, "unknown", sizeof(ifname));
|
||||
ifname = ifindex2ifname (nh->ifindex);
|
||||
zlog_debug (" nexthop: %s%%%.*s(%d)", buf, IFNAMSIZ, ifname,
|
||||
nh->ifindex);
|
||||
}
|
||||
@ -1015,7 +1014,8 @@ ospf6_route_show (struct vty *vty, struct ospf6_route *route)
|
||||
{
|
||||
int i;
|
||||
char destination[PREFIX2STR_BUFFER], nexthop[64];
|
||||
char duration[16], ifname[IFNAMSIZ];
|
||||
char duration[16];
|
||||
const char *ifname;
|
||||
struct timeval now, res;
|
||||
struct listnode *node;
|
||||
struct ospf6_nexthop *nh;
|
||||
@ -1034,15 +1034,13 @@ ospf6_route_show (struct vty *vty, struct ospf6_route *route)
|
||||
else
|
||||
prefix2str (&route->prefix, destination, sizeof (destination));
|
||||
|
||||
|
||||
i = 0;
|
||||
for (ALL_LIST_ELEMENTS_RO (route->nh_list, node, nh))
|
||||
{
|
||||
/* nexthop */
|
||||
inet_ntop (AF_INET6, &nh->address, nexthop,
|
||||
sizeof (nexthop));
|
||||
if (! if_indextoname (nh->ifindex, ifname))
|
||||
snprintf (ifname, sizeof (ifname), "%d", nh->ifindex);
|
||||
ifname = ifindex2ifname (nh->ifindex);
|
||||
|
||||
if (!i)
|
||||
{
|
||||
@ -1062,7 +1060,8 @@ ospf6_route_show (struct vty *vty, struct ospf6_route *route)
|
||||
void
|
||||
ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route)
|
||||
{
|
||||
char destination[PREFIX2STR_BUFFER], nexthop[64], ifname[IFNAMSIZ];
|
||||
const char *ifname;
|
||||
char destination[PREFIX2STR_BUFFER], nexthop[64];
|
||||
char area_id[16], id[16], adv_router[16], capa[16], options[16];
|
||||
struct timeval now, res;
|
||||
char duration[16];
|
||||
@ -1147,8 +1146,7 @@ ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route)
|
||||
{
|
||||
/* nexthop */
|
||||
inet_ntop (AF_INET6, &nh->address, nexthop, sizeof (nexthop));
|
||||
if (! if_indextoname (nh->ifindex, ifname))
|
||||
snprintf (ifname, sizeof (ifname), "%d", nh->ifindex);
|
||||
ifname = ifindex2ifname (nh->ifindex);
|
||||
vty_out (vty, " %s %.*s%s", nexthop, IFNAMSIZ, ifname, VNL);
|
||||
}
|
||||
vty_out (vty, "%s", VNL);
|
||||
|
Loading…
Reference in New Issue
Block a user