Skip to content

Commit

Permalink
fix: check nlmsghdr flags for interrupt
Browse files Browse the repository at this point in the history
fail if NLM_F_DUMP_INTR flag is set

Signed-off-by: adrianc <adrianc@nvidia.com>
  • Loading branch information
adrianchiris authored and aboch committed Nov 12, 2023
1 parent 77df5d3 commit aa4f20d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions nl/nl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit aa4f20d

Please sign in to comment.