Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2966321ybn; Thu, 26 Sep 2019 21:58:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzlCOUPqiKvagR/xkyhN8ROKN+0scXBcCjrHGZD5Vyk3vzl/YoXbNgezVaOBblCkGAiYw8 X-Received: by 2002:a17:906:c72d:: with SMTP id fj13mr6385651ejb.36.1569560288953; Thu, 26 Sep 2019 21:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569560288; cv=none; d=google.com; s=arc-20160816; b=QfT9+npYV525bEdRAxVh3RfCEout8oIt36Nzb4j7GcnDuBMKsvpfMSWqjt8HuIhfPC TApmyBbPESYG2Ms8AH4oMWoh4W5gEus9yOCtChU5LAxJSPR1OKLP3ctZAIJAI0D9aLZ2 c9A8X1ASiIYtuQI6YFu0UE0R2guJTguehGfbKokrorg9BeB1A84CtcZZGCuirBTNekjY UFu1Ht+JS7ag83BJH5PFDGCTBjr0Sp6fj8xW4OwN/2XPETCN3eTTDCpOTCohxKOfq9Ry cuKyXubOKbTGDR2GMksozEFNQ/CfKZpTE34BVwI3pEddUuslyLV6TrpZ+IXHSvVRDpeV 6ijA== 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=9+P9HcrFScdnWwXx5vTmbOLH8xC0pQZ3RbrmF0Cfjj8=; b=fkeKoco7wrB7ElsZOdfQCj1USh+Cmub7A/EfjmBD0PhBkZxFni3dFyDqjcizldeZ8o hoz4ihB3VNR/iqG7q1VRHRqKPJaV2+XeWbt0NHwrdR6lj6DtSh86mm84Dt+wH3E5nKuj sPM+dlPcEKRfqxna5d7QfxcOhzdxwqAj/0jMBNqVxv3hrjh3L+7aegmTojU4AdufaKP7 vqOIHULheSSMsNwYhZ28LZr5pzSLnYkDElIdRk2lHDj8EM5VrPyZJkV4fsr2xe37ojUS 1V2TlFBvSrbX4zrAS6bU/5TiePzCWhregr4k0oKEDIrquY/emKqLL9gcTkA0J0Gsh0ta IUyQ== 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 b17si2120140ejp.326.2019.09.26.21.57.45; Thu, 26 Sep 2019 21:58:08 -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 S1728932AbfI0Ezp (ORCPT + 99 others); Fri, 27 Sep 2019 00:55:45 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:2541 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfI0Ezo (ORCPT ); Fri, 27 Sep 2019 00:55:44 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app09-12009 (RichMail) with SMTP id 2ee95d8d96370f6-3ae8b; Fri, 27 Sep 2019 12:55:19 +0800 (CST) X-RM-TRANSID: 2ee95d8d96370f6-3ae8b X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.241]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85d8d96366cb-a12cb; Fri, 27 Sep 2019 12:55:19 +0800 (CST) X-RM-TRANSID: 2ee85d8d96366cb-a12cb From: Haishuang Yan To: Julian Anastasov , "David S. Miller" , Pablo Neira Ayuso Cc: netdev@vger.kernel.org, lvs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, Haishuang Yan Subject: [PATCH v2 1/2] ipvs: batch __ip_vs_cleanup Date: Fri, 27 Sep 2019 12:54:50 +0800 Message-Id: <1569560091-20553-2-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569560091-20553-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1569560091-20553-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 --- v2: remove unused pointer list --- include/net/ip_vs.h | 2 +- net/netfilter/ipvs/ip_vs_core.c | 28 ++++++++++++++++------------ net/netfilter/ipvs/ip_vs_ctl.c | 12 +++++++++--- 3 files changed, 26 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 8b80ab7..93cfb47 100644 --- a/net/netfilter/ipvs/ip_vs_core.c +++ b/net/netfilter/ipvs/ip_vs_core.c @@ -2402,18 +2402,22 @@ 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; + + 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 +2446,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 8b48e7c..153c77b 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -1607,14 +1607,20 @@ 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; + 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