Ignore ENOPROTOOPT error when setting NETLINK_EXT_ACK to 0

This commit is contained in:
Hasan Mahmood 2022-04-01 18:53:53 -05:00 committed by Vish (Ishaya) Abrams
parent 5cb84e47ad
commit a7f10103f9
1 changed files with 7 additions and 1 deletions

View File

@ -798,7 +798,13 @@ func (s *NetlinkSocket) SetExtAck(enable bool) error {
enableN = 1
}
return unix.SetsockoptInt(int(s.fd), unix.SOL_NETLINK, unix.NETLINK_EXT_ACK, enableN)
var err error
if err = unix.SetsockoptInt(int(s.fd), unix.SOL_NETLINK, unix.NETLINK_EXT_ACK, enableN); err == unix.ENOPROTOOPT && !enable {
// older kernels may not support NETLINK_EXT_ACK
return nil
}
return err
}
func (s *NetlinkSocket) GetPid() (uint32, error) {