Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2186678ybi; Sat, 13 Jul 2019 08:36:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHu+3vYRxC65X2CeSyonc12TTbbD6thlwbt6utfPuHPGFbc3cAXSAmnuP7Sp/ytD/eY1wx X-Received: by 2002:a63:724f:: with SMTP id c15mr17809024pgn.257.1563032212411; Sat, 13 Jul 2019 08:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563032212; cv=none; d=google.com; s=arc-20160816; b=K0hIVMIDCvDNKhHAWQuddYe6U/ivJUCa8sFBOUlD7tZvb29SW7LzhKOHlC8+Pu6arh jbQkKoRFR6ei6xSR2r3Rn9G5wy9rMC97s8o8c0PQWDPyocCtJTZ80DNDYyPgTJrss4UH UDolRONes3xKv1KggDgftshjL+/HOQQ03XnQE3BrXHmgYfl8ougbYhAOfbFD2vICc2oe D6QyTd0tYTm1SXJLvk4wx1hmiut3+UKQsQ51UI00Ia06pkU02TQ6IwgFB+rfdcNZzXEJ vcuONgqoc37Goyl2VftKnVMj0UilY3irTrFmM45vR1EGXXnd+4PwDFr+cCfYoSiAgOBa c+Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=8IKi/9JoS/lMowg4EBrlBQLpT8RFpGl/4urgeYsjhZo=; b=cs4T8gf1OOD0qoDhUmxkyyzdp3wh0LIqensCKbn7+NSLklgzNzL8Lv/vEZqbSQuYnT KxQBSf3cUYhYHlAzOtW7ZsT+YjqIKhlDAzp0ebSD5yINBcNPTrhqAmsC7iDhLq/PrEeS OiNgRa5q4vitIGoNyCVZCofjvI2P+GcfOtwdXK+fihx98T0vSToHFuTjvgE/ZxKpRg/P Y/n7BoUPjU2i9Udza3KOzqf/Q+Tzn0f50N6rxVLeCyQ/2Klq5y6rtr+/9yy1BoER120s s3lV+DFBwGtcxoEVXAOiMrBIUo0mQXy0MHsOy5m4gNwkdaXeoCOyUEFxSUtjcLq5+lWJ 1ZcQ== 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 j100si10925032pje.52.2019.07.13.08.36.37; Sat, 13 Jul 2019 08:36:52 -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 S1728056AbfGMPgI (ORCPT + 99 others); Sat, 13 Jul 2019 11:36:08 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:56807 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727626AbfGMPgI (ORCPT ); Sat, 13 Jul 2019 11:36:08 -0400 X-Greylist: delayed 594 seconds by postgrey-1.27 at vger.kernel.org; Sat, 13 Jul 2019 11:33:32 EDT Received: from spf.mail.chinamobile.com (unknown[172.16.121.3]) by rmmx-syy-dmz-app11-12011 (RichMail) with SMTP id 2eeb5d29f76a5ff-3a720; Sat, 13 Jul 2019 23:23:22 +0800 (CST) X-RM-TRANSID: 2eeb5d29f76a5ff-3a720 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.241]) by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee25d29f7698ba-83e2a; Sat, 13 Jul 2019 23:23:22 +0800 (CST) X-RM-TRANSID: 2ee25d29f7698ba-83e2a From: Haishuang Yan To: "David S. Miller" , Pablo Neira Ayuso , Simon Horman Cc: netdev@vger.kernel.org, lvs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, Haishuang Yan Subject: [net-next 1/2] ipvs: batch __ip_vs_cleanup Date: Sat, 13 Jul 2019 23:19:45 +0800 Message-Id: <1563031186-2101-2-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1563031186-2101-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1563031186-2101-1-git-send-email-yanhaishuang@cmss.chinamobile.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's better to batch __ip_vs_cleanup to speedup ipvs connections dismantle. Signed-off-by: Haishuang Yan --- include/net/ip_vs.h | 2 +- net/netfilter/ipvs/ip_vs_core.c | 29 +++++++++++++++++------------ net/netfilter/ipvs/ip_vs_ctl.c | 13 ++++++++++--- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 3759167..93e7a25 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h @@ -1324,7 +1324,7 @@ static inline void ip_vs_control_del(struct ip_vs_conn *cp) void ip_vs_control_net_cleanup(struct netns_ipvs *ipvs); void ip_vs_estimator_net_cleanup(struct netns_ipvs *ipvs); void ip_vs_sync_net_cleanup(struct netns_ipvs *ipvs); -void ip_vs_service_net_cleanup(struct netns_ipvs *ipvs); +void ip_vs_service_nets_cleanup(struct list_head *net_list); /* IPVS application functions * (from ip_vs_app.c) diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c index 46f06f9..b4d79b7 100644 --- a/net/netfilter/ipvs/ip_vs_core.c +++ b/net/netfilter/ipvs/ip_vs_core.c @@ -2402,18 +2402,23 @@ static int __net_init __ip_vs_init(struct net *net) return -ENOMEM; } -static void __net_exit __ip_vs_cleanup(struct net *net) +static void __net_exit __ip_vs_cleanup_batch(struct list_head *net_list) { - struct netns_ipvs *ipvs = net_ipvs(net); - - ip_vs_service_net_cleanup(ipvs); /* ip_vs_flush() with locks */ - ip_vs_conn_net_cleanup(ipvs); - ip_vs_app_net_cleanup(ipvs); - ip_vs_protocol_net_cleanup(ipvs); - ip_vs_control_net_cleanup(ipvs); - ip_vs_estimator_net_cleanup(ipvs); - IP_VS_DBG(2, "ipvs netns %d released\n", ipvs->gen); - net->ipvs = NULL; + struct netns_ipvs *ipvs; + struct net *net; + LIST_HEAD(list); + + ip_vs_service_nets_cleanup(net_list); /* ip_vs_flush() with locks */ + list_for_each_entry(net, net_list, exit_list) { + ipvs = net_ipvs(net); + ip_vs_conn_net_cleanup(ipvs); + ip_vs_app_net_cleanup(ipvs); + ip_vs_protocol_net_cleanup(ipvs); + ip_vs_control_net_cleanup(ipvs); + ip_vs_estimator_net_cleanup(ipvs); + IP_VS_DBG(2, "ipvs netns %d released\n", ipvs->gen); + net->ipvs = NULL; + } } static int __net_init __ip_vs_dev_init(struct net *net) @@ -2442,7 +2447,7 @@ static void __net_exit __ip_vs_dev_cleanup(struct net *net) static struct pernet_operations ipvs_core_ops = { .init = __ip_vs_init, - .exit = __ip_vs_cleanup, + .exit_batch = __ip_vs_cleanup_batch, .id = &ip_vs_net_id, .size = sizeof(struct netns_ipvs), }; diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 07e0967..c8e652b 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -1607,14 +1607,21 @@ static int ip_vs_flush(struct netns_ipvs *ipvs, bool cleanup) /* * Delete service by {netns} in the service table. - * Called by __ip_vs_cleanup() + * Called by __ip_vs_batch_cleanup() */ -void ip_vs_service_net_cleanup(struct netns_ipvs *ipvs) +void ip_vs_service_nets_cleanup(struct list_head *net_list) { + struct netns_ipvs *ipvs; + struct net *net; + LIST_HEAD(list); + EnterFunction(2); /* Check for "full" addressed entries */ mutex_lock(&__ip_vs_mutex); - ip_vs_flush(ipvs, true); + list_for_each_entry(net, net_list, exit_list) { + ipvs = net_ipvs(net); + ip_vs_flush(ipvs, true); + } mutex_unlock(&__ip_vs_mutex); LeaveFunction(2); } -- 1.8.3.1