Received: by 10.223.176.46 with SMTP id f43csp2287882wra; Thu, 25 Jan 2018 07:40:52 -0800 (PST) X-Google-Smtp-Source: AH8x226xlLhz45LC8xTF6TnqvUPBvj29tC1ceYHFMzgQpLKHkd4ai6oOKEy2XvpqWQZttz7qJH/h X-Received: by 2002:a17:902:59ce:: with SMTP id d14-v6mr11534387plj.36.1516894852759; Thu, 25 Jan 2018 07:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516894852; cv=none; d=google.com; s=arc-20160816; b=FHSndbBTSXQ0kGx0Z46ukvqpkOHCmXjWPtIZtv6XZzvcfRHu1tTZEizsbeuq92r5XD PeYEjO852IfMzPyw3c5l7Al11SeYEBh3IYQsF9RiWkyM99SMweyCEuLAedz8OlbL5PIW HqYzAWch3yo1qo8lqTVoQ75kNrzFVSrzY1kzQiAwH9dSCm6EocMvz3GK94xW1e4aoy4/ R3l8S5ZtzbWkWNs5WFxjuYPtLpMwOh8UAEwPQ5R/boAWBNAo9ixu3fbZgOduLaQT+EfX YU/MqB0PZvqV1pcDoki9JYp7pmdKQ5Fvzg7Sa5BsB1hNRGj+J0gfgAIxh5ZrSOJEa95n /xZw== 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 :arc-authentication-results; bh=bDwKN3M510hDsk1qAwUHSd8Yw/Y8FFtPpa1yr/fILP0=; b=kEfk0F8OjZ8shNhpayhihpJO5XqcUBihD5tQoAXabBpJ5vf00SY5mDVDkSwHI6JdVQ l2CMC3uUKQwdxRNfKc/+jSOEaQDvOWXHagfylxEzarSv2vAnJCSP7AQfrolaJHRbLogK fulfqVKKIthFWLK4ZzydqNrF3RvuQsAdMQLGzV0CiulytzkgHgJaJizXErmnu6G+k5IF +3dXnLZBEUgVl0hcgD5fGxOPHPbh+eq76QrKROPfeHSGI7FOmT02abfq1jWBE7anNh2h L5MU02QWmmoiJ17oLgcACm39HHhQnFXncJ1/zUzzlYDVbIXGCFMGR5yyM83U7huLkpsY 00MA== 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 z8-v6si1228643plk.614.2018.01.25.07.40.38; Thu, 25 Jan 2018 07:40:52 -0800 (PST) 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 S1751395AbeAYPjY (ORCPT + 99 others); Thu, 25 Jan 2018 10:39:24 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:58080 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbeAYPjW (ORCPT ); Thu, 25 Jan 2018 10:39:22 -0500 Received: from localhost (67.110.78.66.ptr.us.xo.net [67.110.78.66]) (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 CD2B110916C87; Thu, 25 Jan 2018 07:39:20 -0800 (PST) Date: Thu, 25 Jan 2018 10:39:17 -0500 (EST) Message-Id: <20180125.103917.1230915444107795288.davem@davemloft.net> To: ddstreet@ieee.org Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ddstreet@canonical.com Subject: Re: [PATCH] net: tcp: close sock if net namespace is exiting From: David Miller In-Reply-To: <20180118211426.24441-1-ddstreet@ieee.org> References: <20180118211426.24441-1-ddstreet@ieee.org> X-Mailer: Mew version 6.7 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) 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]); Thu, 25 Jan 2018 07:39:21 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Streetman Date: Thu, 18 Jan 2018 16:14:26 -0500 > When a tcp socket is closed, if it detects that its net namespace is > exiting, close immediately and do not wait for FIN sequence. > > For normal sockets, a reference is taken to their net namespace, so it will > never exit while the socket is open. However, kernel sockets do not take a > reference to their net namespace, so it may begin exiting while the kernel > socket is still open. In this case if the kernel socket is a tcp socket, > it will stay open trying to complete its close sequence. The sock's dst(s) > hold a reference to their interface, which are all transferred to the > namespace's loopback interface when the real interfaces are taken down. > When the namespace tries to take down its loopback interface, it hangs > waiting for all references to the loopback interface to release, which > results in messages like: > > unregister_netdevice: waiting for lo to become free. Usage count = 1 > > These messages continue until the socket finally times out and closes. > Since the net namespace cleanup holds the net_mutex while calling its > registered pernet callbacks, any new net namespace initialization is > blocked until the current net namespace finishes exiting. > > After this change, the tcp socket notices the exiting net namespace, and > closes immediately, releasing its dst(s) and their reference to the > loopback interface, which lets the net namespace continue exiting. > > Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1711407 > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=97811 > Signed-off-by: Dan Streetman Looks good, thanks for the detailed commit message and references to analysis in those bugzilla. Applied and queued up for -stable.