Skip to content

Commit

Permalink
tcplife: fix dport filter on tracepoints
Browse files Browse the repository at this point in the history
When using tracepoints, the destination port is retrieved in host
byte order and there is no need to convert it, contrary to the
kprobe version.
  • Loading branch information
pchaigno committed May 30, 2018
1 parent b50c725 commit 95b3d8c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/tcplife.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
// dport is either used in a filter here, or later
u16 dport = sk->__sk_common.skc_dport;
dport = ntohs(dport);
FILTER_DPORT
/*
Expand Down Expand Up @@ -366,7 +367,7 @@
'if (pid != %s) { return 0; }' % args.pid)
if args.remoteport:
dports = [int(dport) for dport in args.remoteport.split(',')]
dports_if = ' && '.join(['dport != %d' % ntohs(dport) for dport in dports])
dports_if = ' && '.join(['dport != %d' % dport for dport in dports])
bpf_text = bpf_text.replace('FILTER_DPORT',
'if (%s) { birth.delete(&sk); return 0; }' % dports_if)
if args.localport:
Expand Down

0 comments on commit 95b3d8c

Please sign in to comment.