Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcptracer: initialize skc_net variable #1483

Conversation

iaguis
Copy link
Contributor

@iaguis iaguis commented Dec 12, 2017

We need to do this in old kernels since the verifier was stricter then.

Tested with 4.4.105.

Fixes #1482

We need to do this in old kernels since the verifier was stricter then.

Tested with 4.4.105.
@yonghong-song
Copy link
Collaborator

[buildbot, ok to test]

Copy link
Collaborator

@yonghong-song yonghong-song left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brendangregg
Copy link
Member

Errors on 4.9-rc2:

./tcptracer.py.2
bpf: Permission denied
0: (79) r7 = *(u64 *)(r1 +80)
1: (85) call 14
2: (7b) *(u64 *)(r10 -8) = r0
3: (18) r1 = 0x4e0d6540
5: (bf) r2 = r10
6: (07) r2 += -8
7: (85) call 1
8: (bf) r6 = r0
9: (15) if r6 == 0x0 goto pc+55
 R0=map_value_or_null(ks=8,vs=8),min_value=0,max_value=0 R6=map_value(ks=8,vs=8),min_value=0,max_value=0 R7=inv R10=fp
10: (18) r1 = 0x4e0d6540
12: (bf) r2 = r10
13: (07) r2 += -8
14: (85) call 3
15: (67) r7 <<= 32
16: (77) r7 >>= 32
17: (55) if r7 != 0x0 goto pc+47
 R0=inv,min_value=0,max_value=0 R6=map_value(ks=8,vs=8),min_value=0,max_value=0 R7=inv32,min_value=0,max_value=0 R10=fp
18: (79) r1 = *(u64 *)(r6 +0)
19: (b7) r2 = 0
20: (7b) *(u64 *)(r10 -16) = r2
21: (7b) *(u64 *)(r10 -24) = r2
22: (63) *(u32 *)(r10 -48) = r2
23: (69) r6 = *(u16 *)(r1 +12)
R1 invalid mem access 'inv'

HINT: The invalid mem access 'inv' error can happen if you try to dereference memory without first using bpf_probe_read() to copy it to the BPF stack. Sometimes the bpf_probe_read is automatic by the bcc rewriter, other times you'll need to be explicit.

Traceback (most recent call last):
  File "./tcptracer.py.2", line 628, in <module>
    b.attach_kretprobe(event="tcp_v4_connect", fn_name="trace_connect_v4_return")
  File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 552, in attach_kretprobe
    fn = self.load_func(fn_name, BPF.KPROBE)
  File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 346, in load_func
    (func_name, errstr))
Exception: Failed to load BPF program trace_connect_v4_return: Permission denied

It does work on 4.4.0-98-generic. Maybe I should find another 4.9 to try.

@alexgpg
Copy link

alexgpg commented Jan 9, 2018

It works on 4.4.0-103-generic Ubuntu 16.04 Xenial.

@yonghong-song
Copy link
Collaborator

The error above seems unrelated:
b.attach_kretprobe(event="tcp_v4_connect", fn_name="trace_connect_v4_return")
has failures, while the change is in function trace_accept_return for kprobe:
b.attach_kretprobe(event="inet_csk_accept", fn_name="trace_accept_return")

@yonghong-song yonghong-song merged commit 956a983 into iovisor:master Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants