Signed-off-by: Christoph Paasch <cpaasch(a)apple.com>
---
include/net/tcp.h | 7 ++++---
net/ipv4/tcp.c | 4 ++--
net/ipv4/tcp_input.c | 6 ++++++
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 63fe6e02a963..f2708d69bb43 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -202,6 +202,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
#define TCPOLEN_FASTOPEN_BASE 2
#define TCPOLEN_EXP_FASTOPEN_BASE 4
#define TCPOLEN_EXP_SMC_BASE 6
+#define TCPOLEN_EXP_BASE 6
/* But this is what stacks really send out. */
#define TCPOLEN_TSTAMP_ALIGNED 12
@@ -2069,7 +2070,7 @@ extern struct static_key_false tcp_extra_options_enabled;
struct tcp_extra_option_store;
struct tcp_extra_option_ops {
- unsigned char option_kind;
+ u32 option_kind;
unsigned char priority;
void (*parse)(int opsize, const unsigned char *opptr,
const struct sk_buff *skb,
@@ -2122,10 +2123,10 @@ struct tcp_extra_option_store {
const struct tcp_extra_option_ops *ops;
};
-struct tcp_extra_option_store *tcp_extra_options_find_kind(unsigned char kind,
+struct tcp_extra_option_store *tcp_extra_options_find_kind(u32 kind,
const struct sock *sk);
-void tcp_extra_options_parse(int opcode, int opsize, const unsigned char *opptr,
+void tcp_extra_options_parse(u32 opcode, int opsize, const unsigned char *opptr,
const struct sk_buff *skb,
struct tcp_options_received *opt_rx,
struct sock *sk);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index bc7f471bcf96..6d4e87aa1bbf 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3491,7 +3491,7 @@ static struct list_head *tcp_extra_options_get_list(const struct
sock *sk)
return NULL;
}
-struct tcp_extra_option_store *tcp_extra_options_find_kind(unsigned char kind,
+struct tcp_extra_option_store *tcp_extra_options_find_kind(u32 kind,
const struct sock *sk)
{
struct tcp_extra_option_store *entry;
@@ -3507,7 +3507,7 @@ struct tcp_extra_option_store *tcp_extra_options_find_kind(unsigned
char kind,
return entry;
}
-void tcp_extra_options_parse(int opcode, int opsize, const unsigned char *opptr,
+void tcp_extra_options_parse(u32 opcode, int opsize, const unsigned char *opptr,
const struct sk_buff *skb,
struct tcp_options_received *opt_rx,
struct sock *sk)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 23c62d8e4e06..2a3debb2c7fe 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3796,6 +3796,12 @@ void tcp_parse_options(const struct net *net,
else if (smc_parse_options(th, opt_rx, ptr,
opsize))
break;
+ else if (static_branch_unlikely(&tcp_extra_options_enabled) &&
+ opsize >= TCPOLEN_EXP_BASE)
+ tcp_extra_options_parse(get_unaligned_be32(ptr),
+ opsize, ptr,
+ skb, opt_rx,
+ sk);
break;
default:
--
2.15.0