netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Toralf Förster" <toralf.foerster@gmx.de>,
	netdev@vger.kernel.org,
	"Linux Kernel" <linux-kernel@vger.kernel.org>,
	"David Miller" <davem@davemloft.net>
Subject: Re: [PATCHv2] tun: fix carrier on/off status
Date: Mon, 28 Jan 2013 19:00:20 +0800	[thread overview]
Message-ID: <51065A44.10401@redhat.com> (raw)
In-Reply-To: <20130128103801.GA6648@redhat.com>

On 01/28/2013 06:38 PM, Michael S. Tsirkin wrote:
> Commit c8d68e6be1c3b242f1c598595830890b65cea64a removed carrier off call
> from tun_detach since it's now called on queue disable and not only on
> tun close.  This confuses userspace which used this flag to detect a
> free tun. To fix, put this back but under if (clean).
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ---
>
> Changes from v1:
> 	Don't set carrier off unless all queues are closed.
>
> Note: didn't test in MQ mode - Jason, care checking this does the
> right thing there?

Tested-by: Jason Wang <jasowang@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index af372d0..06b2723 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -434,10 +434,13 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
>  	}
>  
>  	if (clean) {
> -		if (tun && tun->numqueues == 0 && tun->numdisabled == 0 &&
> -		    !(tun->flags & TUN_PERSIST))
> -			if (tun->dev->reg_state == NETREG_REGISTERED)
> +		if (tun && tun->numqueues == 0 && tun->numdisabled == 0) {
> +			netif_carrier_off(tun->dev);
> +
> +			if (!(tun->flags & TUN_PERSIST) &&
> +			    tun->dev->reg_state == NETREG_REGISTERED)
>  				unregister_netdevice(tun->dev);
> +		}
>  
>  		BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED,
>  				 &tfile->socket.flags));
> @@ -1644,10 +1647,10 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
>  		    device_create_file(&tun->dev->dev, &dev_attr_owner) ||
>  		    device_create_file(&tun->dev->dev, &dev_attr_group))
>  			pr_err("Failed to create tun sysfs files\n");
> -
> -		netif_carrier_on(tun->dev);
>  	}
>  
> +	netif_carrier_on(tun->dev);
> +
>  	tun_debug(KERN_INFO, tun, "tun_set_iff\n");
>  
>  	if (ifr->ifr_flags & IFF_NO_PI)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2013-01-28 11:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-26 10:29 How to find an unused TAP device with kernel 3.8 ? Toralf Förster
2013-01-28  9:38 ` Jason Wang
2013-01-28 10:11   ` [PATCH] tun: fix carrier on/off status Michael S. Tsirkin
2013-01-28 10:38     ` [PATCHv2] " Michael S. Tsirkin
2013-01-28 11:00       ` Jason Wang [this message]
2013-01-28 19:38       ` Toralf Förster
2013-01-29 20:45       ` David Miller
2013-02-02 10:27       ` Toralf Förster

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=51065A44.10401@redhat.com \
    --to=jasowang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=toralf.foerster@gmx.de \
    /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).