From: "Denis V. Lunev" <den@openvz.org>
To: davem@davemloft.net
Cc: benjamin.thery@bull.net, dlezcano@fr.ibm.com, devel@openvz.org,
containers@lists.osdl.org, netdev@vger.kernel.org,
xemul@openvz.org
Subject: [PATCH net-2.6.25 12/19] [NETNS] Show routing information from correct namespace (fib_trie.c)
Date: Wed, 19 Dec 2007 18:24:42 +0300 [thread overview]
Message-ID: <1198077889-10693-13-git-send-email-den@openvz.org> (raw)
In-Reply-To: <4769370F.5020303@openvz.org>
This is the second part (for the CONFIG_IP_FIB_TRIE case) of the patch #4,
where we have created proc files in namespaces.
Now we can dump correct info in them.
Acked-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
net/ipv4/fib_trie.c | 44 ++++++++++++++++++++++++++++++++------------
1 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 9526758..708faa9 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1992,6 +1992,7 @@ struct fib_table *fib_hash_init(u32 id)
#ifdef CONFIG_PROC_FS
/* Depth first Trie walk iterator */
struct fib_trie_iter {
+ struct seq_net_private p;
struct trie *trie_local, *trie_main;
struct tnode *tnode;
struct trie *trie;
@@ -2159,17 +2160,18 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
static int fib_triestat_seq_show(struct seq_file *seq, void *v)
{
+ struct net *net = (struct net *)seq->private;
struct trie *trie_local, *trie_main;
struct trie_stat *stat;
struct fib_table *tb;
trie_local = NULL;
- tb = fib_get_table(&init_net, RT_TABLE_LOCAL);
+ tb = fib_get_table(net, RT_TABLE_LOCAL);
if (tb)
trie_local = (struct trie *) tb->tb_data;
trie_main = NULL;
- tb = fib_get_table(&init_net, RT_TABLE_MAIN);
+ tb = fib_get_table(net, RT_TABLE_MAIN);
if (tb)
trie_main = (struct trie *) tb->tb_data;
@@ -2199,7 +2201,25 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
static int fib_triestat_seq_open(struct inode *inode, struct file *file)
{
- return single_open(file, fib_triestat_seq_show, NULL);
+ int err;
+ struct net *net;
+
+ net = get_proc_net(inode);
+ if (net == NULL)
+ return -ENXIO;
+ err = single_open(file, fib_triestat_seq_show, net);
+ if (err < 0) {
+ put_net(net);
+ return err;
+ }
+ return 0;
+}
+
+static int fib_triestat_seq_release(struct inode *ino, struct file *f)
+{
+ struct seq_file *seq = f->private_data;
+ put_net(seq->private);
+ return single_release(ino, f);
}
static const struct file_operations fib_triestat_fops = {
@@ -2207,7 +2227,7 @@ static const struct file_operations fib_triestat_fops = {
.open = fib_triestat_seq_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = single_release,
+ .release = fib_triestat_seq_release,
};
static struct node *fib_trie_get_idx(struct fib_trie_iter *iter,
@@ -2236,12 +2256,12 @@ static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos)
struct fib_table *tb;
if (!iter->trie_local) {
- tb = fib_get_table(&init_net, RT_TABLE_LOCAL);
+ tb = fib_get_table(iter->p.net, RT_TABLE_LOCAL);
if (tb)
iter->trie_local = (struct trie *) tb->tb_data;
}
if (!iter->trie_main) {
- tb = fib_get_table(&init_net, RT_TABLE_MAIN);
+ tb = fib_get_table(iter->p.net, RT_TABLE_MAIN);
if (tb)
iter->trie_main = (struct trie *) tb->tb_data;
}
@@ -2385,8 +2405,8 @@ static const struct seq_operations fib_trie_seq_ops = {
static int fib_trie_seq_open(struct inode *inode, struct file *file)
{
- return seq_open_private(file, &fib_trie_seq_ops,
- sizeof(struct fib_trie_iter));
+ return seq_open_net(inode, file, &fib_trie_seq_ops,
+ sizeof(struct fib_trie_iter));
}
static const struct file_operations fib_trie_fops = {
@@ -2394,7 +2414,7 @@ static const struct file_operations fib_trie_fops = {
.open = fib_trie_seq_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = seq_release_private,
+ .release = seq_release_net,
};
static unsigned fib_flag_trans(int type, __be32 mask, const struct fib_info *fi)
@@ -2489,8 +2509,8 @@ static const struct seq_operations fib_route_seq_ops = {
static int fib_route_seq_open(struct inode *inode, struct file *file)
{
- return seq_open_private(file, &fib_route_seq_ops,
- sizeof(struct fib_trie_iter));
+ return seq_open_net(inode, file, &fib_route_seq_ops,
+ sizeof(struct fib_trie_iter));
}
static const struct file_operations fib_route_fops = {
@@ -2498,7 +2518,7 @@ static const struct file_operations fib_route_fops = {
.open = fib_route_seq_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = seq_release_private,
+ .release = seq_release_net,
};
int __net_init fib_proc_init(struct net *net)
--
1.5.3.rc5
next prev parent reply other threads:[~2007-12-19 15:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-19 15:21 [PATCH netns-2.6.25 0/19] routing virtualization Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 1/19] [NETNS] Add netns parameter to fib_rules_(un)register Denis V. Lunev
2007-12-20 23:46 ` David Miller
2007-12-19 15:24 ` [PATCH net-2.6.25 2/19] [NETNS] Pass fib_rules_ops into default_pref method Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 3/19] [NETNS] Namespacing in the generic fib rules code Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 4/19] [NETNS] Add namespace to API for routing /proc entries creation Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 5/19] [IPV4] Check fib4_rules_init failure Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 6/19] [NETNS] Refactor fib initialization so it can handle multiple namespaces Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 7/19] [IPV4] Unify access to the routing tables Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 8/19] [NETNS] Add netns parameter to fib_get_table/fib_new_table Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 9/19] [NETNS] Add netns parameter to inet_(dev_)add_type Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 10/19] [NETNS] Add netns to nl_info structure Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 11/19] [NETNS] Show routing information from correct namespace (fib_hash.c) Denis V. Lunev
2007-12-19 15:24 ` Denis V. Lunev [this message]
2007-12-19 15:24 ` [PATCH net-2.6.25 13/19] [NETNS] Namespacing IPv4 fib rules Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 14/19] [NETNS] Place fib tables into netns Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 15/19] [NETNS] Provide correct namespace for fibnl netlink socket Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 16/19] [NETNS] Correctly fill fib_config data Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 17/19] [NETNS] Pass namespace through ip_rt_ioctl Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 18/19] [NETNS] Replace init_net with the correct context in fib_frontend.c Denis V. Lunev
2007-12-19 15:24 ` [PATCH net-2.6.25 19/19] [NETNS] Enable routing configuration in non-initial namespace Denis V. Lunev
-- strict thread matches above, loose matches on Subject: below --
2008-01-09 18:03 [PATCH netns-2.6.25 0/19] routing virtualization v2 Denis V. Lunev
[not found] ` <47850C57.60907-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2008-01-09 18:04 ` [PATCH net-2.6.25 12/19] [NETNS] Show routing information from correct namespace (fib_trie.c) Denis V. Lunev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1198077889-10693-13-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=benjamin.thery@bull.net \
--cc=containers@lists.osdl.org \
--cc=davem@davemloft.net \
--cc=devel@openvz.org \
--cc=dlezcano@fr.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=xemul@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).