2022-08-23 05:51:43 -05:00
|
|
|
#!/usr/bin/bpftrace
|
|
|
|
#include <net/sock.h>
|
|
|
|
|
|
|
|
kprobe:udp_sendmsg,
|
|
|
|
kprobe:tcp_sendmsg
|
|
|
|
{
|
|
|
|
$sk = (struct sock *)arg0;
|
|
|
|
|
2024-04-25 17:21:49 -05:00
|
|
|
if($sk->__sk_common.skc_family==2) {
|
|
|
|
$daddr = ntop($sk->__sk_common.skc_daddr);
|
|
|
|
}
|
|
|
|
else if($sk->__sk_common.skc_family==10) {
|
|
|
|
$daddr = ntop($sk->__sk_common.skc_v6_daddr.in6_u.u6_addr8);
|
|
|
|
}
|
2022-08-23 05:51:43 -05:00
|
|
|
|
2024-04-25 17:21:49 -05:00
|
|
|
/* skc_v6_daddr, skc_family */
|
|
|
|
|
|
|
|
printf("direct\t%s\tpid%d\t%d\t%s\n", $daddr , pid, $sk->__sk_common.skc_family, comm);
|
2022-08-23 05:51:43 -05:00
|
|
|
}
|
2024-04-25 17:21:49 -05:00
|
|
|
|