Skip to content

Conversation

shrek-wang
Copy link
Contributor

@shrek-wang shrek-wang commented May 13, 2025

The NULL-pkt parameter for tcp_in() was designed for generating a SYN packet to start the 1st TCP handshake. It is only used in net_tcp_connect() and tp_input().
To simplify the tcp_in() code logic and make it better under- standable, a tcp_start_handshake() is added for net_tcp_connect() and tp_input() to use. Thus, the tcp_in() only handles the in- coming TCP packets.

ret = tcp_out_ext(conn, FIN | ACK, NULL,
conn->seq + conn->unacked_len);
if (ret == 0) {
conn_seq(conn, + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those kind of changes necessary? It just blurs the diff. At the very least they should be in a separate commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this change is not related with this PR. That was because I saw some check failures when I run the check_compliance.py to my patch, and then I modified all similar issues throughout the tcp.c.
I will remove this line of change. Thanks, @rlubos.

* FIN & ACK -> TCP_TIME_WAIT
*/
if (th) {
do {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wrapping this code in a dummy do { } while (0) loop? I think we should be consistent and just reduce the indentation everywhere, let's do it once and for good.

return 0;
}

static int tcp_start_handshaking(struct tcp *conn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, but I'd call it tcp_start_handshake(), present form.

@shrek-wang
Copy link
Contributor Author

Thanks, @rlubos. I will update the code accordingly.

@shrek-wang
Copy link
Contributor Author

@jukkar, the twister check failures look confusing - not much like related with this PR changes? Could you please help taking a look? Thanks!

@rlubos
Copy link
Contributor

rlubos commented May 14, 2025

@jukkar, the twister check failures look confusing - not much like related with this PR changes? Could you please help taking a look? Thanks!

Those failures seem to be inherited from main and are being taken care of already: #89928

Copy link
Contributor

@rlubos rlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nits, looks good otherwise.

tcp_out(conn, SYN | ACK);
conn->send_options.mss_found = false;
conn_seq(conn, + 1);
conn_seq(conn, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's similar to #89862 (comment), same in other places below.

}
}
break;
} break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break; should be in a separate line according to CS I think.

case TCP_TIME_WAIT:
if (th) {
int32_t new_len = tcp_compute_new_length(conn, th, len, true);
} break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}
}
break;
} break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@shrek-wang
Copy link
Contributor Author

@rlubos , it's a bit weird that I always got compliance-check failure if keeping the '+ 1'. I tried multiple times and finally succeeded after removing the '+'.
And, the local compliance-check also failed if I put 'break' in another line. It suggests to stay same line with '}'.
I just don't know whether or not the online CI will have similar strict check.
I can do the update base on your suggestion and force push tomorrow.
Thanks

The NULL-pkt parameter for tcp_in() was designed for generating
a SYN packet to start the 1st TCP handshake. It is only used
in net_tcp_connect() and tp_input().
To simplify the tcp_in() code logic and make it better under-
standable, a tcp_start_handshake() is added for net_tcp_connect()
and tp_input() to use. Thus, the tcp_in() only handles the in-
coming TCP packets.

Signed-off-by: Shrek Wang <[email protected]>
Copy link

@kartben kartben merged commit 6ee55e4 into zephyrproject-rtos:main May 15, 2025
27 checks passed
@shrek-wang shrek-wang deleted the tcp_polish branch May 16, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants