Skip to content

Commit 6a80370

Browse files
ip6: fix cleanup on ip6 address deletion
When adding a previously deleted interface, grout can't add a link local ip. ERR: GROUT: ip6_iface_event_handler: iface_addr_add: File exists (17) Instead of calling rib6_cleanup, call rib6_delete and nexthop_decref. Similarly, ip6 address deletion wasn't working properly as we couldn't re-add the same IP6 address. Apply a similar fix in addr6_del. Update tests accordingly. Signed-off-by: Christophe Fontaine <[email protected]>
1 parent 50aec94 commit 6a80370

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

modules/ip6/control/address.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,13 @@ static struct api_out addr6_del(const void *request, void ** /*response*/) {
213213
struct rte_ipv6_addr solicited_node;
214214
struct nexthop *nh = NULL;
215215
struct hoplist *addrs;
216+
struct iface *iface;
216217
unsigned i = 0;
217218

219+
iface = iface_from_id(req->addr.iface_id);
220+
if (iface == NULL)
221+
return api_out(errno, 0);
222+
218223
if ((addrs = addr6_get_all(req->addr.iface_id)) == NULL)
219224
return api_out(errno, 0);
220225

@@ -236,6 +241,8 @@ static struct api_out addr6_del(const void *request, void ** /*response*/) {
236241
return api_out(EBUSY, 0);
237242

238243
rib6_cleanup(nh);
244+
rib6_delete(iface->vrf_id, iface->id, &nh->ipv6, nh->prefixlen);
245+
nexthop_decref(nh);
239246

240247
// shift the remaining addresses
241248
gr_vec_del(addrs->nh, i);
@@ -299,7 +306,7 @@ static const struct rte_ipv6_addr well_known_mcast_addrs[] = {
299306
RTE_IPV6_ADDR_ALLROUTERS_SITE_LOCAL,
300307
};
301308

302-
static void ip6_iface_event_handler(uint32_t event, const void *obj) {
309+
static void ip6_iface_event_handler(iface_event_t event, const void *obj) {
303310
struct rte_ipv6_addr link_local, solicited_node;
304311
const struct iface *iface = obj;
305312
struct rte_ether_addr mac;
@@ -325,8 +332,11 @@ static void ip6_iface_event_handler(uint32_t event, const void *obj) {
325332
case IFACE_EVENT_PRE_REMOVE:
326333
struct hoplist *addrs = &iface_addrs[iface->id];
327334

328-
gr_vec_foreach (nh, addrs->nh)
329-
rib6_cleanup(nh);
335+
gr_vec_foreach (nh, addrs->nh) {
336+
rib6_delete(iface->vrf_id, iface->id, &nh->ipv6, nh->prefixlen);
337+
nexthop_decref(nh);
338+
}
339+
330340
gr_vec_free(addrs->nh);
331341

332342
addrs = &iface_mcast_addrs[iface->id];

smoke/ip6_add_del_test.sh

+4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
p0=${run_id}0
88

9+
grcli add interface port $p0 devargs net_tap0,iface=$p0 mac f0:0d:ac:dc:00:00
10+
grcli del interface $p0
911
grcli add interface port $p0 devargs net_tap0,iface=$p0 mac f0:0d:ac:dc:00:00
1012

1113
grcli add ip6 address 2001::1/64 iface $p0
1214
grcli show ip6 address
1315
grcli del ip6 address 2001::1/64 iface $p0
1416
grcli show ip6 address
17+
grcli add ip6 address 2001::1/64 iface $p0
18+
grcli show ip6 address

0 commit comments

Comments
 (0)