From aa4f20db57d498a8db66aaa202ddae15c1fa81a5 Mon Sep 17 00:00:00 2001 From: adrianc Date: Sun, 12 Nov 2023 16:18:23 +0200 Subject: [PATCH] fix: check nlmsghdr flags for interrupt fail if NLM_F_DUMP_INTR flag is set Signed-off-by: adrianc --- nl/nl_linux.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/nl/nl_linux.go b/nl/nl_linux.go index 663ae48d..ff9e5cf3 100644 --- a/nl/nl_linux.go +++ b/nl/nl_linux.go @@ -559,6 +559,11 @@ done: if m.Header.Pid != pid { continue } + + if m.Header.Flags&unix.NLM_F_DUMP_INTR != 0 { + return nil, syscall.Errno(unix.EINTR) + } + if m.Header.Type == unix.NLMSG_DONE || m.Header.Type == unix.NLMSG_ERROR { native := NativeEndian() errno := int32(native.Uint32(m.Data[0:4])) @@ -661,12 +666,14 @@ func GetNetlinkSocketAt(newNs, curNs netns.NsHandle, protocol int) (*NetlinkSock // In case of success, the caller is expected to execute the returned function // at the end of the code that needs to be executed in the network namespace. // Example: -// func jobAt(...) error { -// d, err := executeInNetns(...) -// if err != nil { return err} -// defer d() -// < code which needs to be executed in specific netns> -// } +// +// func jobAt(...) error { +// d, err := executeInNetns(...) +// if err != nil { return err} +// defer d() +// < code which needs to be executed in specific netns> +// } +// // TODO: his function probably belongs to netns pkg. func executeInNetns(newNs, curNs netns.NsHandle) (func(), error) { var (