Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4052846ybi; Tue, 18 Jun 2019 10:56:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVCRLzVrYi0QtB56gogkQJLOH6+lPiarL9EsSuTr2XcIcfdMlMcO1fFaMWQ4mHvN1QtqAK X-Received: by 2002:a62:e119:: with SMTP id q25mr84961416pfh.148.1560880586201; Tue, 18 Jun 2019 10:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560880586; cv=none; d=google.com; s=arc-20160816; b=M4qvALy6tz8dTNicBy+z0fa8yyDgTD2nqoyB/ao5xVv/KmKNctaICBsfYfaShhxs8+ h2A/ChoYN/tnLH1+fU5qEEBdTKneUG/RLRy4oxNlE4KkVNQShRZX4fE75CmNnAfemjB8 r2LXwlomN/hbkoRVmEcp0oMXQy28Q2e4J1r9qFLV2jC2pHT8mmK9o182qlj4Wg25a+Ak /rn3W8Ndf3aXpZWjSStvd1dDtoalhBZJH/Px2oD25DtsneBdbhEXOARG24IpCTCVAHeC xmxPjKAhSLGDZrEcDS2SIWLF2oVNqaq/vjwKSvhP4yw800oc0r8oKxEd8av/kliPud2M +WSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=zPZab/o6LN5pOGRa86C9C+Kc0BP+6aDY7/3neP8UVdQ=; b=eLS0v05SHWd+n40XZV0fOAo6rLSpvCJ0bPOWtsIDSyDsxNvfmGRa/QkYH/kzVDO4XV EybivnXw2Rki7wDv+M65AJtRRwOVQXOH6rC9RYQKNlcJY4eD2eTBwG9cS7OSe5/t3k1K kEYsPC/unUeMj/l76UFG50SpwSppLiMPdnunuT6bTQ4DQ6kxxiMaBn4xKWawaX72t/As yGlbE5Gt9xGWCwE1SajgCO3MZzF7a/V3er4c3YWoNBfc610+5Zw8ytCn/t4u/Hg3ayte 6l/pZGIoX7gwlKGI49rfjBDPJ8N12P+rnPZXZLuPknYD33nRNywgi+WF8Mx6FxWgGQOi +5cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h96si13670700plb.281.2019.06.18.10.56.11; Tue, 18 Jun 2019 10:56:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730226AbfFRRzu (ORCPT + 99 others); Tue, 18 Jun 2019 13:55:50 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:51006 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729285AbfFRRzt (ORCPT ); Tue, 18 Jun 2019 13:55:49 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id B00C21510A308; Tue, 18 Jun 2019 10:55:48 -0700 (PDT) Date: Tue, 18 Jun 2019 10:55:48 -0700 (PDT) Message-Id: <20190618.105548.2200622033433520074.davem@davemloft.net> To: lifei.shirley@bytedance.com Cc: jasowang@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, zhengfeiran@bytedance.com, duanxiongchun@bytedance.com Subject: Re: [PATCH net v2] tun: wake up waitqueues after IFF_UP is set From: David Miller In-Reply-To: <20190617132636.72496-1-lifei.shirley@bytedance.com> References: <20190617132636.72496-1-lifei.shirley@bytedance.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 18 Jun 2019 10:55:48 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fei Li Date: Mon, 17 Jun 2019 21:26:36 +0800 > Currently after setting tap0 link up, the tun code wakes tx/rx waited > queues up in tun_net_open() when .ndo_open() is called, however the > IFF_UP flag has not been set yet. If there's already a wait queue, it > would fail to transmit when checking the IFF_UP flag in tun_sendmsg(). > Then the saving vhost_poll_start() will add the wq into wqh until it > is waken up again. Although this works when IFF_UP flag has been set > when tun_chr_poll detects; this is not true if IFF_UP flag has not > been set at that time. Sadly the latter case is a fatal error, as > the wq will never be waken up in future unless later manually > setting link up on purpose. > > Fix this by moving the wakeup process into the NETDEV_UP event > notifying process, this makes sure IFF_UP has been set before all > waited queues been waken up. > > Signed-off-by: Fei Li > Acked-by: Jason Wang Applied and queued up for -stable, thanks.