Commit 95b3d8c8 authored by Paul Chaignon's avatar Paul Chaignon

tcplife: fix dport filter on tracepoints

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.
parent b50c7251
...@@ -128,6 +128,7 @@ int kprobe__tcp_set_state(struct pt_regs *ctx, struct sock *sk, int state) ...@@ -128,6 +128,7 @@ int kprobe__tcp_set_state(struct pt_regs *ctx, struct sock *sk, int state)
// dport is either used in a filter here, or later // dport is either used in a filter here, or later
u16 dport = sk->__sk_common.skc_dport; u16 dport = sk->__sk_common.skc_dport;
dport = ntohs(dport);
FILTER_DPORT FILTER_DPORT
/* /*
...@@ -366,7 +367,7 @@ if args.pid: ...@@ -366,7 +367,7 @@ if args.pid:
'if (pid != %s) { return 0; }' % args.pid) 'if (pid != %s) { return 0; }' % args.pid)
if args.remoteport: if args.remoteport:
dports = [int(dport) for dport in args.remoteport.split(',')] 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', bpf_text = bpf_text.replace('FILTER_DPORT',
'if (%s) { birth.delete(&sk); return 0; }' % dports_if) 'if (%s) { birth.delete(&sk); return 0; }' % dports_if)
if args.localport: if args.localport:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment