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

Fixes for socket buffer size #16982

Merged
merged 10 commits into from Sep 9, 2020
Merged

Conversation

yuwata
Copy link
Member

@yuwata yuwata commented Sep 8, 2020

Hopefully fixes #14417.
Hopefully fixes #16865.

src/basic/socket-util.c Show resolved Hide resolved
r = setsockopt_int(fd, SOL_SOCKET, SO_RCVBUFFORCE, n);
if (r < 0)
return r;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


return 0;
return fd_inc_rcvbuf(m->sock, size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, hmm, is this right? fd_inc_recvbuf() only increases the socket buffer, while the pre-existing code might also lower it if the caller asks for it. Is this an intentional change? I guess in most cases this is called to increase the buffer, but do we want to encode that it can only be used for that?

}
r = fd_inc_rcvbuf(fd, s->receive_buffer);
if (r < 0)
log_unit_warning_errno(UNIT(s), r, "SO_RCVBUF/SO_RCVBUFFORCE failed: %m");
Copy link
Member

@poettering poettering Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, previous code could also lower buffer size, new code only increases.

@yuwata
Copy link
Member Author

yuwata commented Sep 8, 2020

@poettering Thank you for your review. Updated. I hope all comments are addressed. PTAL.

@keszybz I think it is worth to backport this to some stable branches.

@poettering poettering added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label 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.
If networkd creates huge amount of netdevs, then the buffer of device
monitor becomes easily flowed.

Hopefully fixes systemd#16865.
@poettering poettering merged commit 39c4e2c into systemd:master Sep 9, 2020
@yuwata yuwata deleted the socket-buffer-size branch September 9, 2020 16:02
@andir
Copy link
Contributor

andir commented Sep 10, 2020

Is there a chance this could be included in a stable systemd release or do you think this is too big of a change for the current stable version?

@keszybz keszybz removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Sep 10, 2020
@yuwata
Copy link
Member Author

yuwata commented Sep 10, 2020

Note. If this will be backported to a stable repository, then please do not forget to include 4934ba2.

yuwata added a commit to yuwata/systemd that referenced this pull request Sep 11, 2020
The issue seems already fixed by PR systemd#16982 and its follow-up commit
4934ba2.
keszybz pushed a commit that referenced this pull request Sep 11, 2020
The issue seems already fixed by PR #16982 and its follow-up commit
4934ba2.
@keszybz
Copy link
Member

keszybz commented Sep 11, 2020

This will be included in systemd-246.5.

peckato1 pushed a commit to peckato1/systemd that referenced this pull request Oct 1, 2020
The issue seems already fixed by PR systemd#16982 and its follow-up commit
4934ba2.

(cherry picked from commit 766f8f3)
ssahani pushed a commit to ssahani/systemd that referenced this pull request Oct 5, 2020
The issue seems already fixed by PR systemd#16982 and its follow-up commit
4934ba2.
ssahani pushed a commit to ssahani/systemd that referenced this pull request Oct 5, 2020
The issue seems already fixed by PR systemd#16982 and its follow-up commit
4934ba2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

several vlans stuck in pending network: Many interfaces lead to "kernel receive buffer overrun"
4 participants