1 // SPDX-License-Identifier: GPL-2.0
2 #define BPF_NO_KFUNC_PROTOTYPES
4 #include <bpf/bpf_tracing.h>
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_core_read.h>
10 struct bpf_ct_opts___local {
15 } __attribute__((preserve_access_index));
17 struct nf_conn *bpf_skb_ct_alloc(struct __sk_buff *, struct bpf_sock_tuple *, u32,
18 struct bpf_ct_opts___local *, u32) __ksym;
19 struct nf_conn *bpf_skb_ct_lookup(struct __sk_buff *, struct bpf_sock_tuple *, u32,
20 struct bpf_ct_opts___local *, u32) __ksym;
21 struct nf_conn *bpf_ct_insert_entry(struct nf_conn *) __ksym;
22 void bpf_ct_release(struct nf_conn *) __ksym;
23 void bpf_ct_set_timeout(struct nf_conn *, u32) __ksym;
24 int bpf_ct_change_timeout(struct nf_conn *, u32) __ksym;
25 int bpf_ct_set_status(struct nf_conn *, u32) __ksym;
26 int bpf_ct_change_status(struct nf_conn *, u32) __ksym;
29 int alloc_release(struct __sk_buff *ctx)
31 struct bpf_ct_opts___local opts = {};
32 struct bpf_sock_tuple tup = {};
35 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
43 int insert_insert(struct __sk_buff *ctx)
45 struct bpf_ct_opts___local opts = {};
46 struct bpf_sock_tuple tup = {};
49 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
52 ct = bpf_ct_insert_entry(ct);
55 ct = bpf_ct_insert_entry(ct);
60 int lookup_insert(struct __sk_buff *ctx)
62 struct bpf_ct_opts___local opts = {};
63 struct bpf_sock_tuple tup = {};
66 ct = bpf_skb_ct_lookup(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
69 bpf_ct_insert_entry(ct);
74 int write_not_allowlisted_field(struct __sk_buff *ctx)
76 struct bpf_ct_opts___local opts = {};
77 struct bpf_sock_tuple tup = {};
80 ct = bpf_skb_ct_lookup(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
88 int set_timeout_after_insert(struct __sk_buff *ctx)
90 struct bpf_ct_opts___local opts = {};
91 struct bpf_sock_tuple tup = {};
94 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
97 ct = bpf_ct_insert_entry(ct);
100 bpf_ct_set_timeout(ct, 0);
105 int set_status_after_insert(struct __sk_buff *ctx)
107 struct bpf_ct_opts___local opts = {};
108 struct bpf_sock_tuple tup = {};
111 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
114 ct = bpf_ct_insert_entry(ct);
117 bpf_ct_set_status(ct, 0);
122 int change_timeout_after_alloc(struct __sk_buff *ctx)
124 struct bpf_ct_opts___local opts = {};
125 struct bpf_sock_tuple tup = {};
128 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
131 bpf_ct_change_timeout(ct, 0);
136 int change_status_after_alloc(struct __sk_buff *ctx)
138 struct bpf_ct_opts___local opts = {};
139 struct bpf_sock_tuple tup = {};
142 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
145 bpf_ct_change_status(ct, 0);
149 char _license[] SEC("license") = "GPL";