[NET]: Modify all rtnetlink methods to only work in the initial namespace (v2)
Before I can enable rtnetlink to work in all network namespaces I need to be certain that something won't break. So this patch deliberately disables all of the rtnletlink methods in everything except the initial network namespace. After the methods have been audited this extra check can be disabled. Changes from v1: - added IPv6 addrlabel protection Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:

committed by
David S. Miller

parent
ad5d20a639
commit
b854272b3c
@@ -538,10 +538,14 @@ errout:
|
||||
|
||||
static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
struct fib_config cfg;
|
||||
struct fib_table *tb;
|
||||
int err;
|
||||
|
||||
if (net != &init_net)
|
||||
return -EINVAL;
|
||||
|
||||
err = rtm_to_fib_config(skb, nlh, &cfg);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
@@ -559,10 +563,14 @@ errout:
|
||||
|
||||
static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
struct fib_config cfg;
|
||||
struct fib_table *tb;
|
||||
int err;
|
||||
|
||||
if (net != &init_net)
|
||||
return -EINVAL;
|
||||
|
||||
err = rtm_to_fib_config(skb, nlh, &cfg);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
@@ -580,12 +588,16 @@ errout:
|
||||
|
||||
static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
unsigned int h, s_h;
|
||||
unsigned int e = 0, s_e;
|
||||
struct fib_table *tb;
|
||||
struct hlist_node *node;
|
||||
int dumped = 0;
|
||||
|
||||
if (net != &init_net)
|
||||
return 0;
|
||||
|
||||
if (nlmsg_len(cb->nlh) >= sizeof(struct rtmsg) &&
|
||||
((struct rtmsg *) nlmsg_data(cb->nlh))->rtm_flags & RTM_F_CLONED)
|
||||
return ip_rt_dump(skb, cb);
|
||||
|
Reference in New Issue
Block a user