rtnetlink: expose Conn.SetOption from underlying netlink.Conn (#123)

Signed-off-by: Matt Layher <mdlayher@gmail.com>

Co-authored-by: Jeroen Simonetti <jsimonetti@users.noreply.github.com>
This commit is contained in:
Matt Layher 2021-07-14 07:25:21 -06:00 committed by GitHub
parent f05e8793e9
commit 5ecc0c63ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -27,6 +27,7 @@ type conn interface {
Send(m netlink.Message) (netlink.Message, error)
Receive() ([]netlink.Message, error)
Execute(m netlink.Message) ([]netlink.Message, error)
SetOption(option netlink.ConnOption, enable bool) error
SetReadDeadline(t time.Time) error
}
@ -62,6 +63,11 @@ func (c *Conn) Close() error {
return c.c.Close()
}
// SetOption enables or disables a netlink socket option for the Conn.
func (c *Conn) SetOption(option netlink.ConnOption, enable bool) error {
return c.c.SetOption(option, enable)
}
// SetReadDeadline sets the read deadline associated with the connection.
func (c *Conn) SetReadDeadline(t time.Time) error {
return c.c.SetReadDeadline(t)

View File

@ -211,6 +211,7 @@ func (c *noopConn) Close() error { retur
func (c *noopConn) Send(_ netlink.Message) (netlink.Message, error) { return netlink.Message{}, nil }
func (c *noopConn) Receive() ([]netlink.Message, error) { return nil, nil }
func (c *noopConn) Execute(m netlink.Message) ([]netlink.Message, error) { return nil, nil }
func (c *noopConn) SetOption(_ netlink.ConnOption, _ bool) error { return nil }
func (c *noopConn) SetReadDeadline(t time.Time) error { return nil }
func mustMarshal(m encoding.BinaryMarshaler) []byte {