Switch to using typesafe kernel ebpf map accessors
Test: atest libbpf_android_test libnetdbpf_test netd_integration_test netd_unit_test netdutils_test resolv_integration_test resolv_unit_test
Bug: 130746652
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1a2e8fe1bdf0914a90902666895705b45fd1f959
diff --git a/bpf_progs/clatd.c b/bpf_progs/clatd.c
index 4c2953f..578d244 100644
--- a/bpf_progs/clatd.c
+++ b/bpf_progs/clatd.c
@@ -48,12 +48,7 @@
#define ntohs(x) htons(x)
#define ntohl(x) htonl(x)
-struct bpf_map_def SEC("maps") clat_ingress_map = {
- .type = BPF_MAP_TYPE_HASH,
- .key_size = sizeof(struct ClatIngressKey),
- .value_size = sizeof(struct ClatIngressValue),
- .max_entries = 16,
-};
+DEFINE_BPF_MAP(clat_ingress_map, HASH, ClatIngressKey, ClatIngressValue, 16)
static inline __always_inline int nat64(struct __sk_buff* skb, bool is_ethernet) {
const int l2_header_size = is_ethernet ? sizeof(struct ethhdr) : 0;
@@ -92,7 +87,7 @@
return TC_ACT_OK;
}
- struct ClatIngressKey k = {
+ ClatIngressKey k = {
.iif = skb->ifindex,
.pfx96.in6_u.u6_addr32 =
{
@@ -103,7 +98,7 @@
.local6 = ip6->daddr,
};
- struct ClatIngressValue* v = bpf_map_lookup_elem(&clat_ingress_map, &k);
+ ClatIngressValue* v = bpf_clat_ingress_map_lookup_elem(&k);
if (!v) return TC_ACT_OK;