1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_tracing.h>
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_core_read.h>
9 struct bpf_ct_opts___local {
14 } __attribute__((preserve_access_index));
16 struct nf_conn *bpf_skb_ct_alloc(struct __sk_buff *, struct bpf_sock_tuple *, u32,
17 struct bpf_ct_opts___local *, u32) __ksym;
18 struct nf_conn *bpf_skb_ct_lookup(struct __sk_buff *, struct bpf_sock_tuple *, u32,
19 struct bpf_ct_opts___local *, u32) __ksym;
20 struct nf_conn *bpf_ct_insert_entry(struct nf_conn *) __ksym;
21 void bpf_ct_release(struct nf_conn *) __ksym;
22 void bpf_ct_set_timeout(struct nf_conn *, u32) __ksym;
23 int bpf_ct_change_timeout(struct nf_conn *, u32) __ksym;
24 int bpf_ct_set_status(struct nf_conn *, u32) __ksym;
25 int bpf_ct_change_status(struct nf_conn *, u32) __ksym;
28 int alloc_release(struct __sk_buff *ctx)
30 struct bpf_ct_opts___local opts = {};
31 struct bpf_sock_tuple tup = {};
34 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
42 int insert_insert(struct __sk_buff *ctx)
44 struct bpf_ct_opts___local opts = {};
45 struct bpf_sock_tuple tup = {};
48 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
51 ct = bpf_ct_insert_entry(ct);
54 ct = bpf_ct_insert_entry(ct);
59 int lookup_insert(struct __sk_buff *ctx)
61 struct bpf_ct_opts___local opts = {};
62 struct bpf_sock_tuple tup = {};
65 ct = bpf_skb_ct_lookup(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
68 bpf_ct_insert_entry(ct);
73 int write_not_allowlisted_field(struct __sk_buff *ctx)
75 struct bpf_ct_opts___local opts = {};
76 struct bpf_sock_tuple tup = {};
79 ct = bpf_skb_ct_lookup(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
87 int set_timeout_after_insert(struct __sk_buff *ctx)
89 struct bpf_ct_opts___local opts = {};
90 struct bpf_sock_tuple tup = {};
93 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
96 ct = bpf_ct_insert_entry(ct);
99 bpf_ct_set_timeout(ct, 0);
104 int set_status_after_insert(struct __sk_buff *ctx)
106 struct bpf_ct_opts___local opts = {};
107 struct bpf_sock_tuple tup = {};
110 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
113 ct = bpf_ct_insert_entry(ct);
116 bpf_ct_set_status(ct, 0);
121 int change_timeout_after_alloc(struct __sk_buff *ctx)
123 struct bpf_ct_opts___local opts = {};
124 struct bpf_sock_tuple tup = {};
127 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
130 bpf_ct_change_timeout(ct, 0);
135 int change_status_after_alloc(struct __sk_buff *ctx)
137 struct bpf_ct_opts___local opts = {};
138 struct bpf_sock_tuple tup = {};
141 ct = bpf_skb_ct_alloc(ctx, &tup, sizeof(tup.ipv4), &opts, sizeof(opts));
144 bpf_ct_change_status(ct, 0);
148 char _license[] SEC("license") = "GPL";