Page MenuHomeFreeBSD

Enabling SO_LINGER to the so_reuseport_lb_test regression tests
ClosedPublic

Authored by olivier on Sep 24 2020, 10:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 23, 8:51 AM
Unknown Object (File)
Oct 8 2024, 10:01 AM
Unknown Object (File)
Oct 6 2024, 10:38 PM
Unknown Object (File)
Oct 5 2024, 10:32 AM
Unknown Object (File)
Oct 2 2024, 7:31 PM
Unknown Object (File)
Oct 2 2024, 4:31 PM
Unknown Object (File)
Oct 1 2024, 5:13 AM
Unknown Object (File)
Oct 1 2024, 1:40 AM

Details

Summary

The reuseport_lb_test regression test is consuming a lot of sockets, but once ended the system will kept all those sockets open waiting for the TIME_WAIT.
And if another tests, consuming a lot of sockets is started just after, this could reach the system limit and fail.

Test Plan

Running this regression test in a simple loop, like this example of shell script:

#!/bin/sh
i=1
cd /usr/tests
while true; do
  echo -n "Run: $i, "
  if /usr/tests/sys/netinet/so_reuseport_lb_test basic_ipv4 >/dev/null 2>&1; then
        echo -n ipv4 success,
  else
        echo failed
    exit
  fi
  if /usr/tests/sys/netinet/so_reuseport_lb_test basic_ipv6 >/dev/null 2>&1; then
    echo -n ipv6 success,
  else
    echo failed
    exit
  fi
  i=$((i + 1))
  echo connected sockets: $(sockstat -c | wc -l)
done

Before the patch, on a standard FreeBSD stack:

# sh burn.sh
Run: 1, ipv4 success,ipv6 success,socket open: 26525
Run: 2, ipv4 success,ipv6 success,socket open: 26525
Run: 3, ipv4 success,ipv6 success,socket open: 26525
Run: 4, ipv4 success,ipv6 success,socket open: 26525
Run: 5, ipv4 success,ipv6 success,socket open: 26525

And after applied this patch:

sh ./burn.sh
Run: 1, ipv4 success,ipv6 success,connected sockets: 29
Run: 2, ipv4 success,ipv6 success,connected sockets: 29
Run: 3, ipv4 success,ipv6 success,connected sockets: 29
Run: 4, ipv4 success,ipv6 success,connected sockets: 29

On our customized stack, this solve a problem:

# sh burn.sh
Run: 1, ipv4 success,ipv6 success,socket open: 26298
Run: 2, ipv4 success,ipv6 success,socket open: 50006
Run: 3, ipv4 success,ipv6 success,socket open: 77663
Run: 4, ipv4 success,ipv6 success,socket open: 105208
Run: 5, ipv4 success,ipv6 success,socket open: 132550
Run: 6, ipv4 success,ipv6 success,socket open: 159735
Run: 7, ipv4 success,ipv6 success,socket open: 186304
Run: 8, ipv4 success,ipv6 success,socket open: 212833
Run: 9, ipv4 success,ipv6 success,socket open: 239115
Run: 10, ipv4 success,[zone: tcp_inpcb] kern.ipc.maxsockets limit reached

After:

Run: 1, ipv4 success,ipv6 success,socket open: 7
Run: 2, ipv4 success,ipv6 success,socket open: 7
Run: 3, ipv4 success,ipv6 success,socket open: 7
Run: 4, ipv4 success,ipv6 success,socket open: 7
Run: 5, ipv4 success,ipv6 success,socket open: 7
Run: 6, ipv4 success,ipv6 success,socket open: 7
(...)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added inline comments.
tests/sys/netinet/so_reuseport_lb_test.c
57 ↗(On Diff #77498)

I'd declare this const.

This revision is now accepted and ready to land.Sep 25 2020, 1:20 PM

switching a variable to const.

This revision now requires review to proceed.Sep 25 2020, 3:49 PM
This revision was not accepted when it landed; it landed in state Needs Review.Sep 25 2020, 4:02 PM
This revision was automatically updated to reflect the committed changes.

The change is good from a technical standpoint, but some of the documentation could be a bit more polished.

head/tests/sys/netinet/so_reuseport_lb_test.c
78

Minor feedback: the one thing that might have made this message better is to use the constant name. “Setting linger” might be a bit confusing to the reader. Saying “Setting SO_LINGER on socket failed: %s” is more precise.

Also, a terse comment would have improved this for future readers trying to understand why setting SO_LINGER on the socket was so important.

head/tests/sys/netinet/so_reuseport_lb_test.c
78

yes, good idea: Could you do it ? (as non source committer, I will have to create a review to ask for approval, so lot's of work for such small changes).