Skip to content

Commit

Permalink
ip6: avoid duplicate nh entry with overlapping prefix routes
Browse files Browse the repository at this point in the history
Similar to ip4 fix, do not create unconditionnaly a new nexthop. Reuse
an existing one if any.
If the NH is associated with an existing route, makes sure that
the interface id is properly populated.

Signed-off-by: Christophe Fontaine <[email protected]>
  • Loading branch information
christophefontaine committed Oct 31, 2024
1 parent 20ff41b commit 07123c0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/ip6/datapath/ip6_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,18 @@ ip6_output_process(struct rte_graph *graph, struct rte_node *node, void **objs,
// We currently do not have an explicit entry for this destination IP.
// Create a new next hop and its associated /128 route so that next
// packets take it in priority with a single route lookup.
struct nexthop6 *remote = ip6_nexthop_new(
nh->vrf_id, nh->iface_id, &ip->dst_addr
);
struct nexthop6 *remote = ip6_nexthop_lookup(nh->vrf_id, &ip->dst_addr);
if (remote == NULL)
remote = ip6_nexthop_new(nh->vrf_id, nh->iface_id, &ip->dst_addr);
else if (remote->flags & GR_IP6_NH_F_GATEWAY && remote->iface_id == 0)
remote->iface_id = nh->iface_id;

if (remote == NULL) {
edge = ERROR;
goto next;
}

assert(remote->iface_id == nh->iface_id);
if (ip6_route_insert(nh->vrf_id, &ip->dst_addr, RTE_IPV6_MAX_DEPTH, remote)
< 0) {
edge = ERROR;
Expand Down

0 comments on commit 07123c0

Please sign in to comment.