/usr/share/systemtap/examples/network
Edit: /usr/share/systemtap/examples/network/netfilter_drop.stp (1156B)
#!/usr/bin/stap
global drop_count
probe begin {
// Make sure the protocol is either UDP or TCP
// and the number of packets is positive.
if ((@1 != "TCP" && @1 != "UDP" && @1 != "ALL") || ($2 <0))
{
printf("Please enter \"TCP\", \"UDP\" or \"ALL\" on the command line, followed by the number of packets to drop.\n")
exit()
}
else
printf("Dropping packets! Ctrl-C to exit.\n")
}
probe netfilter.ipv4.local_in {
// If the protocol matches that specified (or ALL),
// make sure we have not exceeded the number
// provided, then drop the packet.
if(convert_protocol(protocol) == @1 || @1 == "ALL") {
if(@count(drop_count[@1]) >= $2 && $2 != 0)
exit()
else {
$verdict = nf_drop
drop_count[@1]<<