[Bug 260116] [sctp] POLLOUT/EVFILT_WRITE is always true for poll/kqueue

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 24 Jan 2022 11:31:14 UTC

--- Comment #2 from Björn Svensson <bjorn.a.svensson@est.tech> ---
After some investigations we have seen that the introduction of
"sendfile(2) system call' required some changes in the struct sockbuf.
The field sb_cc was split into sb_ccc and sb_acc in commit: 0f9d0a73a495

For SCTP a macro was introduced to handle this change via commit: 4e88d37a2a73

The change of using sb_ccc instead of sb_cc unfortunately seemed to trigger
problems with SCTP sockets and select() so it was changed to use sb_acc instead
via commit: 975c975bf0f1

The problem we now see is that when POLLOUT/EVFILT_WRITE are handled in
sopoll_generic() and filt_sowrite() they call sbspace():


but sbspace() still uses sb->sb_ccc when calculating the space.


This results in that the socket always seems writeable even when the sendbuffer
is full.

Some ideas to solve this would be to:

- Change sbspace() to use sb_acc when sb_ccc is zero.
  * This might be a bit hacky
  * This might affect other users of the function.

- Update both sb_acc and sb_ccc in SCTP
  Since SCTP already updates sb_acc to fit into the framework we can 
  double book the value to sb_ccc as well. The sb_acc field should be the
  owner of the information, but when changed it's copied to sb_ccc.
  * This only affects the SCTP code

Any thoughts or other ideas?

I will create a patchset for updating both sb_ccc and sb_acc and test this

You are receiving this mail because:
You are the assignee for the bug.