Skip to content

Commit 075a96e

Browse files
christophefontainerjarry
authored andcommitted
ip: homogenize nexthop suppression
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]>
1 parent fa0f89c commit 075a96e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

modules/ip/control/route.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,14 @@ void rib4_cleanup(struct nexthop *nh) {
350350
uintptr_t nh_id;
351351
ip4_addr_t ip;
352352

353-
rib4_delete(nh->vrf_id, nh->ipv4, 32);
354353
local_ip = nh->ipv4;
355354
local_prefixlen = nh->prefixlen;
356355

356+
if (nh->flags & (GR_NH_F_LOCAL | GR_NH_F_LINK))
357+
rib4_delete(nh->vrf_id, nh->ipv4, nh->prefixlen);
358+
else
359+
rib4_delete(nh->vrf_id, nh->ipv4, 32);
360+
357361
rib = get_rib(nh->vrf_id);
358362
while ((rn = rte_rib_get_nxt(rib, 0, 0, rn, RTE_RIB_GET_NXT_ALL)) != NULL) {
359363
rte_rib_get_nh(rn, &nh_id);

smoke/ip_add_del_test.sh

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ grcli add ip address 172.16.0.1/24 iface $p0
1212
grcli show ip address
1313
grcli del ip address 172.16.0.1/24 iface $p0
1414
grcli show ip address
15+
grcli add ip address 172.16.0.1/24 iface $p0
16+
grcli show ip address

0 commit comments

Comments
 (0)