Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90473
b: refs/heads/master
c: 17eed24
h: refs/heads/master
i:
  90471: 70a7c10
v: v3
  • Loading branch information
David S. Miller committed Mar 29, 2008
1 parent b117307 commit 77ecf3e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 75 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 318a94d68979cbe9cc98a3050b4b7be2f08513c8
refs/heads/master: 17eed249539a7b756ca65a5cb0940abc48ef553b
8 changes: 3 additions & 5 deletions trunk/include/net/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,18 @@ DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);

/* /proc */
struct udp_seq_afinfo {
struct module *owner;
char *name;
sa_family_t family;
struct hlist_head *hashtable;
int (*seq_show) (struct seq_file *m, void *v);
struct file_operations *seq_fops;
struct file_operations seq_fops;
struct seq_operations seq_ops;
};

struct udp_iter_state {
struct net *net;
struct seq_net_private p;
sa_family_t family;
struct hlist_head *hashtable;
int bucket;
struct seq_operations seq_ops;
};

#ifdef CONFIG_PROC_FS
Expand Down
82 changes: 25 additions & 57 deletions trunk/net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ static struct sock *udp_get_first(struct seq_file *seq)
{
struct sock *sk;
struct udp_iter_state *state = seq->private;
struct net *net = state->net;
struct net *net = seq_file_net(seq);

for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
struct hlist_node *node;
Expand All @@ -1522,7 +1522,7 @@ static struct sock *udp_get_first(struct seq_file *seq)
static struct sock *udp_get_next(struct seq_file *seq, struct sock *sk)
{
struct udp_iter_state *state = seq->private;
struct net *net = state->net;
struct net *net = seq_file_net(seq);

do {
sk = sk_next(sk);
Expand Down Expand Up @@ -1576,50 +1576,18 @@ static void udp_seq_stop(struct seq_file *seq, void *v)
static int udp_seq_open(struct inode *inode, struct file *file)
{
struct udp_seq_afinfo *afinfo = PDE(inode)->data;
struct seq_file *seq;
struct net *net;
int rc = -ENOMEM;
struct udp_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);

if (!s)
goto out;
struct udp_iter_state *s;
int err;

rc = -ENXIO;
net = get_proc_net(inode);
if (!net)
goto out_kfree;
err = seq_open_net(inode, file, &afinfo->seq_ops,
sizeof(struct udp_iter_state));
if (err < 0)
return err;

s = ((struct seq_file *)file->private_data)->private;
s->family = afinfo->family;
s->hashtable = afinfo->hashtable;
s->seq_ops.start = udp_seq_start;
s->seq_ops.next = udp_seq_next;
s->seq_ops.show = afinfo->seq_show;
s->seq_ops.stop = udp_seq_stop;
s->net = net;

rc = seq_open(file, &s->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->net);
seq_release_private(inode, file);
return 0;
return err;
}

/* ------------------------------------------------------------------------ */
Expand All @@ -1628,15 +1596,16 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo)
struct proc_dir_entry *p;
int rc = 0;

if (!afinfo)
return -EINVAL;
afinfo->seq_fops->owner = afinfo->owner;
afinfo->seq_fops->open = udp_seq_open;
afinfo->seq_fops->read = seq_read;
afinfo->seq_fops->llseek = seq_lseek;
afinfo->seq_fops->release = udp_seq_release;
afinfo->seq_fops.open = udp_seq_open;
afinfo->seq_fops.read = seq_read;
afinfo->seq_fops.llseek = seq_lseek;
afinfo->seq_fops.release = seq_release_net;

afinfo->seq_ops.start = udp_seq_start;
afinfo->seq_ops.next = udp_seq_next;
afinfo->seq_ops.stop = udp_seq_stop;

p = proc_net_fops_create(net, afinfo->name, S_IRUGO, afinfo->seq_fops);
p = proc_net_fops_create(net, afinfo->name, S_IRUGO, &afinfo->seq_fops);
if (p)
p->data = afinfo;
else
Expand All @@ -1646,10 +1615,7 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo)

void udp_proc_unregister(struct net *net, struct udp_seq_afinfo *afinfo)
{
if (!afinfo)
return;
proc_net_remove(net, afinfo->name);
memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops));
}

/* ------------------------------------------------------------------------ */
Expand Down Expand Up @@ -1688,14 +1654,16 @@ int udp4_seq_show(struct seq_file *seq, void *v)
}

/* ------------------------------------------------------------------------ */
static struct file_operations udp4_seq_fops;
static struct udp_seq_afinfo udp4_seq_afinfo = {
.owner = THIS_MODULE,
.name = "udp",
.family = AF_INET,
.hashtable = udp_hash,
.seq_show = udp4_seq_show,
.seq_fops = &udp4_seq_fops,
.seq_fops = {
.owner = THIS_MODULE,
},
.seq_ops = {
.show = udp4_seq_show,
},
};

static int udp4_proc_init_net(struct net *net)
Expand Down
10 changes: 6 additions & 4 deletions trunk/net/ipv4/udplite.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ static struct inet_protosw udplite4_protosw = {
};

#ifdef CONFIG_PROC_FS
static struct file_operations udplite4_seq_fops;
static struct udp_seq_afinfo udplite4_seq_afinfo = {
.owner = THIS_MODULE,
.name = "udplite",
.family = AF_INET,
.hashtable = udplite_hash,
.seq_show = udp4_seq_show,
.seq_fops = &udplite4_seq_fops,
.seq_fops = {
.owner = THIS_MODULE,
},
.seq_ops = {
.show = udp4_seq_show,
},
};

static int udplite4_proc_init_net(struct net *net)
Expand Down
10 changes: 6 additions & 4 deletions trunk/net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,14 +977,16 @@ int udp6_seq_show(struct seq_file *seq, void *v)
return 0;
}

static struct file_operations udp6_seq_fops;
static struct udp_seq_afinfo udp6_seq_afinfo = {
.owner = THIS_MODULE,
.name = "udp6",
.family = AF_INET6,
.hashtable = udp_hash,
.seq_show = udp6_seq_show,
.seq_fops = &udp6_seq_fops,
.seq_fops = {
.owner = THIS_MODULE,
},
.seq_ops = {
.show = udp6_seq_show,
},
};

int udp6_proc_init(struct net *net)
Expand Down
10 changes: 6 additions & 4 deletions trunk/net/ipv6/udplite.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ void udplitev6_exit(void)
}

#ifdef CONFIG_PROC_FS
static struct file_operations udplite6_seq_fops;
static struct udp_seq_afinfo udplite6_seq_afinfo = {
.owner = THIS_MODULE,
.name = "udplite6",
.family = AF_INET6,
.hashtable = udplite_hash,
.seq_show = udp6_seq_show,
.seq_fops = &udplite6_seq_fops,
.seq_fops = {
.owner = THIS_MODULE,
},
.seq_ops = {
.show = udp6_seq_show,
},
};

static int udplite6_proc_init_net(struct net *net)
Expand Down

0 comments on commit 77ecf3e

Please sign in to comment.