diff options
author | Denis V. Lunev <den@openvz.org> | 2007-11-20 01:31:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:54:28 -0500 |
commit | e372c41401993b45c721c4d92730e7e0a79f7c1b (patch) | |
tree | 8f062f506c0578fc83b7d05c8751a7ccac96e50e /net/netlink/af_netlink.c | |
parent | 097e66c578459f79e3a2128c54e9df5194e1419a (diff) |
[NET]: Consolidate net namespace related proc files creation.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r-- | net/netlink/af_netlink.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index de3988ba1f46..1518244ffad9 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -1681,7 +1681,7 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 pid, | |||
1681 | 1681 | ||
1682 | #ifdef CONFIG_PROC_FS | 1682 | #ifdef CONFIG_PROC_FS |
1683 | struct nl_seq_iter { | 1683 | struct nl_seq_iter { |
1684 | struct net *net; | 1684 | struct seq_net_private p; |
1685 | int link; | 1685 | int link; |
1686 | int hash_idx; | 1686 | int hash_idx; |
1687 | }; | 1687 | }; |
@@ -1699,7 +1699,7 @@ static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos) | |||
1699 | 1699 | ||
1700 | for (j = 0; j <= hash->mask; j++) { | 1700 | for (j = 0; j <= hash->mask; j++) { |
1701 | sk_for_each(s, node, &hash->table[j]) { | 1701 | sk_for_each(s, node, &hash->table[j]) { |
1702 | if (iter->net != s->sk_net) | 1702 | if (iter->p.net != s->sk_net) |
1703 | continue; | 1703 | continue; |
1704 | if (off == pos) { | 1704 | if (off == pos) { |
1705 | iter->link = i; | 1705 | iter->link = i; |
@@ -1734,7 +1734,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1734 | s = v; | 1734 | s = v; |
1735 | do { | 1735 | do { |
1736 | s = sk_next(s); | 1736 | s = sk_next(s); |
1737 | } while (s && (iter->net != s->sk_net)); | 1737 | } while (s && (iter->p.net != s->sk_net)); |
1738 | if (s) | 1738 | if (s) |
1739 | return s; | 1739 | return s; |
1740 | 1740 | ||
@@ -1746,7 +1746,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1746 | 1746 | ||
1747 | for (; j <= hash->mask; j++) { | 1747 | for (; j <= hash->mask; j++) { |
1748 | s = sk_head(&hash->table[j]); | 1748 | s = sk_head(&hash->table[j]); |
1749 | while (s && (iter->net != s->sk_net)) | 1749 | while (s && (iter->p.net != s->sk_net)) |
1750 | s = sk_next(s); | 1750 | s = sk_next(s); |
1751 | if (s) { | 1751 | if (s) { |
1752 | iter->link = i; | 1752 | iter->link = i; |
@@ -1802,27 +1802,8 @@ static const struct seq_operations netlink_seq_ops = { | |||
1802 | 1802 | ||
1803 | static int netlink_seq_open(struct inode *inode, struct file *file) | 1803 | static int netlink_seq_open(struct inode *inode, struct file *file) |
1804 | { | 1804 | { |
1805 | struct nl_seq_iter *iter; | 1805 | return seq_open_net(inode, file, &netlink_seq_ops, |
1806 | 1806 | sizeof(struct nl_seq_iter)); | |
1807 | iter = __seq_open_private(file, &netlink_seq_ops, sizeof(*iter)); | ||
1808 | if (!iter) | ||
1809 | return -ENOMEM; | ||
1810 | |||
1811 | iter->net = get_proc_net(inode); | ||
1812 | if (!iter->net) { | ||
1813 | seq_release_private(inode, file); | ||
1814 | return -ENXIO; | ||
1815 | } | ||
1816 | |||
1817 | return 0; | ||
1818 | } | ||
1819 | |||
1820 | static int netlink_seq_release(struct inode *inode, struct file *file) | ||
1821 | { | ||
1822 | struct seq_file *seq = file->private_data; | ||
1823 | struct nl_seq_iter *iter = seq->private; | ||
1824 | put_net(iter->net); | ||
1825 | return seq_release_private(inode, file); | ||
1826 | } | 1807 | } |
1827 | 1808 | ||
1828 | static const struct file_operations netlink_seq_fops = { | 1809 | static const struct file_operations netlink_seq_fops = { |
@@ -1830,7 +1811,7 @@ static const struct file_operations netlink_seq_fops = { | |||
1830 | .open = netlink_seq_open, | 1811 | .open = netlink_seq_open, |
1831 | .read = seq_read, | 1812 | .read = seq_read, |
1832 | .llseek = seq_lseek, | 1813 | .llseek = seq_lseek, |
1833 | .release = netlink_seq_release, | 1814 | .release = seq_release_net, |
1834 | }; | 1815 | }; |
1835 | 1816 | ||
1836 | #endif | 1817 | #endif |