Commit 1937504d authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Enable all routing manipulation via netlink inside namespace.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e5b13cb1
...@@ -2701,9 +2701,6 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void ...@@ -2701,9 +2701,6 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
int err; int err;
struct sk_buff *skb; struct sk_buff *skb;
if (net != &init_net)
return -EINVAL;
err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv4_policy); err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv4_policy);
if (err < 0) if (err < 0)
goto errout; goto errout;
...@@ -2733,7 +2730,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void ...@@ -2733,7 +2730,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
if (iif) { if (iif) {
struct net_device *dev; struct net_device *dev;
dev = __dev_get_by_index(&init_net, iif); dev = __dev_get_by_index(net, iif);
if (dev == NULL) { if (dev == NULL) {
err = -ENODEV; err = -ENODEV;
goto errout_free; goto errout_free;
...@@ -2759,7 +2756,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void ...@@ -2759,7 +2756,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
}, },
.oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0, .oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0,
}; };
err = ip_route_output_key(&init_net, &rt, &fl); err = ip_route_output_key(net, &rt, &fl);
} }
if (err) if (err)
...@@ -2774,7 +2771,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void ...@@ -2774,7 +2771,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
if (err <= 0) if (err <= 0)
goto errout_free; goto errout_free;
err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid); err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).pid);
errout: errout:
return err; return err;
...@@ -2788,6 +2785,9 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2788,6 +2785,9 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct rtable *rt; struct rtable *rt;
int h, s_h; int h, s_h;
int idx, s_idx; int idx, s_idx;
struct net *net;
net = skb->sk->sk_net;
s_h = cb->args[0]; s_h = cb->args[0];
if (s_h < 0) if (s_h < 0)
...@@ -2797,7 +2797,7 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2797,7 +2797,7 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb)
rcu_read_lock_bh(); rcu_read_lock_bh();
for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt; for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt;
rt = rcu_dereference(rt->u.dst.rt_next), idx++) { rt = rcu_dereference(rt->u.dst.rt_next), idx++) {
if (idx < s_idx) if (rt->u.dst.dev->nd_net != net || idx < s_idx)
continue; continue;
if (rt->rt_genid != atomic_read(&rt_genid)) if (rt->rt_genid != atomic_read(&rt_genid))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment