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

bpf_trace_printk result in LoadElf() failed: loadPrograms() failed: map '' doesn't exist #83

Open
vincentmli opened this issue Feb 23, 2023 · 0 comments

Comments

@vincentmli
Copy link

Hi,

when I add bpf_trace_printk in example below, it compiles fine, when run the program, it result in error below:

[root@centos-dev basic_firewall]# ./main -drop 10.169.72.0/24 -iface ens192
LoadElf() failed: loadPrograms() failed: map '' doesn't exist

the diff

diff --git a/examples/xdp/basic_firewall/ebpf_prog/xdp_fw.c b/examples/xdp/basic_firewall/ebpf_prog/xdp_fw.c
index 6d399fb..b9aa66c 100644
--- a/examples/xdp/basic_firewall/ebpf_prog/xdp_fw.c
+++ b/examples/xdp/basic_firewall/ebpf_prog/xdp_fw.c
@@ -80,6 +80,8 @@ int firewall(struct xdp_md *ctx) {
   key.prefixlen = 32;
   key.saddr = ip->saddr;
 
+  bpf_trace_printk("Matched with protocol %d and sAddr %lu.\n", ip->protocol, ip->saddr);
+
   // Lookup SRC IP in blacklisted IPs
   __u64 *rule_idx = bpf_map_lookup_elem(&blacklist, &key);
   if (rule_idx) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant