]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6d: don't use if_lookup_by_index_all_vrf
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 14 Oct 2021 16:08:01 +0000 (19:08 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Thu, 28 Oct 2021 15:54:46 +0000 (18:54 +0300)
if_lookup_by_index_all_vrf doesn't work correctly with netns VRF backend
as the same index may be used in multiple netns simultaneously.

We always know the OSPF6 instance we work with, so use its VRF id for
the interface lookup.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
ospf6d/ospf6_route.c

index 4b87c4cf3089b44f612f81a6a00ecd50f1967d93..1b05b9d8addc2e5177dedcf0f8539360f022cc60 100644 (file)
@@ -1117,6 +1117,7 @@ void ospf6_route_show(struct vty *vty, struct ospf6_route *route,
        json_object *json_route = NULL;
        json_object *json_array_next_hops = NULL;
        json_object *json_next_hop;
+       vrf_id_t vrf_id = route->ospf6->vrf_id;
 
        monotime(&now);
        timersub(&now, &route->changed, &res);
@@ -1150,16 +1151,15 @@ void ospf6_route_show(struct vty *vty, struct ospf6_route *route,
        else
                i = 0;
        for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
-               struct interface *ifp;
                /* nexthop */
                inet_ntop(AF_INET6, &nh->address, nexthop, sizeof(nexthop));
-               ifp = if_lookup_by_index_all_vrf(nh->ifindex);
                if (use_json) {
                        json_next_hop = json_object_new_object();
                        json_object_string_add(json_next_hop, "nextHop",
                                               nexthop);
-                       json_object_string_add(json_next_hop, "interfaceName",
-                                              ifp->name);
+                       json_object_string_add(
+                               json_next_hop, "interfaceName",
+                               ifindex2ifname(nh->ifindex, vrf_id));
                        json_object_array_add(json_array_next_hops,
                                              json_next_hop);
                } else {
@@ -1171,12 +1171,14 @@ void ospf6_route_show(struct vty *vty, struct ospf6_route *route,
                                        OSPF6_PATH_TYPE_SUBSTR(
                                                route->path.type),
                                        destination, nexthop, IFNAMSIZ,
-                                       ifp->name, duration);
+                                       ifindex2ifname(nh->ifindex, vrf_id),
+                                       duration);
                                i++;
                        } else
                                vty_out(vty, "%c%1s %2s %-30s %-25s %6.*s %s\n",
                                        ' ', "", "", "", nexthop, IFNAMSIZ,
-                                       ifp->name, "");
+                                       ifindex2ifname(nh->ifindex, vrf_id),
+                                       "");
                }
        }
        if (use_json) {
@@ -1200,6 +1202,7 @@ void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route,
        json_object *json_route = NULL;
        json_object *json_array_next_hops = NULL;
        json_object *json_next_hop;
+       vrf_id_t vrf_id = route->ospf6->vrf_id;
 
        monotime(&now);
 
@@ -1350,8 +1353,6 @@ void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route,
                vty_out(vty, "Nexthop:\n");
 
        for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
-               struct interface *ifp;
-               ifp = if_lookup_by_index_all_vrf(nh->ifindex);
                /* nexthop */
                if (use_json) {
                        inet_ntop(AF_INET6, &nh->address, nexthop,
@@ -1359,13 +1360,14 @@ void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route,
                        json_next_hop = json_object_new_object();
                        json_object_string_add(json_next_hop, "nextHop",
                                               nexthop);
-                       json_object_string_add(json_next_hop, "interfaceName",
-                                              ifp->name);
+                       json_object_string_add(
+                               json_next_hop, "interfaceName",
+                               ifindex2ifname(nh->ifindex, vrf_id));
                        json_object_array_add(json_array_next_hops,
                                              json_next_hop);
                } else
                        vty_out(vty, "  %pI6 %.*s\n", &nh->address, IFNAMSIZ,
-                               ifp->name);
+                               ifindex2ifname(nh->ifindex, vrf_id));
        }
        if (use_json) {
                json_object_object_add(json_route, "nextHops",