Bug 260120 - [sctp] DSCP/TOS not always set during an association establishment (IPv6)
Summary: [sctp] DSCP/TOS not always set during an association establishment (IPv6)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Michael Tuexen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-29 14:56 UTC by Albin
Modified: 2021-12-10 10:47 UTC (History)
2 users (show)

See Also:
tuexen: mfc-stable13+


Attachments
Pcaps for different DSCP/TOS scenarios (6.96 KB, application/x-zip-compressed)
2021-11-29 14:56 UTC, Albin
no flags Details
Test files for reproducing the bug (4.31 KB, application/x-zip-compressed)
2021-11-29 14:58 UTC, Albin
no flags Details
Pcaps for DSCP/TOS after fixes (2.51 KB, application/x-zip-compressed)
2021-12-05 12:12 UTC, Albin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Albin 2021-11-29 14:56:41 UTC
Created attachment 229796 [details]
Pcaps for different DSCP/TOS scenarios

It seems like the DSCP/TOS field isn't getting set for INIT_ACK (but is for COOKIE_ACK) when establishing an SCTP association (IPv6). This works for IPv4 however.

I have made a summary here:
FreeBSD 12.2:
IPv4 TCP:  Working
IPv6 TCP:  Not working
IPv4 SCTP: Working
IPv6 SCTP: Not working

FreeBSD 13.0:
IPv4 TCP:  Working
IPv6 TCP:  Working
IPv4 SCTP: Working
IPv6 SCTP: Not working

Linux:
IPv4 TCP:  Working
IPv6 TCP:  Working
IPv4 SCTP: Working
IPv6 SCTP: Working

I haven't tested this for the FIN/SHUTDOWN phase.
Comment 1 Albin 2021-11-29 14:58:35 UTC
Created attachment 229797 [details]
Test files for reproducing the bug

I added some tests if it helps. They can be compiled using:
g++ -o client client.cpp utils.cpp
g++ -o server server.cpp utils.cpp

I have tested it in VMs with the SCTP module enabled. I have also added alias addresses to the loopback interface so that I could run both the server and client over the loopback interface.

These alias addresess were added:
127.0.0.2
127.0.0.3
127.0.0.4
127.0.0.5
127.0.0.6
127.0.0.7
::2
::3
::4
::5
::6
::7

The test can be started using:
./server --poll --ipv6 --sctp --test-dscp
./client --poll --ipv6 --sctp --test-dscp

IPv4 as well as TCP can be tested as well to compare the behavior.
Comment 2 commit-hook freebsd_committer 2021-12-03 20:37:50 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f32357be53d07622603049f9855be2d66ca6dc2b

commit f32357be53d07622603049f9855be2d66ca6dc2b
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2021-12-03 20:28:47 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2021-12-03 20:36:44 +0000

    sctp: use the correct traffic class when sending SCTP/IPv6 packets

    When sending packets the stcb was used to access the inp and then
    access the endpoint specific IPv6 level options. This fails when
    there exists an inp, but no stcb yet. This is the case for sending
    an INIT-ACK in response to an INIT when no association already
    exists. Fix this by just providing the inp instead of the stcb.

    PR:             260120
    MFC after:      1 week

 sys/netinet/sctp_os_bsd.h | 42 ++++++++++++++++++++++--------------------
 sys/netinet/sctp_output.c |  4 ++--
 2 files changed, 24 insertions(+), 22 deletions(-)
Comment 3 Albin 2021-12-05 12:12:48 UTC
Created attachment 229924 [details]
Pcaps for DSCP/TOS after fixes

I have tested this with your fixes and it works great. Thank you for the help!
Comment 4 commit-hook freebsd_committer 2021-12-10 10:41:21 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7a49fc843975cecb87ed36a33a85efdf12912089

commit 7a49fc843975cecb87ed36a33a85efdf12912089
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2021-12-03 20:28:47 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2021-12-10 10:39:44 +0000

    sctp: use the correct traffic class when sending SCTP/IPv6 packets

    When sending packets the stcb was used to access the inp and then
    access the endpoint specific IPv6 level options. This fails when
    there exists an inp, but no stcb yet. This is the case for sending
    an INIT-ACK in response to an INIT when no association already
    exists. Fix this by just providing the inp instead of the stcb.

    PR:             260120
    MFC after:      1 week

    (cherry picked from commit f32357be53d07622603049f9855be2d66ca6dc2b)

 sys/netinet/sctp_os_bsd.h | 42 ++++++++++++++++++++++--------------------
 sys/netinet/sctp_output.c |  4 ++--
 2 files changed, 24 insertions(+), 22 deletions(-)