Page MenuHomeFreeBSD

tcp: add support for TCP_RST_REASON_CODE socket option
Needs ReviewPublic

Authored by tuexen on Tue, Feb 17, 10:05 PM.
Tags
None
Referenced Files
F145909386: D55338.id172698.diff
Thu, Feb 26, 1:37 AM
F145891155: D55338.diff
Wed, Feb 25, 7:07 PM
F145868996: D55338.id172215.diff
Wed, Feb 25, 11:26 AM
F145867866: D55338.id172367.diff
Wed, Feb 25, 11:01 AM
F145865705: D55338.id172367.diff
Wed, Feb 25, 10:13 AM
F145863830: D55338.id172368.diff
Wed, Feb 25, 9:30 AM
F145851299: D55338.id172215.diff
Wed, Feb 25, 6:01 AM
F145851267: D55338.id172215.diff
Wed, Feb 25, 6:01 AM

Details

Reviewers
glebius
gnn
rrs
Group Reviewers
transport
Summary

This code is based on revision 15 of draft-boucadair-tcpm-rst-diagnostic-payload.
Right now, only the IPPROTO_TCP-level socket option with name TCP_RST_REASON_CODE is implemented.
It is planned to implement also the socket option with name TCP_RST_REASON_CODE, but it is NOT planned to implement the socket option with name TCP_RST_REASON_DESC.

Test Plan
  • Use {F145514417} and {F145514426} in combination with {F145514432}.
  • Extend packetdrill to support these socket options and write tests.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This revision is now accepted and ready to land.Wed, Feb 18, 2:22 PM

This is work in progress. There will be some more changes.

This is work in progress. There will be some more changes.

Thats fine.. nice to see the IETF catching TCP up to SCTP's abort codes :)

Allow socket option processing on inps with the INP_DROPPED flag set only for getsockopt() of the IPPROTO_TCP-level socket option with name TCP_RST_REASON_CODE, as glebius suggested.

This revision now requires review to proceed.Wed, Feb 18, 3:07 PM

Fix sender side stats counter and teach netstat how to print the stats counters added in this patch.

Fix TCP over UDP tunneling.

Improve inputs validation for UDP encapsulated TCP segments.

Update names of structure and provide a way that setsocktion SO_LINGER is not required anymore.

sys/netinet/tcp_output.c
1336

Let's use char * cast here.

sys/netinet/tcp_var.h
484–487

tcpcb is a mix of members prefixed with t_ and non-prefixed. Neither is great, imho. May be using a meaningful prefix for new members that are dedicated for a certain facility is going to be better? For these new I can suggest:

/* draft-rst-reason/RFCXXXX support */
uint16_t trr_snd_code;          /* Reason code to be sent in RST */
uint16_t trr_rcv_code;          /* Reason code received in RST */
uint32_t trr_snd_pen;           /* PEN to be sent in RST */
uint32_t trr_rcv_pen;           /* PEN received in RST */

Just suggesting, not insisting at all.

Use names for members in struct tcpcb as suggested by glebius.

tuexen edited the summary of this revision. (Show Details)
tuexen added inline comments.
sys/netinet/tcp_output.c
1336

Let's use char * cast here.

Willing to do that, but I have chosen caddr_t since it is used in line 1181, 1166 and other places in the file. I wanted to be consistent.
If you think using char * in a non-consistent way is better, I will change that.

sys/netinet/tcp_var.h
484–487

Done. I like that. Thanks for suggesting.

sys/netinet/tcp_output.c
207

IMHO, would be better to declare *dp in the only small block of code, where it is used. The top level declarations are no longer dictated by the style(9), thanks. Same suggestion applies to rack_output().

sys/netinet/tcp_output.c
1336

caddr_t is a pre-C89 type invented for the lack of void * [1]. We should avoid it in any new code resorting only when there is a documented prototype, that we should match, e.g. ioctl handlers.

In this particular case we want to achieve pointer arithmetic where pointed type is sized by one byte. This doesn't even match original purpose of caddr_t. Any reader of the code without historical context will be puzzled to read this line and won't be able to answer right away the question of "how much do we actually add here with + optlen?". Contrary, with (char *) cast any reader coming from Linux, Windows or any other world will right away read the line of code and understand what it does.

[1] In the past I had always had a hard time proving the point. Now, thanks to LLM it is easier. Took LLM 2 minutes to come up with the summary and all links: https://grok.com/share/c2hhcmQtMg_de591786-ba8b-4215-a4a3-d665de24d727