Bug 215793 - ip netns del is asynchronous??? -- very unexpected and puzzling
Summary: ip netns del is asynchronous??? -- very unexpected and puzzling
Status: NEW
Alias: None
Product: Networking
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-02 12:14 UTC by Roman Mamedov
Modified: 2022-04-02 12:14 UTC (History)
0 users

See Also:
Kernel Version: 5.10.106
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Roman Mamedov 2022-04-02 12:14:36 UTC
Hello,

I have a script like this:

  ip netns del test-ns
  ip netns add test-ns
  ip link add tun-test type gre local any remote 8.8.8.8
  ip link set tun-test netns test-ns

As is, the script will fail exactly every other time:

---------------
# ./nstest.sh 
RTNETLINK answers: File exists
Cannot find device "tun-test"

# ./nstest.sh 

# ./nstest.sh 
RTNETLINK answers: File exists
Cannot find device "tun-test"

# ./nstest.sh 

# ./nstest.sh 
RTNETLINK answers: File exists
Cannot find device "tun-test"

# ./nstest.sh 

# ./nstest.sh 
RTNETLINK answers: File exists
Cannot find device "tun-test"

# ./nstest.sh 

# ./nstest.sh 
RTNETLINK answers: File exists
Cannot find device "tun-test"

# ./nstest.sh 

# ./nstest.sh 
RTNETLINK answers: File exists
Cannot find device "tun-test"

---------------
That's because "ip netns del" seems to return without actually finishing to fully delete the NS. Adding a "sleep 1" after the first line, makes the script complete successfully every time. This is a very unexpected behavior. I would ask for a better workaround than "sleep 1", but I believe there should be no workaround, and the script should reliably work as posted.

Hope you can consider changing this.

Thanks!

Note You need to log in before you can comment on or make changes to this bug.