From cbe4bc48b8c0ef51598d9b843c9f29b39e80d94f Mon Sep 17 00:00:00 2001
From: Andreas Gnau <andreas.gnau@iopsys.eu>
Date: Mon, 21 Dec 2020 12:22:52 +0100
Subject: [PATCH] include: uapi: Add hack for BCM multi-path TCP

Broadcom's kernel conditionally adds additional enum constants
TCP_RST_WAIT and BPF_TCP_RST_WAIT. TCP_* and BPF_TCP_* enums have to be
in sync which is checked by a static assert during build. The enums are
guarded by an ifdef depending on a config option in Broadcom's kernel.

Broadcom option BUILD_MPTCP, which controls the corresponding kernel
option, is unconditionally enabled for all profiles, so we can enable
the ifdef unconditionally as a workaround.

Signed-off-by: Andreas Gnau <andreas.gnau@iopsys.eu>
---
 include/net/tcp_states.h       | 6 +++++-
 include/uapi/linux/bpf.h       | 6 +++++-
 tools/include/uapi/linux/bpf.h | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/net/tcp_states.h b/include/net/tcp_states.h
index 81357aa885..68e500f8e6 100644
--- a/include/net/tcp_states.h
+++ b/include/net/tcp_states.h
@@ -26,7 +26,11 @@ enum {
 	TCP_LISTEN,
 	TCP_CLOSING,	/* Now a valid state */
 	TCP_NEW_SYN_RECV,
-#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP)
+/* HACK: Enable this unconditionally (it is enabled in BCM's build system).
+ *       There are static asserts failing if the enums do not match (see comment above).
+ */
+/* #if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) */
+#if 1
 	TCP_RST_WAIT,
 #endif
 
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 39335a9a74..a529f324a9 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -2674,7 +2674,11 @@ enum {
 	BPF_TCP_LISTEN,
 	BPF_TCP_CLOSING,	/* Now a valid state */
 	BPF_TCP_NEW_SYN_RECV,
-#if ((defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP)) || !defined(CONFIG_BCM_IN_KERNEL))
+/* HACK: Enable this unconditionally (it is enabled in BCM's build system).
+ *       There are static asserts failing if the enums do not match (see comment above).
+ */
+/* #if ((defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP)) || !defined(CONFIG_BCM_IN_KERNEL)) */
+#if 1
 	BPF_TCP_RST_WAIT,
 #endif
 
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index eb85adb26f..227b9b0e9f 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -2672,7 +2672,11 @@ enum {
 	BPF_TCP_LISTEN,
 	BPF_TCP_CLOSING,	/* Now a valid state */
 	BPF_TCP_NEW_SYN_RECV,
-#if ((defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP)) || !defined(CONFIG_BCM_IN_KERNEL))
+/* HACK: Enable this unconditionally (it is enabled in BCM's build system).
+ *       There are static asserts failing if the enums do not match (see comment above).
+ */
+/* #if ((defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP)) || !defined(CONFIG_BCM_IN_KERNEL)) */
+#if 1
 	BPF_TCP_RST_WAIT,
 #endif
 
-- 
GitLab