aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ip6_flowlabel.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/ip6_flowlabel.c')
-rw-r--r--net/ipv6/ip6_flowlabel.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 7712578bdc66..14e23216eb28 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -20,6 +20,7 @@
20#include <linux/route.h> 20#include <linux/route.h>
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/slab.h>
23 24
24#include <net/net_namespace.h> 25#include <net/net_namespace.h>
25#include <net/sock.h> 26#include <net/sock.h>
@@ -67,7 +68,7 @@ static inline struct ip6_flowlabel *__fl_lookup(struct net *net, __be32 label)
67 struct ip6_flowlabel *fl; 68 struct ip6_flowlabel *fl;
68 69
69 for (fl=fl_ht[FL_HASH(label)]; fl; fl = fl->next) { 70 for (fl=fl_ht[FL_HASH(label)]; fl; fl = fl->next) {
70 if (fl->label == label && fl->fl_net == net) 71 if (fl->label == label && net_eq(fl->fl_net, net))
71 return fl; 72 return fl;
72 } 73 }
73 return NULL; 74 return NULL;
@@ -154,7 +155,7 @@ static void ip6_fl_gc(unsigned long dummy)
154 write_unlock(&ip6_fl_lock); 155 write_unlock(&ip6_fl_lock);
155} 156}
156 157
157static void ip6_fl_purge(struct net *net) 158static void __net_exit ip6_fl_purge(struct net *net)
158{ 159{
159 int i; 160 int i;
160 161
@@ -163,7 +164,8 @@ static void ip6_fl_purge(struct net *net)
163 struct ip6_flowlabel *fl, **flp; 164 struct ip6_flowlabel *fl, **flp;
164 flp = &fl_ht[i]; 165 flp = &fl_ht[i];
165 while ((fl = *flp) != NULL) { 166 while ((fl = *flp) != NULL) {
166 if (fl->fl_net == net && atomic_read(&fl->users) == 0) { 167 if (net_eq(fl->fl_net, net) &&
168 atomic_read(&fl->users) == 0) {
167 *flp = fl->next; 169 *flp = fl->next;
168 fl_free(fl); 170 fl_free(fl);
169 atomic_dec(&fl_size); 171 atomic_dec(&fl_size);
@@ -377,8 +379,8 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,
377 goto done; 379 goto done;
378 fl->share = freq->flr_share; 380 fl->share = freq->flr_share;
379 addr_type = ipv6_addr_type(&freq->flr_dst); 381 addr_type = ipv6_addr_type(&freq->flr_dst);
380 if ((addr_type&IPV6_ADDR_MAPPED) 382 if ((addr_type & IPV6_ADDR_MAPPED) ||
381 || addr_type == IPV6_ADDR_ANY) { 383 addr_type == IPV6_ADDR_ANY) {
382 err = -EINVAL; 384 err = -EINVAL;
383 goto done; 385 goto done;
384 } 386 }
@@ -421,8 +423,8 @@ static int mem_check(struct sock *sk)
421 423
422 if (room <= 0 || 424 if (room <= 0 ||
423 ((count >= FL_MAX_PER_SOCK || 425 ((count >= FL_MAX_PER_SOCK ||
424 (count > 0 && room < FL_MAX_SIZE/2) || room < FL_MAX_SIZE/4) 426 (count > 0 && room < FL_MAX_SIZE/2) || room < FL_MAX_SIZE/4) &&
425 && !capable(CAP_NET_ADMIN))) 427 !capable(CAP_NET_ADMIN)))
426 return -ENOBUFS; 428 return -ENOBUFS;
427 429
428 return 0; 430 return 0;
@@ -630,7 +632,7 @@ static struct ip6_flowlabel *ip6fl_get_first(struct seq_file *seq)
630 for (state->bucket = 0; state->bucket <= FL_HASH_MASK; ++state->bucket) { 632 for (state->bucket = 0; state->bucket <= FL_HASH_MASK; ++state->bucket) {
631 fl = fl_ht[state->bucket]; 633 fl = fl_ht[state->bucket];
632 634
633 while (fl && fl->fl_net != net) 635 while (fl && !net_eq(fl->fl_net, net))
634 fl = fl->next; 636 fl = fl->next;
635 if (fl) 637 if (fl)
636 break; 638 break;
@@ -645,7 +647,7 @@ static struct ip6_flowlabel *ip6fl_get_next(struct seq_file *seq, struct ip6_flo
645 647
646 fl = fl->next; 648 fl = fl->next;
647try_again: 649try_again:
648 while (fl && fl->fl_net != net) 650 while (fl && !net_eq(fl->fl_net, net))
649 fl = fl->next; 651 fl = fl->next;
650 652
651 while (!fl) { 653 while (!fl) {
@@ -734,7 +736,7 @@ static const struct file_operations ip6fl_seq_fops = {
734 .release = seq_release_net, 736 .release = seq_release_net,
735}; 737};
736 738
737static int ip6_flowlabel_proc_init(struct net *net) 739static int __net_init ip6_flowlabel_proc_init(struct net *net)
738{ 740{
739 if (!proc_net_fops_create(net, "ip6_flowlabel", 741 if (!proc_net_fops_create(net, "ip6_flowlabel",
740 S_IRUGO, &ip6fl_seq_fops)) 742 S_IRUGO, &ip6fl_seq_fops))
@@ -742,7 +744,7 @@ static int ip6_flowlabel_proc_init(struct net *net)
742 return 0; 744 return 0;
743} 745}
744 746
745static void ip6_flowlabel_proc_fini(struct net *net) 747static void __net_exit ip6_flowlabel_proc_fini(struct net *net)
746{ 748{
747 proc_net_remove(net, "ip6_flowlabel"); 749 proc_net_remove(net, "ip6_flowlabel");
748} 750}
@@ -753,11 +755,10 @@ static inline int ip6_flowlabel_proc_init(struct net *net)
753} 755}
754static inline void ip6_flowlabel_proc_fini(struct net *net) 756static inline void ip6_flowlabel_proc_fini(struct net *net)
755{ 757{
756 return ;
757} 758}
758#endif 759#endif
759 760
760static inline void ip6_flowlabel_net_exit(struct net *net) 761static void __net_exit ip6_flowlabel_net_exit(struct net *net)
761{ 762{
762 ip6_fl_purge(net); 763 ip6_fl_purge(net);
763 ip6_flowlabel_proc_fini(net); 764 ip6_flowlabel_proc_fini(net);