Proposal Details
Hi fellow Gophers,
I didn't find any open (or closed) issues for this, so
on a journey to add "VRF support" to ping_exporter, I followed the bread crumbs through go-ping and go/x/net/icmp.ListenPacket() to go/net.PacketConn.
It looks like currently there is no way - at least none I could find - to do a SETSOCKOPT(SO_BINDTODEV) on the underlying fd of this connection, or more specifically, to get access to the underlying fd to do so.
After a bit of further digging I found change 72810: net: add ListenConfig, Dialer.Control to permit socket opts before listen/dial from 2018 (related to #9661), which adds some methods to create a net.PacketConn based on a ListenConfig which seems to be close what I'm looking for, however doesn't yield a icmp.PacketConn.
So I guess my proposal is to add something like
pkg icmp, method (*ListenConfig) ListenPacket(string, string) (*PacketConn, error)
to add feature parity to the net package.
Proposal Details
Hi fellow Gophers,
I didn't find any open (or closed) issues for this, so
on a journey to add "VRF support" to ping_exporter, I followed the bread crumbs through go-ping and go/x/net/icmp.ListenPacket() to go/net.PacketConn.
It looks like currently there is no way - at least none I could find - to do a
SETSOCKOPT(SO_BINDTODEV)on the underlyingfdof this connection, or more specifically, to get access to the underlyingfdto do so.After a bit of further digging I found change 72810: net: add ListenConfig, Dialer.Control to permit socket opts before listen/dial from 2018 (related to #9661), which adds some methods to create a
net.PacketConnbased on aListenConfigwhich seems to be close what I'm looking for, however doesn't yield aicmp.PacketConn.So I guess my proposal is to add something like
to add feature parity to the net package.