mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
selftest: bpf: Use bpf_tcp_ops_set_flags() in bpf_tcp_ops_hdr.c.
The next patch guards bpf_tcp_ops callbacks in the fast path with per-socket flags. Let's use bpf_tcp_ops_set_flags() to enable flags for parse_hdr, write_hdr_opt, and hdr_opt_len. Note that BPF_TCP_OPS_FLAG_PARSE_HDR_OPT_ALL and BPF_TCP_OPS_FLAG_PARSE_HDR_OPT_UNKNOWN are used on the server and client, respectively, for better coverage. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Amery Hung <ameryhung@gmail.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20261008031604.256498-4-kuniyu@google.com
This commit is contained in:
parent
4e2385abec
commit
ca577d08f8
|
|
@ -18,6 +18,24 @@ int found_cnt;
|
|||
__u8 found_d0;
|
||||
__u8 found_d1;
|
||||
|
||||
SEC("struct_ops")
|
||||
void BPF_PROG(test_listen, struct sock *sk)
|
||||
{
|
||||
bpf_tcp_ops_set_flags((struct tcp_sock *)sk,
|
||||
BPF_TCP_OPS_FLAG_PARSE_HDR_OPT_ALL |
|
||||
BPF_TCP_OPS_FLAG_WRITE_HDR_OPT,
|
||||
0);
|
||||
}
|
||||
|
||||
SEC("struct_ops")
|
||||
void BPF_PROG(test_connect, struct sock *sk)
|
||||
{
|
||||
bpf_tcp_ops_set_flags((struct tcp_sock *)sk,
|
||||
BPF_TCP_OPS_FLAG_PARSE_HDR_OPT_UNKNOWN |
|
||||
BPF_TCP_OPS_FLAG_WRITE_HDR_OPT,
|
||||
0);
|
||||
}
|
||||
|
||||
SEC("struct_ops")
|
||||
void BPF_PROG(test_hdr_opt_len, struct sock *sk, struct sk_buff *skb,
|
||||
struct request_sock *req, struct sk_buff *syn_skb,
|
||||
|
|
@ -78,6 +96,8 @@ void BPF_PROG(test_parse_hdr, struct sock *sk, struct sk_buff *skb)
|
|||
|
||||
SEC(".struct_ops.link")
|
||||
struct bpf_tcp_ops test_hdr_ops = {
|
||||
.listen = (void *)test_listen,
|
||||
.connect = (void *)test_connect,
|
||||
.hdr_opt_len = (void *)test_hdr_opt_len,
|
||||
.write_hdr_opt = (void *)test_write_hdr_opt,
|
||||
.parse_hdr = (void *)test_parse_hdr,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user