One patch at a time, this is one of the few steps to re-factor these super
long TCP functions.
The eventual goal is to extract the mass of tcp loss recovery logic out of
tcp_do_segment().
Differential D47130
tcp: remove the `goto drop` label by reusing equivalences in tcp_do_segment(). cc on Tue, Oct 15, 5:07 PM. Authored by Tags None Referenced Files
Details
Diff Detail
Event TimelineComment Actions While I agree that "goto" statements are not nice, and hard to follow - there is something to be said about the overhead of a function preamble, stack use and cleanup. I would suggest to make this an "__inline" function.
Comment Actions We discussed this change (and supposedly following up changes) on the TCP call 2024-10-17. @cc , @rscheff , @tuexen , @thj and Peter Lei participated. First, more context needs to pulled for those who did not participate in the call. There is overall dissatisfaction with how long tcp_do_segment() is, and especially with level of indentation in some of its parts. There is also a concern with use of goto. Cheng plans to improve the function and this review is just the first step. Second, let's categorize problems with tcp_do_segment() into roughly three parts:
This review addresses one of the gotos in #3. I don't agree that use of goto should be an absolute taboo in the computer programming. The fear & hate towards goto is based on use of goto inside or outside a cycle and on a goto that jumps backwards. Using a goto to a cleanup epilogue is a standard solution used everywhere in the FreeBSD kernel, userland and endless list of other projects with overall good code quality. Now I would argue that isolating function cleanup epilogue into a separate function doesn't improve readability. A reader still needs scrolling to check where resources are freed, just needs to scroll in a different direction. The new function is supposed to be called only by tcp_do_segment() and must be followed by return (or a tail call may be used). But this is not enforced by the compiler in any way! This leads to at least two problems with future code development and maintenance:
|