Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary network devices created #7791

Closed
1 of 2 tasks
shemminger opened this issue Dec 1, 2021 · 20 comments
Closed
1 of 2 tasks

Unnecessary network devices created #7791

shemminger opened this issue Dec 1, 2021 · 20 comments

Comments

@shemminger
Copy link

shemminger commented Dec 1, 2021

Version

Microsoft Windows [Version 10.0.22000.318]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.60.1-microsoft-standard-WSL2

Distro Version

Debian GNU/Linux 11 (bullseye)

Other Software

No response

Repro Steps

Tools that show list of network interfaces discover unwanted devices: bond0, dummy0, etc

This is an unwanted side effect caused by bonding, dummy, etc being built into the kernel rather being loadable modules.
A workaround would be to add parameters to those modules to not have them create default devices.

Expected Behavior

I would expect:

$ ip -br a
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0             UP             192.168.126.91/20 fe80::215:5dff:feee:2fe/64

Actual Behavior

What I see when doing network device commands is.

$ ip -br a
lo               UNKNOWN        127.0.0.1/8 ::1/128
bond0            DOWN
dummy0           DOWN
tunl0@NONE       DOWN
sit0@NONE        DOWN
eth0             UP             192.168.126.91/20 fe80::215:5dff:feee:2fe/64

Diagnostic Logs

No response

@zer0-memory
Copy link

zer0-memory commented Dec 3, 2021

This is an unwanted side effect caused by bonding, dummy, etc being built into the kernel rather being loadable modules.
A workaround would be to add parameters to those modules to not have them create default devices.

Do you know what settings I would have to change in the kernel to stop these from being created? I found the line in the config file to disable sit0, but I'm not sure about tunl0; I have to disable them as due to their abnormal MAC address length a program I'm using is getting a segfault since it tries reading their MAC address for license activation but tries reading beyond their length.

Also, if you know a way to permanently set the MAC address of eth0 please let me know, its not essential but it would save me the work of creating a virtual interface and setting its MAC address to the one linked to my license key every time.

@Biswa96
Copy link

Biswa96 commented Dec 3, 2021

Those network interfaces are enabled by default. Generally those do not interfere with eth0 or any network operations. If you want to remove those network interface you can use basic ip commands.

sudo ip link delete dummy0
sudo ip link delete bond0

Or you can disable creation of dummy0 by recompiling Linux kernel with CONFIG_DUMMY disabled.

It is possible to set a MAC address by creating a new virtual network and endpoint, detach the old one and attach the new one in WSL2.

@zer0-memory
Copy link

Those network interfaces are enabled by default. Generally those do not interfere with eth0 or any network operations. If you want to remove those network interface you can use basic ip commands.

sudo ip link delete dummy0
sudo ip link delete bond0

Or you can disable creation of dummy0 by recompiling Linux kernel with CONFIG_DUMMY disabled.

It is possible to set a MAC address by creating a new virtual network and endpoint, detach the old one and attach the new one in WSL2.

I'm only able to delete dummy0 and bond0 with ip link delete, I'm having a problem with sit0 and tunl0 though, they have the MAC address 00-00-00-00 which is an abnormal size as usually MAC addresses are in the form xx-xx-xx-xx-xx-xx; this is causing a segmentation fault on a program I'm trying to use.

Do you know which settings I would need to disable in the kernel to disable the sit0 and tunl0 interfaces?

@shemminger
Copy link
Author

shemminger commented Dec 3, 2021

The root cause is that WSL kernel is monolithic and does not use kernel modules.
Some of these drivers allow setting module parameters that might help. But these would have to go on kernel boot command line, not sure how to change that with WSL.
Examples:

  • bonding.max_bonds=0
  • dummy.numdummies=0
  • fb_tunnels=2

The first tells bonding not to make any devices by default. Second does same for dummy device.
The last does:

Controls if fallback tunnels (like tunl0, gre0, gretap0, erspan0,
sit0, ip6tnl0, ip6gre0) are automatically created. There are 3 possibilities
(a) value = 0; respective fallback tunnels are created when module is
loaded in every net namespaces (backward compatible behavior).
(b) value = 1; [kcmd value: initns] respective fallback tunnels are
created only in init net namespace and every other net namespace will
not have them.
(c) value = 2; [kcmd value: none] fallback tunnels are not created
when a module is loaded in any of the net namespace. Setting value to
"2" is pointless after boot if these modules are built-in, so there is
a kernel command-line option that can change this default. Please refer to
Documentation/admin-guide/kernel-parameters.txt for additional details.

@Biswa96
Copy link

Biswa96 commented Dec 3, 2021

Linux kernel command line options can be added in .wslconfig file. Create a .wslconfig file in %UserProfile% directory and add the lines like this

[wsl2]
kernelCommandLine = bonding.max_bonds=0 dummy.numdummies=0 fb_tunnels=2

Run wsl.exe --shutdown to forcefully shutdown WSL2 VM and re-run the Linux distribution in WSL2.

@zer0-memory
Copy link

zer0-memory commented Dec 5, 2021

Linux kernel command line options can be added in .wslconfig file. Create a .wslconfig file in %UserProfile% directory and add the lines like this

[wsl2]
kernelCommandLine = bonding.max_bonds=0 dummy.numdummies=0 fb_tunnels=2

Run wsl.exe --shutdown to forcefully shutdown WSL2 VM and re-run the Linux distribution in WSL2.

This removed the dummy0 and bond0 interfaces for me, but sit0 and tunl0 are still there. Are there any other settings that are needed to remove those?

@Biswa96
Copy link

Biswa96 commented Dec 5, 2021

but sit0 and tunl0 are still there.

Those do not have any MAC address.

it tries reading their MAC address for license activation but tries reading beyond their length.

Wait a second! It seems that the issue is with that software. Why does a software (or a spyware) scan all available network interfaces?

I'm having a problem with sit0 and tunl0 though, they have the MAC address 00-00-00-00

They don't have MAC address. Only bond0 and dummy0 have MAC address which are in valid format always.

@zer0-memory
Copy link

zer0-memory commented Dec 5, 2021

but sit0 and tunl0 are still there.

Those do not have any MAC address.

it tries reading their MAC address for license activation but tries reading beyond their length.

Wait a second! It seems that the issue is with that software. Why does a software (or a spyware) scan all available network interfaces?

I'm having a problem with sit0 and tunl0 though, they have the MAC address 00-00-00-00

They don't have MAC address. Only bond0 and dummy0 have MAC address which are in valid format always.

It reads them for licensing purposes; this is the last few lines of the strace output from the application:

ioctl(3, SIOCGIFHWADDR, {ifr_name="lo", ifr_hwaddr={sa_family=ARPHRD_LOOPBACK, sa_data=00:00:00:00:00:00}}) = 0
ioctl(3, SIOCGIFHWADDR, {ifr_name="eth0", ifr_hwaddr={sa_family=ARPHRD_ETHER, sa_data=00:15:5d:55:c2:20}}) = 0
ioctl(3, SIOCGIFHWADDR, {ifr_name="tunl0", ifr_hwaddr={sa_family=ARPHRD_TUNNEL, sa_data=00:00:00:00}}) = 0
ioctl(3, SIOCGIFHWADDR, {ifr_name="sit0", ifr_hwaddr={sa_family=ARPHRD_SIT, sa_data=00:00:00:00}}) = 0
read(4, "", 1024)                       = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xffffffffff600400} ---
+++ killed by SIGSEGV +++
Segmentation fault

Is there something I can change in the config-wsl file for the kernel to remove these interfaces? I tried turning off CONFIG_NET_IPIP and CONFIG_IPV6_SIT but I get errors while compiling the kernel with those settings.

@shemminger
Copy link
Author

This is workaround that worked for me

kernelCommandLine = bonding.max_bonds=0 dummy.numdummies=0 fb_tunnels=none

Any license code that reads list of available network devices is broken. There is no way to be sure network device MAC address is not changed or will be the same under a whole range of scenarios.

One could argue all DRM code is fundamentally flawed.

@benhillis
Copy link
Member

This is not an area I'm very experienced in, what would the implications be of setting max_bonds, numdummies, and fb_tunnels to zero / none? Would this break any existing workflow?

@shemminger
Copy link
Author

I doubt it would cause problems, these default devices are a legacy thing from early days of Linux (like 10+ yrs ago).
Earlier versions of WSL kernel did not appear to have this.

@benhillis
Copy link
Member

@shemminger - thanks for the context - I'll see if I can figure out why these got added.

@zer0-memory
Copy link

zer0-memory commented Dec 8, 2021

I

This is workaround that worked for me

kernelCommandLine = bonding.max_bonds=0 dummy.numdummies=0 fb_tunnels=none

Any license code that reads list of available network devices is broken. There is no way to be sure network device MAC address is not changed or will be the same under a whole range of scenarios.

One could argue all DRM code is fundamentally flawed.

I fixed my segfault, turned out that it wasn't caused by the extra network devices; I fixed it by adding "vsyscall=emulate" to my kernelCommandLine.

For keeping the same MAC address, I ran echo "ip link set dev dummy0 address <mac address here>" >> ~/.bashrc to set the MAC address of the dummy0 interface to the one linked to my license every time WSL starts.

@benhillis
Copy link
Member

@romarowski
Copy link

romarowski commented Apr 18, 2023

how would you go about recovering these extra networks if they suddenly disappeared?

@shemminger
Copy link
Author

These devices are not useful or used. Modern Linux distros handle device management using network manager or related infrastructure.

@romarowski
Copy link

ok, but I need bond0 to verify my MATLAB license,

@zer0-memory
Copy link

ok, but I need bond0 to verify my MATLAB license,

Same here

@shemminger
Copy link
Author

Then make a dummy bond device with command line or with /etc/network/interfaces.

@shareefj
Copy link

shareefj commented May 12, 2023

For others who have come here looking for a solution after their tools stop working, add the following to your .bashrc:

# Define the interface name and MAC address 
ifname=bond0
wantmac=<your_mac_here>

# Check if the interface already exists
ip link show $ifname |& grep -q ether 
if [[ $? == 1 ]]; then
    sudo ip link add $ifname type bond
fi

# Set the MAC address if it's different to what we want
mac=$(ip link show $ifname | awk '/ether/ {print $2}')
if [[ $mac != $wantmac ]]; then
    sudo ip link set dev $ifname address $wantmac
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants