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

Light refactoring of the TC attachment code #1466

Merged
merged 5 commits into from
Dec 17, 2024
Merged

Conversation

rafaelroquetto
Copy link
Contributor

This PR introduces a light refactoring of the TC attachment code, in order to enable it to be reused between the tracers and netolly. The key changes are:

  • Break WatchAndRegisterTC into multiple atomic functions, that allow them to be used by the netolly flow tracer
  • Parameterise the TC attachment handles and names
  • Use unique handles for different classes of TC programs, in order to avoid collisions with ourselves or third parties (such as cilium) - the handles follow the format 0xb31N.

Ideally I would have liked to collapse the code gap between the tracers and netolly even more, but that would entail a larger refactoring that requires further discussion, involving sharing the interface informers and registers, so that the interface name cache inside the registerer can be shared. I've thus opted for the pragmatic approach, which translates on sharing the core attachment, qdisc creation and cleanup code, as well as the main watcher loop.

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 70.21277% with 28 lines in your changes missing coverage. Please review.

Project coverage is 81.32%. Comparing base (5770689) to head (882f3e1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/internal/netolly/ebpf/tracer.go 57.14% 10 Missing and 5 partials ⚠️
pkg/internal/ebpf/common/tc_linux.go 72.34% 10 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1466      +/-   ##
==========================================
+ Coverage   81.11%   81.32%   +0.21%     
==========================================
  Files         149      149              
  Lines       15342    15253      -89     
==========================================
- Hits        12444    12404      -40     
+ Misses       2281     2244      -37     
+ Partials      617      605      -12     
Flag Coverage Δ
integration-test 59.77% <70.21%> (+0.07%) ⬆️
k8s-integration-test 60.73% <70.21%> (+0.10%) ⬆️
oats-test 34.02% <0.00%> (+0.19%) ⬆️
unittests 52.11% <2.12%> (+0.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

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

LGTM!

@rafaelroquetto rafaelroquetto merged commit f03e4f4 into main Dec 17, 2024
13 checks passed
@rafaelroquetto rafaelroquetto deleted the tc_api_refactor branch December 17, 2024 19:34
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