tcp: Remove 'zero_len' goto from tcp_data_from_sock

This goto exists purely to move this exception case out of line.  Although
that does make the "normal" path a little clearer, it comes at the cost of
not knowing how where control will flow after jumping to the zero_len
label.  The exceptional case isn't that long, so just put it inline.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2023-02-16 16:43:11 +11:00 committed by Stefano Brivio
parent 83b2061ae7
commit 89e0fbfaa7

26
tcp.c
View file

@ -2193,8 +2193,18 @@ static int tcp_data_from_sock(struct ctx *c, struct tcp_tap_conn *conn)
if (len < 0) if (len < 0)
goto err; goto err;
if (!len) if (!len) {
goto zero_len; if ((conn->events & (SOCK_FIN_RCVD | TAP_FIN_SENT)) == SOCK_FIN_RCVD) {
if ((ret = tcp_send_flag(c, conn, FIN | ACK))) {
tcp_rst(c, conn);
return ret;
}
conn_event(c, conn, TAP_FIN_SENT);
}
return 0;
}
sendlen = len - already_sent; sendlen = len - already_sent;
if (sendlen <= 0) { if (sendlen <= 0) {
@ -2233,18 +2243,6 @@ err:
} }
return ret; return ret;
zero_len:
if ((conn->events & (SOCK_FIN_RCVD | TAP_FIN_SENT)) == SOCK_FIN_RCVD) {
if ((ret = tcp_send_flag(c, conn, FIN | ACK))) {
tcp_rst(c, conn);
return ret;
}
conn_event(c, conn, TAP_FIN_SENT);
}
return 0;
} }
/** /**