veth: delete device before creation to handle stale state
authorFelix Fietkau <[email protected]>
Mon, 20 Oct 2025 17:43:14 +0000 (19:43 +0200)
committerFelix Fietkau <[email protected]>
Mon, 20 Oct 2025 17:44:20 +0000 (19:44 +0200)
When a veth device already exists in the kernel (from a previous failed
cleanup or external creation), attempting to create it again with
NLM_F_EXCL fails with -EEXIST. This leaves the device in a broken state
where netifd marks it as present but cannot bring it up.

Signed-off-by: Felix Fietkau <[email protected]>
veth.c

diff --git a/veth.c b/veth.c
index 46b6eff646a70f4b306f5e0aa1246b5e50eb8b40..2f034563e94f2af600d95f5a32d73a4ab88eee84 100644 (file)
--- a/veth.c
+++ b/veth.c
@@ -68,6 +68,8 @@ veth_set_up(struct veth *veth)
 {
        int ret;
 
+       system_veth_del(&veth->dev);
+
        ret = system_veth_add(&veth->dev, &veth->config);
        if (ret < 0)
                return ret;