From 6c972a1eabd14163babe9ff309170ea9cc98a8ef Mon Sep 17 00:00:00 2001 From: Vincent Li Date: Tue, 3 Sep 2024 21:38:28 +0000 Subject: [PATCH] pin ebpf map pin map so when xdp-loader load then unload, and load again, the same map can be reused. Signed-off-by: Vincent Li --- xdp-dnsrrl/xdp_dnsrrl.bpf.c | 2 ++ xdp-synproxy/xdp_synproxy.bpf.c | 2 ++ xdp-udp/xdp_udp.bpf.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/xdp-dnsrrl/xdp_dnsrrl.bpf.c b/xdp-dnsrrl/xdp_dnsrrl.bpf.c index 2a9ba2d7..b6f3eee8 100644 --- a/xdp-dnsrrl/xdp_dnsrrl.bpf.c +++ b/xdp-dnsrrl/xdp_dnsrrl.bpf.c @@ -101,6 +101,7 @@ struct { __type(key, __u32); __type(value, struct bucket_time); __uint(max_entries, RRL_SIZE); + __uint(pinning, LIBBPF_PIN_BY_NAME); } state_map __section(".maps"); struct { @@ -108,6 +109,7 @@ struct { __type(key, sizeof(struct in6_addr)); __type(value, struct bucket_time); __uint(max_entries, RRL_SIZE); + __uint(pinning, LIBBPF_PIN_BY_NAME); } state_map_v6 __section(".maps"); diff --git a/xdp-synproxy/xdp_synproxy.bpf.c b/xdp-synproxy/xdp_synproxy.bpf.c index 6b0ae03e..7386218d 100644 --- a/xdp-synproxy/xdp_synproxy.bpf.c +++ b/xdp-synproxy/xdp_synproxy.bpf.c @@ -78,6 +78,7 @@ struct { __type(key, __u32); __type(value, __u64); __uint(max_entries, 2); + __uint(pinning, LIBBPF_PIN_BY_NAME); } values SEC(".maps"); struct { @@ -85,6 +86,7 @@ struct { __type(key, __u32); __type(value, __u16); __uint(max_entries, MAX_ALLOWED_PORTS); + __uint(pinning, LIBBPF_PIN_BY_NAME); } allowed_ports SEC(".maps"); /* Some symbols defined in net/netfilter/nf_conntrack_bpf.c are unavailable in diff --git a/xdp-udp/xdp_udp.bpf.c b/xdp-udp/xdp_udp.bpf.c index 8a5452f2..3d8191aa 100644 --- a/xdp-udp/xdp_udp.bpf.c +++ b/xdp-udp/xdp_udp.bpf.c @@ -72,6 +72,7 @@ struct { __type(key, __u32); __type(value, __u16); __uint(max_entries, MAX_ALLOWED_PORTS); + __uint(pinning, LIBBPF_PIN_BY_NAME); } udp_ports SEC(".maps"); @@ -88,6 +89,7 @@ struct { __type(key, __u32); __type(value, struct bucket_time); __uint(max_entries, RRL_SIZE); + __uint(pinning, LIBBPF_PIN_BY_NAME); } udp_state_map __section(".maps"); /** Copied from the kernel module of the base03-map-counter example of the