aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-21 01:19:27 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-21 01:19:27 +0200
commit849308d20716f40452e70a230f3a403ee88b207d (patch)
tree178d07059fb5a95c1d8c9cf923be4dd532fa274d
parenta20626fb3516169c8c06bd1729cf29465d2cbd1f (diff)
downloadpasst-849308d20716f40452e70a230f3a403ee88b207d.tar
passt-849308d20716f40452e70a230f3a403ee88b207d.tar.gz
passt-849308d20716f40452e70a230f3a403ee88b207d.tar.bz2
passt-849308d20716f40452e70a230f3a403ee88b207d.tar.lz
passt-849308d20716f40452e70a230f3a403ee88b207d.tar.xz
passt-849308d20716f40452e70a230f3a403ee88b207d.tar.zst
passt-849308d20716f40452e70a230f3a403ee88b207d.zip
Makefile, tcp: Don't try to use tcpi_snd_wnd from tcp_info on pre-5.3 kernels
Detect missing tcpi_snd_wnd in struct tcp_info at build time, otherwise build fails with a pre-5.3 linux/tcp.h header. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--Makefile5
-rw-r--r--tcp.c9
-rw-r--r--tcp.h2
3 files changed, 15 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 85d7400..83140ad 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,11 @@ endif
endif
endif
+C := \#include <linux/tcp.h>\nstruct tcp_info x = { .tcpi_snd_wnd = 0 };
+ifeq ($(shell printf "$(C)" | $(CC) -S -xc - -o - >/dev/null 2>&1; echo $$?),0)
+ CFLAGS += -DHAS_SND_WND
+endif
+
prefix ?= /usr/local
all: passt pasta passt4netns qrap
diff --git a/tcp.c b/tcp.c
index 6b5d29b..813d2ed 100644
--- a/tcp.c
+++ b/tcp.c
@@ -359,6 +359,11 @@
sizeof(struct ipv6hdr) - sizeof(struct tcphdr))
#define WINDOW_DEFAULT 14600 /* RFC 6928 */
+#ifdef HAS_SND_WND
+# define KERNEL_REPORTS_SND_WND(c) (c->tcp.kernel_snd_wnd)
+#else
+# define KERNEL_REPORTS_SND_WND(c) (0 && (c))
+#endif
#define SYN_TIMEOUT 240000 /* ms */
#define ACK_TIMEOUT 2000
@@ -1563,7 +1568,7 @@ static int tcp_update_seqack_wnd(struct ctx *c, struct tcp_tap_conn *conn,
conn->seq_ack_to_tap = prev_ack_to_tap;
}
- if (!c->tcp.kernel_snd_wnd) {
+ if (!KERNEL_REPORTS_SND_WND(c)) {
tcp_get_sndbuf(conn);
conn->wnd_to_tap = MIN(conn->snd_buf, MAX_WINDOW);
goto out;
@@ -1675,8 +1680,10 @@ static int tcp_send_to_tap(struct ctx *c, struct tcp_tap_conn *conn, int flags,
data += OPT_MSS_LEN - 2;
th->doff += OPT_MSS_LEN / 4;
+#ifdef HAS_SND_WND
if (!c->tcp.kernel_snd_wnd && info.tcpi_snd_wnd)
c->tcp.kernel_snd_wnd = 1;
+#endif
conn->ws = MIN(MAX_WS, info.tcpi_snd_wscale);
diff --git a/tcp.h b/tcp.h
index bfd6082..dc854b8 100644
--- a/tcp.h
+++ b/tcp.h
@@ -67,7 +67,9 @@ struct tcp_ctx {
uint8_t port_to_init [USHRT_MAX / 8];
int ns_detect_ports;
struct timespec timer_run;
+#ifdef HAS_SND_WND
int kernel_snd_wnd;
+#endif
size_t pipe_size;
struct timespec refill_ts;
struct timespec port_detect_ts;