-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support context extensions #495
Conversation
51184a3
to
3f4b1cc
Compare
I find this quite clever and nice for many reasons! But I have some concerns:
Point 2 could be worked out by letting collectors install context hook even if not enabled (there's a slight subtility to get right wrt. the compatibility check collectors make — e.g. not loading the context probe in case the Point 3 can be easily improved by moving the logic to be inside the collectors. This even raises the question to extend this to all types and let the collectors provide type offsets themselves (extending the logic added here wrt. the getters Retis provides). Point 1 is more tricky. Context hooks should be added to the right list of probes (user defined, collector defined and core defined). Also multiple collectors could add a context hook to the same probe. I don't really see a problem with the later (a collector operates on his own types). For the former, maybe context hooks should be added to all probes. Or collectors should be able to inspect all probes after all are initialized? Another way of seeing this would be context hooks are a nice addition for providing a way to do a really specialized thing that only applies to a specific probe; but that doesn't apply to indirect accesses of well known types and here for the |
Maybe we could have some built-in ctx "hooks" (they would not be hooks anymore) and them a way to freplace a custom one for collector-driven probes?
Probes with
But it's not in the core anymore, is it? It lives in the nft collector.
I think I agree. As I suggested above, we could have a built-in indirect-based skb extraction logic (only outside of retis_get_sk_buff), plus a custom hook. |
I think doing
The offsets are, in
I'm not sure to get the "only outside of retis_get_sk_buff" part. Except that, if I think I agree. Let me rephrase to be sure: we would keep the indirect access logic for common objects in the core and add context hooks (on targeted probes only) for specialized handling (here providing access to an skb ojbect from a specific ovs probe so that retis_get_sk_buff is aware of it upon later calls)? |
Ok, now I get what you were referring to.
What I mean is: remove the part of
|
Side note: I have a plan to make this completely generic; it's just low priority.
So we would make:
Right? That's fine IMO. I think (without having a look at the code) a clean way to handle indirections would be to add extra registers (after |
Yes.
Yest, that's a nice idea. I'll give it a try |
Note this does not work today. |
Nice finding. We should probably extend the collector known args with known indirections. E.g. if a collector knows |
Even so, I think it would still not work given the current implementation of indirection. It is very much focused on |
3f4b1cc
to
a444914
Compare
Right, this should be handled too; as part of another effort to add common indirections. |
Yes, it was, mostly because there was no plan/reason to support anything other than what was required to implement rule tracing. |
a444914
to
96ab00f
Compare
96ab00f
to
d167071
Compare
The dynamic version of the context extension (ctx hooks) used in #493 |
d167071
to
1fc66d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good, I guess you can remove "WIP" from the PR title.
Ctx extensions allows extending the retis ctx in manual ways. For example, by having a custom indirection logic to find the skb. These extensions are run before filtering and are available to all probes. However, collectors can implement their own logic to extend the ctx via ctx_hooks. Signed-off-by: Adrian Moreno <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
The retis context contains enough information to access common types such as the
sk_buff
pointer.Sometimes this information cannot be easily available through the probe's arguments. In such cases, the context needs to be dynamically extended.
Well known types to
sk_buff
indirection can be implemented in the core so that it can be used in generic probes. However, this might be insufficient for some specific probes, for which a freplaced hook is available.Note the hook is currently unused, the first user will be #493