Refactor register_tcp_functions_as_names() such that either all or no (in error cases) registrations happen atomically (while holding the tcp_function_lock write lock). Also ensure that the TCP function block is not already registered.
This avoids situations, where some registrations were performed and then they were just removed without holding a lock in between or checking ref counts.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/netinet/tcp_subr.c | ||
---|---|---|
1188 | This E2BIG returns a new error, please update and specify it in section ERRORS of the man page of TCP_FUNCTIONS(9). | |
1203 | This is critical. It will not free f[0]. Shall be: while (--i >= 0) | |
sys/netinet/tcp_var.h | ||
647 | Glancing through TCP_FUNCTIONS(9) and manually counting the number of functions in struct tcp_function_block (which is 19 if my eyes don't cheat), why pick this number 16? Or this is a readability problem to me that TCP_FUNCTION_NAME_NUM_MAX shall be TCP_FUNCTION_BLOCK_NAME_NUM_MAX , per the usage. That means you can't register more than 16 TCP stacks (TCP function blocks)? Then, again why pick this number 16? If it is the readability problem, I suggest update the comment as well, something like: |
sys/netinet/tcp_subr.c | ||
---|---|---|
1188 | Done. | |
1203 | Fixed. Thanks for catching. | |
sys/netinet/tcp_var.h | ||
647 | A TCP function block has one name and is registered using a number of names or aliases. TCP_FUNCTION_NAME_NUM_MAX is the maximum number of times each TCP function block an be registered under different names. |
Over all looks good to me. Thanks for the update.
sys/netinet/tcp_var.h | ||
---|---|---|
647 | I understand. Thanks for the clarity. First, it was confusing to me that I was thinking something else like these function pointer names inside the struct tcp_function_block at the first glance, given the word use in the comment. That's why I guessed it's a readability problem to me and I recommended the comment update. Something like below, with the emphasis on word register:
Second, I took some time to think about this magic number 16 per the discussion in our group meeting.
So I would like to recommend this magic number to 8. |
sys/netinet/tcp_var.h | ||
---|---|---|
647 | I reduced the constant to 8 and improved the comment describing this constant. |