-
Notifications
You must be signed in to change notification settings - Fork 18k
x/net/bpf: add Setter interface #19912
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
Comments
Given that this interface is already implemented by x/net/ipv4 and x/net/ipv6, it seems fine to add the interface definition too. Any thoughts, @danderson, @mikioh? |
I'll leave it up to @danderson. |
ping @danderson |
The interface definition seems fine, however: what benefit does it provide? I don't understand what benefit this definition provides, given that the package itself doesn't make use of it. My first instinct is that this is an attempt to define a java-style interface that other packages can What am I missing? |
To be clear: if the intent is just to try and steer implementors to standardize on using that method signature to attach BPF programs, sure, I'm happy to go along with it. It just makes me feel a bit strange to have a package define an interface exclusively as a "serving suggestion" for other packages. If I'm alone in feeling weird about that, then definitely let's do it :) |
Hmmm, not sure how I missed this notification, sorry!
That's exactly it. Think of it like the interfaces defined in: https://golang.org/pkg/encoding/. |
CL https://golang.org/cl/44972 mentions this issue. |
@danderson, OK to accept this proposal? |
LGTM, ship it. |
In order to standardize BPF filter attachment in Go, I propose an interface which mimics the most popular signature used in the wild:
I believe this pattern was first used in
x/net/ipv{4,6}
:https://godoc.org/golang.org/x/net/ipv4#PacketConn.SetBPF
https://godoc.org/golang.org/x/net/ipv6#PacketConn.SetBPF
I've used it in a couple of my own repositories as well:
https://godoc.org/github.com/mdlayher/raw#Conn.SetBPF
https://godoc.org/github.com/mdlayher/netlink#Conn.SetBPF
Finally, on at least two occasions, I have defined an unexported interface that contains a method using this proposed interface:
https://github.com/coreos/torus/blob/master/block/aoe/aoe.go#L106-L111
https://github.com/mdlayher/netlink/blob/master/conn.go#L230-L234
For simplicity and standardization, I'd like to add the proposed interface to
x/net/bpf
's API, in order to ensure consistency between types that can attach a BPF filter to themselves./cc @danderson, @mikioh, @breml
The text was updated successfully, but these errors were encountered: