| 1 |
global packets, addr_errors, family_errors |
| 2 |
global localhost |
| 3 |
|
| 4 |
probe tcp.recvmsg |
| 5 |
{ |
| 6 |
if (sport != 8079 && dport != 8079) { |
| 7 |
next |
| 8 |
} |
| 9 |
#printf("receive [%s]:%d -> [%s]:%d\n", saddr, sport, daddr, dport) |
| 10 |
# We got a packet with either a source or destination port of 8079. |
| 11 |
packets <<< 1 |
| 12 |
|
| 13 |
# Did the IP address get converted correctly? |
| 14 |
if (family == AF_INET() || family == AF_INET6()) { |
| 15 |
if (sport == 8079 && saddr != localhost[family]) { |
| 16 |
addr_errors <<< 1 |
| 17 |
printf("error: saddr %s isn't %s\n", saddr, |
| 18 |
localhost[family]) |
| 19 |
} |
| 20 |
else if (dport == 8079 && daddr != localhost[family]) { |
| 21 |
addr_errors <<< 1 |
| 22 |
printf("error: daddr %s isn't %s\n", daddr, |
| 23 |
localhost[family]) |
| 24 |
} |
| 25 |
} |
| 26 |
else { |
| 27 |
family_errors <<< 1 |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
probe begin { |
| 32 |
printf("systemtap starting probe\n") |
| 33 |
localhost[AF_INET()] = "127.0.0.1" |
| 34 |
localhost[AF_INET6()] = "0000:0000:0000:0000:0000:0000:0000:0001" |
| 35 |
} |
| 36 |
probe end { |
| 37 |
printf("systemtap ending probe\n") |
| 38 |
if (@count(packets) > 0) { |
| 39 |
printf("packets = %d\n", @count(packets)) |
| 40 |
} |
| 41 |
else { |
| 42 |
printf("no packets seen\n") |
| 43 |
} |
| 44 |
printf("address errors = %d\n", @count(addr_errors)) |
| 45 |
printf("bad family errors = %d\n", @count(family_errors)) |
| 46 |
} |