-
Notifications
You must be signed in to change notification settings - Fork 18k
Proposal: x/net/ethernet: new package for ethernet sockets #15985
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
/cc @mikioh |
Ping, @mikioh . |
Thank you for your proposal. A few random thoughts.
A simple question: What's the reason why we need to provide RawConn on Linux? |
I'd be okay with making this package called
I'm not familiar with Netmap or DPDK, but perhaps they could be cleanly integrated into this package at some point too.
Sure, but what type of options would need to be configured? Would this be things like the ability to set the socket to nonblocking, or change the direction of traffic to capture using BPF?
Maybe we don't. My intention for the |
I think that providing separated datalink IO and datalink wire-format/coding packages makes sense. Because the former needs to work on abstraction of various kernel system calls and data types, and the latter should take a burden of various wire-formats/codings come from IEEE wildcats. For example,
For the package that provides Ethernet encoding/decoding functionality, all of us know a variety of MAC/LLC sublayers from DIX/dot3 through dot22, and dot1 higher layers including MAC bridging through congestion notification. Ah, I have no strong opinion on it. Probably we can use github.com/google/gopacket package.
There are a few options that should be configured before calling bind on AF_PACKET sockets, I guess. |
Assigning to @mikioh to make a decision. |
I just found this proposal because I was searching for a way to read and emit raw ethernet frames in Go. My intended project is a "universal auto-join" tool which is used in security testing settings to join any network, regardless of configuration (presence of DHCP, MAC filtering, etc). I need to have direct access to raw frames for this project to do things like packet sniffing, ARP spoofing, manually speaking DHCP, etc. |
@joshlf as an interim solution, you can use my packages: |
@mdlayher Thanks, I will :) While we're on the subject - if this proposal ends up getting adopted, I'd suggest two additions from your
|
Hey @mikioh : package datalink
type PacketConn struct { /* TBD */ } // implements net.PacketConn interface and a few fancy datalink IO specific methods
type Listener struct {} // or Datalink or Config or something else
func (ln Listener) Listen(ifi *net.Inteface) (PacketConn, error) ^ I'd be happy to look into implementing your proposed API here for a Looks like it's up to you to accept the proposal, if I understand the process correctly. We can leave ethernet and things that run on top of |
func (ln Listener) Listen(ifi *net.Inteface) (PacketConn, error) Why have a |
The |
@freddierice That's a good point; I suppose if you had a top-level |
On hold for #17244. |
At this point in time, I don't think it's necessary for this functionality to live under x/net; especially since it isn't needed in the standard library or similar. I'd be okay with closing this out, unless there are strong objections to doing so. |
Punch it, please! |
At this time, no official
x/net
package is available to create and use ethernet sockets in Go. I have written a couple of packages which can be used for this purpose, but I'd like to try to create anx/net/ethernet
package as an official Gox/net
subproject.My packages can be found at:
Ethernet sockets are useful for low-level networking applications like ARP, LLDP, ATA over Ethernet, and a wide variety of other networking protocols. This package would make use of Linux's raw sockets and the BSD family's BPF to enable this functionality, and I already have working examples for these operating systems in my
raw
package. Adding support for other operating systems should be possible over time, but I have no personal experience working with ethernet sockets outside of Linux and BSD.The proposed API could look something like:
I am curious if 802.11Q VLAN tags should be included in this package. In general, the operating system seamlessly handles adding and removing VLAN tags as needed, so it may not be necessary, but could also be nice to have.
In addition, since the runtime network poller is not accessible outside of package
net
at the moment, theSetDeadline
methods may just return an error until implemented later. See my other proposal at #15984 .If implemented, this package would fix #8432.
Thanks for your time, and please feel free to ask for clarification if needed.
The text was updated successfully, but these errors were encountered: