From patchwork Sun Mar 12 23:00:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hannes Frederic Sowa X-Patchwork-Id: 737900 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vhGgc4f1dz9s78 for ; Mon, 13 Mar 2017 10:00:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=stressinduktion.org header.i=@stressinduktion.org header.b="P7orEqcx"; dkim=pass (1024-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="PEYcIwoR"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935378AbdCLXAk (ORCPT ); Sun, 12 Mar 2017 19:00:40 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:57342 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933224AbdCLXAh (ORCPT ); Sun, 12 Mar 2017 19:00:37 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 8D9112084C; Sun, 12 Mar 2017 19:00:35 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Sun, 12 Mar 2017 19:00:35 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= stressinduktion.org; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=auWWOK5ORz+2vSw ZvF/lIFJIvIc=; b=P7orEqcxDU04JfAZ+Rfmvbe712lumUXhuX+PnPiIK+Ab2a5 NpZl0bSD44byQH+zOl04dJGhIIdq8XKfvJv9KaIM70bZO1ap3SMDbc2owC4taT5H EKBiu6PviMkzdz4dlCIuRGYD3GAOsFnQ3n9kpxaraC2kvCVXNtyfOaCmi2rU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=auWWOK5ORz+2vS wZvF/lIFJIvIc=; b=PEYcIwoRftqYxVVCYaRYZq5FRnBhGRN4t83y1JZEhegcsV METP4CgjIKfr9XGDzuyKEeBrT2jqvzGXmPD7G5IXACsm2WvNA0M+1NrWy2+i+YvD kZ/r5hdaWEWhvb7SXLUSV++CbJ0A6VE//YDDfvL3pH36r4PeSsorA01FdW0qY= X-ME-Sender: X-Sasl-enc: h17hxyV7513F77oP78ywe6uCbg40oCq7+mQ1vnUR36uq 1489359634 Received: from m.localhost.localhost (unknown [213.55.211.72]) by mail.messagingengine.com (Postfix) with ESMTPA id 39642240CF; Sun, 12 Mar 2017 19:00:32 -0400 (EDT) From: Hannes Frederic Sowa To: netdev@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B8rn=20Mork?= , Valdis Kletnieks , Jonas Lippuner , aszlig Subject: [PATCH net] tun: fix premature POLLOUT notification on tun devices Date: Mon, 13 Mar 2017 00:00:26 +0100 Message-Id: <20170312230026.4632-1-hannes@stressinduktion.org> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org aszlig observed failing ssh tunnels (-w) during initialization since commit cc9da6cc4f56e0 ("ipv6: addrconf: use stable address generator for ARPHRD_NONE"). We already had reports that the mentioned commit breaks Juniper VPN connections. I can't clearly say that the Juniper VPN client has the same problem, but it is worth a try to hint to this patch. Because of the early generation of link local addresses, the kernel now can start asking for routers on the local subnet much earlier than usual. Those router solicitation packets arrive inside the ssh channels and should be transmitted to the tun fd before the configuration scripts might have upped the interface and made it ready for transmission. ssh polls on the interface and receives back a POLL_OUT. It tries to send the earily router solicitation packet to the tun interface. Unfortunately it hasn't been up'ed yet by config scripts, thus failing with -EIO. ssh doesn't retry again and considers the tun interface broken forever. Link: https://bugzilla.kernel.org/show_bug.cgi?id=121131 Fixes: cc9da6cc4f56 ("ipv6: addrconf: use stable address generator for ARPHRD_NONE") Cc: Bjørn Mork Reported-by: Valdis Kletnieks Cc: Valdis Kletnieks Reported-by: Jonas Lippuner Cc: Jonas Lippuner Reported-by: aszlig Cc: aszlig Signed-off-by: Hannes Frederic Sowa --- drivers/net/tun.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index f58b7d850114b0..34cc3c590aa5c5 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -822,7 +822,18 @@ static void tun_net_uninit(struct net_device *dev) /* 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; } @@ -1103,9 +1114,10 @@ static unsigned int tun_chr_poll(struct file *file, poll_table *wait) if (!skb_array_empty(&tfile->tx_array)) mask |= POLLIN | POLLRDNORM; - if (sock_writeable(sk) || - (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) && - sock_writeable(sk))) + if (tun->dev->flags & IFF_UP && + (sock_writeable(sk) || + (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) && + sock_writeable(sk)))) mask |= POLLOUT | POLLWRNORM; if (tun->dev->reg_state != NETREG_REGISTERED)