netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org,
	xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
	benjamin.thery-6ktuUTfB/bM@public.gmane.org
Subject: [PATCH net-2.6.25 16/19] [NETNS] Correctly fill fib_config data.
Date: Wed,  9 Jan 2008 21:04:37 +0300	[thread overview]
Message-ID: <1199901880-6812-16-git-send-email-den@openvz.org> (raw)
In-Reply-To: <47850C57.60907-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>

Acked-by: Benjamin Thery <benjamin.thery-6ktuUTfB/bM@public.gmane.org>
Acked-by: Daniel Lezcano <dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org> 
Signed-off-by: Denis V. Lunev <den-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
---
 net/ipv4/fib_frontend.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index abe9f43..cecb660 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -305,14 +305,14 @@ static int put_rtax(struct nlattr *mx, int len, int type, u32 value)
 	return len + nla_total_size(4);
 }
 
-static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
+static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt,
 				 struct fib_config *cfg)
 {
 	__be32 addr;
 	int plen;
 
 	memset(cfg, 0, sizeof(*cfg));
-	cfg->fc_nlinfo.nl_net = &init_net;
+	cfg->fc_nlinfo.nl_net = net;
 
 	if (rt->rt_dst.sa_family != AF_INET)
 		return -EAFNOSUPPORT;
@@ -373,7 +373,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
 		colon = strchr(devname, ':');
 		if (colon)
 			*colon = 0;
-		dev = __dev_get_by_name(&init_net, devname);
+		dev = __dev_get_by_name(net, devname);
 		if (!dev)
 			return -ENODEV;
 		cfg->fc_oif = dev->ifindex;
@@ -396,7 +396,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
 	if (rt->rt_gateway.sa_family == AF_INET && addr) {
 		cfg->fc_gw = addr;
 		if (rt->rt_flags & RTF_GATEWAY &&
-		    inet_addr_type(&init_net, addr) == RTN_UNICAST)
+		    inet_addr_type(net, addr) == RTN_UNICAST)
 			cfg->fc_scope = RT_SCOPE_UNIVERSE;
 	}
 
@@ -453,7 +453,7 @@ int ip_rt_ioctl(unsigned int cmd, void __user *arg)
 			return -EFAULT;
 
 		rtnl_lock();
-		err = rtentry_to_fib_config(cmd, &rt, &cfg);
+		err = rtentry_to_fib_config(&init_net, cmd, &rt, &cfg);
 		if (err == 0) {
 			struct fib_table *tb;
 
@@ -494,8 +494,8 @@ const struct nla_policy rtm_ipv4_policy[RTA_MAX+1] = {
 	[RTA_FLOW]		= { .type = NLA_U32 },
 };
 
-static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
-			     struct fib_config *cfg)
+static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
+			    struct nlmsghdr *nlh, struct fib_config *cfg)
 {
 	struct nlattr *attr;
 	int err, remaining;
@@ -519,7 +519,7 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid;
 	cfg->fc_nlinfo.nlh = nlh;
-	cfg->fc_nlinfo.nl_net = &init_net;
+	cfg->fc_nlinfo.nl_net = net;
 
 	if (cfg->fc_type > RTN_MAX) {
 		err = -EINVAL;
@@ -575,7 +575,7 @@ static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *ar
 	if (net != &init_net)
 		return -EINVAL;
 
-	err = rtm_to_fib_config(skb, nlh, &cfg);
+	err = rtm_to_fib_config(net, skb, nlh, &cfg);
 	if (err < 0)
 		goto errout;
 
@@ -600,7 +600,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *ar
 	if (net != &init_net)
 		return -EINVAL;
 
-	err = rtm_to_fib_config(skb, nlh, &cfg);
+	err = rtm_to_fib_config(net, skb, nlh, &cfg);
 	if (err < 0)
 		goto errout;
 
@@ -667,6 +667,7 @@ out:
 
 static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa)
 {
+	struct net *net = ifa->ifa_dev->dev->nd_net;
 	struct fib_table *tb;
 	struct fib_config cfg = {
 		.fc_protocol = RTPROT_KERNEL,
@@ -677,14 +678,14 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad
 		.fc_oif = ifa->ifa_dev->dev->ifindex,
 		.fc_nlflags = NLM_F_CREATE | NLM_F_APPEND,
 		.fc_nlinfo = {
-			.nl_net = &init_net,
+			.nl_net = net,
 		},
 	};
 
 	if (type == RTN_UNICAST)
-		tb = fib_new_table(&init_net, RT_TABLE_MAIN);
+		tb = fib_new_table(net, RT_TABLE_MAIN);
 	else
-		tb = fib_new_table(&init_net, RT_TABLE_LOCAL);
+		tb = fib_new_table(net, RT_TABLE_LOCAL);
 
 	if (tb == NULL)
 		return;
-- 
1.5.3.rc5

  parent reply	other threads:[~2008-01-09 18:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 1/19] [NETNS] Add netns parameter to fib_rules_(un)register Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 2/19] [NETNS] Pass fib_rules_ops into default_pref method Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 3/19] [NETNS] Namespacing in the generic fib rules code Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 4/19] [NETNS] Add namespace to API for routing /proc entries creation Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 5/19] [IPV4] Check fib4_rules_init failure Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 6/19] [NETNS] Refactor fib initialization so it can handle multiple namespaces Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 7/19] [IPV4] Unify access to the routing tables Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 8/19] [NETNS] Add netns parameter to fib_get_table/fib_new_table Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 9/19] [NETNS] Add netns parameter to inet_(dev_)add_type Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 10/19] [NETNS] Add netns to nl_info structure Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 11/19] [NETNS] Show routing information from correct namespace (fib_hash.c) Denis V. Lunev
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
2008-01-09 18:04   ` [PATCH net-2.6.25 13/19] [NETNS] Namespacing IPv4 fib rules Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 14/19] [NETNS] Place fib tables into netns Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 15/19] [NETNS] Provide correct namespace for fibnl netlink socket Denis V. Lunev
2008-01-09 18:04   ` Denis V. Lunev [this message]
2008-01-09 18:04   ` [PATCH net-2.6.25 17/19] [NETNS] Pass namespace through ip_rt_ioctl Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 18/19] [NETNS] Replace init_net with the correct context in fib_frontend.c Denis V. Lunev
2008-01-09 18:04   ` [PATCH net-2.6.25 19/19] [NETNS] Enable routing configuration in non-initial namespace Denis V. Lunev
2008-01-10 11:38 ` [PATCH netns-2.6.25 0/19] routing virtualization v2 David Miller
  -- strict thread matches above, loose matches on Subject: below --
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 16/19] [NETNS] Correctly fill fib_config data 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=1199901880-6812-16-git-send-email-den@openvz.org \
    --to=den-gefaqzzx7r8dnm+yrofe0a@public.gmane.org \
    --cc=benjamin.thery-6ktuUTfB/bM@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.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).