diff options
| -rw-r--r-- | tcp.c | 29 |
1 files changed, 7 insertions, 22 deletions
@@ -2393,37 +2393,22 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, if (th->syn && !th->ack && !th->fin) return packet_next(p, idx) - idx; - if (!(conn->events & TAP_SYN_ACK_SENT)) + if (!(conn->events & TAP_SYN_ACK_SENT) || !th->ack) goto reset; conn_event(c, conn, ESTABLISHED, now); if (tcp_set_peek_offset(conn, 0, now)) goto reset; - if (th->fin) { - conn->seq_from_tap++; - - if (shutdown(conn->sock, SHUT_WR) < 0) { - flow_warn_perror_ratelimit(conn, now, - "shutdown() failed"); - goto reset; - } - - if (tcp_send_flag(c, conn, ACK, now)) - goto reset; - - conn_event(c, conn, SOCK_FIN_SENT, now); - - return packet_next(p, idx) - idx; - } - - if (!th->ack) - goto reset; - if (tcp_tap_window_update(c, conn, ntohs(th->window), now)) tcp_data_from_sock(c, conn, now); - if (packet_next(p, idx) == p->count) + /* Pure ACK completing the handshake, and nothing else to + * process: otherwise, data and FIN, even if they're out of + * order, are handled by tcp_data_from_tap() below + */ + if (packet_next(p, idx) == p->count && !th->fin && + !tcp_packet_data_len(th, l4len)) return packet_next(p, idx) - idx; } |
