Skip to content

Commit d8f21a5

Browse files
committed
ip,ip6: allow deleting routes with directly connected nexthops
Previously, attempting to delete a route whose nexthop is directly connected (i.e., not a gateway) would fail with -EBUSY. For example: add ip address 6.6.7.7/24 iface p4 add ip route 83.0.0.0/24 via 6.6.7.7 del ip route 83.0.0.0/24 error: command failed: Device or resource busy This behavior stems from route4/6_del, which checks whether the nexthop is a gateway before allowing deletion. If not, it assumes the nexthop is still in use and blocks the operation. However, there is no functional reason to prevent deletion in this case. The underlying rib4/6_del logic ensures that a nexthop is only fully removed when its reference count drops to zero—preserving it as long as it's still needed by a connected route. Signed-off-by: Maxime Leroy <[email protected]>
1 parent 7fd2c04 commit d8f21a5

File tree

2 files changed

+0
-6
lines changed

2 files changed

+0
-6
lines changed

modules/ip/control/route.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ static struct api_out route4_del(const void *request, void ** /*response*/) {
250250
return api_out(ENOENT, 0);
251251
}
252252

253-
if (!(nh->flags & GR_NH_F_GATEWAY))
254-
return api_out(EBUSY, 0);
255-
256253
if (rib4_delete(req->vrf_id, req->dest.ip, req->dest.prefixlen) < 0)
257254
return api_out(errno, 0);
258255

modules/ip6/control/route.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ static struct api_out route6_del(const void *request, void ** /*response*/) {
276276
return api_out(ENOENT, 0);
277277
}
278278

279-
if (!(nh->flags & GR_NH_F_GATEWAY))
280-
return api_out(EBUSY, 0);
281-
282279
if (rib6_delete(req->vrf_id, nh->iface_id, &req->dest.ip, req->dest.prefixlen) < 0)
283280
return api_out(errno, 0);
284281

0 commit comments

Comments
 (0)