aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrlabel.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/addrlabel.c')
-rw-r--r--net/ipv6/addrlabel.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index 6ff73c4c126a..8175f802651b 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -13,6 +13,7 @@
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/rcupdate.h> 14#include <linux/rcupdate.h>
15#include <linux/in6.h> 15#include <linux/in6.h>
16#include <linux/slab.h>
16#include <net/addrconf.h> 17#include <net/addrconf.h>
17#include <linux/if_addrlabel.h> 18#include <linux/if_addrlabel.h>
18#include <linux/netlink.h> 19#include <linux/netlink.h>
@@ -52,11 +53,7 @@ static struct ip6addrlbl_table
52static inline 53static inline
53struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl) 54struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl)
54{ 55{
55#ifdef CONFIG_NET_NS 56 return read_pnet(&lbl->lbl_net);
56 return lbl->lbl_net;
57#else
58 return &init_net;
59#endif
60} 57}
61 58
62/* 59/*
@@ -396,6 +393,11 @@ int __init ipv6_addr_label_init(void)
396 return register_pernet_subsys(&ipv6_addr_label_ops); 393 return register_pernet_subsys(&ipv6_addr_label_ops);
397} 394}
398 395
396void ipv6_addr_label_cleanup(void)
397{
398 unregister_pernet_subsys(&ipv6_addr_label_ops);
399}
400
399static const struct nla_policy ifal_policy[IFAL_MAX+1] = { 401static const struct nla_policy ifal_policy[IFAL_MAX+1] = {
400 [IFAL_ADDRESS] = { .len = sizeof(struct in6_addr), }, 402 [IFAL_ADDRESS] = { .len = sizeof(struct in6_addr), },
401 [IFAL_LABEL] = { .len = sizeof(u32), }, 403 [IFAL_LABEL] = { .len = sizeof(u32), },
@@ -421,10 +423,6 @@ static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh,
421 ifal->ifal_prefixlen > 128) 423 ifal->ifal_prefixlen > 128)
422 return -EINVAL; 424 return -EINVAL;
423 425
424 if (ifal->ifal_index &&
425 !__dev_get_by_index(net, ifal->ifal_index))
426 return -EINVAL;
427
428 if (!tb[IFAL_ADDRESS]) 426 if (!tb[IFAL_ADDRESS])
429 return -EINVAL; 427 return -EINVAL;
430 428
@@ -440,6 +438,10 @@ static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh,
440 438
441 switch(nlh->nlmsg_type) { 439 switch(nlh->nlmsg_type) {
442 case RTM_NEWADDRLABEL: 440 case RTM_NEWADDRLABEL:
441 if (ifal->ifal_index &&
442 !__dev_get_by_index(net, ifal->ifal_index))
443 return -EINVAL;
444
443 err = ip6addrlbl_add(net, pfx, ifal->ifal_prefixlen, 445 err = ip6addrlbl_add(net, pfx, ifal->ifal_prefixlen,
444 ifal->ifal_index, label, 446 ifal->ifal_index, label,
445 nlh->nlmsg_flags & NLM_F_REPLACE); 447 nlh->nlmsg_flags & NLM_F_REPLACE);