-
-
Save jschwinger233/845e2fd2c746f19b7a29f42e4e131672 to your computer and use it in GitHub Desktop.
simple bpftrace script to print out forwarding traffic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bpftrace | |
#include <linux/skbuff.h> | |
#include <linux/ip.h> | |
BEGIN | |
{ | |
printf("follow the white rabbit\n"); | |
} | |
kprobe:netif_rx | |
{ | |
$skb = (struct sk_buff*) arg0; | |
$ipheader = ((iphdr *) ($skb->head + $skb->network_header)); | |
$version = ($ipheader->version) >>4; | |
printf("[%d] %d\t%s > %s\n", $version, $ipheader->protocol, | |
ntop($ipheader->saddr), ntop($ipheader->daddr)); | |
} | |
END | |
{ | |
printf("good bye, Alice\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment