Loading...
1// SPDX-License-Identifier: GPL-2.0
2#define BPF_NO_KFUNC_PROTOTYPES
3#include "vmlinux.h"
4#include "bpf_tracing_net.h"
5#include <bpf/bpf_helpers.h>
6
7struct bpf_xfrm_info___local {
8 u32 if_id;
9 int link;
10} __attribute__((preserve_access_index));
11
12__u32 req_if_id;
13__u32 resp_if_id;
14
15int bpf_skb_set_xfrm_info(struct __sk_buff *skb_ctx,
16 const struct bpf_xfrm_info___local *from) __ksym;
17int bpf_skb_get_xfrm_info(struct __sk_buff *skb_ctx,
18 struct bpf_xfrm_info___local *to) __ksym;
19
20SEC("tc")
21int set_xfrm_info(struct __sk_buff *skb)
22{
23 struct bpf_xfrm_info___local info = { .if_id = req_if_id };
24
25 return bpf_skb_set_xfrm_info(skb, &info) ? TC_ACT_SHOT : TC_ACT_UNSPEC;
26}
27
28SEC("tc")
29int get_xfrm_info(struct __sk_buff *skb)
30{
31 struct bpf_xfrm_info___local info = {};
32
33 if (bpf_skb_get_xfrm_info(skb, &info) < 0)
34 return TC_ACT_SHOT;
35
36 resp_if_id = info.if_id;
37
38 return TC_ACT_UNSPEC;
39}
40
41char _license[] SEC("license") = "GPL";
1// SPDX-License-Identifier: GPL-2.0
2#include "vmlinux.h"
3#include "bpf_tracing_net.h"
4#include <bpf/bpf_helpers.h>
5
6struct bpf_xfrm_info___local {
7 u32 if_id;
8 int link;
9} __attribute__((preserve_access_index));
10
11__u32 req_if_id;
12__u32 resp_if_id;
13
14int bpf_skb_set_xfrm_info(struct __sk_buff *skb_ctx,
15 const struct bpf_xfrm_info___local *from) __ksym;
16int bpf_skb_get_xfrm_info(struct __sk_buff *skb_ctx,
17 struct bpf_xfrm_info___local *to) __ksym;
18
19SEC("tc")
20int set_xfrm_info(struct __sk_buff *skb)
21{
22 struct bpf_xfrm_info___local info = { .if_id = req_if_id };
23
24 return bpf_skb_set_xfrm_info(skb, &info) ? TC_ACT_SHOT : TC_ACT_UNSPEC;
25}
26
27SEC("tc")
28int get_xfrm_info(struct __sk_buff *skb)
29{
30 struct bpf_xfrm_info___local info = {};
31
32 if (bpf_skb_get_xfrm_info(skb, &info) < 0)
33 return TC_ACT_SHOT;
34
35 resp_if_id = info.if_id;
36
37 return TC_ACT_UNSPEC;
38}
39
40char _license[] SEC("license") = "GPL";