MSS clamping with XDP/eBPF

Valentín Gutierrez <[email protected]> Mon, 6 Nov 2023 10:57:22 +0100
Newsgroups org.kernel.vger.xdp-newbies
Message-ID <CALQkE9a0VWPZs3cXmWCyd4TWp2uDzghfhd8-VAAAb2Gtc-5CgA@mail.gmail.com>
Hi,

I'm trying to perform some basic TCP MSS clamping with eBPF and it's
being harder than expected:

* Parsing TCP options can be challenging for the eBPF verifier as it's
been shown in [1] by Christian Deacon.
* bpf_store_hdr_opt() introduced in [2] doesn't seem to be useful here
cause it refuses to overwrite an existing TCP option and MSS is
already set when BPF_SOCK_OPS_WRITE_HDR_OPT_CB is triggered.
* bpf_setsockopt() isn't able to set TCP_MAXSEG per [3].

Am I missing something?

Thanks,
Valentin Gutierrez

[1] https://github.com/gamemann/XDP-TCP-Header-Options/
[2] https://lore.kernel.org/bpf/[email protected]/T/
[3] https://github.com/torvalds/linux/blob/d2f51b3516dade79269ff45eae2a7668ae711b25/net/core/filter.c#L5151