Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1767973imm; Wed, 16 May 2018 02:47:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqECZ9dXUF7m29oEIutBucABQ3PSPh2/NubVQrFYJFJ8fXv4tG+zJPnBKVdYcuRzHc84wrE X-Received: by 2002:a62:1fc8:: with SMTP id l69-v6mr174268pfj.49.1526464026233; Wed, 16 May 2018 02:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526464026; cv=none; d=google.com; s=arc-20160816; b=WPBYvM0aCAisAiLkU3qf22EkFtMEoXkDIFPddN4eKhlqiosv3eJeVLHd3t3CYWcgi8 i+Z16hAtvvUK/YbECMPQUbOxAOYMNwA8yybH0lxNGQLZvwA4vHJzP9QRUS0sJbeqLZrh w5allDyRSwLYUS3S5O22rInFglUXQKBlsMuZWJ65TCuCevSEmpjv39xAdYisEDcoFzu3 0rSQbsYWGVwoWRFKBaMupDf8o8wX6fS3wmngPQ78+m/K6IJWylrylu6aYbboYzX5fOcY Sycie+ViPiAQWqL0qZWxnFcX5a7OJ/gBdbROb3jY0vL21s67o1MtIuRDExspQ8jcyqqo hgjw== 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:dkim-signature:arc-authentication-results; bh=6OliRbz8HnallWGCOLMOhpqMyzBjXcs0a9K2PCffJtI=; b=GOgXoJhoaUN4Gmr2y4YwhKzpd5w9Cg1039LMmONq1si66KO6T/5l0uQRJevPdREwPy u2BmIAST+GQvQ5dnUSFQUG3+VXOXEwkwpLbl12iGyzucJJ9hgEhJkN9elavD18aBqle+ 2VN2KrVXrC6H7uDzIG3Ll7uYVVChCTRBZUzj35kV5Gf2wIbxn1EusUMlPYsLOW860SsR WFGn/0E5SxbbxFI5hZxHFvyaoqy+l9S473zwITiCPh+/eu/6/LuvBny5JPdCSSlRMVaE 1UG88AUe9evLEGRG/XQ0FIkT7kTNesGo8JrVivxSpLQB41awUiiOExDRbOldjs2b0uVT BShQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OV1NmqYL; 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 f64-v6si1986393plf.496.2018.05.16.02.46.51; Wed, 16 May 2018 02:47:06 -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=OV1NmqYL; 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 S1752798AbeEPJpJ (ORCPT + 99 others); Wed, 16 May 2018 05:45:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:47266 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752770AbeEPJpB (ORCPT ); Wed, 16 May 2018 05:45:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding: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=6OliRbz8HnallWGCOLMOhpqMyzBjXcs0a9K2PCffJtI=; b=OV1NmqYLbrndrVVpbBFI0R9vJ Zp/SjgHCtf0RMfN4ofQQeLr7MRgtC7TRoAp9jiDYVEXvHJWgbiFX8pcAgDhis4M8VGqBwX1c2xqwQ SUyjIuMsdwDrv4m1bGT71YaIyRgDxEwaq81ZaFfI8jesZaC3MH2gtn0vmEmqjHKSqmSmazbECQwXB OiERTIzMwnO4VI5/k8NPIpR9t8PhQSnhULcRZDM4PiInN7xp11cY3r34cOdAwhdMAaahFXM6FM9y0 sGMhiRvmje+ChXyLfq6a/iE95kss9of99CKUZ5udwzVhmC9Dst4qCdoI0xdItEBXgoRCUI7wn+6tg GgyX/lZiQ==; 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 1fIsz9-0005Cx-Kn; Wed, 16 May 2018 09:44:40 +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 11/42] ipv{4,6}/ping: simplify proc file creation Date: Wed, 16 May 2018 11:43:15 +0200 Message-Id: <20180516094346.20506-12-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> 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 Remove the pointless ping_seq_afinfo indirection and make the code look like most other protocols. Signed-off-by: Christoph Hellwig --- include/net/ping.h | 11 ---------- net/ipv4/ping.c | 50 +++++++++++++--------------------------------- net/ipv6/ping.c | 35 +++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 59 deletions(-) diff --git a/include/net/ping.h b/include/net/ping.h index 4cd90d6b5c25..fd080e043a6e 100644 --- a/include/net/ping.h +++ b/include/net/ping.h @@ -83,20 +83,9 @@ int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); bool ping_rcv(struct sk_buff *skb); #ifdef CONFIG_PROC_FS -struct ping_seq_afinfo { - char *name; - sa_family_t family; - const struct file_operations *seq_fops; - const struct seq_operations seq_ops; -}; - -extern const struct file_operations ping_seq_fops; - void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family); void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos); void ping_seq_stop(struct seq_file *seq, void *v); -int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo); -void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo); int __init ping_proc_init(void); void ping_proc_exit(void); diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 56a010622f70..4d21c24dba78 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -1150,58 +1150,36 @@ static int ping_v4_seq_show(struct seq_file *seq, void *v) return 0; } -static int ping_seq_open(struct inode *inode, struct file *file) +static const struct seq_operations ping_v4_seq_ops = { + .start = ping_v4_seq_start, + .show = ping_v4_seq_show, + .next = ping_seq_next, + .stop = ping_seq_stop, +}; + +static int ping_v4_seq_open(struct inode *inode, struct file *file) { - struct ping_seq_afinfo *afinfo = PDE_DATA(inode); - return seq_open_net(inode, file, &afinfo->seq_ops, + return seq_open_net(inode, file, &ping_v4_seq_ops, sizeof(struct ping_iter_state)); } -const struct file_operations ping_seq_fops = { - .open = ping_seq_open, +const struct file_operations ping_v4_seq_fops = { + .open = ping_v4_seq_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release_net, }; -EXPORT_SYMBOL_GPL(ping_seq_fops); - -static struct ping_seq_afinfo ping_v4_seq_afinfo = { - .name = "icmp", - .family = AF_INET, - .seq_fops = &ping_seq_fops, - .seq_ops = { - .start = ping_v4_seq_start, - .show = ping_v4_seq_show, - .next = ping_seq_next, - .stop = ping_seq_stop, - }, -}; -int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo) +static int __net_init ping_v4_proc_init_net(struct net *net) { - struct proc_dir_entry *p; - p = proc_create_data(afinfo->name, 0444, net->proc_net, - afinfo->seq_fops, afinfo); - if (!p) + if (!proc_create("icmp", 0444, net->proc_net, &ping_v4_seq_fops)) return -ENOMEM; return 0; } -EXPORT_SYMBOL_GPL(ping_proc_register); - -void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo) -{ - remove_proc_entry(afinfo->name, net->proc_net); -} -EXPORT_SYMBOL_GPL(ping_proc_unregister); - -static int __net_init ping_v4_proc_init_net(struct net *net) -{ - return ping_proc_register(net, &ping_v4_seq_afinfo); -} static void __net_exit ping_v4_proc_exit_net(struct net *net) { - ping_proc_unregister(net, &ping_v4_seq_afinfo); + remove_proc_entry("icmp", net->proc_net); } static struct pernet_operations ping_v4_net_ops = { diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index 746eeae7f581..45d5c8e0f2bf 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c @@ -24,6 +24,7 @@ #include #include #include +#include #include /* Compatibility glue so we can support IPv6 when it's compiled as a module */ @@ -215,26 +216,36 @@ static int ping_v6_seq_show(struct seq_file *seq, void *v) return 0; } -static struct ping_seq_afinfo ping_v6_seq_afinfo = { - .name = "icmp6", - .family = AF_INET6, - .seq_fops = &ping_seq_fops, - .seq_ops = { - .start = ping_v6_seq_start, - .show = ping_v6_seq_show, - .next = ping_seq_next, - .stop = ping_seq_stop, - }, +static const struct seq_operations ping_v6_seq_ops = { + .start = ping_v6_seq_start, + .show = ping_v6_seq_show, + .next = ping_seq_next, + .stop = ping_seq_stop, +}; + +static int ping_v6_seq_open(struct inode *inode, struct file *file) +{ + return seq_open_net(inode, file, &ping_v6_seq_ops, + sizeof(struct ping_iter_state)); +} + +const struct file_operations ping_v6_seq_fops = { + .open = ping_v6_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_net, }; static int __net_init ping_v6_proc_init_net(struct net *net) { - return ping_proc_register(net, &ping_v6_seq_afinfo); + if (!proc_create("icmp6", 0444, net->proc_net, &ping_v6_seq_fops)) + return -ENOMEM; + return 0; } static void __net_init ping_v6_proc_exit_net(struct net *net) { - return ping_proc_unregister(net, &ping_v6_seq_afinfo); + remove_proc_entry("icmp6", net->proc_net); } static struct pernet_operations ping_v6_net_ops = { -- 2.17.0