From patchwork Fri Apr 7 11:25:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Feng X-Patchwork-Id: 748198 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vzy1v4lh5z9s7m for ; Fri, 7 Apr 2017 21:25:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=foxmail.com header.i=@foxmail.com header.b="y03XSjFK"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754980AbdDGLZy (ORCPT ); Fri, 7 Apr 2017 07:25:54 -0400 Received: from smtpbgau2.qq.com ([54.206.34.216]:44615 "EHLO smtpbgau2.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753883AbdDGLZy (ORCPT ); Fri, 7 Apr 2017 07:25:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1491564349; bh=lLzIpxhep5/rhGelUJtb5MSDy9R2xuLOCOyKMVQAZdE=; h=From:To:Cc:Subject:Date:Message-Id; b=y03XSjFKoAj9ztLTGqLQTfTSPKUFZqKsVEO581dJVgrup0avTcoO7Q3gREzGObh5N J9OUKnzseu6ydPxT7Iz+Dj7uSjB3neT84FPnBQRhmb9EX7sBM+zOYWLcBn+T349RQz Nkqw1qzGM0Cb/7IEyuysTDooY+4/pGQW+WeugQ+4= X-QQ-mid: esmtp12t1491564347tw2au9csf Received: from ikuai8.com (unknown [114.242.17.232]) by esmtp4.qq.com (ESMTP) with id ; Fri, 07 Apr 2017 19:25:39 +0800 (CST) X-QQ-SSF: 01000000000000F0FG500F00000000Q X-QQ-FEAT: uLC2yWZT8bFF4R/edyhQdmVs6xkmPh8n+yVkBa7Zk/Jdv2ouzzYp1ezzndVWP Dr1i6dl00vtbiYeUzBpv9LIYspCiVzXMsLBnHpchXJ0XZDpz1k8VB8YwfrrA6bz//kYFZaA Yj20NbpHTWEZrNmGscCE2ISPFQpPrSZJWZg4GppVXYT9T1IS3jRaGtNG01vxcAx+gQOacFx DjVDF4gBTrjSq4OGNaIKmZw9l2g1yladc1+s6/RLo/ekI46Qx9NLZnwd5kVbtiJw1wKbUC3 A3pOAomG+ZwnHFEGw35qMChIA= X-QQ-GoodBg: 0 From: gfree.wind@foxmail.com To: pablo@netfilter.org, netfilter-devel@vger.kernel.org Cc: Gao Feng Subject: [PATCH nf-next 1/1] netfilter: cttimeout: Refine cttimeout_del_timeout Date: Fri, 7 Apr 2017 19:25:36 +0800 Message-Id: <1491564336-44483-1-git-send-email-gfree.wind@foxmail.com> X-Mailer: git-send-email 1.9.1 X-QQ-SENDSIZE: 520 Feedback-ID: esmtp:foxmail.com:bgforeign:bgforeign1 X-QQ-Bgrelay: 1 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org From: Gao Feng 1. Return one error when try to delete all timeouts and meet one erorr; 2. Delete the condition block when fail to delete specified timeout. It is more clear that it would stop the loop when find one matched timeout. Signed-off-by: Gao Feng --- net/netfilter/nfnetlink_cttimeout.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index baa75f3..220847a 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c @@ -361,11 +361,17 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl, char *name; if (!cda[CTA_TIMEOUT_NAME]) { + int cur_ret; + + ret = 0; list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, - head) - ctnl_timeout_try_del(net, cur); + head) { + cur_ret = ctnl_timeout_try_del(net, cur); + if (cur_ret && !ret) + ret = cur_ret; + } - return 0; + return ret; } name = nla_data(cda[CTA_TIMEOUT_NAME]); @@ -374,9 +380,6 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl, continue; ret = ctnl_timeout_try_del(net, cur); - if (ret < 0) - return ret; - break; } return ret;