mirror of https://github.com/vishvananda/netlink
Add SetStrictCheck() method to NetlinkHandle
Allows the ability to set NETLINK_GET_STRICT_CHK socket option on netlink handles. This can be used to avoid missing routes due to a kernel bug[1]. The choice to make this a toggle is because not all operations use the correctly formatted message and so some will fail. The scope of determining which calls use the wrong message format is an unknown amount of work at this time so we give the consumer of the library a toggle they can use when needed. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=885b8b4dbba5ca6114db0fcd0737fe2512650745
This commit is contained in:
parent
657c30750a
commit
8f52b0b093
|
@ -107,6 +107,21 @@ func (h *Handle) GetSocketReceiveBufferSize() ([]int, error) {
|
|||
return results, nil
|
||||
}
|
||||
|
||||
// SetStrictCheck sets the strict check socket option for each socket in the netlink handle. Returns early if any set operation fails
|
||||
func (h *Handle) SetStrictCheck(state bool) error {
|
||||
for _, sh := range h.sockets {
|
||||
var stateInt int = 0
|
||||
if state {
|
||||
stateInt = 1
|
||||
}
|
||||
err := unix.SetsockoptInt(sh.Socket.GetFd(), unix.SOL_NETLINK, unix.NETLINK_GET_STRICT_CHK, stateInt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewHandleAt returns a netlink handle on the network namespace
|
||||
// specified by ns. If ns=netns.None(), current network namespace
|
||||
// will be assumed
|
||||
|
|
Loading…
Reference in New Issue