diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2008-01-10 06:25:28 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:01:27 -0500 |
commit | 6b175b26c1048d331508940ad3516ead1998084f (patch) | |
tree | 810b0a18cee4d87c573274fdfd4a59fc624cfed2 /net/ipv4/fib_frontend.c | |
parent | 8ad4942cd5bdad4143f7aa1d1bd4f7b2526c19c5 (diff) |
[NETNS]: Add netns parameter to inet_(dev_)add_type.
The patch extends the inet_addr_type and inet_dev_addr_type with the
network namespace pointer. That allows to access the different tables
relatively to the network namespace.
The modification of the signature function is reported in all the
callers of the inet_addr_type using the pointer to the well known
init_net.
Acked-by: Benjamin Thery <benjamin.thery@bull.net>
Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_frontend.c')
-rw-r--r-- | net/ipv4/fib_frontend.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 7718823711e3..d1a45cb6f6b0 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -166,7 +166,8 @@ out: | |||
166 | * Find address type as if only "dev" was present in the system. If | 166 | * Find address type as if only "dev" was present in the system. If |
167 | * on_dev is NULL then all interfaces are taken into consideration. | 167 | * on_dev is NULL then all interfaces are taken into consideration. |
168 | */ | 168 | */ |
169 | static inline unsigned __inet_dev_addr_type(const struct net_device *dev, | 169 | static inline unsigned __inet_dev_addr_type(struct net *net, |
170 | const struct net_device *dev, | ||
170 | __be32 addr) | 171 | __be32 addr) |
171 | { | 172 | { |
172 | struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; | 173 | struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; |
@@ -183,7 +184,7 @@ static inline unsigned __inet_dev_addr_type(const struct net_device *dev, | |||
183 | res.r = NULL; | 184 | res.r = NULL; |
184 | #endif | 185 | #endif |
185 | 186 | ||
186 | local_table = fib_get_table(&init_net, RT_TABLE_LOCAL); | 187 | local_table = fib_get_table(net, RT_TABLE_LOCAL); |
187 | if (local_table) { | 188 | if (local_table) { |
188 | ret = RTN_UNICAST; | 189 | ret = RTN_UNICAST; |
189 | if (!local_table->tb_lookup(local_table, &fl, &res)) { | 190 | if (!local_table->tb_lookup(local_table, &fl, &res)) { |
@@ -195,14 +196,15 @@ static inline unsigned __inet_dev_addr_type(const struct net_device *dev, | |||
195 | return ret; | 196 | return ret; |
196 | } | 197 | } |
197 | 198 | ||
198 | unsigned int inet_addr_type(__be32 addr) | 199 | unsigned int inet_addr_type(struct net *net, __be32 addr) |
199 | { | 200 | { |
200 | return __inet_dev_addr_type(NULL, addr); | 201 | return __inet_dev_addr_type(net, NULL, addr); |
201 | } | 202 | } |
202 | 203 | ||
203 | unsigned int inet_dev_addr_type(const struct net_device *dev, __be32 addr) | 204 | unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev, |
205 | __be32 addr) | ||
204 | { | 206 | { |
205 | return __inet_dev_addr_type(dev, addr); | 207 | return __inet_dev_addr_type(net, dev, addr); |
206 | } | 208 | } |
207 | 209 | ||
208 | /* Given (packet source, input interface) and optional (dst, oif, tos): | 210 | /* Given (packet source, input interface) and optional (dst, oif, tos): |
@@ -391,7 +393,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt, | |||
391 | if (rt->rt_gateway.sa_family == AF_INET && addr) { | 393 | if (rt->rt_gateway.sa_family == AF_INET && addr) { |
392 | cfg->fc_gw = addr; | 394 | cfg->fc_gw = addr; |
393 | if (rt->rt_flags & RTF_GATEWAY && | 395 | if (rt->rt_flags & RTF_GATEWAY && |
394 | inet_addr_type(addr) == RTN_UNICAST) | 396 | inet_addr_type(&init_net, addr) == RTN_UNICAST) |
395 | cfg->fc_scope = RT_SCOPE_UNIVERSE; | 397 | cfg->fc_scope = RT_SCOPE_UNIVERSE; |
396 | } | 398 | } |
397 | 399 | ||
@@ -782,7 +784,7 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa) | |||
782 | fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 32, prim); | 784 | fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 32, prim); |
783 | 785 | ||
784 | /* Check, that this local address finally disappeared. */ | 786 | /* Check, that this local address finally disappeared. */ |
785 | if (inet_addr_type(ifa->ifa_local) != RTN_LOCAL) { | 787 | if (inet_addr_type(&init_net, ifa->ifa_local) != RTN_LOCAL) { |
786 | /* And the last, but not the least thing. | 788 | /* And the last, but not the least thing. |
787 | We must flush stray FIB entries. | 789 | We must flush stray FIB entries. |
788 | 790 | ||