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

[kprobe] add support for kprobes #33

Merged
merged 13 commits into from
Jul 24, 2020
Merged

[kprobe] add support for kprobes #33

merged 13 commits into from
Jul 24, 2020

Conversation

jcramb
Copy link
Contributor

@jcramb jcramb commented Jun 3, 2020

Initial support for kprobes with exec_dump example.

@auto-assign auto-assign bot requested review from belyalov, piscesdk and veshij June 3, 2020 07:59
@jcramb jcramb marked this pull request as draft June 3, 2020 08:08
@codecov
Copy link

codecov bot commented Jun 3, 2020

Codecov Report

Merging #33 into master will decrease coverage by 2.89%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
- Coverage   20.34%   17.44%   -2.90%     
==========================================
  Files          14       15       +1     
  Lines        1170     1364     +194     
==========================================
  Hits          238      238              
- Misses        918     1112     +194     
  Partials       14       14              
Impacted Files Coverage Δ
ebpf.go 0.00% <ø> (ø)
goebpf_mock/mock_prog.go 13.33% <0.00%> (-0.96%) ⬇️
loader.go 7.17% <0.00%> (-0.43%) ⬇️
perf_events.go 0.00% <0.00%> (ø)
perf_events_handler.go 8.00% <0.00%> (ø)
program_base.go 0.00% <0.00%> (ø)
program_kprobe.go 0.00% <0.00%> (ø)
program_socket_filter.go 0.00% <0.00%> (ø)
program_xdp.go 0.00% <0.00%> (ø)
utils.go 41.80% <0.00%> (-1.22%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6cc432...f7cebdf. Read the comment docs.

@jcramb jcramb marked this pull request as ready for review June 3, 2020 20:13
pe.handlers = make([]*perfEventHandler, nCpus)
for cpu := 0; cpu < nCpus; cpu++ {
handler, err := newPerfEventHandler(cpu, -1, bufferSize) // All processes
handler, err = newPerfEventHandler(cpu, -1, bufferSize) // All processes
Copy link
Contributor

Choose a reason for hiding this comment

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

What was wrong with := ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was shadowing the err variable from outside the loop which then broke the error handling which relies on it checking the value of err after the loop exits.

ebpf.go Outdated
@@ -35,6 +35,8 @@ type Program interface {
Detach() error
// Returns program name as it defined in C code
GetName() string
// Returns program target symbol as defined in the section name e.g. kprobe/SyS_execve
GetTarget() string
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe GetNameExtras or similar to make it kinda generic and possibly reusable for future types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed this to be more generically applicable as GetSection to return the section name used for the program.

Copy link
Contributor

@belyalov belyalov left a comment

Choose a reason for hiding this comment

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

Getting close! :)

Few action items:

  • Revert format for bpf_helpers.h?
  • Add at least basic documentation to doc.go?
  • Update readme with super simple example?
  • Update readme under examples directory?

jcramb added 3 commits July 23, 2020 13:43
	- added simple example to README.md
	- added basic info to doc.go
	- updated examples/README.md
	- updated BaseProgram usage to be by value
	- improved kprobe code comments and godoc
	- increased timeout from 1 to 3 seconds for unit test
@jcramb
Copy link
Contributor Author

jcramb commented Jul 23, 2020

Build is succeeding on tip but seems to be running into an issue with testify on older go versions - you had any experience with this before?

@belyalov
Copy link
Contributor

hmm, interesting, let me check it as well

@belyalov
Copy link
Contributor

Now all version passes.. :)

Konstantin Belyalov and others added 2 commits July 24, 2020 00:43
Copy link
Contributor

@belyalov belyalov left a comment

Choose a reason for hiding this comment

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

Great job! :)

@belyalov belyalov merged commit c30f689 into dropbox:master Jul 24, 2020
bersoare pushed a commit to bersoare/goebpf that referenced this pull request Apr 15, 2021
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