From 8f828bbe3c22e1f0406d4d6d9e8c18afb690d931 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Fri, 20 Apr 2018 12:40:25 -0700 Subject: [PATCH] uevent: Fix netlink error while assigning pid in netlink client unix.SockaddrNetlink represents a netlink client with the Pid being the netlink socket address. This can be assigned the actual pid of the process, but in case we have two netlink sockets opened at the same time, this results in errors in binding to the netlink socket. Assign this to zero which means the kernel takes care of assigning it. See http://man7.org/linux/man-pages/man7/netlink.7.html Fixes #216 Signed-off-by: Archana Shinde --- pkg/uevent/uevent.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/uevent/uevent.go b/pkg/uevent/uevent.go index 9ea6eda158..1904f8795d 100644 --- a/pkg/uevent/uevent.go +++ b/pkg/uevent/uevent.go @@ -9,7 +9,6 @@ package uevent import ( "bufio" "io" - "os" "strings" "golang.org/x/sys/unix" @@ -35,7 +34,9 @@ type ReaderCloser struct { func NewReaderCloser() (io.ReadCloser, error) { nl := unix.SockaddrNetlink{ Family: unix.AF_NETLINK, - Pid: uint32(os.Getpid()), + // Passing Pid as 0 here allows the kernel to take care of assigning + // it. This allows multiple netlink sockets to be used. + Pid: uint32(0), Groups: 1, }