Commit cf7732e4 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller
Browse files

[NET]: Make core networking code use seq_open_private



This concerns the ipv4 and ipv6 code mostly, but also the netlink
and unix sockets.

The netlink code is an example of how to use the __seq_open_private()
call - it saves the net namespace on this private.

Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 39699037
Loading
Loading
Loading
Loading
+2 −18
Original line number Diff line number Diff line
@@ -1378,24 +1378,8 @@ static const struct seq_operations arp_seq_ops = {

static int arp_seq_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct neigh_seq_state *s = kzalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;

	rc = seq_open(file, &arp_seq_ops);
	if (rc)
		goto out_kfree;

	seq	     = file->private_data;
	seq->private = s;
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;
	return seq_open_private(file, &arp_seq_ops,
			sizeof(struct neigh_seq_state));
}

static const struct file_operations arp_seq_fops = {
+2 −18
Original line number Diff line number Diff line
@@ -1039,24 +1039,8 @@ static const struct seq_operations fib_seq_ops = {

static int fib_seq_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct fib_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;

	rc = seq_open(file, &fib_seq_ops);
	if (rc)
		goto out_kfree;

	seq	     = file->private_data;
	seq->private = s;
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;
	return seq_open_private(file, &fib_seq_ops,
			sizeof(struct fib_iter_state));
}

static const struct file_operations fib_seq_fops = {
+4 −38
Original line number Diff line number Diff line
@@ -2379,25 +2379,8 @@ static const struct seq_operations fib_trie_seq_ops = {

static int fib_trie_seq_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;

	rc = seq_open(file, &fib_trie_seq_ops);
	if (rc)
		goto out_kfree;

	seq	     = file->private_data;
	seq->private = s;
	memset(s, 0, sizeof(*s));
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;
	return seq_open_private(file, &fib_trie_seq_ops,
			sizeof(struct fib_trie_iter));
}

static const struct file_operations fib_trie_fops = {
@@ -2500,25 +2483,8 @@ static const struct seq_operations fib_route_seq_ops = {

static int fib_route_seq_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;

	rc = seq_open(file, &fib_route_seq_ops);
	if (rc)
		goto out_kfree;

	seq	     = file->private_data;
	seq->private = s;
	memset(s, 0, sizeof(*s));
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;
	return seq_open_private(file, &fib_route_seq_ops,
			sizeof(struct fib_trie_iter));
}

static const struct file_operations fib_route_fops = {
+4 −34
Original line number Diff line number Diff line
@@ -2410,23 +2410,8 @@ static const struct seq_operations igmp_mc_seq_ops = {

static int igmp_mc_seq_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct igmp_mc_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;
	rc = seq_open(file, &igmp_mc_seq_ops);
	if (rc)
		goto out_kfree;

	seq = file->private_data;
	seq->private = s;
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;
	return seq_open_private(file, &igmp_mc_seq_ops,
			sizeof(struct igmp_mc_iter_state));
}

static const struct file_operations igmp_mc_seq_fops = {
@@ -2584,23 +2569,8 @@ static const struct seq_operations igmp_mcf_seq_ops = {

static int igmp_mcf_seq_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct igmp_mcf_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;
	rc = seq_open(file, &igmp_mcf_seq_ops);
	if (rc)
		goto out_kfree;

	seq = file->private_data;
	seq->private = s;
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;
	return seq_open_private(file, &igmp_mcf_seq_ops,
			sizeof(struct igmp_mcf_iter_state));
}

static const struct file_operations igmp_mcf_seq_fops = {
+4 −39
Original line number Diff line number Diff line
@@ -1714,26 +1714,8 @@ static const struct seq_operations ipmr_vif_seq_ops = {

static int ipmr_vif_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;

	rc = seq_open(file, &ipmr_vif_seq_ops);
	if (rc)
		goto out_kfree;

	s->ct = 0;
	seq = file->private_data;
	seq->private = s;
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;

	return seq_open_private(file, &ipmr_vif_seq_ops,
			sizeof(struct ipmr_vif_iter));
}

static const struct file_operations ipmr_vif_fops = {
@@ -1877,25 +1859,8 @@ static const struct seq_operations ipmr_mfc_seq_ops = {

static int ipmr_mfc_open(struct inode *inode, struct file *file)
{
	struct seq_file *seq;
	int rc = -ENOMEM;
	struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);

	if (!s)
		goto out;

	rc = seq_open(file, &ipmr_mfc_seq_ops);
	if (rc)
		goto out_kfree;

	seq = file->private_data;
	seq->private = s;
out:
	return rc;
out_kfree:
	kfree(s);
	goto out;

	return seq_open_private(file, &ipmr_mfc_seq_ops,
			sizeof(struct ipmr_mfc_iter));
}

static const struct file_operations ipmr_mfc_fops = {
Loading