Skip to content

Commit

Permalink
Opt-in skb whose netns inode is 0 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwinger233 committed Dec 27, 2023
1 parent 89c2102 commit 4528e40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Binary file modified bpf/bpf_bpfel_x86.o
Binary file not shown.
4 changes: 3 additions & 1 deletion bpf/skbdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ handle_skb_kprobe(struct sk_buff *skb, struct pt_regs *ctx)
{
__u32 tid;
__u64 skb_addr = (__u64)skb;
__u32 netns_inode = get_netns(skb);

if (bpf_map_lookup_elem(&skb_addresses, &skb_addr))
goto cont;

Expand All @@ -260,7 +262,7 @@ handle_skb_kprobe(struct sk_buff *skb, struct pt_regs *ctx)
bpf_map_update_elem(&skb_addresses, &skb_addr, &TRUE, BPF_ANY);

cont:
if (SKBDUMP_CONFIG.netns != get_netns(skb))
if (netns_inode != SKBDUMP_CONFIG.netns && netns_inode != 0)
return 0;

tid = bpf_get_current_pid_tgid() & 0xffffffff;
Expand Down

0 comments on commit 4528e40

Please sign in to comment.