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

Add cBPF ops support to BpfFilter #909

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stffabi
Copy link
Contributor

@stffabi stffabi commented Sep 8, 2023

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.

@@ -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 {
Copy link
Collaborator

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:]),
}

Copy link
Collaborator

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")
}

Copy link
Collaborator

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

@aboch
Copy link
Collaborator

aboch commented Jul 3, 2024

@stffabi please resolve the conflict and address a couple of minor comemnts

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