From: "Petr Písař" <ppisar@redhat.com>
To: <netdev@vger.kernel.org>
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
"Petr Písař" <ppisar@redhat.com>
Subject: [PATCH] Do not listen if rtnl_send() fails in ip link iplink_have_newlink() test
Date: Thu, 12 Dec 2013 08:18:25 +0100 [thread overview]
Message-ID: <1386832705-3101-1-git-send-email-ppisar@redhat.com> (raw)
In-Reply-To: <20131211105749.1ee87844@nehalam.linuxnetplumber.net>
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. It falls back to IOCTL in case of failure.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
ip/iplink.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index 58b6c20..5132868 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -178,8 +178,13 @@ 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) {
+ perror("Could not check for "
+ "link configuration over netlink support");
+ have_rtnl_newlink = 0;
+ } else {
+ rtnl_listen(&rth, accept_msg, NULL);
+ }
}
return have_rtnl_newlink;
}
--
1.8.3.1
next prev parent reply other threads:[~2013-12-12 7:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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ř [this message]
2013-12-20 16:21 ` Stephen Hemminger
2014-01-02 7:42 ` Petr Pisar
2014-01-03 20:36 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386832705-3101-1-git-send-email-ppisar@redhat.com \
--to=ppisar@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).