Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: tcp: When sending FIN, make sure it goes with ACK and proper seq #104

Merged
merged 1 commit into from
May 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion subsys/net/ip/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,19 @@ int net_tcp_prepare_segment(struct net_tcp *tcp, u8_t flags,

if (flags & NET_TCP_FIN) {
tcp->flags |= NET_TCP_FINAL_SENT;
seq++;
/* RFC793 says about ACK bit: "Once a connection is
* established this is always sent." as teardown
* happens when connection is established, it must
* have ACK set.
*/
flags |= NET_TCP_ACK;
/* FIXME: We apparently miss increment in another
* transition of the state machine, so have to
* adjust seq no by 2 here. This is required for
* Linux to detect active close on server side, and
* to make Wireshark happy about sequence numbers.
*/
seq += 2;

if (net_tcp_get_state(tcp) == NET_TCP_ESTABLISHED ||
net_tcp_get_state(tcp) == NET_TCP_SYN_RCVD) {
Expand Down