From add4a8a81406207df84ee856c346bbd13c0f54ae Mon Sep 17 00:00:00 2001 From: Sylvain Afchain Date: Thu, 5 Nov 2015 10:57:17 +0100 Subject: [PATCH] Add an accessor to the fd of the netlink socket Giving a such access could be usefull in order to use the socket in a non-blocking way. This is especially useful when using it in a network namespace since the namespace can be deleted and one can be blocked in a Receive operation. --- nl/nl_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nl/nl_linux.go b/nl/nl_linux.go index 8dbd92b..ef13120 100644 --- a/nl/nl_linux.go +++ b/nl/nl_linux.go @@ -323,6 +323,10 @@ func (s *NetlinkSocket) Close() { syscall.Close(s.fd) } +func (s *NetlinkSocket) GetFd() int { + return s.fd +} + func (s *NetlinkSocket) Send(request *NetlinkRequest) error { if err := syscall.Sendto(s.fd, request.Serialize(), 0, &s.lsa); err != nil { return err