Page MenuHomeFreeBSD

ktls: enumify tcp_tls_mode magic numbers
AbandonedPublic

Authored by rscheff on Mar 1 2024, 1:45 PM.
Tags
None
Referenced Files
F83123209: D44165.diff
Mon, May 6, 3:13 PM
Unknown Object (File)
Sun, Apr 14, 5:45 PM
Unknown Object (File)
Mon, Apr 8, 10:43 PM
Unknown Object (File)
Mar 4 2024, 2:57 AM
Unknown Object (File)
Mar 2 2024, 2:54 AM

Details

Reviewers
cc
jhb
emaste
tuexen
Group Reviewers
transport
Summary

In order to allow stricter type checking,
convert KTLS related magic numbers to enum.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 56363
Build 53251: arc lint + arc unit

Event Timeline

The ktls draws my attention. Hope you add reviewers.

sys/sys/ktls.h
153

This extra empty line is not necessary.

223

This extra empty line is not necessary.

rscheff marked an inline comment as done.

whitespace fix 2

tuexen added inline comments.
sys/sys/ktls.h
151

Why do you move the definition from tcp.h to ktls.h? At least the names sound to be TCP specific.

rscheff added inline comments.
sys/sys/ktls.h
151

To minimize header churn; many drivers don't actually use tcp.h (and use the universally availabe int) prior to enum. But all drivers with tls offload to use ktls.h.

with the typedef in tcp.h, ktls.h would also have to come past tcp.h.

overall this was more of a test case, if the -Wswitch for clang would properly catch missing default / incomplete enum conditions in switch statements throughout the tree (and it worked, my clang caught the missing default in uipc_ktls.c.

I used the phabricator to get this patch from my local machine to the beefy build vm I allocated the other day.

But then again, I think using enums more broadly, and thus allowing the compiler to type-check and verify style(9) would have a few benefits...

Note that the mode is tcp.h because it is a user-facing API (you can use it with setsockopt/getsockopt) and needs to stay in tcp.h

sys/kern/uipc_ktls.c
1941

This should be __assert_unreachable(). It is not a reachable case (and a false positive from the compiler warning).

sys/netinet/tcp_usrreq.c
2663

I'm not a super fan of the cast and assuming that the enum aliases to an int. I would rather have a local variable in this function of the right type that is assigned to optval before the call to sooptcopyout.

rscheff marked an inline comment as done.

Discussed transport