diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-10 05:29:29 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:55:33 -0400 |
commit | cf7732e4cc14b56d593ff53352673e1fd5e3ba52 (patch) | |
tree | 3479e278b72f9d535a58066bc2a26238806252ce /net/ipv4 | |
parent | 39699037a5c94d7cd1363dfe48a50c78c643fd9a (diff) |
[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: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/arp.c | 20 | ||||
-rw-r--r-- | net/ipv4/fib_hash.c | 20 | ||||
-rw-r--r-- | net/ipv4/fib_trie.c | 42 | ||||
-rw-r--r-- | net/ipv4/igmp.c | 38 | ||||
-rw-r--r-- | net/ipv4/ipmr.c | 43 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_ctl.c | 20 | ||||
-rw-r--r-- | net/ipv4/raw.c | 20 | ||||
-rw-r--r-- | net/ipv4/route.c | 19 |
8 files changed, 22 insertions, 200 deletions
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index d8248198bcd7..36d6798947b5 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -1378,24 +1378,8 @@ static const struct seq_operations arp_seq_ops = { | |||
1378 | 1378 | ||
1379 | static int arp_seq_open(struct inode *inode, struct file *file) | 1379 | static int arp_seq_open(struct inode *inode, struct file *file) |
1380 | { | 1380 | { |
1381 | struct seq_file *seq; | 1381 | return seq_open_private(file, &arp_seq_ops, |
1382 | int rc = -ENOMEM; | 1382 | sizeof(struct neigh_seq_state)); |
1383 | struct neigh_seq_state *s = kzalloc(sizeof(*s), GFP_KERNEL); | ||
1384 | |||
1385 | if (!s) | ||
1386 | goto out; | ||
1387 | |||
1388 | rc = seq_open(file, &arp_seq_ops); | ||
1389 | if (rc) | ||
1390 | goto out_kfree; | ||
1391 | |||
1392 | seq = file->private_data; | ||
1393 | seq->private = s; | ||
1394 | out: | ||
1395 | return rc; | ||
1396 | out_kfree: | ||
1397 | kfree(s); | ||
1398 | goto out; | ||
1399 | } | 1383 | } |
1400 | 1384 | ||
1401 | static const struct file_operations arp_seq_fops = { | 1385 | static const struct file_operations arp_seq_fops = { |
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c index 9fafbeea8fe6..527a6e0af5b6 100644 --- a/net/ipv4/fib_hash.c +++ b/net/ipv4/fib_hash.c | |||
@@ -1039,24 +1039,8 @@ static const struct seq_operations fib_seq_ops = { | |||
1039 | 1039 | ||
1040 | static int fib_seq_open(struct inode *inode, struct file *file) | 1040 | static int fib_seq_open(struct inode *inode, struct file *file) |
1041 | { | 1041 | { |
1042 | struct seq_file *seq; | 1042 | return seq_open_private(file, &fib_seq_ops, |
1043 | int rc = -ENOMEM; | 1043 | sizeof(struct fib_iter_state)); |
1044 | struct fib_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL); | ||
1045 | |||
1046 | if (!s) | ||
1047 | goto out; | ||
1048 | |||
1049 | rc = seq_open(file, &fib_seq_ops); | ||
1050 | if (rc) | ||
1051 | goto out_kfree; | ||
1052 | |||
1053 | seq = file->private_data; | ||
1054 | seq->private = s; | ||
1055 | out: | ||
1056 | return rc; | ||
1057 | out_kfree: | ||
1058 | kfree(s); | ||
1059 | goto out; | ||
1060 | } | 1044 | } |
1061 | 1045 | ||
1062 | static const struct file_operations fib_seq_fops = { | 1046 | static const struct file_operations fib_seq_fops = { |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index be34bd556d58..81a8285d6d6a 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -2379,25 +2379,8 @@ static const struct seq_operations fib_trie_seq_ops = { | |||
2379 | 2379 | ||
2380 | static int fib_trie_seq_open(struct inode *inode, struct file *file) | 2380 | static int fib_trie_seq_open(struct inode *inode, struct file *file) |
2381 | { | 2381 | { |
2382 | struct seq_file *seq; | 2382 | return seq_open_private(file, &fib_trie_seq_ops, |
2383 | int rc = -ENOMEM; | 2383 | sizeof(struct fib_trie_iter)); |
2384 | struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | ||
2385 | |||
2386 | if (!s) | ||
2387 | goto out; | ||
2388 | |||
2389 | rc = seq_open(file, &fib_trie_seq_ops); | ||
2390 | if (rc) | ||
2391 | goto out_kfree; | ||
2392 | |||
2393 | seq = file->private_data; | ||
2394 | seq->private = s; | ||
2395 | memset(s, 0, sizeof(*s)); | ||
2396 | out: | ||
2397 | return rc; | ||
2398 | out_kfree: | ||
2399 | kfree(s); | ||
2400 | goto out; | ||
2401 | } | 2384 | } |
2402 | 2385 | ||
2403 | static const struct file_operations fib_trie_fops = { | 2386 | static const struct file_operations fib_trie_fops = { |
@@ -2500,25 +2483,8 @@ static const struct seq_operations fib_route_seq_ops = { | |||
2500 | 2483 | ||
2501 | static int fib_route_seq_open(struct inode *inode, struct file *file) | 2484 | static int fib_route_seq_open(struct inode *inode, struct file *file) |
2502 | { | 2485 | { |
2503 | struct seq_file *seq; | 2486 | return seq_open_private(file, &fib_route_seq_ops, |
2504 | int rc = -ENOMEM; | 2487 | sizeof(struct fib_trie_iter)); |
2505 | struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | ||
2506 | |||
2507 | if (!s) | ||
2508 | goto out; | ||
2509 | |||
2510 | rc = seq_open(file, &fib_route_seq_ops); | ||
2511 | if (rc) | ||
2512 | goto out_kfree; | ||
2513 | |||
2514 | seq = file->private_data; | ||
2515 | seq->private = s; | ||
2516 | memset(s, 0, sizeof(*s)); | ||
2517 | out: | ||
2518 | return rc; | ||
2519 | out_kfree: | ||
2520 | kfree(s); | ||
2521 | goto out; | ||
2522 | } | 2488 | } |
2523 | 2489 | ||
2524 | static const struct file_operations fib_route_fops = { | 2490 | static const struct file_operations fib_route_fops = { |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 2b6e59c4c0d0..7dbc282d4f9f 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -2410,23 +2410,8 @@ static const struct seq_operations igmp_mc_seq_ops = { | |||
2410 | 2410 | ||
2411 | static int igmp_mc_seq_open(struct inode *inode, struct file *file) | 2411 | static int igmp_mc_seq_open(struct inode *inode, struct file *file) |
2412 | { | 2412 | { |
2413 | struct seq_file *seq; | 2413 | return seq_open_private(file, &igmp_mc_seq_ops, |
2414 | int rc = -ENOMEM; | 2414 | sizeof(struct igmp_mc_iter_state)); |
2415 | struct igmp_mc_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL); | ||
2416 | |||
2417 | if (!s) | ||
2418 | goto out; | ||
2419 | rc = seq_open(file, &igmp_mc_seq_ops); | ||
2420 | if (rc) | ||
2421 | goto out_kfree; | ||
2422 | |||
2423 | seq = file->private_data; | ||
2424 | seq->private = s; | ||
2425 | out: | ||
2426 | return rc; | ||
2427 | out_kfree: | ||
2428 | kfree(s); | ||
2429 | goto out; | ||
2430 | } | 2415 | } |
2431 | 2416 | ||
2432 | static const struct file_operations igmp_mc_seq_fops = { | 2417 | static const struct file_operations igmp_mc_seq_fops = { |
@@ -2584,23 +2569,8 @@ static const struct seq_operations igmp_mcf_seq_ops = { | |||
2584 | 2569 | ||
2585 | static int igmp_mcf_seq_open(struct inode *inode, struct file *file) | 2570 | static int igmp_mcf_seq_open(struct inode *inode, struct file *file) |
2586 | { | 2571 | { |
2587 | struct seq_file *seq; | 2572 | return seq_open_private(file, &igmp_mcf_seq_ops, |
2588 | int rc = -ENOMEM; | 2573 | sizeof(struct igmp_mcf_iter_state)); |
2589 | struct igmp_mcf_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL); | ||
2590 | |||
2591 | if (!s) | ||
2592 | goto out; | ||
2593 | rc = seq_open(file, &igmp_mcf_seq_ops); | ||
2594 | if (rc) | ||
2595 | goto out_kfree; | ||
2596 | |||
2597 | seq = file->private_data; | ||
2598 | seq->private = s; | ||
2599 | out: | ||
2600 | return rc; | ||
2601 | out_kfree: | ||
2602 | kfree(s); | ||
2603 | goto out; | ||
2604 | } | 2574 | } |
2605 | 2575 | ||
2606 | static const struct file_operations igmp_mcf_seq_fops = { | 2576 | static const struct file_operations igmp_mcf_seq_fops = { |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index b8b4b497fb57..37bb497d92af 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -1714,26 +1714,8 @@ static const struct seq_operations ipmr_vif_seq_ops = { | |||
1714 | 1714 | ||
1715 | static int ipmr_vif_open(struct inode *inode, struct file *file) | 1715 | static int ipmr_vif_open(struct inode *inode, struct file *file) |
1716 | { | 1716 | { |
1717 | struct seq_file *seq; | 1717 | return seq_open_private(file, &ipmr_vif_seq_ops, |
1718 | int rc = -ENOMEM; | 1718 | sizeof(struct ipmr_vif_iter)); |
1719 | struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | ||
1720 | |||
1721 | if (!s) | ||
1722 | goto out; | ||
1723 | |||
1724 | rc = seq_open(file, &ipmr_vif_seq_ops); | ||
1725 | if (rc) | ||
1726 | goto out_kfree; | ||
1727 | |||
1728 | s->ct = 0; | ||
1729 | seq = file->private_data; | ||
1730 | seq->private = s; | ||
1731 | out: | ||
1732 | return rc; | ||
1733 | out_kfree: | ||
1734 | kfree(s); | ||
1735 | goto out; | ||
1736 | |||
1737 | } | 1719 | } |
1738 | 1720 | ||
1739 | static const struct file_operations ipmr_vif_fops = { | 1721 | static const struct file_operations ipmr_vif_fops = { |
@@ -1877,25 +1859,8 @@ static const struct seq_operations ipmr_mfc_seq_ops = { | |||
1877 | 1859 | ||
1878 | static int ipmr_mfc_open(struct inode *inode, struct file *file) | 1860 | static int ipmr_mfc_open(struct inode *inode, struct file *file) |
1879 | { | 1861 | { |
1880 | struct seq_file *seq; | 1862 | return seq_open_private(file, &ipmr_mfc_seq_ops, |
1881 | int rc = -ENOMEM; | 1863 | sizeof(struct ipmr_mfc_iter)); |
1882 | struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | ||
1883 | |||
1884 | if (!s) | ||
1885 | goto out; | ||
1886 | |||
1887 | rc = seq_open(file, &ipmr_mfc_seq_ops); | ||
1888 | if (rc) | ||
1889 | goto out_kfree; | ||
1890 | |||
1891 | seq = file->private_data; | ||
1892 | seq->private = s; | ||
1893 | out: | ||
1894 | return rc; | ||
1895 | out_kfree: | ||
1896 | kfree(s); | ||
1897 | goto out; | ||
1898 | |||
1899 | } | 1864 | } |
1900 | 1865 | ||
1901 | static const struct file_operations ipmr_mfc_fops = { | 1866 | static const struct file_operations ipmr_mfc_fops = { |
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c index 61d023d58b5d..7345fc252a23 100644 --- a/net/ipv4/ipvs/ip_vs_ctl.c +++ b/net/ipv4/ipvs/ip_vs_ctl.c | |||
@@ -1792,24 +1792,8 @@ static const struct seq_operations ip_vs_info_seq_ops = { | |||
1792 | 1792 | ||
1793 | static int ip_vs_info_open(struct inode *inode, struct file *file) | 1793 | static int ip_vs_info_open(struct inode *inode, struct file *file) |
1794 | { | 1794 | { |
1795 | struct seq_file *seq; | 1795 | return seq_open_private(file, &ip_vs_info_seq_ops, |
1796 | int rc = -ENOMEM; | 1796 | sizeof(struct ip_vs_iter)); |
1797 | struct ip_vs_iter *s = kzalloc(sizeof(*s), GFP_KERNEL); | ||
1798 | |||
1799 | if (!s) | ||
1800 | goto out; | ||
1801 | |||
1802 | rc = seq_open(file, &ip_vs_info_seq_ops); | ||
1803 | if (rc) | ||
1804 | goto out_kfree; | ||
1805 | |||
1806 | seq = file->private_data; | ||
1807 | seq->private = s; | ||
1808 | out: | ||
1809 | return rc; | ||
1810 | out_kfree: | ||
1811 | kfree(s); | ||
1812 | goto out; | ||
1813 | } | 1797 | } |
1814 | 1798 | ||
1815 | static const struct file_operations ip_vs_info_fops = { | 1799 | static const struct file_operations ip_vs_info_fops = { |
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 07070c7067f3..3916faca3afe 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -902,24 +902,8 @@ static const struct seq_operations raw_seq_ops = { | |||
902 | 902 | ||
903 | static int raw_seq_open(struct inode *inode, struct file *file) | 903 | static int raw_seq_open(struct inode *inode, struct file *file) |
904 | { | 904 | { |
905 | struct seq_file *seq; | 905 | return seq_open_private(file, &raw_seq_ops, |
906 | int rc = -ENOMEM; | 906 | sizeof(struct raw_iter_state)); |
907 | struct raw_iter_state *s; | ||
908 | |||
909 | s = kzalloc(sizeof(*s), GFP_KERNEL); | ||
910 | if (!s) | ||
911 | goto out; | ||
912 | rc = seq_open(file, &raw_seq_ops); | ||
913 | if (rc) | ||
914 | goto out_kfree; | ||
915 | |||
916 | seq = file->private_data; | ||
917 | seq->private = s; | ||
918 | out: | ||
919 | return rc; | ||
920 | out_kfree: | ||
921 | kfree(s); | ||
922 | goto out; | ||
923 | } | 907 | } |
924 | 908 | ||
925 | static const struct file_operations raw_seq_fops = { | 909 | static const struct file_operations raw_seq_fops = { |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 307e1f1107ca..21b12de9e653 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -375,23 +375,8 @@ static const struct seq_operations rt_cache_seq_ops = { | |||
375 | 375 | ||
376 | static int rt_cache_seq_open(struct inode *inode, struct file *file) | 376 | static int rt_cache_seq_open(struct inode *inode, struct file *file) |
377 | { | 377 | { |
378 | struct seq_file *seq; | 378 | return seq_open_private(file, &rt_cache_seq_ops, |
379 | int rc = -ENOMEM; | 379 | sizeof(struct rt_cache_iter_state)); |
380 | struct rt_cache_iter_state *s; | ||
381 | |||
382 | s = kzalloc(sizeof(*s), GFP_KERNEL); | ||
383 | if (!s) | ||
384 | goto out; | ||
385 | rc = seq_open(file, &rt_cache_seq_ops); | ||
386 | if (rc) | ||
387 | goto out_kfree; | ||
388 | seq = file->private_data; | ||
389 | seq->private = s; | ||
390 | out: | ||
391 | return rc; | ||
392 | out_kfree: | ||
393 | kfree(s); | ||
394 | goto out; | ||
395 | } | 380 | } |
396 | 381 | ||
397 | static const struct file_operations rt_cache_seq_fops = { | 382 | static const struct file_operations rt_cache_seq_fops = { |