[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>
This commit is contained in:
committed by
David S. Miller
parent
8ad4942cd5
commit
6b175b26c1
@@ -166,7 +166,8 @@ out:
|
||||
* Find address type as if only "dev" was present in the system. If
|
||||
* on_dev is NULL then all interfaces are taken into consideration.
|
||||
*/
|
||||
static inline unsigned __inet_dev_addr_type(const struct net_device *dev,
|
||||
static inline unsigned __inet_dev_addr_type(struct net *net,
|
||||
const struct net_device *dev,
|
||||
__be32 addr)
|
||||
{
|
||||
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,
|
||||
res.r = NULL;
|
||||
#endif
|
||||
|
||||
local_table = fib_get_table(&init_net, RT_TABLE_LOCAL);
|
||||
local_table = fib_get_table(net, RT_TABLE_LOCAL);
|
||||
if (local_table) {
|
||||
ret = RTN_UNICAST;
|
||||
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,
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned int inet_addr_type(__be32 addr)
|
||||
unsigned int inet_addr_type(struct net *net, __be32 addr)
|
||||
{
|
||||
return __inet_dev_addr_type(NULL, addr);
|
||||
return __inet_dev_addr_type(net, NULL, addr);
|
||||
}
|
||||
|
||||
unsigned int inet_dev_addr_type(const struct net_device *dev, __be32 addr)
|
||||
unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,
|
||||
__be32 addr)
|
||||
{
|
||||
return __inet_dev_addr_type(dev, addr);
|
||||
return __inet_dev_addr_type(net, dev, addr);
|
||||
}
|
||||
|
||||
/* 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,
|
||||
if (rt->rt_gateway.sa_family == AF_INET && addr) {
|
||||
cfg->fc_gw = addr;
|
||||
if (rt->rt_flags & RTF_GATEWAY &&
|
||||
inet_addr_type(addr) == RTN_UNICAST)
|
||||
inet_addr_type(&init_net, addr) == RTN_UNICAST)
|
||||
cfg->fc_scope = RT_SCOPE_UNIVERSE;
|
||||
}
|
||||
|
||||
@@ -782,7 +784,7 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa)
|
||||
fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 32, prim);
|
||||
|
||||
/* Check, that this local address finally disappeared. */
|
||||
if (inet_addr_type(ifa->ifa_local) != RTN_LOCAL) {
|
||||
if (inet_addr_type(&init_net, ifa->ifa_local) != RTN_LOCAL) {
|
||||
/* And the last, but not the least thing.
|
||||
We must flush stray FIB entries.
|
||||
|
||||
|
Reference in New Issue
Block a user