Subject: Re: [PATCH v3 bpf-next 11/11] selftest: bpf: Add test for BPF_SOCK_OPS_RCVQ_CB.

From: Martin KaFai Lau <[email-masked]>
Date: Tue, 26 May 2026 14:01:32 -0700

On Sat, May 23, 2026 at 08:29:40AM +0000, Kuniyuki Iwashima wrote:
> +static void tcp_do_autolowat(struct bpf_sock_ops *skops,
> +			     struct tcp_autolowat_cb *cb,
> +			     struct tcp_sock *tp)
> +{
> +	struct bpf_sock_ops_kern *skops_kern;
> +	struct tcp_skb_cb *tcb;
> +	struct sk_buff *skb;
> +	u32 seq, end_seq;
> +	int ret = 0, i;
> +
> +	skops_kern = bpf_cast_to_kern_ctx(skops);
> +	skb = skops_kern->skb;
> +
> +	if (!skb)
> +		goto update;
> +
> +	tcb = bpf_core_cast(skb->cb, struct tcp_skb_cb);
> +	seq = tcb->seq;
> +	end_seq = tcb->end_seq - !!(tcb->tcp_flags & TCPHDR_FIN);
> +
> +	LOG("Start parsing skb: seq: %u, end_seq: %u, len: %u, "
> +	    "rpc_desc_seq: %u, rpc_end_seq: %u, rpc_buff_len: %u",
> +	    SEQ(seq), SEQ(end_seq), end_seq - seq,
> +	    CB_SEQ(rpc_desc_seq), CB_SEQ(rpc_end_seq), cb->rpc_desc_buff_len);
> +
> +	if (cb->rpc_desc_buff_len != RPC_DESC_SIZE) {
> +		ret = tcp_parse_descriptor(skops, cb, seq, end_seq);
> +		if (ret)
> +			goto update;
> +	}
> +
> +	i = 0;
> +
> +	while (1) {

A nit. It may be useful to take a look at progs/arena_htab.c or
rbtree_search.c on the 'for (i = zero; i < xyz && can_loop; i++)' usage.

#> ./veristat tcp_autolowat.bpf.o
Processing 'tcp_autolowat.bpf.o'...
File                 Program                   Verdict  Duration (us)  Insns  States  Program size  Jited size
-------------------  ------------------------  -------  -------------  -----  ------  ------------  ----------
tcp_autolowat.bpf.o  tcp_autolowat             success         245961  12624     338           141         939

The "Insns" could likely be reduced to ~1000s level.