oncn-bwm/0008-adapt-map-define-for-libbpf-1.2.2.patch
2024-04-24 11:04:13 +08:00

71 lines
1.7 KiB
Diff

From bc1ac8f89714535f3cdcae4aa970d4a82d5bcf5c Mon Sep 17 00:00:00 2001
From: kwb0523 <kwb0523@163.com>
Date: Wed, 24 Apr 2024 10:53:19 +0800
Subject: [PATCH] adapt map define for libbpf-1.2.2
---
bpf/bwm_tc.c | 47 +++++++++++++++++------------------------------
1 file changed, 17 insertions(+), 30 deletions(-)
diff --git a/bpf/bwm_tc.c b/bpf/bwm_tc.c
index d04d454..72bb944 100644
--- a/bpf/bwm_tc.c
+++ b/bpf/bwm_tc.c
@@ -22,36 +22,23 @@
#define PIN_GLOBAL_NS 2
#define OFFLINE_PRIO ((unsigned int)-1)
-struct bpf_elf_map_t {
- __u32 type;
- __u32 key_size;
- __u32 value_size;
- __u32 max_elem;
- __u32 flags;
- __u32 id;
- __u32 pinning;
-};
-
-
-struct bpf_elf_map_t SEC("maps") throttle_cfg = {
- .type = BPF_MAP_TYPE_ARRAY,
- .key_size = sizeof(unsigned int),
- .value_size = sizeof(struct edt_throttle_cfg),
- .pinning = PIN_GLOBAL_NS,
- .max_elem = 1,
- .flags = 0,
- .id = 0,
-};
-
-struct bpf_elf_map_t SEC("maps") throttle_map = {
- .type = BPF_MAP_TYPE_ARRAY,
- .key_size = sizeof(unsigned int),
- .value_size = sizeof(struct edt_throttle),
- .pinning = PIN_GLOBAL_NS,
- .max_elem = 1,
- .flags = 0,
- .id = 0,
-};
+struct {
+ __uint(type, BPF_MAP_TYPE_ARRAY);
+ __uint(key_size, sizeof(unsigned int));
+ __uint(value_size, sizeof(struct edt_throttle_cfg));
+ __uint(max_entries, 1);
+ __uint(map_flags, 0);
+ __uint(pinning, LIBBPF_PIN_BY_NAME);
+} throttle_cfg SEC(".maps");
+
+struct {
+ __uint(type, BPF_MAP_TYPE_ARRAY);
+ __uint(key_size, sizeof(unsigned int));
+ __uint(value_size, sizeof(struct edt_throttle));
+ __uint(max_entries, 1);
+ __uint(map_flags, 0);
+ __uint(pinning, LIBBPF_PIN_BY_NAME);
+} throttle_map SEC(".maps");
static void throttle_init(const struct edt_throttle_cfg *cfg, struct edt_throttle *throttle)
{
--
2.33.0