Skip to content

proposal: x/net/icmp: allow setting socket options on PacketConn #64382

Description

@BarbarossaTM

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions