-
Notifications
You must be signed in to change notification settings - Fork 751
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
Add cBPF ops support to BpfFilter #909
base: main
Are you sure you want to change the base?
Conversation
479949c
to
4f2580e
Compare
@@ -1039,3 +1066,42 @@ func SerializeRtab(rtab [256]uint32) []byte { | |||
_ = binary.Write(&w, native, rtab) | |||
return w.Bytes() | |||
} | |||
|
|||
func deserializeSockFilter(opsLen uint16, ops []byte) ([]SockFilter, error) { | |||
if excp := int(opsLen) * 8; len(ops) != excp { |
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.
Why do we need to define this excp
inside this if
?
I do not think it gives us much compared to
if len(ops) != 8*opsLen {
[...]", len(ops), 8*opsLen)
}
Jf: ops[3], | ||
K: native.Uint32(ops[4:]), | ||
} | ||
|
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.
maybe remove this blank line
if filter.Fd >= 0 { | ||
return fmt.Errorf("only Ops or Fd can be specified on a BpfFilter") | ||
} | ||
|
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.
pls remove the blank line
@stffabi please resolve the conflict and address a couple of minor comemnts |
This PR makes it possible to use classic BPF programs to be applied to a BPF Filter, without the need to load a eBPF program.