We will call BPF SOCK_OPS prog with BPF_SOCK_OPS_RCVQ_CB. It requires a similar setup to bpf_skops_established(), and the only difference is the skb data length. Let's factor out the common logic into bpf_skops_common_locked(). Signed-off-by: Kuniyuki Iwashima --- net/ipv4/tcp_input.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index d5c9e65d9760..c4ba4f1e9d9e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -179,8 +179,9 @@ static void bpf_skops_parse_hdr(struct sock *sk, struct sk_buff *skb) BPF_CGROUP_RUN_PROG_SOCK_OPS(&sock_ops); } -static void bpf_skops_established(struct sock *sk, int bpf_op, - struct sk_buff *skb) +static void bpf_skops_common_locked(struct sock *sk, int bpf_op, + struct sk_buff *skb, + unsigned int end_offset) { struct bpf_sock_ops_kern sock_ops; @@ -191,12 +192,18 @@ static void bpf_skops_established(struct sock *sk, int bpf_op, sock_ops.is_fullsock = 1; sock_ops.is_locked_tcp_sock = 1; sock_ops.sk = sk; - /* sk with TCP_REPAIR_ON does not have skb in tcp_finish_connect */ if (skb) - bpf_skops_init_skb(&sock_ops, skb, tcp_hdrlen(skb)); + bpf_skops_init_skb(&sock_ops, skb, end_offset); BPF_CGROUP_RUN_PROG_SOCK_OPS(&sock_ops); } + +static void bpf_skops_established(struct sock *sk, int bpf_op, + struct sk_buff *skb) +{ + /* sk with TCP_REPAIR_ON does not have skb in tcp_finish_connect */ + bpf_skops_common_locked(sk, bpf_op, skb, skb ? tcp_hdrlen(skb) : 0); +} #else static void bpf_skops_parse_hdr(struct sock *sk, struct sk_buff *skb) { -- 2.54.0.746.g67dd491aae-goog