Commit 4b8aa9ab authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Process interface address manipulation routines in the namespace.

The namespace is available when required except rtm_to_ifaddr. Add
namespace argument to it.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7b218574
...@@ -485,7 +485,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg ...@@ -485,7 +485,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
return err; return err;
} }
static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh) static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh)
{ {
struct nlattr *tb[IFA_MAX+1]; struct nlattr *tb[IFA_MAX+1];
struct in_ifaddr *ifa; struct in_ifaddr *ifa;
...@@ -503,7 +503,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh) ...@@ -503,7 +503,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
if (ifm->ifa_prefixlen > 32 || tb[IFA_LOCAL] == NULL) if (ifm->ifa_prefixlen > 32 || tb[IFA_LOCAL] == NULL)
goto errout; goto errout;
dev = __dev_get_by_index(&init_net, ifm->ifa_index); dev = __dev_get_by_index(net, ifm->ifa_index);
err = -ENODEV; err = -ENODEV;
if (dev == NULL) if (dev == NULL)
goto errout; goto errout;
...@@ -563,7 +563,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg ...@@ -563,7 +563,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
if (net != &init_net) if (net != &init_net)
return -EINVAL; return -EINVAL;
ifa = rtm_to_ifaddr(nlh); ifa = rtm_to_ifaddr(net, nlh);
if (IS_ERR(ifa)) if (IS_ERR(ifa))
return PTR_ERR(ifa); return PTR_ERR(ifa);
...@@ -1177,7 +1177,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1177,7 +1177,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
s_ip_idx = ip_idx = cb->args[1]; s_ip_idx = ip_idx = cb->args[1];
idx = 0; idx = 0;
for_each_netdev(&init_net, dev) { for_each_netdev(net, dev) {
if (idx < s_idx) if (idx < s_idx)
goto cont; goto cont;
if (idx > s_idx) if (idx > s_idx)
...@@ -1211,7 +1211,9 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh, ...@@ -1211,7 +1211,9 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh,
struct sk_buff *skb; struct sk_buff *skb;
u32 seq = nlh ? nlh->nlmsg_seq : 0; u32 seq = nlh ? nlh->nlmsg_seq : 0;
int err = -ENOBUFS; int err = -ENOBUFS;
struct net *net;
net = ifa->ifa_dev->dev->nd_net;
skb = nlmsg_new(inet_nlmsg_size(), GFP_KERNEL); skb = nlmsg_new(inet_nlmsg_size(), GFP_KERNEL);
if (skb == NULL) if (skb == NULL)
goto errout; goto errout;
...@@ -1223,10 +1225,10 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh, ...@@ -1223,10 +1225,10 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh,
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, &init_net, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL); err = rtnl_notify(skb, net, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(&init_net, RTNLGRP_IPV4_IFADDR, err); rtnl_set_sk_err(net, RTNLGRP_IPV4_IFADDR, err);
} }
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
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