Page MenuHomeFreeBSD

Enabling SO_LINGER to the so_reuseport_lb_test regression tests
ClosedPublic

Authored by olivier on Thu, Sep 24, 10:19 PM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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.Fri, Sep 25, 1:20 PM

switching a variable to const.

This revision now requires review to proceed.Fri, Sep 25, 3:49 PM
This revision was not accepted when it landed; it landed in state Needs Review.Fri, Sep 25, 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).