1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2020 Google LLC.
9 #include <linux/if_ether.h>
11 #include <bpf/bpf_helpers.h>
14 __uint(type
, BPF_MAP_TYPE_ARRAY
);
15 __uint(max_entries
, 1);
18 } test_result
SEC(".maps");
20 SEC("cgroup_skb/egress")
21 int load_bytes_relative(struct __sk_buff
*skb
)
27 __u32 test_passed
= 0;
29 /* MAC header is not set by the time cgroup_skb/egress triggers */
30 if (bpf_skb_load_bytes_relative(skb
, 0, ð
, sizeof(eth
),
31 BPF_HDR_START_MAC
) != -EFAULT
)
34 if (bpf_skb_load_bytes_relative(skb
, 0, &iph
, sizeof(iph
),
38 if (bpf_skb_load_bytes_relative(skb
, 0xffff, &iph
, sizeof(iph
),
39 BPF_HDR_START_NET
) != -EFAULT
)
45 bpf_map_update_elem(&test_result
, &map_key
, &test_passed
, BPF_ANY
);