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

network: Many interfaces lead to "kernel receive buffer overrun" #14417

Closed
haslersn opened this issue Dec 22, 2019 · 22 comments · Fixed by #16982
Closed

network: Many interfaces lead to "kernel receive buffer overrun" #14417

haslersn opened this issue Dec 22, 2019 · 22 comments · Fixed by #16982

Comments

@haslersn
Copy link

systemd version the issue has been seen with
241, but the relevant code has not changed since.

Used distribution
Debian 10

Expected behaviour you didn't see
systemd-networkd.service should start successfully.

Unexpected behaviour you saw
With about 200 interfaces (100 VLANs and a bridge on each of them), when starting systemd-networkd I get the following error in the journal:

systemd-networkd[1831]: Could not enumerate addresses: No buffer space available

Running sudo SYSTEMD_LOG_LEVEL=debug /lib/systemd/systemd-networkd gives a bit more insight:

rtnl: kernel receive buffer overrun
Could not enumerate addresses: No buffer space available

The buffer that is overrun is probably this one somewhere inside this function.

Steps to reproduce the problem

  • Add 100 VLAN interfaces to one of your interfaces/bridges.
  • Add a bridge to each of those interfaces
  • sudo systemctl restart systemd-networkd
@yuwata yuwata added bug 🐛 Programming errors, that need preferential fixing network sd-netlink labels Dec 22, 2019
@yuwata
Copy link
Member

yuwata commented Dec 22, 2019

Could you give us a script or .netdev files to generate the interfaces to reproduce the issue?

@haslersn
Copy link
Author

haslersn commented Dec 22, 2019

Attached is a .tar file which I had to rename to .txt in order to upload it here.
systemd-network.txt

It is also weird that, using that configuration, starting systemd-networkd.service works on only one of our hypervisors and doesn't work on the other one, where I discovered the mentioned error.

Even more weird: Running sudo /lib/systemd/systemd-networkd gives the mentioned error on both of our hypervisors.

@yuwata
Copy link
Member

yuwata commented Dec 22, 2019

Hmm, I cannot reproduce the issue with your config. Also, I've tested with 2000 dummy device or 1000 veth interface, but they seem to work fine. Could you test the issue with v244?

@haslersn
Copy link
Author

Yes, maybe I can test with a newer version on NixOS or in a VM.

Did you only test via the service, or also by running /lib/systemd/systemd-networkd directly?

@ssahani
Copy link
Contributor

ssahani commented Dec 22, 2019

I think this a very complex situation. Rather than we try to reproduce it if you give us that would be more useful. And it should not restricted to one distribution.

@haslersn
Copy link
Author

haslersn commented Dec 22, 2019

I did not say anything against that. It was a question about your past test.

@ssahani
Copy link
Contributor

ssahani commented Dec 22, 2019

Surely not we just trying to get a reproducer so that we can help you solve your problem . Do you figure?

@yuwata yuwata added cant-reproduce needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer labels Dec 23, 2019
@poettering
Copy link
Member

i figure we should just set the socket buffer for the netlink socket ridiculously high, like udev does. Socket memory is nowadays properly accounted properly to the processes owning them, hence that's not even a bad idea.. If we do that, then the issue should not go away, but be very hard to reproduce

@yuwata yuwata removed cant-reproduce needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer labels Dec 23, 2019
@yuwata
Copy link
Member

yuwata commented Dec 23, 2019

@haslersn I guess a workaround for this issue is extending receive buffer size in systemd-networkd.socket, e.g. by creating the following drop-in file:

[Socket]
ReceiveBuffer=16M

@yuwata
Copy link
Member

yuwata commented Dec 23, 2019

It is also weird that, using that configuration, starting systemd-networkd.service works on only one of our hypervisors and doesn't work on the other one, where I discovered the mentioned error.

I guess one host enables systemd-networkd.socket, and the other one disables it.

Even more weird: Running sudo /lib/systemd/systemd-networkd gives the mentioned error on both of our hypervisors.

In that case, it is almost equivalent that .socket is disabled. So, it is reasonable.

@yuwata yuwata removed the bug 🐛 Programming errors, that need preferential fixing label Dec 23, 2019
@poettering
Copy link
Member

Bumping ReceiveBuffer= is something we definitely should do by default btw. The workaround @yuwata is not just a workaround, but part of the solution I think.

@haslersn
Copy link
Author

haslersn commented Dec 23, 2019

Starting systemd-networkd.socket solved the issue! Do you still want to bump the ReceiveBuffer=, or can this be closed?

yuwata added a commit to yuwata/systemd that referenced this issue Dec 26, 2019
yuwata added a commit to yuwata/systemd that referenced this issue Dec 28, 2019
poettering pushed a commit that referenced this issue Jan 2, 2020
@yuwata yuwata closed this as completed Jan 3, 2020
@andir
Copy link
Contributor

andir commented May 15, 2020

I don't think this has been fixed (entirely). I am running into a very similar case with 200 VLAN interfaces. This is on v245.5 on both NixOS and Fedora 33 (fedora systemctl --version gives v245.5-2.fc33).

On the first start (during system bootup) I am observing timeouts and assertions: https://gist.githubusercontent.com/andir/616f937189d176da86dbe7aa0f65217e/raw/918c9926f66c5788d9de2795dee5200331daf8c5/l (as mentioned in #15669 (comment))

Manually restarting networkd (systemctl restart systemd-networkd) after bootup leads to networkd just exiting with code 1 and the same logged error as originally posted in this issue:

router # [  652.004288] systemd-networkd[1074]: rtnl: kernel receive buffer overrun
router # [  652.005020] systemd-networkd[1074]: Could not enumerate addresses: No buffer space available

Increased buffer size further (1024MB) didn't change that behavior.

The networkd config files that I used are here: https://gist.github.com/andir/7963aa3edcd5b834224515f826f10579 You might have to change the 00-vlans.network file to match whatever hardlink there already is in your test setups.

@andir
Copy link
Contributor

andir commented May 22, 2020

@yuwata This should probable be re-opened as the initial problem isn't gone but only worked around by activating the systemd-networkd.socket unit. I am also not entirely sure the fix introduced in #14434 actually does help at all. From my limited understanding we are running out of buffer space on the kernel side and increasing our receive buffer will probably not help there.

@andir
Copy link
Contributor

andir commented May 28, 2020

I spent a bit more time on this and this bug is indeed partially fixed by the increase of buffer size. At least the rtnl: kernel received buffer overrun messages go away if you set an appropriate value (512MB did it for me) for ReceiveBuffer= in systemd-networkd.socket and obviously also enable that unit.

@yuwata yuwata reopened this May 29, 2020
yuwata added a commit to yuwata/systemd that referenced this issue Sep 8, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.
yuwata added a commit to yuwata/systemd that referenced this issue Sep 8, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.
yuwata added a commit to yuwata/systemd that referenced this issue Sep 8, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.
yuwata added a commit to yuwata/systemd that referenced this issue Sep 8, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.
peckato1 pushed a commit to peckato1/systemd that referenced this issue Oct 1, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.

(cherry picked from commit b92f350)
ssahani pushed a commit to ssahani/systemd that referenced this issue Oct 5, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.
ssahani pushed a commit to ssahani/systemd that referenced this issue Oct 5, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.
@tconrado
Copy link

tconrado commented Nov 3, 2020

by a mistake, instead creating the adapter and moving to its namespace, we created 195 adapters on the host + 3 others that provide the connectivity and we started to get systemd-networkd[2296549]: Could not enumerate addresses: No buffer space available; raising the property ReceiveBuffer=1024M did not help. On the other hand, using namespaces, we can confirm that the system was stable even with 2500 namespaces while all of those had at least 1 IPv6 and some with IPv4. So maybe, this is a "suitable" strategy to deal with multiple IPs (netns)

@haslersn
Copy link
Author

haslersn commented Nov 3, 2020

2500 namespaces while all of those had at least 1 IPv6 and some with IPv4. So maybe, this is a "suitable" strategy

Not really, as long as systemd-networkd doesn't support configuring network namespaces.

@andir
Copy link
Contributor

andir commented Nov 3, 2020

by a mistake, instead creating the adapter and moving to its namespace, we created 195 adapters on the host + 3 others that provide the connectivity and we started to get systemd-networkd[2296549]: Could not enumerate addresses: No buffer space available; raising the property ReceiveBuffer=1024M did not help. On the other hand, using namespaces, we can confirm that the system was stable even with 2500 namespaces while all of those had at least 1 IPv6 and some with IPv4. So maybe, this is a "suitable" strategy to deal with multiple IPs (netns)

@tconrado What version of systemd was this with? IIRC the latest release(s) have somewhat mitigated the issue.

vbatts pushed a commit to kinvolk/systemd that referenced this issue Nov 12, 2020
…ger than the kernel limit

The commit 10ce2e0 inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.

This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.

Hopefully fixes systemd#14417.

(cherry picked from commit b92f350)
(cherry picked from commit 4dcae66)
@DanielWeeber
Copy link

Same problem here with one "real" interface and some docker interfaces. ReceiveBuffer=512M did not help

@apalacheno
Copy link

I just stumbled across this issue on Ubuntu 20.04 using Ubuntu's Netplan.io in version 0.102-0ubuntu1~20.04.2. Systemd is at version 245 (245.4-4ubuntu3.6).

I was unable to create more than 21 bridged VLANs. Trying to create more bridged VLANs resulted in symptoms as described above.

Enabling and activating systemd-networkd.socket seems to mitigate this issue. Initial testing suggests that this solution also survives restarts.

@ImmoWetzel
Copy link

I also think this should be rewritten or reopened. I had same issues on several up2date machines last week.

@yuwata
Copy link
Member

yuwata commented Aug 30, 2021

@ImmoWetzel and others, if you still have the issue with recent systemd (currently, v248, v249, or newer), then please open a new issue with debugging logs of networkd and your relevant configs (.network, .netdev, and so on).

Also, please try to increase ReceiveBuffer=128M in systemd-networkd.socket.

database64128 added a commit to database64128/ksmbd-tools that referenced this issue Sep 4, 2022
This commit fixes the intermittent `Recv() error Out of memory [-5]`
crashes of worker process by raising the netlink socket's receive
buffer size to 1 MiB.

A netlink socket's default receive buffer size is 208 KiB (taken from
net.core.rmem_default). When incoming messages fill up the receive
buffer, the recvmsg(2) call returns -ENOBUFS, which is then translated
to the Out of memory error above by libnl.

Both NetworkManager and systemd-networkd raise their netlink socket's
buffer size to work around the same issue. More details on
systemd-networkd's decision can be found at
systemd/systemd#14417 and
systemd/systemd#14434.

Fixes cifsd-team#235.

Signed-off-by: database64128 <free122448@hotmail.com>
database64128 added a commit to database64128/ksmbd-tools that referenced this issue Sep 4, 2022
This commit fixes the intermittent `Recv() error Out of memory [-5]`
crashes of worker process by raising the netlink socket's receive
buffer size to 1 MiB.

A netlink socket's default receive buffer size is 208 KiB (taken from
net.core.rmem_default). When incoming messages fill up the receive
buffer, the recvmsg(2) call returns -ENOBUFS, which is then translated
to the Out of memory error above by libnl.

Both NetworkManager and systemd-networkd raise their netlink socket's
buffer size to work around the same issue. More details on
systemd-networkd's decision can be found at
systemd/systemd#14417 and
systemd/systemd#14434.

Fixes cifsd-team#235.

Signed-off-by: database64128 <free122448@hotmail.com>
database64128 added a commit to database64128/ksmbd-tools that referenced this issue Sep 4, 2022
This commit fixes the intermittent `Recv() error Out of memory [-5]`
crashes of worker process by raising the netlink socket's receive
buffer size to 1 MiB.

A netlink socket's default receive buffer size is 208 KiB (taken from
net.core.rmem_default). When incoming messages fill up the receive
buffer, the recvmsg(2) call returns -ENOBUFS, which is then translated
to the Out of memory error above by libnl.

Both NetworkManager and systemd-networkd raise their netlink socket's
buffer size to work around the same issue. More details on
systemd-networkd's decision can be found at
systemd/systemd#14417 and
systemd/systemd#14434.

Fixes cifsd-team#235.

Signed-off-by: database64128 <free122448@hotmail.com>
namjaejeon pushed a commit to namjaejeon/ksmbd-tools that referenced this issue Sep 7, 2022
This commit fixes the intermittent `Recv() error Out of memory [-5]`
crashes of worker process by raising the netlink socket's receive
buffer size to 1 MiB.

A netlink socket's default receive buffer size is 208 KiB (taken from
net.core.rmem_default). When incoming messages fill up the receive
buffer, the recvmsg(2) call returns -ENOBUFS, which is then translated
to the Out of memory error above by libnl.

Both NetworkManager and systemd-networkd raise their netlink socket's
buffer size to work around the same issue. More details on
systemd-networkd's decision can be found at
systemd/systemd#14417 and
systemd/systemd#14434.

Fixes cifsd-team#235.

Signed-off-by: database64128 <free122448@hotmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon pushed a commit to cifsd-team/ksmbd-tools that referenced this issue Sep 7, 2022
This commit fixes the intermittent `Recv() error Out of memory [-5]`
crashes of worker process by raising the netlink socket's receive
buffer size to 1 MiB.

A netlink socket's default receive buffer size is 208 KiB (taken from
net.core.rmem_default). When incoming messages fill up the receive
buffer, the recvmsg(2) call returns -ENOBUFS, which is then translated
to the Out of memory error above by libnl.

Both NetworkManager and systemd-networkd raise their netlink socket's
buffer size to work around the same issue. More details on
systemd-networkd's decision can be found at
systemd/systemd#14417 and
systemd/systemd#14434.

Fixes #235.

Signed-off-by: database64128 <free122448@hotmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon pushed a commit to namjaejeon/ksmbd-tools that referenced this issue Sep 8, 2022
This commit fixes the intermittent `Recv() error Out of memory [-5]`
crashes of worker process by raising the netlink socket's receive
buffer size to 1 MiB.

A netlink socket's default receive buffer size is 208 KiB (taken from
net.core.rmem_default). When incoming messages fill up the receive
buffer, the recvmsg(2) call returns -ENOBUFS, which is then translated
to the Out of memory error above by libnl.

Both NetworkManager and systemd-networkd raise their netlink socket's
buffer size to work around the same issue. More details on
systemd-networkd's decision can be found at
systemd/systemd#14417 and
systemd/systemd#14434.

Fixes cifsd-team#235.

Signed-off-by: database64128 <free122448@hotmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon pushed a commit to cifsd-team/ksmbd-tools that referenced this issue Sep 8, 2022
This commit fixes the intermittent `Recv() error Out of memory [-5]`
crashes of worker process by raising the netlink socket's receive
buffer size to 1 MiB.

A netlink socket's default receive buffer size is 208 KiB (taken from
net.core.rmem_default). When incoming messages fill up the receive
buffer, the recvmsg(2) call returns -ENOBUFS, which is then translated
to the Out of memory error above by libnl.

Both NetworkManager and systemd-networkd raise their netlink socket's
buffer size to work around the same issue. More details on
systemd-networkd's decision can be found at
systemd/systemd#14417 and
systemd/systemd#14434.

Fixes #235.

Signed-off-by: database64128 <free122448@hotmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

9 participants