Skip to content

Commit

Permalink
Fix v6 source (remote) and dest (local) address
Browse files Browse the repository at this point in the history
For v6, tcpdrop.py would report the source and destination addresses incorrectly - tcp_drop() covers the input path, where the source of the received packet is the daddr stored in the socket, while the destination of the received packet is the local address.   This commit swaps them to be correct and leaves a comment since it is not obvious.
  • Loading branch information
nspring authored and yonghong-song committed Sep 30, 2020
1 parent 788303e commit 7e3f0c0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/tcpdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@
struct ipv6_data_t data6 = {};
data6.pid = pid;
data6.ip = 6;
// The remote address (skc_v6_daddr) was the source
bpf_probe_read_kernel(&data6.saddr, sizeof(data6.saddr),
sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
bpf_probe_read_kernel(&data6.daddr, sizeof(data6.daddr),
sk->__sk_common.skc_v6_daddr.in6_u.u6_addr32);
// The local address (skc_v6_rcv_saddr) was the destination
bpf_probe_read_kernel(&data6.daddr, sizeof(data6.daddr),
sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
data6.dport = dport;
data6.sport = sport;
data6.state = state;
Expand Down

0 comments on commit 7e3f0c0

Please sign in to comment.