Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751585AbdFIEiP (ORCPT ); Fri, 9 Jun 2017 00:38:15 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:59697 "EHLO cmccmta1.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499AbdFIEiO (ORCPT ); Fri, 9 Jun 2017 00:38:14 -0400 X-RM-TRANSID: 2ee3593a262529c-a815d X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee9593a2627029-e39a7 From: Haishuang Yan To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Haishuang Yan Subject: [PATCH] netfilter: ctnetlink: move CTA_TIMEOUT case to outside Date: Fri, 9 Jun 2017 12:37:47 +0800 Message-Id: <1496983067-11214-1-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1187 Lines: 36 When cda[CTA_TIMEOUT] is zero, ctnetlink_new_conntrack will free allocated ct and return, so move it to outside to optimize this situation. Signed-off-by: Haishuang Yan --- net/netfilter/nf_conntrack_netlink.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index a8be9b7..d1e6b1c 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -1768,9 +1768,6 @@ static int change_seq_adj(struct nf_ct_seqadj *seq, if (IS_ERR(ct)) return ERR_PTR(-ENOMEM); - if (!cda[CTA_TIMEOUT]) - goto err1; - ct->timeout = nfct_time_stamp + ntohl(nla_get_be32(cda[CTA_TIMEOUT])) * HZ; rcu_read_lock(); @@ -1944,7 +1941,7 @@ static int ctnetlink_new_conntrack(struct net *net, struct sock *ctnl, if (nlh->nlmsg_flags & NLM_F_CREATE) { enum ip_conntrack_events events; - if (!cda[CTA_TUPLE_ORIG] || !cda[CTA_TUPLE_REPLY]) + if (!cda[CTA_TUPLE_ORIG] || !cda[CTA_TUPLE_REPLY] || !cda[CTA_TIMEOUT]) return -EINVAL; if (otuple.dst.protonum != rtuple.dst.protonum) return -EINVAL; -- 1.8.3.1