1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright (c) 2020 Facebook 3 4 #include <test_progs.h> 5 #include <network_helpers.h> 6 7 #include "map_ptr_kern.lskel.h" 8 9 void test_map_ptr(void) 10 { 11 struct map_ptr_kern_lskel *skel; 12 __u32 duration = 0, retval; 13 char buf[128]; 14 int err; 15 int page_size = getpagesize(); 16 17 skel = map_ptr_kern_lskel__open(); 18 if (!ASSERT_OK_PTR(skel, "skel_open")) 19 return; 20 21 skel->maps.m_ringbuf.max_entries = page_size; 22 23 err = map_ptr_kern_lskel__load(skel); 24 if (!ASSERT_OK(err, "skel_load")) 25 goto cleanup; 26 27 skel->bss->page_size = page_size; 28 29 err = bpf_prog_test_run(skel->progs.cg_skb.prog_fd, 1, &pkt_v4, 30 sizeof(pkt_v4), buf, NULL, &retval, NULL); 31 32 if (CHECK(err, "test_run", "err=%d errno=%d\n", err, errno)) 33 goto cleanup; 34 35 if (CHECK(!retval, "retval", "retval=%d map_type=%u line=%u\n", retval, 36 skel->bss->g_map_type, skel->bss->g_line)) 37 goto cleanup; 38 39 cleanup: 40 map_ptr_kern_lskel__destroy(skel); 41 } 42