netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Do not listen if rtnl_send() fails in ip link iplink_have_newlink() test
@ 2013-12-11 13:01 Petr Písař
  2013-12-11 18:57 ` Stephen Hemminger
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Písař @ 2013-12-11 13:01 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, Petr Písař

If rtnl_send() fails in iplink_have_newlink() test, listening for
response will result in indefinite hang. This can be demonstrated by
"ip link show" while SELinux preventing from sending the RTM_NEWLINK
over netlink.

This patch checks for the return value as is done at all other
rtnl_send() calls.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 ip/iplink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/iplink.c b/ip/iplink.c
index 58b6c20..f7d9e17 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -178,8 +178,8 @@ static int iplink_have_newlink(void)
 		req.n.nlmsg_type = RTM_NEWLINK;
 		req.i.ifi_family = AF_UNSPEC;
 
-		rtnl_send(&rth, &req.n, req.n.nlmsg_len);
-		rtnl_listen(&rth, accept_msg, NULL);
+		if (rtnl_send(&rth, &req.n, req.n.nlmsg_len) >= 0)
+			rtnl_listen(&rth, accept_msg, NULL);
 	}
 	return have_rtnl_newlink;
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-03 20:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11 13:01 [PATCH] Do not listen if rtnl_send() fails in ip link iplink_have_newlink() test Petr Písař
2013-12-11 18:57 ` Stephen Hemminger
2013-12-12  7:18   ` Petr Písař
2013-12-20 16:21     ` Stephen Hemminger
2014-01-02  7:42       ` Petr Pisar
2014-01-03 20:36         ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).