I noticed that when setting DSCP/TOS on a server socket, it doesn't get inherited to socket from accept(). This is not stated anywhere in any RFCs as far as I know, but it is not consistent with how TCP sockets behaves. There might be other socket options that are affected. I have made a summary for DSCP/TOS at least: FreeBSD 12.2: IPv4 TCP: Not inherited IPv6 TCP: Inherited IPv4 SCTP: Not inherited IPv6 SCTP: Not inherited FreeBSD 13.0: IPv4 TCP: Inherited IPv6 TCP: Inherited IPv4 SCTP: Not inherited IPv6 SCTP: Not inherited Linux (lksctp): IPv4 TCP: Inherited IPv6 TCP: Inherited IPv4 SCTP: Not inherited IPv6 SCTP: Inherited Seems like this was changed for IPV4 TCP between FreeBSD 12.2 and 13.0. I cannot find any ticket for that, but I think that the same design choice could be considered for SCTP as well.
Created attachment 229794 [details] Test files for reproducing the issue 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 --ipv4 --sctp --test-dscp ./client --poll --ipv4 --sctp --test-dscp IPv6 as well as TCP can be tested as well to compare the behavior.
Created attachment 229795 [details] Pcaps for different DSCP/TOS scenarios
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d79676fb1368f5acac5fd182363ea3f46fb3bd93 commit d79676fb1368f5acac5fd182363ea3f46fb3bd93 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2021-12-03 21:40:52 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2021-12-03 21:44:01 +0000 sctp: inherit IP level socket options from listening socket Ensure that TTL and TOS values set on a listener get inheritet to the accepted sockets. PR: 260119 MFC after: 1 week sys/netinet/sctp_pcb.c | 9 +++++++++ 1 file changed, 9 insertions(+)
The issue should be fixed. Please note that setting the DSCP using the SCTP specific API as defined in https://datatracker.ietf.org/doc/html/rfc6458#section-8.1.12 by using the IPPROTO_SCTP level socket option SCTP_PEER_ADDR_PARAMS should work on all SCTP implementations. The interaction with IPPROTO_IP and IPPROTO_IPV6 level socket options is not well defined...
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=54912d47b629807cefaed5b65a8f4e6d9bbbdbcf commit 54912d47b629807cefaed5b65a8f4e6d9bbbdbcf Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2021-12-04 18:13:28 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2021-12-04 18:16:18 +0000 sctp: unbreak NOINET6 builds. PR: 260119 Reported by: kostikbel MFC after: 1 week sys/netinet/sctp_pcb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Created attachment 229925 [details] Pcaps for DSCP/TOS after fixes I have tested this with your fixes and it works great. Thank you for the help! I will check out the SCTP_PEER_ADDR_PARAMS socket option.
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=89bbc849888546bf8cd74c8356de70bc38cced8b commit 89bbc849888546bf8cd74c8356de70bc38cced8b Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2021-12-03 21:40:52 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2021-12-10 10:40:59 +0000 sctp: inherit IP level socket options from listening socket Ensure that TTL and TOS values set on a listener get inheritet to the accepted sockets. PR: 260119 MFC after: 1 week (cherry picked from commit d79676fb1368f5acac5fd182363ea3f46fb3bd93) sys/netinet/sctp_pcb.c | 9 +++++++++ 1 file changed, 9 insertions(+)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c5f3adcce3862cb800d64ae8fd332183ba6eb268 commit c5f3adcce3862cb800d64ae8fd332183ba6eb268 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2021-12-04 18:13:28 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2021-12-10 10:41:44 +0000 sctp: unbreak NOINET6 builds. PR: 260119 Reported by: kostikbel MFC after: 1 week (cherry picked from commit 54912d47b629807cefaed5b65a8f4e6d9bbbdbcf) sys/netinet/sctp_pcb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)