Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix CO-RE issue on kernel 6.9 and above in eBPF tests #723

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions control/kern/tests/bpf_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ int testsetup_ipset_match(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 112; // */16
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 112 , {} }, // */16
};
lpm_key.data[2] = bpf_ntohl(0xffff);
lpm_key.data[3] = bpf_ntohl(0xe0010000); // 224.1.0.0
__u32 lpm_value = bpf_ntohl(0x01000000);
Expand Down Expand Up @@ -164,8 +165,9 @@ int testsetup_ipset_mismatch(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 112; // */16
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 112, {} }, // */16
};
lpm_key.data[2] = bpf_ntohl(0xffff);
lpm_key.data[3] = bpf_ntohl(0xe0010000); // 224.1.0.0
__u32 lpm_value = bpf_ntohl(0x01000000);
Expand Down Expand Up @@ -208,8 +210,9 @@ int testsetup_source_ipset_match(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 120;
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 120, {} },
};
lpm_key.data[2] = bpf_ntohl(0xffff);
lpm_key.data[3] = bpf_ntohl(0xc0a83200); // 192.168.50.0
__u32 lpm_value = bpf_ntohl(0x01000000);
Expand Down Expand Up @@ -252,8 +255,9 @@ int testsetup_source_ipset_mismatch(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 120;
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 120, {} },
};
lpm_key.data[2] = bpf_ntohl(0xffff);
lpm_key.data[3] = bpf_ntohl(0xc0a83200); // 192.168.50.0
__u32 lpm_value = bpf_ntohl(0x01000000);
Expand Down Expand Up @@ -526,8 +530,9 @@ int testsetup_mac_match(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 128;
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 128, {} },
};
__u8 *data = (__u8 *)&lpm_key.data;
data[10] = 0x6;
data[11] = 0x7;
Expand All @@ -548,8 +553,9 @@ int testsetup_mac_match(struct __sk_buff *skb)
SEC("tc/check/mac_match")
int testcheck_mac_match(struct __sk_buff *skb)
{
struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 128;
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 128 , {} },
};
__u8 *data = (__u8 *)&lpm_key.data;
data[10] = 0x6;
data[11] = 0x7;
Expand Down Expand Up @@ -586,8 +592,9 @@ int testsetup_mac_mismatch(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 128;
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 128, {} },
};
__u8 *data = (__u8 *)&lpm_key.data;
data[10] = 0x0;
data[11] = 0x1;
Expand Down Expand Up @@ -711,8 +718,9 @@ int testsetup_and_match_1(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 112; // */16
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 112 , {} }, // */16
};
lpm_key.data[2] = bpf_ntohl(0xffff);
lpm_key.data[3] = bpf_ntohl(0x01010000); // 1.1.0.0
__u32 lpm_value = bpf_ntohl(0x01000000);
Expand Down Expand Up @@ -790,8 +798,9 @@ int testsetup_and_match_2(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 112; // */16
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 112 , {} }, // */16
};
lpm_key.data[2] = bpf_ntohl(0xffff);
lpm_key.data[3] = bpf_ntohl(0x01010000); // 1.1.0.0
__u32 lpm_value = bpf_ntohl(0x01000000);
Expand Down Expand Up @@ -869,8 +878,9 @@ int testsetup_and_mismatch(struct __sk_buff *skb)
ms.mark = 0;
bpf_map_update_elem(&routing_map, &zero_key, &ms, BPF_ANY);

struct lpm_key lpm_key = {};
lpm_key.trie_key.prefixlen = 112; // */16
struct lpm_key lpm_key = {
.trie_key = { .prefixlen = 112 , {} }, // */16
};
lpm_key.data[2] = bpf_ntohl(0xffff);
lpm_key.data[3] = bpf_ntohl(0x01010000); // 1.1.0.0
__u32 lpm_value = bpf_ntohl(0x01000000);
Expand Down
Loading