mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
UPSTREAM: tcp: Add saw_unknown to struct tcp_options_received
In a later patch, the bpf prog only wants to be called to handle a header option if that particular header option cannot be handled by the kernel. This unknown option could be written by the peer's bpf-prog. It could also be a new standard option that the running kernel does not support it while a bpf-prog can handle it. This patch adds a "saw_unknown" bit to "struct tcp_options_received" and it uses an existing one byte hole to do that. "saw_unknown" will be set in tcp_parse_options() if it sees an option that the kernel cannot handle. Change-Id: I27b3e0f9b3188b4a99a23385a2390afc05959d67 Signed-off-by: Martin KaFai Lau <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
This commit is contained in:
parent
4cbcd7d560
commit
f38bffdc5a
2 changed files with 18 additions and 6 deletions
|
|
@ -3895,7 +3895,7 @@ static void tcp_parse_fastopen_option(int len, const unsigned char *cookie,
|
|||
foc->exp = exp_opt;
|
||||
}
|
||||
|
||||
static void smc_parse_options(const struct tcphdr *th,
|
||||
static bool smc_parse_options(const struct tcphdr *th,
|
||||
struct tcp_options_received *opt_rx,
|
||||
const unsigned char *ptr,
|
||||
int opsize)
|
||||
|
|
@ -3904,10 +3904,13 @@ static void smc_parse_options(const struct tcphdr *th,
|
|||
if (static_branch_unlikely(&tcp_have_smc)) {
|
||||
if (th->syn && !(opsize & 1) &&
|
||||
opsize >= TCPOLEN_EXP_SMC_BASE &&
|
||||
get_unaligned_be32(ptr) == TCPOPT_SMC_MAGIC)
|
||||
get_unaligned_be32(ptr) == TCPOPT_SMC_MAGIC) {
|
||||
opt_rx->smc_ok = 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Try to parse the MSS option from the TCP header. Return 0 on failure, clamped
|
||||
|
|
@ -3968,6 +3971,7 @@ void tcp_parse_options(const struct net *net,
|
|||
|
||||
ptr = (const unsigned char *)(th + 1);
|
||||
opt_rx->saw_tstamp = 0;
|
||||
opt_rx->saw_unknown = 0;
|
||||
|
||||
while (length > 0) {
|
||||
int opcode = *ptr++;
|
||||
|
|
@ -4058,15 +4062,21 @@ void tcp_parse_options(const struct net *net,
|
|||
*/
|
||||
if (opsize >= TCPOLEN_EXP_FASTOPEN_BASE &&
|
||||
get_unaligned_be16(ptr) ==
|
||||
TCPOPT_FASTOPEN_MAGIC)
|
||||
TCPOPT_FASTOPEN_MAGIC) {
|
||||
tcp_parse_fastopen_option(opsize -
|
||||
TCPOLEN_EXP_FASTOPEN_BASE,
|
||||
ptr + 2, th->syn, foc, true);
|
||||
else
|
||||
smc_parse_options(th, opt_rx, ptr,
|
||||
opsize);
|
||||
break;
|
||||
}
|
||||
|
||||
if (smc_parse_options(th, opt_rx, ptr, opsize))
|
||||
break;
|
||||
|
||||
opt_rx->saw_unknown = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
opt_rx->saw_unknown = 1;
|
||||
}
|
||||
ptr += opsize-2;
|
||||
length -= opsize;
|
||||
|
|
|
|||
Loading…
Reference in a new issue