Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3054355ybi; Tue, 2 Jul 2019 01:14:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaB/6r4/T0ftjTL+IedOqvxUA/16yNP5u1b/K/cb7KYqvR8onpwS66gPa9IDBNoCDo1DRe X-Received: by 2002:a65:4489:: with SMTP id l9mr11763318pgq.207.1562055245962; Tue, 02 Jul 2019 01:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055245; cv=none; d=google.com; s=arc-20160816; b=ccJ4udrWr1l/iRL0deqteBmUQfpE69Px/Izll+HZYlJbMKqXi4Ez/QuI9KdDtKwMzJ MncI/S/NWLEbaNHocZleslON/q3EqbWbXgbpn5xxbZd3fr54p7c4Jh5lnpBPj4Wl/axW YGhcl72xD3QZ4jHvdKglA+OF8MRR612O1LwrOil3phfhMWcWv04oXksVapYuMLI8sqax Ty1q5kndoZKbZABInKla5oeSzzgDCEEdXl+nU0YMrk54l7drfaH9Vy7W0NFWPAIaQxAf ZA+CCEgRzUESxXwP1b4hdwGFkfHE2WZxVH8nSQRkDAyFAjcQsiLXDZYxuY1YGj0AxTkR Moog== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PjZHWtcekF/ogGlD/NgzDBb3TrlSepWd0O2YVn0LpMg=; b=PdlghEeuUreIX/FL2zZZ0txK3a0tsAsThDj2LNYwNHZofuNLIkwiX2VX7JWDYYVxEK FBBUBY0CqQp0gQ4NWCA/K+OOVBUVNeCg/f/txggoac/AR9vbeq2SPmtHieUl885V6kO9 czj4JrrPhdRQdGIVjxv/av/Bs7O2JXJJF+DwNQ+BU4AZN6H/ymljxJxegpg2I0GaxG+J 3LaJg201N+8TujAEjfnTru1YQISggzuMkkbBU/HMd+KMYmGL+ip5RxHSzbXKS1Up3DH5 7Tm46OXyW0iCip3EEMdNkcA1CfPn9jb6WPdF7i3lD+jB0c8gio1cpPuMp9sI1QBL4hYq tEkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GMnREkKW; 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 1si12865631ply.180.2019.07.02.01.13.51; Tue, 02 Jul 2019 01:14:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=GMnREkKW; 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 S1728277AbfGBINO (ORCPT + 99 others); Tue, 2 Jul 2019 04:13:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:55388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727503AbfGBIH5 (ORCPT ); Tue, 2 Jul 2019 04:07:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 77F922183F; Tue, 2 Jul 2019 08:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054877; bh=CfzKGISLy0baesUffpS+ZxMiRrjmZdabf2zmwiwTGiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GMnREkKWG2rCRf63EiFUjDoRRnSpsZVooy7P09Jp4PCeNr1unPQNDLDBddUFWnVVn niMc6vNh/m6eg8rsSB3iEO3BwHetZfaJdM/PUJwA4nPgbJQ+9r+nAywueepX9FffNr D+ZQCUr6I0QhCYXoN05pWKRJvx4EdpWEOTC/rGf4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fei Li , Jason Wang , "David S. Miller" Subject: [PATCH 4.19 61/72] tun: wake up waitqueues after IFF_UP is set Date: Tue, 2 Jul 2019 10:02:02 +0200 Message-Id: <20190702080127.788211875@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fei Li [ Upstream commit 72b319dc08b4924a29f5e2560ef6d966fa54c429 ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/tun.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1024,18 +1024,8 @@ static void tun_net_uninit(struct net_de /* Net device open. */ static int tun_net_open(struct net_device *dev) { - struct tun_struct *tun = netdev_priv(dev); - int i; - netif_tx_start_all_queues(dev); - for (i = 0; i < tun->numqueues; i++) { - struct tun_file *tfile; - - tfile = rtnl_dereference(tun->tfiles[i]); - tfile->socket.sk->sk_write_space(tfile->socket.sk); - } - return 0; } @@ -3443,6 +3433,7 @@ static int tun_device_event(struct notif { struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct tun_struct *tun = netdev_priv(dev); + int i; if (dev->rtnl_link_ops != &tun_link_ops) return NOTIFY_DONE; @@ -3452,6 +3443,14 @@ static int tun_device_event(struct notif if (tun_queue_resize(tun)) return NOTIFY_BAD; break; + case NETDEV_UP: + for (i = 0; i < tun->numqueues; i++) { + struct tun_file *tfile; + + tfile = rtnl_dereference(tun->tfiles[i]); + tfile->socket.sk->sk_write_space(tfile->socket.sk); + } + break; default: break; }