netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Pisar <ppisar@redhat.com>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH] Do not listen if rtnl_send() fails in ip link iplink_have_newlink() test
Date: Thu, 2 Jan 2014 08:42:57 +0100	[thread overview]
Message-ID: <20140102074257.GA1637@dhcp-0-146.brq.redhat.com> (raw)
In-Reply-To: <20131220082107.0467d57c@nehalam.linuxnetplumber.net>

[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]

On Fri, Dec 20, 2013 at 08:21:07AM -0800, Stephen Hemminger wrote:
> I took your idea and enhanced it to all of iproute2 by doing the following:
> 
> From c4b6330a3a033bd9c9b0664c5f844493137ae599 Mon Sep 17 00:00:00 2001
> From: Stephen Hemminger <stephen@networkplumber.org>
> Date: Fri, 20 Dec 2013 08:15:02 -0800
> Subject: [PATCH] check return value of rtnl_send and related functions
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> Use warn_unused_result to enforce checking return value of rtnl_send,
> and fix where the errors are.
> 
[...]
> diff --git a/ip/iplink.c b/ip/iplink.c
> index 58b6c20..e0c14e6 100644
> --- a/ip/iplink.c
> +++ b/ip/iplink.c
> @@ -178,7 +178,10 @@ 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);
> +		if (rtnl_send(&rth, &req.n, req.n.nlmsg_len) < 0) {
> +			perror("request send failed");
> +			exit(1);
> +		}
>  		rtnl_listen(&rth, accept_msg, NULL);
>  	}
>  	return have_rtnl_newlink;

This one exits instead of falling back to IOCTL. iplink_have_newlink() is
called even from iplink_usage(). This even prevents from printing usage.

I think failure in this very place should be treated as I suggested.

-- Petr

[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]

  reply	other threads:[~2014-01-02  7:43 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ř
2013-12-20 16:21     ` Stephen Hemminger
2014-01-02  7:42       ` Petr Pisar [this message]
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=20140102074257.GA1637@dhcp-0-146.brq.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).