Re: [PATCH 2/6][NET-2.6.24] Make core networking code use seq_open_private

2007-10-10 Thread David Miller
From: Pavel Emelyanov [EMAIL PROTECTED]
Date: Tue, 09 Oct 2007 19:55:28 +0400

 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: Pavel Emelyanov [EMAIL PROTECTED]

Applied.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6][NET-2.6.24] Make core networking code use seq_open_private

2007-10-09 Thread Pavel Emelyanov
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: Pavel Emelyanov [EMAIL PROTECTED]

---

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index d824819..36d6798 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1378,24 +1378,8 @@ static const struct seq_operations arp_s
 
 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 = {
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 9fafbee..527a6e0 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -1039,24 +1039,8 @@ static const struct seq_operations fib_s
 
 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 = {
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index be34bd5..81a8285 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2379,25 +2379,8 @@ static const struct seq_operations fib_t
 
 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_r
 
 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 = {
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 2b6e59c..7dbc282 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2410,23 +2410,8 @@ static const struct seq_operations igmp_
 
 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_
 
 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,
+