From a7f10103f94d2b4814dbd397208bf289490af40d Mon Sep 17 00:00:00 2001 From: Hasan Mahmood Date: Fri, 1 Apr 2022 18:53:53 -0500 Subject: [PATCH] Ignore ENOPROTOOPT error when setting NETLINK_EXT_ACK to 0 --- nl/nl_linux.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nl/nl_linux.go b/nl/nl_linux.go index 20ea144..9db1eca 100644 --- a/nl/nl_linux.go +++ b/nl/nl_linux.go @@ -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) {