Commit a2be75c1 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[UDP]: Cleanup /proc/udp[6] creation/removal.

Replace seq_open with seq_open_net and remove udp_seq_release
completely.  seq_release_net will do this job just fine.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dda61925
...@@ -1576,46 +1576,18 @@ static void udp_seq_stop(struct seq_file *seq, void *v) ...@@ -1576,46 +1576,18 @@ static void udp_seq_stop(struct seq_file *seq, void *v)
static int udp_seq_open(struct inode *inode, struct file *file) static int udp_seq_open(struct inode *inode, struct file *file)
{ {
struct udp_seq_afinfo *afinfo = PDE(inode)->data; struct udp_seq_afinfo *afinfo = PDE(inode)->data;
struct seq_file *seq; struct udp_iter_state *s;
struct net *net; int err;
int rc = -ENOMEM;
struct udp_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
if (!s)
goto out;
rc = -ENXIO; err = seq_open_net(inode, file, &afinfo->seq_ops,
net = get_proc_net(inode); sizeof(struct udp_iter_state));
if (!net) if (err < 0)
goto out_kfree; return err;
s = ((struct seq_file *)file->private_data)->private;
s->family = afinfo->family; s->family = afinfo->family;
s->hashtable = afinfo->hashtable; s->hashtable = afinfo->hashtable;
s->p.net = net; return err;
rc = seq_open(file, &afinfo->seq_ops);
if (rc)
goto out_put_net;
seq = file->private_data;
seq->private = s;
out:
return rc;
out_put_net:
put_net(net);
out_kfree:
kfree(s);
goto out;
}
static int udp_seq_release(struct inode *inode, struct file *file)
{
struct seq_file *seq = file->private_data;
struct udp_iter_state *s = seq->private;
put_net(s->p.net);
seq_release_private(inode, file);
return 0;
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
...@@ -1628,7 +1600,7 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo) ...@@ -1628,7 +1600,7 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo)
afinfo->seq_fops->open = udp_seq_open; afinfo->seq_fops->open = udp_seq_open;
afinfo->seq_fops->read = seq_read; afinfo->seq_fops->read = seq_read;
afinfo->seq_fops->llseek = seq_lseek; afinfo->seq_fops->llseek = seq_lseek;
afinfo->seq_fops->release = udp_seq_release; afinfo->seq_fops->release = seq_release_net;
afinfo->seq_ops.start = udp_seq_start; afinfo->seq_ops.start = udp_seq_start;
afinfo->seq_ops.next = udp_seq_next; afinfo->seq_ops.next = udp_seq_next;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment