luigirizzo / netmap

Automatically exported from code.google.com/p/netmap
BSD 2-Clause "Simplified" License
1.84k stars 534 forks source link

Unable to detach ports from VALE switch #882

Open sergio-gimenez opened 1 year ago

sergio-gimenez commented 1 year ago

vale-ctl fails detaching ports that are not created with vale-ctl -n.

I tried with generic driver and veth driver and both fails the same way:

failed to detach vale6c7:veth939: No such device or address

However, if the interface is previously created with vale -n vi0; vale -a vale0:vi0 then it can be detached as expected.

I'm using latest master

Is this a bug or am I missing something?

giuseppelettieri commented 1 year ago

Definitely a bug. May you please try with the updated master?

sergio-gimenez commented 1 year ago

Yes, I repeated the experiment and now works. I will give it more tries with my application, but for now seems to work fine.

I close the issue and reopen it if something fails.

Thanks

jcaplan commented 1 year ago

We're in the process of rebasing our QNX stack against FreeBSD 13.2. For utils/tests/002_exclusive_open_persistent_vale_port_test I'm seeing a failure that seems related to this issue.

# functional -o
# vale-ctl -n v0
# vale-ctl -a vale0:v0
# functional -vvv -i vale0:v0/x                     # name is updated here since na->nm_register == netmap_vp_reg
# 
# 
# functional -c
# vale-ctl
v0 bridge_idx 0 port_idx 0                           # updated name shown here
# vale-ctl -d vale0:v0
failed to detach vale0:v0: No such device or address         # netmap_get_bdg_na is still looking for the old name
# vale-ctl -d v0       
failed to detach v0: Invalid argument
# vale-ctl -r v0
failed to remove v0: Resource busy

So once the name is changed to v0, then vale-ctl -d vale0:v0 is failing, and I can't remove the v0 persistent interface because there is a dangling reference as I'm short a netmap_adapter_put.

jcaplan commented 1 year ago

I confirmed FreeBSD has the same problem:

/usr/home/jcaplan/netmap/utils /usr/home/jcaplan/netmap/utils
>>> Running tests using functional
>>> Running test #1: "tests/001_exclusive_open_ephemeral_vale_port_test"
>>> Test #1 PASSED
>>> Running test #2: "tests/002_exclusive_open_persistent_vale_port_test"
>>> Test #2 PASSED
>>> Running test #3: "tests/003_exclusive_open_pipe_test"
>>> Test #3 PASSED
>>> Running test #4: "tests/004_extra_buf_send_rec_ephemeral_vale_ports_test"
tests/004_extra_buf_send_rec_ephemeral_vale_ports_test: receive-59 vale0:v1 FAIL(1 != 0).
>>> Test #4 FAILED
root@freebsd:/usr/home/jcaplan/netmap/utils # ifconfig v0
v0: flags=8801<UP,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80000<LINKSTATE>
        ether 00:be:d2:27:04:00
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@freebsd:/usr/home/jcaplan/netmap/utils # vale-ctl -d v0
failed to detach v0: Invalid argument
root@freebsd:/usr/home/jcaplan/netmap/utils # vale-ctl -r v0
failed to remove v0: Device busy
giuseppelettieri commented 1 year ago

May you please try the following?

diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c
index e5f6e1f14..72def843b 100644
--- a/sys/dev/netmap/netmap.c
+++ b/sys/dev/netmap/netmap.c
@@ -763,7 +763,7 @@ netmap_update_config(struct netmap_adapter *na)
 {
        struct nm_config_info info;

-       if (na->ifp && !nm_is_bwrap(na)) {
+       if (na->ifp && !na->na_vp) {
                strlcpy(na->name, if_name(na->ifp), sizeof(na->name));
        }