Skip to content

Commit

Permalink
ip: homogenize nexthop suppression
Browse files Browse the repository at this point in the history
Similar to ipv6 nexthop suppression, check the NH flags to delete
either with embedded prefix len or the max prefix len (/32).

Update test to ensure we can add/del/add the same address.

Signed-off-by: Christophe Fontaine <[email protected]>
  • Loading branch information
christophefontaine authored and rjarry committed Mar 5, 2025
1 parent fa0f89c commit 075a96e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/ip/control/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,14 @@ void rib4_cleanup(struct nexthop *nh) {
uintptr_t nh_id;
ip4_addr_t ip;

rib4_delete(nh->vrf_id, nh->ipv4, 32);
local_ip = nh->ipv4;
local_prefixlen = nh->prefixlen;

if (nh->flags & (GR_NH_F_LOCAL | GR_NH_F_LINK))
rib4_delete(nh->vrf_id, nh->ipv4, nh->prefixlen);
else
rib4_delete(nh->vrf_id, nh->ipv4, 32);

rib = get_rib(nh->vrf_id);
while ((rn = rte_rib_get_nxt(rib, 0, 0, rn, RTE_RIB_GET_NXT_ALL)) != NULL) {
rte_rib_get_nh(rn, &nh_id);
Expand Down
2 changes: 2 additions & 0 deletions smoke/ip_add_del_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ grcli add ip address 172.16.0.1/24 iface $p0
grcli show ip address
grcli del ip address 172.16.0.1/24 iface $p0
grcli show ip address
grcli add ip address 172.16.0.1/24 iface $p0
grcli show ip address

0 comments on commit 075a96e

Please sign in to comment.