diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-02-04 21:41:36 +1000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-02-25 00:17:41 +0100 |
| commit | a681e44ec60179567fb10f34351d7dfdbd2e7c7e (patch) | |
| tree | 1ee4ba580108509dc43157fcbfc762e94f767d86 | |
| parent | 1820103fbbf13df98257a3f5c3ba625de624b0b3 (diff) | |
| download | passt-a681e44ec60179567fb10f34351d7dfdbd2e7c7e.tar passt-a681e44ec60179567fb10f34351d7dfdbd2e7c7e.tar.gz passt-a681e44ec60179567fb10f34351d7dfdbd2e7c7e.tar.bz2 passt-a681e44ec60179567fb10f34351d7dfdbd2e7c7e.tar.lz passt-a681e44ec60179567fb10f34351d7dfdbd2e7c7e.tar.xz passt-a681e44ec60179567fb10f34351d7dfdbd2e7c7e.tar.zst passt-a681e44ec60179567fb10f34351d7dfdbd2e7c7e.zip | |
tcp: Extend tcp_send_flag() to send TCP keepalive segments
TCP keepalives aren't technically a flag, but they are a zero-data segment
so they can be generated with only a small modification to
tcp_{buf,vu}_send_flag(). Implement this, using a new "pseudo-flag"
value (similar to DUP_ACK), KEEPALIVE.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: Fix trivial merge conflict with 812cdb802c6e]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | tcp_buf.c | 4 | ||||
| -rw-r--r-- | tcp_internal.h | 2 | ||||
| -rw-r--r-- | tcp_vu.c | 3 |
3 files changed, 9 insertions, 0 deletions
@@ -229,6 +229,10 @@ int tcp_buf_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags) tcp_frame_conns[tcp_payload_used++] = conn; l4len = optlen + sizeof(struct tcphdr); iov[TCP_IOV_PAYLOAD].iov_len = l4len; + + if (flags & KEEPALIVE) + seq--; + tcp_l2_buf_fill_headers(c, conn, iov, NULL, seq, false); tcp_l2_buf_pad(iov); diff --git a/tcp_internal.h b/tcp_internal.h index 518913b..1d335be 100644 --- a/tcp_internal.h +++ b/tcp_internal.h @@ -38,6 +38,8 @@ /* Flags for internal usage */ #define DUP_ACK (1 << 5) +#define KEEPALIVE (1 << 6) + #define OPT_EOL 0 #define OPT_NOP 1 #define OPT_MSS 2 @@ -134,6 +134,9 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags) flags_elem[0].in_sg[0].iov_len = hdrlen + optlen; payload = IOV_TAIL(flags_elem[0].in_sg, 1, hdrlen); + if (flags & KEEPALIVE) + seq--; + tcp_fill_headers(c, conn, eh, ip4h, ip6h, th, &payload, NULL, seq, !*c->pcap); |
