Answering my own question, parse_tcp_ts()[0] can be easily adapted to find any TCP option and return a pointer to its position so it can be updated using bpf_skb_store_bytes(). Cheers, Valentín Gutiérrez [0] https://github.com/xdp-project/bpf-examples/blob/63cd4007b16b49b44241f17a38f26aea926f8afc/pping/pping_kern.c#L424 On Mon, Nov 6, 2023 at 10:57 AM Valentín Gutierrez <vgutierrez@xxxxxxxxxxxxx> wrote: > > 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/20200730205748.3354954-1-kafai@xxxxxx/T/ > [3] https://github.com/torvalds/linux/blob/d2f51b3516dade79269ff45eae2a7668ae711b25/net/core/filter.c#L5151