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

Fix #1796 and skip probe rewriter for bpf_probe_read #1812

Merged
merged 1 commit into from
Jun 13, 2018

Conversation

pchaigno
Copy link
Contributor

#1796 stops the whole AST traversal if it meets a bpf_probe_read call. I think the original intent was to simply not rewrite the third argument, so this commit fixes it by remembering the third argument on bpf_probe_read call traversals and overriding dataTraverseStmtPre to skip the traversal of that
argument when we meet it later.

/cc @yonghong-song

// return TCP_SKB_CB(skb)->tcp_gso_size;
u16 val = 0;
bpf_probe_read(&val, sizeof(val), &(TCP_SKB_CB(skb)->tcp_gso_size));
return val + skb->protocol;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this pull request, this second test fails because the AST traversal is stopped after meeting the bpf_probe_read call, even though a rewrite is needed for the later expression skb->protocol.

@pchaigno
Copy link
Contributor Author

I don't understand the Jenkins' failures. The tests passed locally (Ubuntu 16.04 and 17.10), and they're passing for the Fedora builds...

@yonghong-song
Copy link
Collaborator

The function dataTraverseStmtPre is defined in clang starting from 3.9. So effectively, 3.7 and 3.8 does not have this function defined in clang hence the ProbeVisitor::dataTraverseStmtPre will not execute for 3.7/3.8.

Currently, we already track LLVM major numbers in the cmake file. We can also track minor number, and guard reference of ProbeVisitor::dataTraverseStmtPre unless compiler version is >= 3.9.
For 3.7 and 3.8, the compiler is pretty old, I guess it is OK to fall into conservative side that the whole bpf_probe_read specialization is not needed and users are responsible to rewrite their code.

What do you think?

@pchaigno
Copy link
Contributor Author

For 3.7 and 3.8, the compiler is pretty old, I guess it is OK to fall into conservative side that the whole bpf_probe_read specialization is not needed and users are responsible to rewrite their code.

I agree, though here, we can actually implement the same behavior without dataTraverseStmtPre, by overriding TraverseStmt. RecursiveASTVisitor::dataTraverseStmtPre is just syntactic sugar. I'll take a stab at it this evening or tomorrow.

@pchaigno pchaigno force-pushed the skip-bpf_probe_read branch 2 times, most recently from 0f86ff3 to 6048c00 Compare June 12, 2018 16:33
20fb64c stops the whole AST traversal if it meets a bpf_probe_read call.  I
think the original intent was to simply not rewrite the third argument, so this
commit fixes it by remembering the third argument on bpf_probe_read call
traversals and overriding TraverseStmt to skip the traversal of that argument
when we meet it later.
@pchaigno pchaigno force-pushed the skip-bpf_probe_read branch from 6048c00 to c289d92 Compare June 12, 2018 16:58
@yonghong-song
Copy link
Collaborator

LGTM. Thanks!

@yonghong-song yonghong-song merged commit eebd485 into iovisor:master Jun 13, 2018
@pchaigno pchaigno deleted the skip-bpf_probe_read branch June 13, 2018 05:08
banh-gao pushed a commit to banh-gao/bcc that referenced this pull request Jun 21, 2018
20fb64c stops the whole AST traversal if it meets a bpf_probe_read call.  I
think the original intent was to simply not rewrite the third argument, so this
commit fixes it by remembering the third argument on bpf_probe_read call
traversals and overriding TraverseStmt to skip the traversal of that argument
when we meet it later.
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
20fb64c stops the whole AST traversal if it meets a bpf_probe_read call.  I
think the original intent was to simply not rewrite the third argument, so this
commit fixes it by remembering the third argument on bpf_probe_read call
traversals and overriding TraverseStmt to skip the traversal of that argument
when we meet it later.
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.

2 participants