Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1785193imm; Wed, 16 May 2018 03:05:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpMZNChVaY9zLpxt2OmjtdMkbO1negamGA/vIHKclW+E2NtWTx6sVqOgAaKJ36hK8FmX8C2 X-Received: by 2002:a63:4143:: with SMTP id o64-v6mr193569pga.280.1526465120435; Wed, 16 May 2018 03:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526465120; cv=none; d=google.com; s=arc-20160816; b=LLp0ccywnmmaT7CEZy0oE6i/qdJH2cxbCi46DA8bCnD45KZN1PacxA82hlMJUVdhFt Z7az4+3EryumrWw8dPcU0pUCW/aEdyHV19R+qMQ/dyhFn5Hm3LkJPSLF/a9+Hx9x9ulw TqPdotI3qfeV0jJJOPcSdHL0okeG+nuseyJGNDIc7Hd70dcejs4OK0SLDQGlxta1q2wd nVI5Big73R0GBJ0PzKAzsDMmTI7mX0Fs1xCexSai/GezfBSOxSwWOwxoI6a0EA9/AFJb 1pXuq70RZOybiIjZbPLA90CFJ//XTpJ2JiBZe8Mr18V3NNBaXG65rVkvEVi6SklL/oh/ 2Omw== 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:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=6pSRtSDRlT3SE3WWdqlSiV8U3pWkmASohkPbs6lWKNc=; b=dxM6MCq4RshDwHwduwGORmFdSPaYHLrVRDOgfzxuLjWSABYccb5RMsDTrSxUPlEjIE GZNyqpgNtSoY+2yunXyo83MeSWlQLkFY/Ks+Mj4rDAJvTuaiimx1QMoum+vQJ+SYGQbL cmll7dskt+E9Dygq0SCFeXHQIPtqidZ/fPtxZd3mMtkypc0vT554oqZ6hNOZufvxfvbH JWRT2rZkKgEVE5lIp6g7JfIH7efAmwMVI8BeT4xGNhfOTkZ3iOV7OGIxkkDPS8z7Cagi Fq6oG3/7C9Tm46OEscv5NUevR1c/VEdhErG7/Vd7DJ0/D5zno4lq7qs02ipQl4Aye2e7 LneQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Cusn2cjR; 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 q7-v6si2107112pls.286.2018.05.16.03.05.06; Wed, 16 May 2018 03:05:20 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Cusn2cjR; 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 S1753012AbeEPKEp (ORCPT + 99 others); Wed, 16 May 2018 06:04:45 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:47416 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752823AbeEPJpM (ORCPT ); Wed, 16 May 2018 05:45:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6pSRtSDRlT3SE3WWdqlSiV8U3pWkmASohkPbs6lWKNc=; b=Cusn2cjRfMYblK/VrHOC7Np5s FXmepzijJn/gQSViWawACWka8saDYjbImXardfRvVKhcZs2ZlFOW6rPk4JNfSVOInHdSw0RuFmFhM NC+llxYjpA1fKd1jNkwI4kfO33mTsoiofejrtve//MXisx9XHXpXIlPt7bRvZjQWImhpUD5Pj2/zP 5hGkLShS6v60k/TeVKFSNIzCPeuRN5tUFJvH5V3pQhYpd6dJNBaDTQpcpPvaa8W/mmVf7ahhBEGfE wEwGxizURcjvojiBEaDI1QAHei+jQoGyC02h/WwXddZAIlD9l49iWBEVqAAsUfnc4fQJ2RlWAH8kQ STVkH87Gw==; Received: from 089144199016.atnat0008.highway.a1.net ([89.144.199.16] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIszQ-0005QJ-8a; Wed, 16 May 2018 09:44:56 +0000 From: Christoph Hellwig To: Andrew Morton , Alexander Viro Cc: Alexey Dobriyan , Greg Kroah-Hartman , Jiri Slaby , Alessandro Zummo , Alexandre Belloni , linux-acpi@vger.kernel.org, drbd-dev@lists.linbit.com, linux-ide@vger.kernel.org, netdev@vger.kernel.org, linux-rtc@vger.kernel.org, megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, devel@driverdev.osuosl.org, linux-afs@lists.infradead.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/42] =?UTF-8?q?netfilter/x=5Ftables:=20simplify=20=D1=95?= =?UTF-8?q?eq=5Ffile=20code?= Date: Wed, 16 May 2018 11:43:19 +0200 Message-Id: <20180516094346.20506-16-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516094346.20506-1-hch@lst.de> References: <20180516094346.20506-1-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just use the address family from the proc private data instead of copying it into per-file data. Signed-off-by: Christoph Hellwig --- net/netfilter/x_tables.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 71325fef647d..3704101af27f 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1489,15 +1489,10 @@ void *xt_unregister_table(struct xt_table *table) EXPORT_SYMBOL_GPL(xt_unregister_table); #ifdef CONFIG_PROC_FS -struct xt_names_priv { - struct seq_net_private p; - u_int8_t af; -}; static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos) { - struct xt_names_priv *priv = seq->private; struct net *net = seq_file_net(seq); - u_int8_t af = priv->af; + u_int8_t af = (unsigned long)PDE_DATA(file_inode(seq->file)); mutex_lock(&xt[af].mutex); return seq_list_start(&net->xt.tables[af], *pos); @@ -1505,17 +1500,15 @@ static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos) static void *xt_table_seq_next(struct seq_file *seq, void *v, loff_t *pos) { - struct xt_names_priv *priv = seq->private; struct net *net = seq_file_net(seq); - u_int8_t af = priv->af; + u_int8_t af = (unsigned long)PDE_DATA(file_inode(seq->file)); return seq_list_next(v, &net->xt.tables[af], pos); } static void xt_table_seq_stop(struct seq_file *seq, void *v) { - struct xt_names_priv *priv = seq->private; - u_int8_t af = priv->af; + u_int8_t af = (unsigned long)PDE_DATA(file_inode(seq->file)); mutex_unlock(&xt[af].mutex); } @@ -1538,16 +1531,8 @@ static const struct seq_operations xt_table_seq_ops = { static int xt_table_open(struct inode *inode, struct file *file) { - int ret; - struct xt_names_priv *priv; - - ret = seq_open_net(inode, file, &xt_table_seq_ops, - sizeof(struct xt_names_priv)); - if (!ret) { - priv = ((struct seq_file *)file->private_data)->private; - priv->af = (unsigned long)PDE_DATA(inode); - } - return ret; + return seq_open_net(inode, file, &xt_table_seq_ops, + sizeof(struct seq_net_private)); } static const struct file_operations xt_table_ops = { @@ -1563,7 +1548,7 @@ static const struct file_operations xt_table_ops = { */ struct nf_mttg_trav { struct list_head *head, *curr; - uint8_t class, nfproto; + uint8_t class; }; enum { @@ -1580,6 +1565,7 @@ static void *xt_mttg_seq_next(struct seq_file *seq, void *v, loff_t *ppos, [MTTG_TRAV_NFP_UNSPEC] = MTTG_TRAV_NFP_SPEC, [MTTG_TRAV_NFP_SPEC] = MTTG_TRAV_DONE, }; + uint8_t nfproto = (unsigned long)PDE_DATA(file_inode(seq->file)); struct nf_mttg_trav *trav = seq->private; switch (trav->class) { @@ -1594,9 +1580,9 @@ static void *xt_mttg_seq_next(struct seq_file *seq, void *v, loff_t *ppos, if (trav->curr != trav->head) break; mutex_unlock(&xt[NFPROTO_UNSPEC].mutex); - mutex_lock(&xt[trav->nfproto].mutex); + mutex_lock(&xt[nfproto].mutex); trav->head = trav->curr = is_target ? - &xt[trav->nfproto].target : &xt[trav->nfproto].match; + &xt[nfproto].target : &xt[nfproto].match; trav->class = next_class[trav->class]; break; case MTTG_TRAV_NFP_SPEC: @@ -1628,6 +1614,7 @@ static void *xt_mttg_seq_start(struct seq_file *seq, loff_t *pos, static void xt_mttg_seq_stop(struct seq_file *seq, void *v) { + uint8_t nfproto = (unsigned long)PDE_DATA(file_inode(seq->file)); struct nf_mttg_trav *trav = seq->private; switch (trav->class) { @@ -1635,7 +1622,7 @@ static void xt_mttg_seq_stop(struct seq_file *seq, void *v) mutex_unlock(&xt[NFPROTO_UNSPEC].mutex); break; case MTTG_TRAV_NFP_SPEC: - mutex_unlock(&xt[trav->nfproto].mutex); + mutex_unlock(&xt[nfproto].mutex); break; } } @@ -1680,8 +1667,6 @@ static int xt_match_open(struct inode *inode, struct file *file) trav = __seq_open_private(file, &xt_match_seq_ops, sizeof(*trav)); if (!trav) return -ENOMEM; - - trav->nfproto = (unsigned long)PDE_DATA(inode); return 0; } @@ -1732,8 +1717,6 @@ static int xt_target_open(struct inode *inode, struct file *file) trav = __seq_open_private(file, &xt_target_seq_ops, sizeof(*trav)); if (!trav) return -ENOMEM; - - trav->nfproto = (unsigned long)PDE_DATA(inode); return 0; } -- 2.17.0