Commit 97c53cac authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NET]: Make rtnetlink infrastructure network namespace aware (v3)

After this patch none of the netlink callback support anything
except the initial network namespace but the rtnetlink infrastructure
now handles multiple network namespaces.

Changes from v2:
- IPv6 addrlabel processing

Changes from v1:
- no need for special rtnl_unlock handling
- fixed IPv6 ndisc
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b854272b
...@@ -620,11 +620,11 @@ extern int __rtattr_parse_nested_compat(struct rtattr *tb[], int maxattr, ...@@ -620,11 +620,11 @@ extern int __rtattr_parse_nested_compat(struct rtattr *tb[], int maxattr,
({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \ ({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
__rtattr_parse_nested_compat(tb, max, rta, len); }) __rtattr_parse_nested_compat(tb, max, rta, len); })
extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo); extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
extern int rtnl_unicast(struct sk_buff *skb, u32 pid); extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
extern int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group, extern int rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group,
struct nlmsghdr *nlh, gfp_t flags); struct nlmsghdr *nlh, gfp_t flags);
extern void rtnl_set_sk_err(u32 group, int error); extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
u32 id, u32 ts, u32 tsage, long expires, u32 id, u32 ts, u32 tsage, long expires,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
struct proc_dir_entry; struct proc_dir_entry;
struct net_device; struct net_device;
struct sock;
struct net { struct net {
atomic_t count; /* To decided when the network atomic_t count; /* To decided when the network
* namespace should be freed. * namespace should be freed.
...@@ -29,6 +30,8 @@ struct net { ...@@ -29,6 +30,8 @@ struct net {
struct list_head dev_base_head; struct list_head dev_base_head;
struct hlist_head *dev_name_head; struct hlist_head *dev_name_head;
struct hlist_head *dev_index_head; struct hlist_head *dev_index_head;
struct sock *rtnl; /* rtnetlink socket */
}; };
#ifdef CONFIG_NET #ifdef CONFIG_NET
......
...@@ -97,10 +97,10 @@ void br_ifinfo_notify(int event, struct net_bridge_port *port) ...@@ -97,10 +97,10 @@ void br_ifinfo_notify(int event, struct net_bridge_port *port)
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); err = rtnl_notify(skb, &init_net,0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_LINK, err); rtnl_set_sk_err(&init_net, RTNLGRP_LINK, err);
} }
/* /*
......
...@@ -599,10 +599,10 @@ static void notify_rule_change(int event, struct fib_rule *rule, ...@@ -599,10 +599,10 @@ static void notify_rule_change(int event, struct fib_rule *rule,
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, pid, ops->nlgroup, nlh, GFP_KERNEL); err = rtnl_notify(skb, &init_net, pid, ops->nlgroup, nlh, GFP_KERNEL);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(ops->nlgroup, err); rtnl_set_sk_err(&init_net, ops->nlgroup, err);
} }
static void attach_rules(struct list_head *rules, struct net_device *dev) static void attach_rules(struct list_head *rules, struct net_device *dev)
......
...@@ -2467,10 +2467,10 @@ static void __neigh_notify(struct neighbour *n, int type, int flags) ...@@ -2467,10 +2467,10 @@ static void __neigh_notify(struct neighbour *n, int type, int flags)
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC); err = rtnl_notify(skb, &init_net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_NEIGH, err); rtnl_set_sk_err(&init_net, RTNLGRP_NEIGH, err);
} }
#ifdef CONFIG_ARPD #ifdef CONFIG_ARPD
......
...@@ -60,7 +60,6 @@ struct rtnl_link ...@@ -60,7 +60,6 @@ struct rtnl_link
}; };
static DEFINE_MUTEX(rtnl_mutex); static DEFINE_MUTEX(rtnl_mutex);
static struct sock *rtnl;
void rtnl_lock(void) void rtnl_lock(void)
{ {
...@@ -458,8 +457,9 @@ size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size) ...@@ -458,8 +457,9 @@ size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size)
return ret; return ret;
} }
int rtnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned group, int echo)
{ {
struct sock *rtnl = net->rtnl;
int err = 0; int err = 0;
NETLINK_CB(skb).dst_group = group; NETLINK_CB(skb).dst_group = group;
...@@ -471,14 +471,17 @@ int rtnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) ...@@ -471,14 +471,17 @@ int rtnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
return err; return err;
} }
int rtnl_unicast(struct sk_buff *skb, u32 pid) int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid)
{ {
struct sock *rtnl = net->rtnl;
return nlmsg_unicast(rtnl, skb, pid); return nlmsg_unicast(rtnl, skb, pid);
} }
int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group, int rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group,
struct nlmsghdr *nlh, gfp_t flags) struct nlmsghdr *nlh, gfp_t flags)
{ {
struct sock *rtnl = net->rtnl;
int report = 0; int report = 0;
if (nlh) if (nlh)
...@@ -487,8 +490,10 @@ int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group, ...@@ -487,8 +490,10 @@ int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,
return nlmsg_notify(rtnl, skb, pid, group, report, flags); return nlmsg_notify(rtnl, skb, pid, group, report, flags);
} }
void rtnl_set_sk_err(u32 group, int error) void rtnl_set_sk_err(struct net *net, u32 group, int error)
{ {
struct sock *rtnl = net->rtnl;
netlink_set_err(rtnl, 0, group, error); netlink_set_err(rtnl, 0, group, error);
} }
...@@ -1201,7 +1206,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -1201,7 +1206,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
kfree_skb(nskb); kfree_skb(nskb);
goto errout; goto errout;
} }
err = rtnl_unicast(nskb, NETLINK_CB(skb).pid); err = rtnl_unicast(nskb, net, NETLINK_CB(skb).pid);
errout: errout:
dev_put(dev); dev_put(dev);
...@@ -1252,10 +1257,10 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change) ...@@ -1252,10 +1257,10 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_KERNEL); err = rtnl_notify(skb, &init_net, 0, RTNLGRP_LINK, NULL, GFP_KERNEL);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_LINK, err); rtnl_set_sk_err(&init_net, RTNLGRP_LINK, err);
} }
/* Protected by RTNL sempahore. */ /* Protected by RTNL sempahore. */
...@@ -1266,6 +1271,7 @@ static int rtattr_max; ...@@ -1266,6 +1271,7 @@ static int rtattr_max;
static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{ {
struct net *net = skb->sk->sk_net;
rtnl_doit_func doit; rtnl_doit_func doit;
int sz_idx, kind; int sz_idx, kind;
int min_len; int min_len;
...@@ -1294,6 +1300,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1294,6 +1300,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
return -EPERM; return -EPERM;
if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) { if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
struct sock *rtnl;
rtnl_dumpit_func dumpit; rtnl_dumpit_func dumpit;
dumpit = rtnl_get_dumpit(family, type); dumpit = rtnl_get_dumpit(family, type);
...@@ -1301,6 +1308,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1301,6 +1308,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
return -EOPNOTSUPP; return -EOPNOTSUPP;
__rtnl_unlock(); __rtnl_unlock();
rtnl = net->rtnl;
err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL); err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
rtnl_lock(); rtnl_lock();
return err; return err;
...@@ -1373,6 +1381,40 @@ static struct notifier_block rtnetlink_dev_notifier = { ...@@ -1373,6 +1381,40 @@ static struct notifier_block rtnetlink_dev_notifier = {
.notifier_call = rtnetlink_event, .notifier_call = rtnetlink_event,
}; };
static int rtnetlink_net_init(struct net *net)
{
struct sock *sk;
sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX,
rtnetlink_rcv, &rtnl_mutex, THIS_MODULE);
if (!sk)
return -ENOMEM;
/* Don't hold an extra reference on the namespace */
put_net(sk->sk_net);
net->rtnl = sk;
return 0;
}
static void rtnetlink_net_exit(struct net *net)
{
struct sock *sk = net->rtnl;
if (sk) {
/* At the last minute lie and say this is a socket for the
* initial network namespace. So the socket will be safe to
* free.
*/
sk->sk_net = get_net(&init_net);
sock_put(sk);
net->rtnl = NULL;
}
}
static struct pernet_operations rtnetlink_net_ops = {
.init = rtnetlink_net_init,
.exit = rtnetlink_net_exit,
};
void __init rtnetlink_init(void) void __init rtnetlink_init(void)
{ {
int i; int i;
...@@ -1385,10 +1427,9 @@ void __init rtnetlink_init(void) ...@@ -1385,10 +1427,9 @@ void __init rtnetlink_init(void)
if (!rta_buf) if (!rta_buf)
panic("rtnetlink_init: cannot allocate rta_buf\n"); panic("rtnetlink_init: cannot allocate rta_buf\n");
rtnl = netlink_kernel_create(&init_net, NETLINK_ROUTE, RTNLGRP_MAX, if (register_pernet_subsys(&rtnetlink_net_ops))
rtnetlink_rcv, &rtnl_mutex, THIS_MODULE);
if (rtnl == NULL)
panic("rtnetlink_init: cannot initialize rtnetlink\n"); panic("rtnetlink_init: cannot initialize rtnetlink\n");
netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV); netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
register_netdevice_notifier(&rtnetlink_dev_notifier); register_netdevice_notifier(&rtnetlink_dev_notifier);
......
...@@ -793,10 +793,10 @@ static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa) ...@@ -793,10 +793,10 @@ static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa)
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL); err = rtnl_notify(skb, &init_net, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_DECnet_IFADDR, err); rtnl_set_sk_err(&init_net, RTNLGRP_DECnet_IFADDR, err);
} }
static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
......
...@@ -1587,7 +1587,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void ...@@ -1587,7 +1587,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
goto out_free; goto out_free;
} }
return rtnl_unicast(skb, NETLINK_CB(in_skb).pid); return rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
out_free: out_free:
kfree_skb(skb); kfree_skb(skb);
......
...@@ -375,10 +375,10 @@ static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id, ...@@ -375,10 +375,10 @@ static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id,
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, pid, RTNLGRP_DECnet_ROUTE, nlh, GFP_KERNEL); err = rtnl_notify(skb, &init_net, pid, RTNLGRP_DECnet_ROUTE, nlh, GFP_KERNEL);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_DECnet_ROUTE, err); rtnl_set_sk_err(&init_net, RTNLGRP_DECnet_ROUTE, err);
} }
static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb, static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb,
......
...@@ -1240,10 +1240,10 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh, ...@@ -1240,10 +1240,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, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL); err = rtnl_notify(skb, &init_net, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_IPV4_IFADDR, err); rtnl_set_sk_err(&init_net, RTNLGRP_IPV4_IFADDR, err);
} }
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
...@@ -320,11 +320,11 @@ void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, ...@@ -320,11 +320,11 @@ void rtmsg_fib(int event, __be32 key, struct fib_alias *fa,
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, info->pid, RTNLGRP_IPV4_ROUTE, err = rtnl_notify(skb, &init_net, info->pid, RTNLGRP_IPV4_ROUTE,
info->nlh, GFP_KERNEL); info->nlh, GFP_KERNEL);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_IPV4_ROUTE, err); rtnl_set_sk_err(&init_net, RTNLGRP_IPV4_ROUTE, err);
} }
/* Return the first fib alias matching TOS with /* Return the first fib alias matching TOS with
......
...@@ -321,7 +321,7 @@ static void ipmr_destroy_unres(struct mfc_cache *c) ...@@ -321,7 +321,7 @@ static void ipmr_destroy_unres(struct mfc_cache *c)
e->error = -ETIMEDOUT; e->error = -ETIMEDOUT;
memset(&e->msg, 0, sizeof(e->msg)); memset(&e->msg, 0, sizeof(e->msg));
rtnl_unicast(skb, NETLINK_CB(skb).pid); rtnl_unicast(skb, &init_net, NETLINK_CB(skb).pid);
} else } else
kfree_skb(skb); kfree_skb(skb);
} }
...@@ -533,7 +533,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) ...@@ -533,7 +533,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
memset(&e->msg, 0, sizeof(e->msg)); memset(&e->msg, 0, sizeof(e->msg));
} }
rtnl_unicast(skb, NETLINK_CB(skb).pid); rtnl_unicast(skb, &init_net, NETLINK_CB(skb).pid);
} else } else
ip_mr_forward(skb, c, 0); ip_mr_forward(skb, c, 0);
} }
......
...@@ -2610,7 +2610,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void ...@@ -2610,7 +2610,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, NETLINK_CB(in_skb).pid); err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
errout: errout:
return err; return err;
......
...@@ -3397,7 +3397,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh, ...@@ -3397,7 +3397,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
kfree_skb(skb); kfree_skb(skb);
goto errout_ifa; goto errout_ifa;
} }
err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid); err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
errout_ifa: errout_ifa:
in6_ifa_put(ifa); in6_ifa_put(ifa);
errout: errout:
...@@ -3420,10 +3420,10 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa) ...@@ -3420,10 +3420,10 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); err = rtnl_notify(skb, &init_net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_IPV6_IFADDR, err); rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_IFADDR, err);
} }
static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
...@@ -3628,10 +3628,10 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev) ...@@ -3628,10 +3628,10 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); err = rtnl_notify(skb, &init_net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_IPV6_IFADDR, err); rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_IFADDR, err);
} }
static inline size_t inet6_prefix_nlmsg_size(void) static inline size_t inet6_prefix_nlmsg_size(void)
...@@ -3697,10 +3697,10 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev, ...@@ -3697,10 +3697,10 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC); err = rtnl_notify(skb, &init_net, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC);
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_IPV6_PREFIX, err); rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_PREFIX, err);
} }
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
......
...@@ -549,7 +549,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, ...@@ -549,7 +549,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh,
goto out; goto out;
} }
err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid); err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
out: out:
return err; return err;
} }
......
...@@ -1049,7 +1049,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt) ...@@ -1049,7 +1049,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
&ipv6_hdr(ra)->saddr); &ipv6_hdr(ra)->saddr);
nlmsg_end(skb, nlh); nlmsg_end(skb, nlh);
err = rtnl_notify(skb, 0, RTNLGRP_ND_USEROPT, NULL, GFP_ATOMIC); err = rtnl_notify(skb, &init_net, 0, RTNLGRP_ND_USEROPT, NULL,
GFP_ATOMIC);
if (err < 0) if (err < 0)
goto errout; goto errout;
...@@ -1059,7 +1060,7 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt) ...@@ -1059,7 +1060,7 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
nlmsg_free(skb); nlmsg_free(skb);
err = -EMSGSIZE; err = -EMSGSIZE;
errout: errout:
rtnl_set_sk_err(RTNLGRP_ND_USEROPT, err); rtnl_set_sk_err(&init_net, RTNLGRP_ND_USEROPT, err);
} }
static void ndisc_router_discovery(struct sk_buff *skb) static void ndisc_router_discovery(struct sk_buff *skb)
......
...@@ -2230,7 +2230,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void ...@@ -2230,7 +2230,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
goto errout; goto errout;
} }
err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid); err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
errout: errout:
return err; return err;
} }
...@@ -2260,10 +2260,10 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) ...@@ -2260,10 +2260,10 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info)
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
} }
err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any()); err = rtnl_notify(skb, &init_net, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any());
errout: errout:
if (err < 0) if (err < 0)
rtnl_set_sk_err(RTNLGRP_IPV6_ROUTE, err); rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_ROUTE, err);
} }
/* /*
......
...@@ -660,7 +660,7 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event) ...@@ -660,7 +660,7 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
return -EINVAL; return -EINVAL;
} }
return rtnl_unicast(skb, pid); return rtnl_unicast(skb, &init_net, pid);
} }
static struct tc_action * static struct tc_action *
...@@ -781,7 +781,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid) ...@@ -781,7 +781,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
nlh->nlmsg_flags |= NLM_F_ROOT; nlh->nlmsg_flags |= NLM_F_ROOT;
module_put(a->ops->owner); module_put(a->ops->owner);
kfree(a); kfree(a);
err = rtnetlink_send(skb, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
if (err > 0) if (err > 0)
return 0; return 0;
...@@ -844,7 +844,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event) ...@@ -844,7 +844,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
/* now do the delete */ /* now do the delete */
tcf_action_destroy(head, 0); tcf_action_destroy(head, 0);
ret = rtnetlink_send(skb, pid, RTNLGRP_TC, ret = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC,
n->nlmsg_flags&NLM_F_ECHO); n->nlmsg_flags&NLM_F_ECHO);
if (ret > 0) if (ret > 0)
return 0; return 0;
...@@ -888,7 +888,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, ...@@ -888,7 +888,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
nlh->nlmsg_len = skb_tail_pointer(skb) - b; nlh->nlmsg_len = skb_tail_pointer(skb) - b;
NETLINK_CB(skb).dst_group = RTNLGRP_TC; NETLINK_CB(skb).dst_group = RTNLGRP_TC;
err = rtnetlink_send(skb, pid, RTNLGRP_TC, flags&NLM_F_ECHO); err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
if (err > 0) if (err > 0)
err = 0; err = 0;
return err; return err;
......
...@@ -361,7 +361,7 @@ static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n, ...@@ -361,7 +361,7 @@ static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n,
return -EINVAL; return -EINVAL;
} }
return rtnetlink_send(skb, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); return rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
} }
struct tcf_dump_args struct tcf_dump_args
......
...@@ -872,7 +872,7 @@ static int qdisc_notify(struct sk_buff *oskb, struct nlmsghdr *n, ...@@ -872,7 +872,7 @@ static int qdisc_notify(struct sk_buff *oskb, struct nlmsghdr *n,
} }
if (skb->len) if (skb->len)
return rtnetlink_send(skb, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); return rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
err_out: err_out:
kfree_skb(skb); kfree_skb(skb);
...@@ -1103,7 +1103,7 @@ static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n, ...@@ -1103,7 +1103,7 @@ static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n,
return -EINVAL; return -EINVAL;
} }
return rtnetlink_send(skb, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); return rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
} }
struct qdisc_dump_args struct qdisc_dump_args
......
...@@ -1137,7 +1137,7 @@ static void wireless_nlevent_process(unsigned long data) ...@@ -1137,7 +1137,7 @@ static void wireless_nlevent_process(unsigned long data)
struct sk_buff *skb; struct sk_buff *skb;
while ((skb = skb_dequeue(&wireless_nlevent_queue))) while ((skb = skb_dequeue(&wireless_nlevent_queue)))
rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); rtnl_notify(skb, &init_net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
} }
static DECLARE_TASKLET(wireless_nlevent_tasklet, wireless_nlevent_process, 0); static DECLARE_TASKLET(wireless_nlevent_tasklet, wireless_nlevent_process, 0);
...@@ -1189,6 +1189,9 @@ static void rtmsg_iwinfo(struct net_device *dev, char *event, int event_len) ...@@ -1189,6 +1189,9 @@ static void rtmsg_iwinfo(struct net_device *dev, char *event, int event_len)
struct sk_buff *skb; struct sk_buff *skb;
int err; int err;
if (dev->nd_net != &init_net)
return;
skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!skb) if (!skb)
return; return;
......
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