aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2011-10-30 02:46:30 -0400
committerDavid S. Miller <davem@davemloft.net>2011-11-01 17:56:14 -0400
commit73cb88ecb950ee67906d02354f781ea293bcf895 (patch)
treefbb4a777410d5a5653537bcd3ee7e954bc9ba5a0 /net/ipv4/udp.c
parent98f41f694f46085fda475cdee8cc0b6d2c5e6f1f (diff)
net: make the tcp and udp file_operations for the /proc stuff const
the tcp and udp code creates a set of struct file_operations at runtime while it can also be done at compile time, with the added benefit of then having these file operations be const. the trickiest part was to get the "THIS_MODULE" reference right; the naive method of declaring a struct in the place of registration would not work for this reason. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index ebaa96bd3464..131d8a720086 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2037,7 +2037,7 @@ static void udp_seq_stop(struct seq_file *seq, void *v)
2037 spin_unlock_bh(&state->udp_table->hash[state->bucket].lock); 2037 spin_unlock_bh(&state->udp_table->hash[state->bucket].lock);
2038} 2038}
2039 2039
2040static int udp_seq_open(struct inode *inode, struct file *file) 2040int udp_seq_open(struct inode *inode, struct file *file)
2041{ 2041{
2042 struct udp_seq_afinfo *afinfo = PDE(inode)->data; 2042 struct udp_seq_afinfo *afinfo = PDE(inode)->data;
2043 struct udp_iter_state *s; 2043 struct udp_iter_state *s;
@@ -2053,6 +2053,7 @@ static int udp_seq_open(struct inode *inode, struct file *file)
2053 s->udp_table = afinfo->udp_table; 2053 s->udp_table = afinfo->udp_table;
2054 return err; 2054 return err;
2055} 2055}
2056EXPORT_SYMBOL(udp_seq_open);
2056 2057
2057/* ------------------------------------------------------------------------ */ 2058/* ------------------------------------------------------------------------ */
2058int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo) 2059int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo)
@@ -2060,17 +2061,12 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo)
2060 struct proc_dir_entry *p; 2061 struct proc_dir_entry *p;
2061 int rc = 0; 2062 int rc = 0;
2062 2063
2063 afinfo->seq_fops.open = udp_seq_open;
2064 afinfo->seq_fops.read = seq_read;
2065 afinfo->seq_fops.llseek = seq_lseek;
2066 afinfo->seq_fops.release = seq_release_net;
2067
2068 afinfo->seq_ops.start = udp_seq_start; 2064 afinfo->seq_ops.start = udp_seq_start;
2069 afinfo->seq_ops.next = udp_seq_next; 2065 afinfo->seq_ops.next = udp_seq_next;
2070 afinfo->seq_ops.stop = udp_seq_stop; 2066 afinfo->seq_ops.stop = udp_seq_stop;
2071 2067
2072 p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net, 2068 p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,
2073 &afinfo->seq_fops, afinfo); 2069 afinfo->seq_fops, afinfo);
2074 if (!p) 2070 if (!p)
2075 rc = -ENOMEM; 2071 rc = -ENOMEM;
2076 return rc; 2072 return rc;
@@ -2120,14 +2116,20 @@ int udp4_seq_show(struct seq_file *seq, void *v)
2120 return 0; 2116 return 0;
2121} 2117}
2122 2118
2119static const struct file_operations udp_afinfo_seq_fops = {
2120 .owner = THIS_MODULE,
2121 .open = udp_seq_open,
2122 .read = seq_read,
2123 .llseek = seq_lseek,
2124 .release = seq_release_net
2125};
2126
2123/* ------------------------------------------------------------------------ */ 2127/* ------------------------------------------------------------------------ */
2124static struct udp_seq_afinfo udp4_seq_afinfo = { 2128static struct udp_seq_afinfo udp4_seq_afinfo = {
2125 .name = "udp", 2129 .name = "udp",
2126 .family = AF_INET, 2130 .family = AF_INET,
2127 .udp_table = &udp_table, 2131 .udp_table = &udp_table,
2128 .seq_fops = { 2132 .seq_fops = &udp_afinfo_seq_fops,
2129 .owner = THIS_MODULE,
2130 },
2131 .seq_ops = { 2133 .seq_ops = {
2132 .show = udp4_seq_show, 2134 .show = udp4_seq_show,
2133 }, 2135 },