diff options
Diffstat (limited to 'net')
157 files changed, 7416 insertions, 4329 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 33f90e7362cc..453512266ea1 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -663,7 +663,7 @@ out: | |||
663 | return err; | 663 | return err; |
664 | } | 664 | } |
665 | 665 | ||
666 | static int vlan_init_net(struct net *net) | 666 | static int __net_init vlan_init_net(struct net *net) |
667 | { | 667 | { |
668 | struct vlan_net *vn = net_generic(net, vlan_net_id); | 668 | struct vlan_net *vn = net_generic(net, vlan_net_id); |
669 | int err; | 669 | int err; |
@@ -675,7 +675,7 @@ static int vlan_init_net(struct net *net) | |||
675 | return err; | 675 | return err; |
676 | } | 676 | } |
677 | 677 | ||
678 | static void vlan_exit_net(struct net *net) | 678 | static void __net_exit vlan_exit_net(struct net *net) |
679 | { | 679 | { |
680 | vlan_proc_cleanup(net); | 680 | vlan_proc_cleanup(net); |
681 | } | 681 | } |
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index e75a2f3b10af..c0316e0ca6e8 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c | |||
@@ -14,6 +14,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, | |||
14 | if (skb_bond_should_drop(skb)) | 14 | if (skb_bond_should_drop(skb)) |
15 | goto drop; | 15 | goto drop; |
16 | 16 | ||
17 | skb->skb_iif = skb->dev->ifindex; | ||
17 | __vlan_hwaccel_put_tag(skb, vlan_tci); | 18 | __vlan_hwaccel_put_tag(skb, vlan_tci); |
18 | skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK); | 19 | skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK); |
19 | 20 | ||
@@ -85,6 +86,7 @@ vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp, | |||
85 | if (skb_bond_should_drop(skb)) | 86 | if (skb_bond_should_drop(skb)) |
86 | goto drop; | 87 | goto drop; |
87 | 88 | ||
89 | skb->skb_iif = skb->dev->ifindex; | ||
88 | __vlan_hwaccel_put_tag(skb, vlan_tci); | 90 | __vlan_hwaccel_put_tag(skb, vlan_tci); |
89 | skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK); | 91 | skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK); |
90 | 92 | ||
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index c1b92cab46c7..a9e1f1785614 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -263,11 +263,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, | |||
263 | vhdr->h_vlan_TCI = htons(vlan_tci); | 263 | vhdr->h_vlan_TCI = htons(vlan_tci); |
264 | 264 | ||
265 | /* | 265 | /* |
266 | * Set the protocol type. For a packet of type ETH_P_802_3 we | 266 | * Set the protocol type. For a packet of type ETH_P_802_3/2 we |
267 | * put the length in here instead. It is up to the 802.2 | 267 | * put the length in here instead. |
268 | * layer to carry protocol information. | ||
269 | */ | 268 | */ |
270 | if (type != ETH_P_802_3) | 269 | if (type != ETH_P_802_3 && type != ETH_P_802_2) |
271 | vhdr->h_vlan_encapsulated_proto = htons(type); | 270 | vhdr->h_vlan_encapsulated_proto = htons(type); |
272 | else | 271 | else |
273 | vhdr->h_vlan_encapsulated_proto = htons(len); | 272 | vhdr->h_vlan_encapsulated_proto = htons(len); |
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index 9ec1f057c03a..afead353e215 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c | |||
@@ -140,7 +140,7 @@ void vlan_proc_cleanup(struct net *net) | |||
140 | * Create /proc/net/vlan entries | 140 | * Create /proc/net/vlan entries |
141 | */ | 141 | */ |
142 | 142 | ||
143 | int vlan_proc_init(struct net *net) | 143 | int __net_init vlan_proc_init(struct net *net) |
144 | { | 144 | { |
145 | struct vlan_net *vn = net_generic(net, vlan_net_id); | 145 | struct vlan_net *vn = net_generic(net, vlan_net_id); |
146 | 146 | ||
diff --git a/net/atm/addr.c b/net/atm/addr.c index 82e85abc303d..cf3ae8b47572 100644 --- a/net/atm/addr.c +++ b/net/atm/addr.c | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | #include <linux/atm.h> | 5 | #include <linux/atm.h> |
6 | #include <linux/atmdev.h> | 6 | #include <linux/atmdev.h> |
7 | #include <asm/uaccess.h> | 7 | #include <linux/uaccess.h> |
8 | 8 | ||
9 | #include "signaling.h" | 9 | #include "signaling.h" |
10 | #include "addr.h" | 10 | #include "addr.h" |
diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c index 02cc7e71efea..fc63526d8695 100644 --- a/net/atm/atm_misc.c +++ b/net/atm/atm_misc.c | |||
@@ -2,37 +2,35 @@ | |||
2 | 2 | ||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL ICA */ |
4 | 4 | ||
5 | |||
6 | #include <linux/module.h> | 5 | #include <linux/module.h> |
7 | #include <linux/atm.h> | 6 | #include <linux/atm.h> |
8 | #include <linux/atmdev.h> | 7 | #include <linux/atmdev.h> |
9 | #include <linux/skbuff.h> | 8 | #include <linux/skbuff.h> |
10 | #include <linux/sonet.h> | 9 | #include <linux/sonet.h> |
11 | #include <linux/bitops.h> | 10 | #include <linux/bitops.h> |
11 | #include <linux/errno.h> | ||
12 | #include <asm/atomic.h> | 12 | #include <asm/atomic.h> |
13 | #include <asm/errno.h> | ||
14 | |||
15 | 13 | ||
16 | int atm_charge(struct atm_vcc *vcc,int truesize) | 14 | int atm_charge(struct atm_vcc *vcc, int truesize) |
17 | { | 15 | { |
18 | atm_force_charge(vcc,truesize); | 16 | atm_force_charge(vcc, truesize); |
19 | if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf) | 17 | if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf) |
20 | return 1; | 18 | return 1; |
21 | atm_return(vcc,truesize); | 19 | atm_return(vcc, truesize); |
22 | atomic_inc(&vcc->stats->rx_drop); | 20 | atomic_inc(&vcc->stats->rx_drop); |
23 | return 0; | 21 | return 0; |
24 | } | 22 | } |
23 | EXPORT_SYMBOL(atm_charge); | ||
25 | 24 | ||
26 | 25 | struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size, | |
27 | struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, | 26 | gfp_t gfp_flags) |
28 | gfp_t gfp_flags) | ||
29 | { | 27 | { |
30 | struct sock *sk = sk_atm(vcc); | 28 | struct sock *sk = sk_atm(vcc); |
31 | int guess = atm_guess_pdu2truesize(pdu_size); | 29 | int guess = atm_guess_pdu2truesize(pdu_size); |
32 | 30 | ||
33 | atm_force_charge(vcc,guess); | 31 | atm_force_charge(vcc, guess); |
34 | if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) { | 32 | if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) { |
35 | struct sk_buff *skb = alloc_skb(pdu_size,gfp_flags); | 33 | struct sk_buff *skb = alloc_skb(pdu_size, gfp_flags); |
36 | 34 | ||
37 | if (skb) { | 35 | if (skb) { |
38 | atomic_add(skb->truesize-guess, | 36 | atomic_add(skb->truesize-guess, |
@@ -40,10 +38,11 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, | |||
40 | return skb; | 38 | return skb; |
41 | } | 39 | } |
42 | } | 40 | } |
43 | atm_return(vcc,guess); | 41 | atm_return(vcc, guess); |
44 | atomic_inc(&vcc->stats->rx_drop); | 42 | atomic_inc(&vcc->stats->rx_drop); |
45 | return NULL; | 43 | return NULL; |
46 | } | 44 | } |
45 | EXPORT_SYMBOL(atm_alloc_charge); | ||
47 | 46 | ||
48 | 47 | ||
49 | /* | 48 | /* |
@@ -73,7 +72,6 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, | |||
73 | * else * | 72 | * else * |
74 | */ | 73 | */ |
75 | 74 | ||
76 | |||
77 | int atm_pcr_goal(const struct atm_trafprm *tp) | 75 | int atm_pcr_goal(const struct atm_trafprm *tp) |
78 | { | 76 | { |
79 | if (tp->pcr && tp->pcr != ATM_MAX_PCR) | 77 | if (tp->pcr && tp->pcr != ATM_MAX_PCR) |
@@ -84,26 +82,20 @@ int atm_pcr_goal(const struct atm_trafprm *tp) | |||
84 | return -tp->max_pcr; | 82 | return -tp->max_pcr; |
85 | return 0; | 83 | return 0; |
86 | } | 84 | } |
85 | EXPORT_SYMBOL(atm_pcr_goal); | ||
87 | 86 | ||
88 | 87 | void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to) | |
89 | void sonet_copy_stats(struct k_sonet_stats *from,struct sonet_stats *to) | ||
90 | { | 88 | { |
91 | #define __HANDLE_ITEM(i) to->i = atomic_read(&from->i) | 89 | #define __HANDLE_ITEM(i) to->i = atomic_read(&from->i) |
92 | __SONET_ITEMS | 90 | __SONET_ITEMS |
93 | #undef __HANDLE_ITEM | 91 | #undef __HANDLE_ITEM |
94 | } | 92 | } |
93 | EXPORT_SYMBOL(sonet_copy_stats); | ||
95 | 94 | ||
96 | 95 | void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to) | |
97 | void sonet_subtract_stats(struct k_sonet_stats *from,struct sonet_stats *to) | ||
98 | { | 96 | { |
99 | #define __HANDLE_ITEM(i) atomic_sub(to->i,&from->i) | 97 | #define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i) |
100 | __SONET_ITEMS | 98 | __SONET_ITEMS |
101 | #undef __HANDLE_ITEM | 99 | #undef __HANDLE_ITEM |
102 | } | 100 | } |
103 | |||
104 | |||
105 | EXPORT_SYMBOL(atm_charge); | ||
106 | EXPORT_SYMBOL(atm_alloc_charge); | ||
107 | EXPORT_SYMBOL(atm_pcr_goal); | ||
108 | EXPORT_SYMBOL(sonet_copy_stats); | ||
109 | EXPORT_SYMBOL(sonet_subtract_stats); | 101 | EXPORT_SYMBOL(sonet_subtract_stats); |
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c index b5674dc2083d..f693b78eb467 100644 --- a/net/atm/atm_sysfs.c +++ b/net/atm/atm_sysfs.c | |||
@@ -42,13 +42,14 @@ static ssize_t show_atmaddress(struct device *cdev, | |||
42 | 42 | ||
43 | spin_lock_irqsave(&adev->lock, flags); | 43 | spin_lock_irqsave(&adev->lock, flags); |
44 | list_for_each_entry(aaddr, &adev->local, entry) { | 44 | list_for_each_entry(aaddr, &adev->local, entry) { |
45 | for(i = 0, j = 0; i < ATM_ESA_LEN; ++i, ++j) { | 45 | for (i = 0, j = 0; i < ATM_ESA_LEN; ++i, ++j) { |
46 | if (j == *fmt) { | 46 | if (j == *fmt) { |
47 | pos += sprintf(pos, "."); | 47 | pos += sprintf(pos, "."); |
48 | ++fmt; | 48 | ++fmt; |
49 | j = 0; | 49 | j = 0; |
50 | } | 50 | } |
51 | pos += sprintf(pos, "%02x", aaddr->addr.sas_addr.prv[i]); | 51 | pos += sprintf(pos, "%02x", |
52 | aaddr->addr.sas_addr.prv[i]); | ||
52 | } | 53 | } |
53 | pos += sprintf(pos, "\n"); | 54 | pos += sprintf(pos, "\n"); |
54 | } | 55 | } |
@@ -78,17 +79,17 @@ static ssize_t show_link_rate(struct device *cdev, | |||
78 | 79 | ||
79 | /* show the link rate, not the data rate */ | 80 | /* show the link rate, not the data rate */ |
80 | switch (adev->link_rate) { | 81 | switch (adev->link_rate) { |
81 | case ATM_OC3_PCR: | 82 | case ATM_OC3_PCR: |
82 | link_rate = 155520000; | 83 | link_rate = 155520000; |
83 | break; | 84 | break; |
84 | case ATM_OC12_PCR: | 85 | case ATM_OC12_PCR: |
85 | link_rate = 622080000; | 86 | link_rate = 622080000; |
86 | break; | 87 | break; |
87 | case ATM_25_PCR: | 88 | case ATM_25_PCR: |
88 | link_rate = 25600000; | 89 | link_rate = 25600000; |
89 | break; | 90 | break; |
90 | default: | 91 | default: |
91 | link_rate = adev->link_rate * 8 * 53; | 92 | link_rate = adev->link_rate * 8 * 53; |
92 | } | 93 | } |
93 | pos += sprintf(pos, "%d\n", link_rate); | 94 | pos += sprintf(pos, "%d\n", link_rate); |
94 | 95 | ||
diff --git a/net/atm/br2684.c b/net/atm/br2684.c index c9230c398697..4d64d87e7578 100644 --- a/net/atm/br2684.c +++ b/net/atm/br2684.c | |||
@@ -6,6 +6,8 @@ | |||
6 | * Eric Kinzie, 2006-2007, US Naval Research Laboratory | 6 | * Eric Kinzie, 2006-2007, US Naval Research Laboratory |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
10 | |||
9 | #include <linux/module.h> | 11 | #include <linux/module.h> |
10 | #include <linux/init.h> | 12 | #include <linux/init.h> |
11 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
@@ -15,7 +17,7 @@ | |||
15 | #include <linux/etherdevice.h> | 17 | #include <linux/etherdevice.h> |
16 | #include <linux/rtnetlink.h> | 18 | #include <linux/rtnetlink.h> |
17 | #include <linux/ip.h> | 19 | #include <linux/ip.h> |
18 | #include <asm/uaccess.h> | 20 | #include <linux/uaccess.h> |
19 | #include <net/arp.h> | 21 | #include <net/arp.h> |
20 | #include <linux/atm.h> | 22 | #include <linux/atm.h> |
21 | #include <linux/atmdev.h> | 23 | #include <linux/atmdev.h> |
@@ -26,20 +28,14 @@ | |||
26 | 28 | ||
27 | #include "common.h" | 29 | #include "common.h" |
28 | 30 | ||
29 | #ifdef SKB_DEBUG | ||
30 | static void skb_debug(const struct sk_buff *skb) | 31 | static void skb_debug(const struct sk_buff *skb) |
31 | { | 32 | { |
33 | #ifdef SKB_DEBUG | ||
32 | #define NUM2PRINT 50 | 34 | #define NUM2PRINT 50 |
33 | char buf[NUM2PRINT * 3 + 1]; /* 3 chars per byte */ | 35 | print_hex_dump(KERN_DEBUG, "br2684: skb: ", DUMP_OFFSET, |
34 | int i = 0; | 36 | 16, 1, skb->data, min(NUM2PRINT, skb->len), true); |
35 | for (i = 0; i < skb->len && i < NUM2PRINT; i++) { | ||
36 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); | ||
37 | } | ||
38 | printk(KERN_DEBUG "br2684: skb: %s\n", buf); | ||
39 | } | ||
40 | #else | ||
41 | #define skb_debug(skb) do {} while (0) | ||
42 | #endif | 37 | #endif |
38 | } | ||
43 | 39 | ||
44 | #define BR2684_ETHERTYPE_LEN 2 | 40 | #define BR2684_ETHERTYPE_LEN 2 |
45 | #define BR2684_PAD_LEN 2 | 41 | #define BR2684_PAD_LEN 2 |
@@ -68,7 +64,7 @@ struct br2684_vcc { | |||
68 | struct atm_vcc *atmvcc; | 64 | struct atm_vcc *atmvcc; |
69 | struct net_device *device; | 65 | struct net_device *device; |
70 | /* keep old push, pop functions for chaining */ | 66 | /* keep old push, pop functions for chaining */ |
71 | void (*old_push) (struct atm_vcc * vcc, struct sk_buff * skb); | 67 | void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb); |
72 | void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); | 68 | void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); |
73 | enum br2684_encaps encaps; | 69 | enum br2684_encaps encaps; |
74 | struct list_head brvccs; | 70 | struct list_head brvccs; |
@@ -148,7 +144,7 @@ static void br2684_pop(struct atm_vcc *vcc, struct sk_buff *skb) | |||
148 | struct br2684_vcc *brvcc = BR2684_VCC(vcc); | 144 | struct br2684_vcc *brvcc = BR2684_VCC(vcc); |
149 | struct net_device *net_dev = skb->dev; | 145 | struct net_device *net_dev = skb->dev; |
150 | 146 | ||
151 | pr_debug("br2684_pop(vcc %p ; net_dev %p )\n", vcc, net_dev); | 147 | pr_debug("(vcc %p ; net_dev %p )\n", vcc, net_dev); |
152 | brvcc->old_pop(vcc, skb); | 148 | brvcc->old_pop(vcc, skb); |
153 | 149 | ||
154 | if (!net_dev) | 150 | if (!net_dev) |
@@ -244,7 +240,7 @@ static netdev_tx_t br2684_start_xmit(struct sk_buff *skb, | |||
244 | struct br2684_dev *brdev = BRPRIV(dev); | 240 | struct br2684_dev *brdev = BRPRIV(dev); |
245 | struct br2684_vcc *brvcc; | 241 | struct br2684_vcc *brvcc; |
246 | 242 | ||
247 | pr_debug("br2684_start_xmit, skb_dst(skb)=%p\n", skb_dst(skb)); | 243 | pr_debug("skb_dst(skb)=%p\n", skb_dst(skb)); |
248 | read_lock(&devs_lock); | 244 | read_lock(&devs_lock); |
249 | brvcc = pick_outgoing_vcc(skb, brdev); | 245 | brvcc = pick_outgoing_vcc(skb, brdev); |
250 | if (brvcc == NULL) { | 246 | if (brvcc == NULL) { |
@@ -300,7 +296,8 @@ static int br2684_setfilt(struct atm_vcc *atmvcc, void __user * arg) | |||
300 | struct br2684_dev *brdev; | 296 | struct br2684_dev *brdev; |
301 | read_lock(&devs_lock); | 297 | read_lock(&devs_lock); |
302 | brdev = BRPRIV(br2684_find_dev(&fs.ifspec)); | 298 | brdev = BRPRIV(br2684_find_dev(&fs.ifspec)); |
303 | if (brdev == NULL || list_empty(&brdev->brvccs) || brdev->brvccs.next != brdev->brvccs.prev) /* >1 VCC */ | 299 | if (brdev == NULL || list_empty(&brdev->brvccs) || |
300 | brdev->brvccs.next != brdev->brvccs.prev) /* >1 VCC */ | ||
304 | brvcc = NULL; | 301 | brvcc = NULL; |
305 | else | 302 | else |
306 | brvcc = list_entry_brvcc(brdev->brvccs.next); | 303 | brvcc = list_entry_brvcc(brdev->brvccs.next); |
@@ -352,7 +349,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb) | |||
352 | struct net_device *net_dev = brvcc->device; | 349 | struct net_device *net_dev = brvcc->device; |
353 | struct br2684_dev *brdev = BRPRIV(net_dev); | 350 | struct br2684_dev *brdev = BRPRIV(net_dev); |
354 | 351 | ||
355 | pr_debug("br2684_push\n"); | 352 | pr_debug("\n"); |
356 | 353 | ||
357 | if (unlikely(skb == NULL)) { | 354 | if (unlikely(skb == NULL)) { |
358 | /* skb==NULL means VCC is being destroyed */ | 355 | /* skb==NULL means VCC is being destroyed */ |
@@ -376,29 +373,25 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb) | |||
376 | __skb_trim(skb, skb->len - 4); | 373 | __skb_trim(skb, skb->len - 4); |
377 | 374 | ||
378 | /* accept packets that have "ipv[46]" in the snap header */ | 375 | /* accept packets that have "ipv[46]" in the snap header */ |
379 | if ((skb->len >= (sizeof(llc_oui_ipv4))) | 376 | if ((skb->len >= (sizeof(llc_oui_ipv4))) && |
380 | && | 377 | (memcmp(skb->data, llc_oui_ipv4, |
381 | (memcmp | 378 | sizeof(llc_oui_ipv4) - BR2684_ETHERTYPE_LEN) == 0)) { |
382 | (skb->data, llc_oui_ipv4, | 379 | if (memcmp(skb->data + 6, ethertype_ipv6, |
383 | sizeof(llc_oui_ipv4) - BR2684_ETHERTYPE_LEN) == 0)) { | 380 | sizeof(ethertype_ipv6)) == 0) |
384 | if (memcmp | ||
385 | (skb->data + 6, ethertype_ipv6, | ||
386 | sizeof(ethertype_ipv6)) == 0) | ||
387 | skb->protocol = htons(ETH_P_IPV6); | 381 | skb->protocol = htons(ETH_P_IPV6); |
388 | else if (memcmp | 382 | else if (memcmp(skb->data + 6, ethertype_ipv4, |
389 | (skb->data + 6, ethertype_ipv4, | 383 | sizeof(ethertype_ipv4)) == 0) |
390 | sizeof(ethertype_ipv4)) == 0) | ||
391 | skb->protocol = htons(ETH_P_IP); | 384 | skb->protocol = htons(ETH_P_IP); |
392 | else | 385 | else |
393 | goto error; | 386 | goto error; |
394 | skb_pull(skb, sizeof(llc_oui_ipv4)); | 387 | skb_pull(skb, sizeof(llc_oui_ipv4)); |
395 | skb_reset_network_header(skb); | 388 | skb_reset_network_header(skb); |
396 | skb->pkt_type = PACKET_HOST; | 389 | skb->pkt_type = PACKET_HOST; |
397 | /* | 390 | /* |
398 | * Let us waste some time for checking the encapsulation. | 391 | * Let us waste some time for checking the encapsulation. |
399 | * Note, that only 7 char is checked so frames with a valid FCS | 392 | * Note, that only 7 char is checked so frames with a valid FCS |
400 | * are also accepted (but FCS is not checked of course). | 393 | * are also accepted (but FCS is not checked of course). |
401 | */ | 394 | */ |
402 | } else if ((skb->len >= sizeof(llc_oui_pid_pad)) && | 395 | } else if ((skb->len >= sizeof(llc_oui_pid_pad)) && |
403 | (memcmp(skb->data, llc_oui_pid_pad, 7) == 0)) { | 396 | (memcmp(skb->data, llc_oui_pid_pad, 7) == 0)) { |
404 | skb_pull(skb, sizeof(llc_oui_pid_pad)); | 397 | skb_pull(skb, sizeof(llc_oui_pid_pad)); |
@@ -479,8 +472,7 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) | |||
479 | write_lock_irq(&devs_lock); | 472 | write_lock_irq(&devs_lock); |
480 | net_dev = br2684_find_dev(&be.ifspec); | 473 | net_dev = br2684_find_dev(&be.ifspec); |
481 | if (net_dev == NULL) { | 474 | if (net_dev == NULL) { |
482 | printk(KERN_ERR | 475 | pr_err("tried to attach to non-existant device\n"); |
483 | "br2684: tried to attach to non-existant device\n"); | ||
484 | err = -ENXIO; | 476 | err = -ENXIO; |
485 | goto error; | 477 | goto error; |
486 | } | 478 | } |
@@ -494,17 +486,16 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) | |||
494 | err = -EEXIST; | 486 | err = -EEXIST; |
495 | goto error; | 487 | goto error; |
496 | } | 488 | } |
497 | if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO || | 489 | if (be.fcs_in != BR2684_FCSIN_NO || |
498 | be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps != | 490 | be.fcs_out != BR2684_FCSOUT_NO || |
499 | BR2684_ENCAPS_VC | 491 | be.fcs_auto || be.has_vpiid || be.send_padding || |
500 | && be.encaps != | 492 | (be.encaps != BR2684_ENCAPS_VC && |
501 | BR2684_ENCAPS_LLC) | 493 | be.encaps != BR2684_ENCAPS_LLC) || |
502 | || be.min_size != 0) { | 494 | be.min_size != 0) { |
503 | err = -EINVAL; | 495 | err = -EINVAL; |
504 | goto error; | 496 | goto error; |
505 | } | 497 | } |
506 | pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, | 498 | pr_debug("vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, be.encaps, brvcc); |
507 | be.encaps, brvcc); | ||
508 | if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) { | 499 | if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) { |
509 | unsigned char *esi = atmvcc->dev->esi; | 500 | unsigned char *esi = atmvcc->dev->esi; |
510 | if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5]) | 501 | if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5]) |
@@ -541,7 +532,8 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) | |||
541 | } | 532 | } |
542 | __module_get(THIS_MODULE); | 533 | __module_get(THIS_MODULE); |
543 | return 0; | 534 | return 0; |
544 | error: | 535 | |
536 | error: | ||
545 | write_unlock_irq(&devs_lock); | 537 | write_unlock_irq(&devs_lock); |
546 | kfree(brvcc); | 538 | kfree(brvcc); |
547 | return err; | 539 | return err; |
@@ -587,7 +579,7 @@ static void br2684_setup_routed(struct net_device *netdev) | |||
587 | INIT_LIST_HEAD(&brdev->brvccs); | 579 | INIT_LIST_HEAD(&brdev->brvccs); |
588 | } | 580 | } |
589 | 581 | ||
590 | static int br2684_create(void __user * arg) | 582 | static int br2684_create(void __user *arg) |
591 | { | 583 | { |
592 | int err; | 584 | int err; |
593 | struct net_device *netdev; | 585 | struct net_device *netdev; |
@@ -595,11 +587,10 @@ static int br2684_create(void __user * arg) | |||
595 | struct atm_newif_br2684 ni; | 587 | struct atm_newif_br2684 ni; |
596 | enum br2684_payload payload; | 588 | enum br2684_payload payload; |
597 | 589 | ||
598 | pr_debug("br2684_create\n"); | 590 | pr_debug("\n"); |
599 | 591 | ||
600 | if (copy_from_user(&ni, arg, sizeof ni)) { | 592 | if (copy_from_user(&ni, arg, sizeof ni)) |
601 | return -EFAULT; | 593 | return -EFAULT; |
602 | } | ||
603 | 594 | ||
604 | if (ni.media & BR2684_FLAG_ROUTED) | 595 | if (ni.media & BR2684_FLAG_ROUTED) |
605 | payload = p_routed; | 596 | payload = p_routed; |
@@ -607,9 +598,8 @@ static int br2684_create(void __user * arg) | |||
607 | payload = p_bridged; | 598 | payload = p_bridged; |
608 | ni.media &= 0xffff; /* strip flags */ | 599 | ni.media &= 0xffff; /* strip flags */ |
609 | 600 | ||
610 | if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) { | 601 | if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) |
611 | return -EINVAL; | 602 | return -EINVAL; |
612 | } | ||
613 | 603 | ||
614 | netdev = alloc_netdev(sizeof(struct br2684_dev), | 604 | netdev = alloc_netdev(sizeof(struct br2684_dev), |
615 | ni.ifname[0] ? ni.ifname : "nas%d", | 605 | ni.ifname[0] ? ni.ifname : "nas%d", |
@@ -624,7 +614,7 @@ static int br2684_create(void __user * arg) | |||
624 | /* open, stop, do_ioctl ? */ | 614 | /* open, stop, do_ioctl ? */ |
625 | err = register_netdev(netdev); | 615 | err = register_netdev(netdev); |
626 | if (err < 0) { | 616 | if (err < 0) { |
627 | printk(KERN_ERR "br2684_create: register_netdev failed\n"); | 617 | pr_err("register_netdev failed\n"); |
628 | free_netdev(netdev); | 618 | free_netdev(netdev); |
629 | return err; | 619 | return err; |
630 | } | 620 | } |
diff --git a/net/atm/clip.c b/net/atm/clip.c index 64629c354343..ebfa022008f7 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ |
4 | 4 | ||
5 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
6 | |||
5 | #include <linux/string.h> | 7 | #include <linux/string.h> |
6 | #include <linux/errno.h> | 8 | #include <linux/errno.h> |
7 | #include <linux/kernel.h> /* for UINT_MAX */ | 9 | #include <linux/kernel.h> /* for UINT_MAX */ |
@@ -30,10 +32,10 @@ | |||
30 | #include <linux/jhash.h> | 32 | #include <linux/jhash.h> |
31 | #include <net/route.h> /* for struct rtable and routing */ | 33 | #include <net/route.h> /* for struct rtable and routing */ |
32 | #include <net/icmp.h> /* icmp_send */ | 34 | #include <net/icmp.h> /* icmp_send */ |
33 | #include <asm/param.h> /* for HZ */ | 35 | #include <linux/param.h> /* for HZ */ |
36 | #include <linux/uaccess.h> | ||
34 | #include <asm/byteorder.h> /* for htons etc. */ | 37 | #include <asm/byteorder.h> /* for htons etc. */ |
35 | #include <asm/system.h> /* save/restore_flags */ | 38 | #include <asm/system.h> /* save/restore_flags */ |
36 | #include <asm/uaccess.h> | ||
37 | #include <asm/atomic.h> | 39 | #include <asm/atomic.h> |
38 | 40 | ||
39 | #include "common.h" | 41 | #include "common.h" |
@@ -51,13 +53,13 @@ static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip) | |||
51 | struct atmarp_ctrl *ctrl; | 53 | struct atmarp_ctrl *ctrl; |
52 | struct sk_buff *skb; | 54 | struct sk_buff *skb; |
53 | 55 | ||
54 | pr_debug("to_atmarpd(%d)\n", type); | 56 | pr_debug("(%d)\n", type); |
55 | if (!atmarpd) | 57 | if (!atmarpd) |
56 | return -EUNATCH; | 58 | return -EUNATCH; |
57 | skb = alloc_skb(sizeof(struct atmarp_ctrl),GFP_ATOMIC); | 59 | skb = alloc_skb(sizeof(struct atmarp_ctrl), GFP_ATOMIC); |
58 | if (!skb) | 60 | if (!skb) |
59 | return -ENOMEM; | 61 | return -ENOMEM; |
60 | ctrl = (struct atmarp_ctrl *) skb_put(skb,sizeof(struct atmarp_ctrl)); | 62 | ctrl = (struct atmarp_ctrl *)skb_put(skb, sizeof(struct atmarp_ctrl)); |
61 | ctrl->type = type; | 63 | ctrl->type = type; |
62 | ctrl->itf_num = itf; | 64 | ctrl->itf_num = itf; |
63 | ctrl->ip = ip; | 65 | ctrl->ip = ip; |
@@ -71,8 +73,7 @@ static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip) | |||
71 | 73 | ||
72 | static void link_vcc(struct clip_vcc *clip_vcc, struct atmarp_entry *entry) | 74 | static void link_vcc(struct clip_vcc *clip_vcc, struct atmarp_entry *entry) |
73 | { | 75 | { |
74 | pr_debug("link_vcc %p to entry %p (neigh %p)\n", clip_vcc, entry, | 76 | pr_debug("%p to entry %p (neigh %p)\n", clip_vcc, entry, entry->neigh); |
75 | entry->neigh); | ||
76 | clip_vcc->entry = entry; | 77 | clip_vcc->entry = entry; |
77 | clip_vcc->xoff = 0; /* @@@ may overrun buffer by one packet */ | 78 | clip_vcc->xoff = 0; /* @@@ may overrun buffer by one packet */ |
78 | clip_vcc->next = entry->vccs; | 79 | clip_vcc->next = entry->vccs; |
@@ -86,7 +87,7 @@ static void unlink_clip_vcc(struct clip_vcc *clip_vcc) | |||
86 | struct clip_vcc **walk; | 87 | struct clip_vcc **walk; |
87 | 88 | ||
88 | if (!entry) { | 89 | if (!entry) { |
89 | printk(KERN_CRIT "!clip_vcc->entry (clip_vcc %p)\n", clip_vcc); | 90 | pr_crit("!clip_vcc->entry (clip_vcc %p)\n", clip_vcc); |
90 | return; | 91 | return; |
91 | } | 92 | } |
92 | netif_tx_lock_bh(entry->neigh->dev); /* block clip_start_xmit() */ | 93 | netif_tx_lock_bh(entry->neigh->dev); /* block clip_start_xmit() */ |
@@ -106,13 +107,11 @@ static void unlink_clip_vcc(struct clip_vcc *clip_vcc) | |||
106 | error = neigh_update(entry->neigh, NULL, NUD_NONE, | 107 | error = neigh_update(entry->neigh, NULL, NUD_NONE, |
107 | NEIGH_UPDATE_F_ADMIN); | 108 | NEIGH_UPDATE_F_ADMIN); |
108 | if (error) | 109 | if (error) |
109 | printk(KERN_CRIT "unlink_clip_vcc: " | 110 | pr_crit("neigh_update failed with %d\n", error); |
110 | "neigh_update failed with %d\n", error); | ||
111 | goto out; | 111 | goto out; |
112 | } | 112 | } |
113 | printk(KERN_CRIT "ATMARP: unlink_clip_vcc failed (entry %p, vcc " | 113 | pr_crit("ATMARP: failed (entry %p, vcc 0x%p)\n", entry, clip_vcc); |
114 | "0x%p)\n", entry, clip_vcc); | 114 | out: |
115 | out: | ||
116 | netif_tx_unlock_bh(entry->neigh->dev); | 115 | netif_tx_unlock_bh(entry->neigh->dev); |
117 | } | 116 | } |
118 | 117 | ||
@@ -127,7 +126,7 @@ static int neigh_check_cb(struct neighbour *n) | |||
127 | 126 | ||
128 | if (cv->idle_timeout && time_after(jiffies, exp)) { | 127 | if (cv->idle_timeout && time_after(jiffies, exp)) { |
129 | pr_debug("releasing vcc %p->%p of entry %p\n", | 128 | pr_debug("releasing vcc %p->%p of entry %p\n", |
130 | cv, cv->vcc, entry); | 129 | cv, cv->vcc, entry); |
131 | vcc_release_async(cv->vcc, -ETIMEDOUT); | 130 | vcc_release_async(cv->vcc, -ETIMEDOUT); |
132 | } | 131 | } |
133 | } | 132 | } |
@@ -139,7 +138,7 @@ static int neigh_check_cb(struct neighbour *n) | |||
139 | struct sk_buff *skb; | 138 | struct sk_buff *skb; |
140 | 139 | ||
141 | pr_debug("destruction postponed with ref %d\n", | 140 | pr_debug("destruction postponed with ref %d\n", |
142 | atomic_read(&n->refcnt)); | 141 | atomic_read(&n->refcnt)); |
143 | 142 | ||
144 | while ((skb = skb_dequeue(&n->arp_queue)) != NULL) | 143 | while ((skb = skb_dequeue(&n->arp_queue)) != NULL) |
145 | dev_kfree_skb(skb); | 144 | dev_kfree_skb(skb); |
@@ -163,7 +162,7 @@ static int clip_arp_rcv(struct sk_buff *skb) | |||
163 | { | 162 | { |
164 | struct atm_vcc *vcc; | 163 | struct atm_vcc *vcc; |
165 | 164 | ||
166 | pr_debug("clip_arp_rcv\n"); | 165 | pr_debug("\n"); |
167 | vcc = ATM_SKB(skb)->vcc; | 166 | vcc = ATM_SKB(skb)->vcc; |
168 | if (!vcc || !atm_charge(vcc, skb->truesize)) { | 167 | if (!vcc || !atm_charge(vcc, skb->truesize)) { |
169 | dev_kfree_skb_any(skb); | 168 | dev_kfree_skb_any(skb); |
@@ -188,7 +187,7 @@ static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
188 | { | 187 | { |
189 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); | 188 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); |
190 | 189 | ||
191 | pr_debug("clip push\n"); | 190 | pr_debug("\n"); |
192 | if (!skb) { | 191 | if (!skb) { |
193 | pr_debug("removing VCC %p\n", clip_vcc); | 192 | pr_debug("removing VCC %p\n", clip_vcc); |
194 | if (clip_vcc->entry) | 193 | if (clip_vcc->entry) |
@@ -206,12 +205,12 @@ static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
206 | } | 205 | } |
207 | ATM_SKB(skb)->vcc = vcc; | 206 | ATM_SKB(skb)->vcc = vcc; |
208 | skb_reset_mac_header(skb); | 207 | skb_reset_mac_header(skb); |
209 | if (!clip_vcc->encap | 208 | if (!clip_vcc->encap || |
210 | || skb->len < RFC1483LLC_LEN | 209 | skb->len < RFC1483LLC_LEN || |
211 | || memcmp(skb->data, llc_oui, sizeof (llc_oui))) | 210 | memcmp(skb->data, llc_oui, sizeof(llc_oui))) |
212 | skb->protocol = htons(ETH_P_IP); | 211 | skb->protocol = htons(ETH_P_IP); |
213 | else { | 212 | else { |
214 | skb->protocol = ((__be16 *) skb->data)[3]; | 213 | skb->protocol = ((__be16 *)skb->data)[3]; |
215 | skb_pull(skb, RFC1483LLC_LEN); | 214 | skb_pull(skb, RFC1483LLC_LEN); |
216 | if (skb->protocol == htons(ETH_P_ARP)) { | 215 | if (skb->protocol == htons(ETH_P_ARP)) { |
217 | skb->dev->stats.rx_packets++; | 216 | skb->dev->stats.rx_packets++; |
@@ -239,7 +238,7 @@ static void clip_pop(struct atm_vcc *vcc, struct sk_buff *skb) | |||
239 | int old; | 238 | int old; |
240 | unsigned long flags; | 239 | unsigned long flags; |
241 | 240 | ||
242 | pr_debug("clip_pop(vcc %p)\n", vcc); | 241 | pr_debug("(vcc %p)\n", vcc); |
243 | clip_vcc->old_pop(vcc, skb); | 242 | clip_vcc->old_pop(vcc, skb); |
244 | /* skb->dev == NULL in outbound ARP packets */ | 243 | /* skb->dev == NULL in outbound ARP packets */ |
245 | if (!dev) | 244 | if (!dev) |
@@ -255,7 +254,7 @@ static void clip_pop(struct atm_vcc *vcc, struct sk_buff *skb) | |||
255 | 254 | ||
256 | static void clip_neigh_solicit(struct neighbour *neigh, struct sk_buff *skb) | 255 | static void clip_neigh_solicit(struct neighbour *neigh, struct sk_buff *skb) |
257 | { | 256 | { |
258 | pr_debug("clip_neigh_solicit (neigh %p, skb %p)\n", neigh, skb); | 257 | pr_debug("(neigh %p, skb %p)\n", neigh, skb); |
259 | to_atmarpd(act_need, PRIV(neigh->dev)->number, NEIGH2ENTRY(neigh)->ip); | 258 | to_atmarpd(act_need, PRIV(neigh->dev)->number, NEIGH2ENTRY(neigh)->ip); |
260 | } | 259 | } |
261 | 260 | ||
@@ -284,7 +283,7 @@ static int clip_constructor(struct neighbour *neigh) | |||
284 | struct in_device *in_dev; | 283 | struct in_device *in_dev; |
285 | struct neigh_parms *parms; | 284 | struct neigh_parms *parms; |
286 | 285 | ||
287 | pr_debug("clip_constructor (neigh %p, entry %p)\n", neigh, entry); | 286 | pr_debug("(neigh %p, entry %p)\n", neigh, entry); |
288 | neigh->type = inet_addr_type(&init_net, entry->ip); | 287 | neigh->type = inet_addr_type(&init_net, entry->ip); |
289 | if (neigh->type != RTN_UNICAST) | 288 | if (neigh->type != RTN_UNICAST) |
290 | return -EINVAL; | 289 | return -EINVAL; |
@@ -369,9 +368,9 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, | |||
369 | int old; | 368 | int old; |
370 | unsigned long flags; | 369 | unsigned long flags; |
371 | 370 | ||
372 | pr_debug("clip_start_xmit (skb %p)\n", skb); | 371 | pr_debug("(skb %p)\n", skb); |
373 | if (!skb_dst(skb)) { | 372 | if (!skb_dst(skb)) { |
374 | printk(KERN_ERR "clip_start_xmit: skb_dst(skb) == NULL\n"); | 373 | pr_err("skb_dst(skb) == NULL\n"); |
375 | dev_kfree_skb(skb); | 374 | dev_kfree_skb(skb); |
376 | dev->stats.tx_dropped++; | 375 | dev->stats.tx_dropped++; |
377 | return NETDEV_TX_OK; | 376 | return NETDEV_TX_OK; |
@@ -385,7 +384,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, | |||
385 | return 0; | 384 | return 0; |
386 | } | 385 | } |
387 | #endif | 386 | #endif |
388 | printk(KERN_ERR "clip_start_xmit: NO NEIGHBOUR !\n"); | 387 | pr_err("NO NEIGHBOUR !\n"); |
389 | dev_kfree_skb(skb); | 388 | dev_kfree_skb(skb); |
390 | dev->stats.tx_dropped++; | 389 | dev->stats.tx_dropped++; |
391 | return NETDEV_TX_OK; | 390 | return NETDEV_TX_OK; |
@@ -421,7 +420,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, | |||
421 | pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev); | 420 | pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev); |
422 | old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */ | 421 | old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */ |
423 | if (old) { | 422 | if (old) { |
424 | printk(KERN_WARNING "clip_start_xmit: XOFF->XOFF transition\n"); | 423 | pr_warning("XOFF->XOFF transition\n"); |
425 | return NETDEV_TX_OK; | 424 | return NETDEV_TX_OK; |
426 | } | 425 | } |
427 | dev->stats.tx_packets++; | 426 | dev->stats.tx_packets++; |
@@ -456,7 +455,7 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout) | |||
456 | clip_vcc = kmalloc(sizeof(struct clip_vcc), GFP_KERNEL); | 455 | clip_vcc = kmalloc(sizeof(struct clip_vcc), GFP_KERNEL); |
457 | if (!clip_vcc) | 456 | if (!clip_vcc) |
458 | return -ENOMEM; | 457 | return -ENOMEM; |
459 | pr_debug("mkip clip_vcc %p vcc %p\n", clip_vcc, vcc); | 458 | pr_debug("%p vcc %p\n", clip_vcc, vcc); |
460 | clip_vcc->vcc = vcc; | 459 | clip_vcc->vcc = vcc; |
461 | vcc->user_back = clip_vcc; | 460 | vcc->user_back = clip_vcc; |
462 | set_bit(ATM_VF_IS_CLIP, &vcc->flags); | 461 | set_bit(ATM_VF_IS_CLIP, &vcc->flags); |
@@ -506,16 +505,16 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip) | |||
506 | struct rtable *rt; | 505 | struct rtable *rt; |
507 | 506 | ||
508 | if (vcc->push != clip_push) { | 507 | if (vcc->push != clip_push) { |
509 | printk(KERN_WARNING "clip_setentry: non-CLIP VCC\n"); | 508 | pr_warning("non-CLIP VCC\n"); |
510 | return -EBADF; | 509 | return -EBADF; |
511 | } | 510 | } |
512 | clip_vcc = CLIP_VCC(vcc); | 511 | clip_vcc = CLIP_VCC(vcc); |
513 | if (!ip) { | 512 | if (!ip) { |
514 | if (!clip_vcc->entry) { | 513 | if (!clip_vcc->entry) { |
515 | printk(KERN_ERR "hiding hidden ATMARP entry\n"); | 514 | pr_err("hiding hidden ATMARP entry\n"); |
516 | return 0; | 515 | return 0; |
517 | } | 516 | } |
518 | pr_debug("setentry: remove\n"); | 517 | pr_debug("remove\n"); |
519 | unlink_clip_vcc(clip_vcc); | 518 | unlink_clip_vcc(clip_vcc); |
520 | return 0; | 519 | return 0; |
521 | } | 520 | } |
@@ -529,9 +528,9 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip) | |||
529 | entry = NEIGH2ENTRY(neigh); | 528 | entry = NEIGH2ENTRY(neigh); |
530 | if (entry != clip_vcc->entry) { | 529 | if (entry != clip_vcc->entry) { |
531 | if (!clip_vcc->entry) | 530 | if (!clip_vcc->entry) |
532 | pr_debug("setentry: add\n"); | 531 | pr_debug("add\n"); |
533 | else { | 532 | else { |
534 | pr_debug("setentry: update\n"); | 533 | pr_debug("update\n"); |
535 | unlink_clip_vcc(clip_vcc); | 534 | unlink_clip_vcc(clip_vcc); |
536 | } | 535 | } |
537 | link_vcc(clip_vcc, entry); | 536 | link_vcc(clip_vcc, entry); |
@@ -614,16 +613,16 @@ static int clip_device_event(struct notifier_block *this, unsigned long event, | |||
614 | 613 | ||
615 | switch (event) { | 614 | switch (event) { |
616 | case NETDEV_UP: | 615 | case NETDEV_UP: |
617 | pr_debug("clip_device_event NETDEV_UP\n"); | 616 | pr_debug("NETDEV_UP\n"); |
618 | to_atmarpd(act_up, PRIV(dev)->number, 0); | 617 | to_atmarpd(act_up, PRIV(dev)->number, 0); |
619 | break; | 618 | break; |
620 | case NETDEV_GOING_DOWN: | 619 | case NETDEV_GOING_DOWN: |
621 | pr_debug("clip_device_event NETDEV_DOWN\n"); | 620 | pr_debug("NETDEV_DOWN\n"); |
622 | to_atmarpd(act_down, PRIV(dev)->number, 0); | 621 | to_atmarpd(act_down, PRIV(dev)->number, 0); |
623 | break; | 622 | break; |
624 | case NETDEV_CHANGE: | 623 | case NETDEV_CHANGE: |
625 | case NETDEV_CHANGEMTU: | 624 | case NETDEV_CHANGEMTU: |
626 | pr_debug("clip_device_event NETDEV_CHANGE*\n"); | 625 | pr_debug("NETDEV_CHANGE*\n"); |
627 | to_atmarpd(act_change, PRIV(dev)->number, 0); | 626 | to_atmarpd(act_change, PRIV(dev)->number, 0); |
628 | break; | 627 | break; |
629 | } | 628 | } |
@@ -645,7 +644,6 @@ static int clip_inet_event(struct notifier_block *this, unsigned long event, | |||
645 | return clip_device_event(this, NETDEV_CHANGE, in_dev->dev); | 644 | return clip_device_event(this, NETDEV_CHANGE, in_dev->dev); |
646 | } | 645 | } |
647 | 646 | ||
648 | |||
649 | static struct notifier_block clip_dev_notifier = { | 647 | static struct notifier_block clip_dev_notifier = { |
650 | .notifier_call = clip_device_event, | 648 | .notifier_call = clip_device_event, |
651 | }; | 649 | }; |
@@ -660,7 +658,7 @@ static struct notifier_block clip_inet_notifier = { | |||
660 | 658 | ||
661 | static void atmarpd_close(struct atm_vcc *vcc) | 659 | static void atmarpd_close(struct atm_vcc *vcc) |
662 | { | 660 | { |
663 | pr_debug("atmarpd_close\n"); | 661 | pr_debug("\n"); |
664 | 662 | ||
665 | rtnl_lock(); | 663 | rtnl_lock(); |
666 | atmarpd = NULL; | 664 | atmarpd = NULL; |
@@ -671,7 +669,6 @@ static void atmarpd_close(struct atm_vcc *vcc) | |||
671 | module_put(THIS_MODULE); | 669 | module_put(THIS_MODULE); |
672 | } | 670 | } |
673 | 671 | ||
674 | |||
675 | static struct atmdev_ops atmarpd_dev_ops = { | 672 | static struct atmdev_ops atmarpd_dev_ops = { |
676 | .close = atmarpd_close | 673 | .close = atmarpd_close |
677 | }; | 674 | }; |
@@ -693,11 +690,11 @@ static int atm_init_atmarp(struct atm_vcc *vcc) | |||
693 | return -EADDRINUSE; | 690 | return -EADDRINUSE; |
694 | } | 691 | } |
695 | 692 | ||
696 | mod_timer(&idle_timer, jiffies+CLIP_CHECK_INTERVAL*HZ); | 693 | mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ); |
697 | 694 | ||
698 | atmarpd = vcc; | 695 | atmarpd = vcc; |
699 | set_bit(ATM_VF_META,&vcc->flags); | 696 | set_bit(ATM_VF_META, &vcc->flags); |
700 | set_bit(ATM_VF_READY,&vcc->flags); | 697 | set_bit(ATM_VF_READY, &vcc->flags); |
701 | /* allow replies and avoid getting closed if signaling dies */ | 698 | /* allow replies and avoid getting closed if signaling dies */ |
702 | vcc->dev = &atmarpd_dev; | 699 | vcc->dev = &atmarpd_dev; |
703 | vcc_insert_socket(sk_atm(vcc)); | 700 | vcc_insert_socket(sk_atm(vcc)); |
@@ -950,8 +947,7 @@ static int __init atm_clip_init(void) | |||
950 | 947 | ||
951 | p = proc_create("arp", S_IRUGO, atm_proc_root, &arp_seq_fops); | 948 | p = proc_create("arp", S_IRUGO, atm_proc_root, &arp_seq_fops); |
952 | if (!p) { | 949 | if (!p) { |
953 | printk(KERN_ERR "Unable to initialize " | 950 | pr_err("Unable to initialize /proc/net/atm/arp\n"); |
954 | "/proc/net/atm/arp\n"); | ||
955 | atm_clip_exit_noproc(); | 951 | atm_clip_exit_noproc(); |
956 | return -ENOMEM; | 952 | return -ENOMEM; |
957 | } | 953 | } |
diff --git a/net/atm/common.c b/net/atm/common.c index d61e051e0a3f..74d095a081e3 100644 --- a/net/atm/common.c +++ b/net/atm/common.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ |
4 | 4 | ||
5 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
5 | 6 | ||
6 | #include <linux/module.h> | 7 | #include <linux/module.h> |
7 | #include <linux/kmod.h> | 8 | #include <linux/kmod.h> |
@@ -18,11 +19,10 @@ | |||
18 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
20 | #include <net/sock.h> /* struct sock */ | 21 | #include <net/sock.h> /* struct sock */ |
22 | #include <linux/uaccess.h> | ||
23 | #include <linux/poll.h> | ||
21 | 24 | ||
22 | #include <asm/uaccess.h> | ||
23 | #include <asm/atomic.h> | 25 | #include <asm/atomic.h> |
24 | #include <asm/poll.h> | ||
25 | |||
26 | 26 | ||
27 | #include "resources.h" /* atm_find_dev */ | 27 | #include "resources.h" /* atm_find_dev */ |
28 | #include "common.h" /* prototypes */ | 28 | #include "common.h" /* prototypes */ |
@@ -31,13 +31,15 @@ | |||
31 | #include "signaling.h" /* for WAITING and sigd_attach */ | 31 | #include "signaling.h" /* for WAITING and sigd_attach */ |
32 | 32 | ||
33 | struct hlist_head vcc_hash[VCC_HTABLE_SIZE]; | 33 | struct hlist_head vcc_hash[VCC_HTABLE_SIZE]; |
34 | EXPORT_SYMBOL(vcc_hash); | ||
35 | |||
34 | DEFINE_RWLOCK(vcc_sklist_lock); | 36 | DEFINE_RWLOCK(vcc_sklist_lock); |
37 | EXPORT_SYMBOL(vcc_sklist_lock); | ||
35 | 38 | ||
36 | static void __vcc_insert_socket(struct sock *sk) | 39 | static void __vcc_insert_socket(struct sock *sk) |
37 | { | 40 | { |
38 | struct atm_vcc *vcc = atm_sk(sk); | 41 | struct atm_vcc *vcc = atm_sk(sk); |
39 | struct hlist_head *head = &vcc_hash[vcc->vci & | 42 | struct hlist_head *head = &vcc_hash[vcc->vci & (VCC_HTABLE_SIZE - 1)]; |
40 | (VCC_HTABLE_SIZE - 1)]; | ||
41 | sk->sk_hash = vcc->vci & (VCC_HTABLE_SIZE - 1); | 43 | sk->sk_hash = vcc->vci & (VCC_HTABLE_SIZE - 1); |
42 | sk_add_node(sk, head); | 44 | sk_add_node(sk, head); |
43 | } | 45 | } |
@@ -48,6 +50,7 @@ void vcc_insert_socket(struct sock *sk) | |||
48 | __vcc_insert_socket(sk); | 50 | __vcc_insert_socket(sk); |
49 | write_unlock_irq(&vcc_sklist_lock); | 51 | write_unlock_irq(&vcc_sklist_lock); |
50 | } | 52 | } |
53 | EXPORT_SYMBOL(vcc_insert_socket); | ||
51 | 54 | ||
52 | static void vcc_remove_socket(struct sock *sk) | 55 | static void vcc_remove_socket(struct sock *sk) |
53 | { | 56 | { |
@@ -56,37 +59,32 @@ static void vcc_remove_socket(struct sock *sk) | |||
56 | write_unlock_irq(&vcc_sklist_lock); | 59 | write_unlock_irq(&vcc_sklist_lock); |
57 | } | 60 | } |
58 | 61 | ||
59 | 62 | static struct sk_buff *alloc_tx(struct atm_vcc *vcc, unsigned int size) | |
60 | static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size) | ||
61 | { | 63 | { |
62 | struct sk_buff *skb; | 64 | struct sk_buff *skb; |
63 | struct sock *sk = sk_atm(vcc); | 65 | struct sock *sk = sk_atm(vcc); |
64 | 66 | ||
65 | if (sk_wmem_alloc_get(sk) && !atm_may_send(vcc, size)) { | 67 | if (sk_wmem_alloc_get(sk) && !atm_may_send(vcc, size)) { |
66 | pr_debug("Sorry: wmem_alloc = %d, size = %d, sndbuf = %d\n", | 68 | pr_debug("Sorry: wmem_alloc = %d, size = %d, sndbuf = %d\n", |
67 | sk_wmem_alloc_get(sk), size, | 69 | sk_wmem_alloc_get(sk), size, sk->sk_sndbuf); |
68 | sk->sk_sndbuf); | ||
69 | return NULL; | 70 | return NULL; |
70 | } | 71 | } |
71 | while (!(skb = alloc_skb(size, GFP_KERNEL))) | 72 | while (!(skb = alloc_skb(size, GFP_KERNEL))) |
72 | schedule(); | 73 | schedule(); |
73 | pr_debug("AlTx %d += %d\n", sk_wmem_alloc_get(sk), skb->truesize); | 74 | pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize); |
74 | atomic_add(skb->truesize, &sk->sk_wmem_alloc); | 75 | atomic_add(skb->truesize, &sk->sk_wmem_alloc); |
75 | return skb; | 76 | return skb; |
76 | } | 77 | } |
77 | 78 | ||
78 | |||
79 | EXPORT_SYMBOL(vcc_hash); | ||
80 | EXPORT_SYMBOL(vcc_sklist_lock); | ||
81 | EXPORT_SYMBOL(vcc_insert_socket); | ||
82 | |||
83 | static void vcc_sock_destruct(struct sock *sk) | 79 | static void vcc_sock_destruct(struct sock *sk) |
84 | { | 80 | { |
85 | if (atomic_read(&sk->sk_rmem_alloc)) | 81 | if (atomic_read(&sk->sk_rmem_alloc)) |
86 | printk(KERN_DEBUG "vcc_sock_destruct: rmem leakage (%d bytes) detected.\n", atomic_read(&sk->sk_rmem_alloc)); | 82 | printk(KERN_DEBUG "%s: rmem leakage (%d bytes) detected.\n", |
83 | __func__, atomic_read(&sk->sk_rmem_alloc)); | ||
87 | 84 | ||
88 | if (atomic_read(&sk->sk_wmem_alloc)) | 85 | if (atomic_read(&sk->sk_wmem_alloc)) |
89 | printk(KERN_DEBUG "vcc_sock_destruct: wmem leakage (%d bytes) detected.\n", atomic_read(&sk->sk_wmem_alloc)); | 86 | printk(KERN_DEBUG "%s: wmem leakage (%d bytes) detected.\n", |
87 | __func__, atomic_read(&sk->sk_wmem_alloc)); | ||
90 | } | 88 | } |
91 | 89 | ||
92 | static void vcc_def_wakeup(struct sock *sk) | 90 | static void vcc_def_wakeup(struct sock *sk) |
@@ -142,8 +140,8 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family) | |||
142 | 140 | ||
143 | vcc = atm_sk(sk); | 141 | vcc = atm_sk(sk); |
144 | vcc->dev = NULL; | 142 | vcc->dev = NULL; |
145 | memset(&vcc->local,0,sizeof(struct sockaddr_atmsvc)); | 143 | memset(&vcc->local, 0, sizeof(struct sockaddr_atmsvc)); |
146 | memset(&vcc->remote,0,sizeof(struct sockaddr_atmsvc)); | 144 | memset(&vcc->remote, 0, sizeof(struct sockaddr_atmsvc)); |
147 | vcc->qos.txtp.max_sdu = 1 << 16; /* for meta VCs */ | 145 | vcc->qos.txtp.max_sdu = 1 << 16; /* for meta VCs */ |
148 | atomic_set(&sk->sk_wmem_alloc, 1); | 146 | atomic_set(&sk->sk_wmem_alloc, 1); |
149 | atomic_set(&sk->sk_rmem_alloc, 0); | 147 | atomic_set(&sk->sk_rmem_alloc, 0); |
@@ -156,7 +154,6 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family) | |||
156 | return 0; | 154 | return 0; |
157 | } | 155 | } |
158 | 156 | ||
159 | |||
160 | static void vcc_destroy_socket(struct sock *sk) | 157 | static void vcc_destroy_socket(struct sock *sk) |
161 | { | 158 | { |
162 | struct atm_vcc *vcc = atm_sk(sk); | 159 | struct atm_vcc *vcc = atm_sk(sk); |
@@ -171,7 +168,7 @@ static void vcc_destroy_socket(struct sock *sk) | |||
171 | vcc->push(vcc, NULL); /* atmarpd has no push */ | 168 | vcc->push(vcc, NULL); /* atmarpd has no push */ |
172 | 169 | ||
173 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { | 170 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { |
174 | atm_return(vcc,skb->truesize); | 171 | atm_return(vcc, skb->truesize); |
175 | kfree_skb(skb); | 172 | kfree_skb(skb); |
176 | } | 173 | } |
177 | 174 | ||
@@ -182,7 +179,6 @@ static void vcc_destroy_socket(struct sock *sk) | |||
182 | vcc_remove_socket(sk); | 179 | vcc_remove_socket(sk); |
183 | } | 180 | } |
184 | 181 | ||
185 | |||
186 | int vcc_release(struct socket *sock) | 182 | int vcc_release(struct socket *sock) |
187 | { | 183 | { |
188 | struct sock *sk = sock->sk; | 184 | struct sock *sk = sock->sk; |
@@ -197,7 +193,6 @@ int vcc_release(struct socket *sock) | |||
197 | return 0; | 193 | return 0; |
198 | } | 194 | } |
199 | 195 | ||
200 | |||
201 | void vcc_release_async(struct atm_vcc *vcc, int reply) | 196 | void vcc_release_async(struct atm_vcc *vcc, int reply) |
202 | { | 197 | { |
203 | struct sock *sk = sk_atm(vcc); | 198 | struct sock *sk = sk_atm(vcc); |
@@ -208,8 +203,6 @@ void vcc_release_async(struct atm_vcc *vcc, int reply) | |||
208 | clear_bit(ATM_VF_WAITING, &vcc->flags); | 203 | clear_bit(ATM_VF_WAITING, &vcc->flags); |
209 | sk->sk_state_change(sk); | 204 | sk->sk_state_change(sk); |
210 | } | 205 | } |
211 | |||
212 | |||
213 | EXPORT_SYMBOL(vcc_release_async); | 206 | EXPORT_SYMBOL(vcc_release_async); |
214 | 207 | ||
215 | 208 | ||
@@ -235,37 +228,37 @@ void atm_dev_release_vccs(struct atm_dev *dev) | |||
235 | write_unlock_irq(&vcc_sklist_lock); | 228 | write_unlock_irq(&vcc_sklist_lock); |
236 | } | 229 | } |
237 | 230 | ||
238 | 231 | static int adjust_tp(struct atm_trafprm *tp, unsigned char aal) | |
239 | static int adjust_tp(struct atm_trafprm *tp,unsigned char aal) | ||
240 | { | 232 | { |
241 | int max_sdu; | 233 | int max_sdu; |
242 | 234 | ||
243 | if (!tp->traffic_class) return 0; | 235 | if (!tp->traffic_class) |
236 | return 0; | ||
244 | switch (aal) { | 237 | switch (aal) { |
245 | case ATM_AAL0: | 238 | case ATM_AAL0: |
246 | max_sdu = ATM_CELL_SIZE-1; | 239 | max_sdu = ATM_CELL_SIZE-1; |
247 | break; | 240 | break; |
248 | case ATM_AAL34: | 241 | case ATM_AAL34: |
249 | max_sdu = ATM_MAX_AAL34_PDU; | 242 | max_sdu = ATM_MAX_AAL34_PDU; |
250 | break; | 243 | break; |
251 | default: | 244 | default: |
252 | printk(KERN_WARNING "ATM: AAL problems ... " | 245 | pr_warning("AAL problems ... (%d)\n", aal); |
253 | "(%d)\n",aal); | 246 | /* fall through */ |
254 | /* fall through */ | 247 | case ATM_AAL5: |
255 | case ATM_AAL5: | 248 | max_sdu = ATM_MAX_AAL5_PDU; |
256 | max_sdu = ATM_MAX_AAL5_PDU; | ||
257 | } | 249 | } |
258 | if (!tp->max_sdu) tp->max_sdu = max_sdu; | 250 | if (!tp->max_sdu) |
259 | else if (tp->max_sdu > max_sdu) return -EINVAL; | 251 | tp->max_sdu = max_sdu; |
260 | if (!tp->max_cdv) tp->max_cdv = ATM_MAX_CDV; | 252 | else if (tp->max_sdu > max_sdu) |
253 | return -EINVAL; | ||
254 | if (!tp->max_cdv) | ||
255 | tp->max_cdv = ATM_MAX_CDV; | ||
261 | return 0; | 256 | return 0; |
262 | } | 257 | } |
263 | 258 | ||
264 | |||
265 | static int check_ci(const struct atm_vcc *vcc, short vpi, int vci) | 259 | static int check_ci(const struct atm_vcc *vcc, short vpi, int vci) |
266 | { | 260 | { |
267 | struct hlist_head *head = &vcc_hash[vci & | 261 | struct hlist_head *head = &vcc_hash[vci & (VCC_HTABLE_SIZE - 1)]; |
268 | (VCC_HTABLE_SIZE - 1)]; | ||
269 | struct hlist_node *node; | 262 | struct hlist_node *node; |
270 | struct sock *s; | 263 | struct sock *s; |
271 | struct atm_vcc *walk; | 264 | struct atm_vcc *walk; |
@@ -289,7 +282,6 @@ static int check_ci(const struct atm_vcc *vcc, short vpi, int vci) | |||
289 | return 0; | 282 | return 0; |
290 | } | 283 | } |
291 | 284 | ||
292 | |||
293 | static int find_ci(const struct atm_vcc *vcc, short *vpi, int *vci) | 285 | static int find_ci(const struct atm_vcc *vcc, short *vpi, int *vci) |
294 | { | 286 | { |
295 | static short p; /* poor man's per-device cache */ | 287 | static short p; /* poor man's per-device cache */ |
@@ -327,14 +319,13 @@ static int find_ci(const struct atm_vcc *vcc, short *vpi, int *vci) | |||
327 | if ((c == ATM_NOT_RSV_VCI || *vci != ATM_VCI_ANY) && | 319 | if ((c == ATM_NOT_RSV_VCI || *vci != ATM_VCI_ANY) && |
328 | *vpi == ATM_VPI_ANY) { | 320 | *vpi == ATM_VPI_ANY) { |
329 | p++; | 321 | p++; |
330 | if (p >= 1 << vcc->dev->ci_range.vpi_bits) p = 0; | 322 | if (p >= 1 << vcc->dev->ci_range.vpi_bits) |
323 | p = 0; | ||
331 | } | 324 | } |
332 | } | 325 | } while (old_p != p || old_c != c); |
333 | while (old_p != p || old_c != c); | ||
334 | return -EADDRINUSE; | 326 | return -EADDRINUSE; |
335 | } | 327 | } |
336 | 328 | ||
337 | |||
338 | static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi, | 329 | static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi, |
339 | int vci) | 330 | int vci) |
340 | { | 331 | { |
@@ -362,37 +353,46 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi, | |||
362 | __vcc_insert_socket(sk); | 353 | __vcc_insert_socket(sk); |
363 | write_unlock_irq(&vcc_sklist_lock); | 354 | write_unlock_irq(&vcc_sklist_lock); |
364 | switch (vcc->qos.aal) { | 355 | switch (vcc->qos.aal) { |
365 | case ATM_AAL0: | 356 | case ATM_AAL0: |
366 | error = atm_init_aal0(vcc); | 357 | error = atm_init_aal0(vcc); |
367 | vcc->stats = &dev->stats.aal0; | 358 | vcc->stats = &dev->stats.aal0; |
368 | break; | 359 | break; |
369 | case ATM_AAL34: | 360 | case ATM_AAL34: |
370 | error = atm_init_aal34(vcc); | 361 | error = atm_init_aal34(vcc); |
371 | vcc->stats = &dev->stats.aal34; | 362 | vcc->stats = &dev->stats.aal34; |
372 | break; | 363 | break; |
373 | case ATM_NO_AAL: | 364 | case ATM_NO_AAL: |
374 | /* ATM_AAL5 is also used in the "0 for default" case */ | 365 | /* ATM_AAL5 is also used in the "0 for default" case */ |
375 | vcc->qos.aal = ATM_AAL5; | 366 | vcc->qos.aal = ATM_AAL5; |
376 | /* fall through */ | 367 | /* fall through */ |
377 | case ATM_AAL5: | 368 | case ATM_AAL5: |
378 | error = atm_init_aal5(vcc); | 369 | error = atm_init_aal5(vcc); |
379 | vcc->stats = &dev->stats.aal5; | 370 | vcc->stats = &dev->stats.aal5; |
380 | break; | 371 | break; |
381 | default: | 372 | default: |
382 | error = -EPROTOTYPE; | 373 | error = -EPROTOTYPE; |
383 | } | 374 | } |
384 | if (!error) error = adjust_tp(&vcc->qos.txtp,vcc->qos.aal); | 375 | if (!error) |
385 | if (!error) error = adjust_tp(&vcc->qos.rxtp,vcc->qos.aal); | 376 | error = adjust_tp(&vcc->qos.txtp, vcc->qos.aal); |
377 | if (!error) | ||
378 | error = adjust_tp(&vcc->qos.rxtp, vcc->qos.aal); | ||
386 | if (error) | 379 | if (error) |
387 | goto fail; | 380 | goto fail; |
388 | pr_debug("VCC %d.%d, AAL %d\n",vpi,vci,vcc->qos.aal); | 381 | pr_debug("VCC %d.%d, AAL %d\n", vpi, vci, vcc->qos.aal); |
389 | pr_debug(" TX: %d, PCR %d..%d, SDU %d\n",vcc->qos.txtp.traffic_class, | 382 | pr_debug(" TX: %d, PCR %d..%d, SDU %d\n", |
390 | vcc->qos.txtp.min_pcr,vcc->qos.txtp.max_pcr,vcc->qos.txtp.max_sdu); | 383 | vcc->qos.txtp.traffic_class, |
391 | pr_debug(" RX: %d, PCR %d..%d, SDU %d\n",vcc->qos.rxtp.traffic_class, | 384 | vcc->qos.txtp.min_pcr, |
392 | vcc->qos.rxtp.min_pcr,vcc->qos.rxtp.max_pcr,vcc->qos.rxtp.max_sdu); | 385 | vcc->qos.txtp.max_pcr, |
386 | vcc->qos.txtp.max_sdu); | ||
387 | pr_debug(" RX: %d, PCR %d..%d, SDU %d\n", | ||
388 | vcc->qos.rxtp.traffic_class, | ||
389 | vcc->qos.rxtp.min_pcr, | ||
390 | vcc->qos.rxtp.max_pcr, | ||
391 | vcc->qos.rxtp.max_sdu); | ||
393 | 392 | ||
394 | if (dev->ops->open) { | 393 | if (dev->ops->open) { |
395 | if ((error = dev->ops->open(vcc))) | 394 | error = dev->ops->open(vcc); |
395 | if (error) | ||
396 | goto fail; | 396 | goto fail; |
397 | } | 397 | } |
398 | return 0; | 398 | return 0; |
@@ -406,14 +406,13 @@ fail_module_put: | |||
406 | return error; | 406 | return error; |
407 | } | 407 | } |
408 | 408 | ||
409 | |||
410 | int vcc_connect(struct socket *sock, int itf, short vpi, int vci) | 409 | int vcc_connect(struct socket *sock, int itf, short vpi, int vci) |
411 | { | 410 | { |
412 | struct atm_dev *dev; | 411 | struct atm_dev *dev; |
413 | struct atm_vcc *vcc = ATM_SD(sock); | 412 | struct atm_vcc *vcc = ATM_SD(sock); |
414 | int error; | 413 | int error; |
415 | 414 | ||
416 | pr_debug("vcc_connect (vpi %d, vci %d)\n",vpi,vci); | 415 | pr_debug("(vpi %d, vci %d)\n", vpi, vci); |
417 | if (sock->state == SS_CONNECTED) | 416 | if (sock->state == SS_CONNECTED) |
418 | return -EISCONN; | 417 | return -EISCONN; |
419 | if (sock->state != SS_UNCONNECTED) | 418 | if (sock->state != SS_UNCONNECTED) |
@@ -422,30 +421,33 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci) | |||
422 | return -EINVAL; | 421 | return -EINVAL; |
423 | 422 | ||
424 | if (vpi != ATM_VPI_UNSPEC && vci != ATM_VCI_UNSPEC) | 423 | if (vpi != ATM_VPI_UNSPEC && vci != ATM_VCI_UNSPEC) |
425 | clear_bit(ATM_VF_PARTIAL,&vcc->flags); | 424 | clear_bit(ATM_VF_PARTIAL, &vcc->flags); |
426 | else | 425 | else |
427 | if (test_bit(ATM_VF_PARTIAL,&vcc->flags)) | 426 | if (test_bit(ATM_VF_PARTIAL, &vcc->flags)) |
428 | return -EINVAL; | 427 | return -EINVAL; |
429 | pr_debug("vcc_connect (TX: cl %d,bw %d-%d,sdu %d; " | 428 | pr_debug("(TX: cl %d,bw %d-%d,sdu %d; " |
430 | "RX: cl %d,bw %d-%d,sdu %d,AAL %s%d)\n", | 429 | "RX: cl %d,bw %d-%d,sdu %d,AAL %s%d)\n", |
431 | vcc->qos.txtp.traffic_class,vcc->qos.txtp.min_pcr, | 430 | vcc->qos.txtp.traffic_class, vcc->qos.txtp.min_pcr, |
432 | vcc->qos.txtp.max_pcr,vcc->qos.txtp.max_sdu, | 431 | vcc->qos.txtp.max_pcr, vcc->qos.txtp.max_sdu, |
433 | vcc->qos.rxtp.traffic_class,vcc->qos.rxtp.min_pcr, | 432 | vcc->qos.rxtp.traffic_class, vcc->qos.rxtp.min_pcr, |
434 | vcc->qos.rxtp.max_pcr,vcc->qos.rxtp.max_sdu, | 433 | vcc->qos.rxtp.max_pcr, vcc->qos.rxtp.max_sdu, |
435 | vcc->qos.aal == ATM_AAL5 ? "" : vcc->qos.aal == ATM_AAL0 ? "" : | 434 | vcc->qos.aal == ATM_AAL5 ? "" : |
436 | " ??? code ",vcc->qos.aal == ATM_AAL0 ? 0 : vcc->qos.aal); | 435 | vcc->qos.aal == ATM_AAL0 ? "" : " ??? code ", |
436 | vcc->qos.aal == ATM_AAL0 ? 0 : vcc->qos.aal); | ||
437 | if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) | 437 | if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) |
438 | return -EBADFD; | 438 | return -EBADFD; |
439 | if (vcc->qos.txtp.traffic_class == ATM_ANYCLASS || | 439 | if (vcc->qos.txtp.traffic_class == ATM_ANYCLASS || |
440 | vcc->qos.rxtp.traffic_class == ATM_ANYCLASS) | 440 | vcc->qos.rxtp.traffic_class == ATM_ANYCLASS) |
441 | return -EINVAL; | 441 | return -EINVAL; |
442 | if (likely(itf != ATM_ITF_ANY)) { | 442 | if (likely(itf != ATM_ITF_ANY)) { |
443 | dev = try_then_request_module(atm_dev_lookup(itf), "atm-device-%d", itf); | 443 | dev = try_then_request_module(atm_dev_lookup(itf), |
444 | "atm-device-%d", itf); | ||
444 | } else { | 445 | } else { |
445 | dev = NULL; | 446 | dev = NULL; |
446 | mutex_lock(&atm_dev_mutex); | 447 | mutex_lock(&atm_dev_mutex); |
447 | if (!list_empty(&atm_devs)) { | 448 | if (!list_empty(&atm_devs)) { |
448 | dev = list_entry(atm_devs.next, struct atm_dev, dev_list); | 449 | dev = list_entry(atm_devs.next, |
450 | struct atm_dev, dev_list); | ||
449 | atm_dev_hold(dev); | 451 | atm_dev_hold(dev); |
450 | } | 452 | } |
451 | mutex_unlock(&atm_dev_mutex); | 453 | mutex_unlock(&atm_dev_mutex); |
@@ -458,13 +460,12 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci) | |||
458 | return error; | 460 | return error; |
459 | } | 461 | } |
460 | if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC) | 462 | if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC) |
461 | set_bit(ATM_VF_PARTIAL,&vcc->flags); | 463 | set_bit(ATM_VF_PARTIAL, &vcc->flags); |
462 | if (test_bit(ATM_VF_READY,&ATM_SD(sock)->flags)) | 464 | if (test_bit(ATM_VF_READY, &ATM_SD(sock)->flags)) |
463 | sock->state = SS_CONNECTED; | 465 | sock->state = SS_CONNECTED; |
464 | return 0; | 466 | return 0; |
465 | } | 467 | } |
466 | 468 | ||
467 | |||
468 | int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | 469 | int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, |
469 | size_t size, int flags) | 470 | size_t size, int flags) |
470 | { | 471 | { |
@@ -478,8 +479,8 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
478 | if (flags & ~MSG_DONTWAIT) /* only handle MSG_DONTWAIT */ | 479 | if (flags & ~MSG_DONTWAIT) /* only handle MSG_DONTWAIT */ |
479 | return -EOPNOTSUPP; | 480 | return -EOPNOTSUPP; |
480 | vcc = ATM_SD(sock); | 481 | vcc = ATM_SD(sock); |
481 | if (test_bit(ATM_VF_RELEASED,&vcc->flags) || | 482 | if (test_bit(ATM_VF_RELEASED, &vcc->flags) || |
482 | test_bit(ATM_VF_CLOSE,&vcc->flags) || | 483 | test_bit(ATM_VF_CLOSE, &vcc->flags) || |
483 | !test_bit(ATM_VF_READY, &vcc->flags)) | 484 | !test_bit(ATM_VF_READY, &vcc->flags)) |
484 | return 0; | 485 | return 0; |
485 | 486 | ||
@@ -497,13 +498,12 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
497 | if (error) | 498 | if (error) |
498 | return error; | 499 | return error; |
499 | sock_recv_ts_and_drops(msg, sk, skb); | 500 | sock_recv_ts_and_drops(msg, sk, skb); |
500 | pr_debug("RcvM %d -= %d\n", atomic_read(&sk->sk_rmem_alloc), skb->truesize); | 501 | pr_debug("%d -= %d\n", atomic_read(&sk->sk_rmem_alloc), skb->truesize); |
501 | atm_return(vcc, skb->truesize); | 502 | atm_return(vcc, skb->truesize); |
502 | skb_free_datagram(sk, skb); | 503 | skb_free_datagram(sk, skb); |
503 | return copied; | 504 | return copied; |
504 | } | 505 | } |
505 | 506 | ||
506 | |||
507 | int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, | 507 | int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, |
508 | size_t total_len) | 508 | size_t total_len) |
509 | { | 509 | { |
@@ -511,7 +511,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, | |||
511 | DEFINE_WAIT(wait); | 511 | DEFINE_WAIT(wait); |
512 | struct atm_vcc *vcc; | 512 | struct atm_vcc *vcc; |
513 | struct sk_buff *skb; | 513 | struct sk_buff *skb; |
514 | int eff,error; | 514 | int eff, error; |
515 | const void __user *buff; | 515 | const void __user *buff; |
516 | int size; | 516 | int size; |
517 | 517 | ||
@@ -550,7 +550,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, | |||
550 | eff = (size+3) & ~3; /* align to word boundary */ | 550 | eff = (size+3) & ~3; /* align to word boundary */ |
551 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 551 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
552 | error = 0; | 552 | error = 0; |
553 | while (!(skb = alloc_tx(vcc,eff))) { | 553 | while (!(skb = alloc_tx(vcc, eff))) { |
554 | if (m->msg_flags & MSG_DONTWAIT) { | 554 | if (m->msg_flags & MSG_DONTWAIT) { |
555 | error = -EAGAIN; | 555 | error = -EAGAIN; |
556 | break; | 556 | break; |
@@ -560,9 +560,9 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, | |||
560 | error = -ERESTARTSYS; | 560 | error = -ERESTARTSYS; |
561 | break; | 561 | break; |
562 | } | 562 | } |
563 | if (test_bit(ATM_VF_RELEASED,&vcc->flags) || | 563 | if (test_bit(ATM_VF_RELEASED, &vcc->flags) || |
564 | test_bit(ATM_VF_CLOSE,&vcc->flags) || | 564 | test_bit(ATM_VF_CLOSE, &vcc->flags) || |
565 | !test_bit(ATM_VF_READY,&vcc->flags)) { | 565 | !test_bit(ATM_VF_READY, &vcc->flags)) { |
566 | error = -EPIPE; | 566 | error = -EPIPE; |
567 | send_sig(SIGPIPE, current, 0); | 567 | send_sig(SIGPIPE, current, 0); |
568 | break; | 568 | break; |
@@ -574,20 +574,20 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, | |||
574 | goto out; | 574 | goto out; |
575 | skb->dev = NULL; /* for paths shared with net_device interfaces */ | 575 | skb->dev = NULL; /* for paths shared with net_device interfaces */ |
576 | ATM_SKB(skb)->atm_options = vcc->atm_options; | 576 | ATM_SKB(skb)->atm_options = vcc->atm_options; |
577 | if (copy_from_user(skb_put(skb,size),buff,size)) { | 577 | if (copy_from_user(skb_put(skb, size), buff, size)) { |
578 | kfree_skb(skb); | 578 | kfree_skb(skb); |
579 | error = -EFAULT; | 579 | error = -EFAULT; |
580 | goto out; | 580 | goto out; |
581 | } | 581 | } |
582 | if (eff != size) memset(skb->data+size,0,eff-size); | 582 | if (eff != size) |
583 | error = vcc->dev->ops->send(vcc,skb); | 583 | memset(skb->data + size, 0, eff-size); |
584 | error = vcc->dev->ops->send(vcc, skb); | ||
584 | error = error ? error : size; | 585 | error = error ? error : size; |
585 | out: | 586 | out: |
586 | release_sock(sk); | 587 | release_sock(sk); |
587 | return error; | 588 | return error; |
588 | } | 589 | } |
589 | 590 | ||
590 | |||
591 | unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait) | 591 | unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait) |
592 | { | 592 | { |
593 | struct sock *sk = sock->sk; | 593 | struct sock *sk = sock->sk; |
@@ -623,8 +623,7 @@ unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
623 | return mask; | 623 | return mask; |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | static int atm_change_qos(struct atm_vcc *vcc, struct atm_qos *qos) | |
627 | static int atm_change_qos(struct atm_vcc *vcc,struct atm_qos *qos) | ||
628 | { | 627 | { |
629 | int error; | 628 | int error; |
630 | 629 | ||
@@ -636,25 +635,31 @@ static int atm_change_qos(struct atm_vcc *vcc,struct atm_qos *qos) | |||
636 | qos->rxtp.traffic_class != vcc->qos.rxtp.traffic_class || | 635 | qos->rxtp.traffic_class != vcc->qos.rxtp.traffic_class || |
637 | qos->txtp.traffic_class != vcc->qos.txtp.traffic_class) | 636 | qos->txtp.traffic_class != vcc->qos.txtp.traffic_class) |
638 | return -EINVAL; | 637 | return -EINVAL; |
639 | error = adjust_tp(&qos->txtp,qos->aal); | 638 | error = adjust_tp(&qos->txtp, qos->aal); |
640 | if (!error) error = adjust_tp(&qos->rxtp,qos->aal); | 639 | if (!error) |
641 | if (error) return error; | 640 | error = adjust_tp(&qos->rxtp, qos->aal); |
642 | if (!vcc->dev->ops->change_qos) return -EOPNOTSUPP; | 641 | if (error) |
642 | return error; | ||
643 | if (!vcc->dev->ops->change_qos) | ||
644 | return -EOPNOTSUPP; | ||
643 | if (sk_atm(vcc)->sk_family == AF_ATMPVC) | 645 | if (sk_atm(vcc)->sk_family == AF_ATMPVC) |
644 | return vcc->dev->ops->change_qos(vcc,qos,ATM_MF_SET); | 646 | return vcc->dev->ops->change_qos(vcc, qos, ATM_MF_SET); |
645 | return svc_change_qos(vcc,qos); | 647 | return svc_change_qos(vcc, qos); |
646 | } | 648 | } |
647 | 649 | ||
648 | |||
649 | static int check_tp(const struct atm_trafprm *tp) | 650 | static int check_tp(const struct atm_trafprm *tp) |
650 | { | 651 | { |
651 | /* @@@ Should be merged with adjust_tp */ | 652 | /* @@@ Should be merged with adjust_tp */ |
652 | if (!tp->traffic_class || tp->traffic_class == ATM_ANYCLASS) return 0; | 653 | if (!tp->traffic_class || tp->traffic_class == ATM_ANYCLASS) |
654 | return 0; | ||
653 | if (tp->traffic_class != ATM_UBR && !tp->min_pcr && !tp->pcr && | 655 | if (tp->traffic_class != ATM_UBR && !tp->min_pcr && !tp->pcr && |
654 | !tp->max_pcr) return -EINVAL; | 656 | !tp->max_pcr) |
655 | if (tp->min_pcr == ATM_MAX_PCR) return -EINVAL; | 657 | return -EINVAL; |
658 | if (tp->min_pcr == ATM_MAX_PCR) | ||
659 | return -EINVAL; | ||
656 | if (tp->min_pcr && tp->max_pcr && tp->max_pcr != ATM_MAX_PCR && | 660 | if (tp->min_pcr && tp->max_pcr && tp->max_pcr != ATM_MAX_PCR && |
657 | tp->min_pcr > tp->max_pcr) return -EINVAL; | 661 | tp->min_pcr > tp->max_pcr) |
662 | return -EINVAL; | ||
658 | /* | 663 | /* |
659 | * We allow pcr to be outside [min_pcr,max_pcr], because later | 664 | * We allow pcr to be outside [min_pcr,max_pcr], because later |
660 | * adjustment may still push it in the valid range. | 665 | * adjustment may still push it in the valid range. |
@@ -662,7 +667,6 @@ static int check_tp(const struct atm_trafprm *tp) | |||
662 | return 0; | 667 | return 0; |
663 | } | 668 | } |
664 | 669 | ||
665 | |||
666 | static int check_qos(const struct atm_qos *qos) | 670 | static int check_qos(const struct atm_qos *qos) |
667 | { | 671 | { |
668 | int error; | 672 | int error; |
@@ -672,9 +676,11 @@ static int check_qos(const struct atm_qos *qos) | |||
672 | if (qos->txtp.traffic_class != qos->rxtp.traffic_class && | 676 | if (qos->txtp.traffic_class != qos->rxtp.traffic_class && |
673 | qos->txtp.traffic_class && qos->rxtp.traffic_class && | 677 | qos->txtp.traffic_class && qos->rxtp.traffic_class && |
674 | qos->txtp.traffic_class != ATM_ANYCLASS && | 678 | qos->txtp.traffic_class != ATM_ANYCLASS && |
675 | qos->rxtp.traffic_class != ATM_ANYCLASS) return -EINVAL; | 679 | qos->rxtp.traffic_class != ATM_ANYCLASS) |
680 | return -EINVAL; | ||
676 | error = check_tp(&qos->txtp); | 681 | error = check_tp(&qos->txtp); |
677 | if (error) return error; | 682 | if (error) |
683 | return error; | ||
678 | return check_tp(&qos->rxtp); | 684 | return check_tp(&qos->rxtp); |
679 | } | 685 | } |
680 | 686 | ||
@@ -690,37 +696,41 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, | |||
690 | 696 | ||
691 | vcc = ATM_SD(sock); | 697 | vcc = ATM_SD(sock); |
692 | switch (optname) { | 698 | switch (optname) { |
693 | case SO_ATMQOS: | 699 | case SO_ATMQOS: |
694 | { | 700 | { |
695 | struct atm_qos qos; | 701 | struct atm_qos qos; |
696 | 702 | ||
697 | if (copy_from_user(&qos,optval,sizeof(qos))) | 703 | if (copy_from_user(&qos, optval, sizeof(qos))) |
698 | return -EFAULT; | 704 | return -EFAULT; |
699 | error = check_qos(&qos); | 705 | error = check_qos(&qos); |
700 | if (error) return error; | 706 | if (error) |
701 | if (sock->state == SS_CONNECTED) | 707 | return error; |
702 | return atm_change_qos(vcc,&qos); | 708 | if (sock->state == SS_CONNECTED) |
703 | if (sock->state != SS_UNCONNECTED) | 709 | return atm_change_qos(vcc, &qos); |
704 | return -EBADFD; | 710 | if (sock->state != SS_UNCONNECTED) |
705 | vcc->qos = qos; | 711 | return -EBADFD; |
706 | set_bit(ATM_VF_HASQOS,&vcc->flags); | 712 | vcc->qos = qos; |
707 | return 0; | 713 | set_bit(ATM_VF_HASQOS, &vcc->flags); |
708 | } | 714 | return 0; |
709 | case SO_SETCLP: | ||
710 | if (get_user(value,(unsigned long __user *)optval)) | ||
711 | return -EFAULT; | ||
712 | if (value) vcc->atm_options |= ATM_ATMOPT_CLP; | ||
713 | else vcc->atm_options &= ~ATM_ATMOPT_CLP; | ||
714 | return 0; | ||
715 | default: | ||
716 | if (level == SOL_SOCKET) return -EINVAL; | ||
717 | break; | ||
718 | } | 715 | } |
719 | if (!vcc->dev || !vcc->dev->ops->setsockopt) return -EINVAL; | 716 | case SO_SETCLP: |
720 | return vcc->dev->ops->setsockopt(vcc,level,optname,optval,optlen); | 717 | if (get_user(value, (unsigned long __user *)optval)) |
718 | return -EFAULT; | ||
719 | if (value) | ||
720 | vcc->atm_options |= ATM_ATMOPT_CLP; | ||
721 | else | ||
722 | vcc->atm_options &= ~ATM_ATMOPT_CLP; | ||
723 | return 0; | ||
724 | default: | ||
725 | if (level == SOL_SOCKET) | ||
726 | return -EINVAL; | ||
727 | break; | ||
728 | } | ||
729 | if (!vcc->dev || !vcc->dev->ops->setsockopt) | ||
730 | return -EINVAL; | ||
731 | return vcc->dev->ops->setsockopt(vcc, level, optname, optval, optlen); | ||
721 | } | 732 | } |
722 | 733 | ||
723 | |||
724 | int vcc_getsockopt(struct socket *sock, int level, int optname, | 734 | int vcc_getsockopt(struct socket *sock, int level, int optname, |
725 | char __user *optval, int __user *optlen) | 735 | char __user *optval, int __user *optlen) |
726 | { | 736 | { |
@@ -734,33 +744,33 @@ int vcc_getsockopt(struct socket *sock, int level, int optname, | |||
734 | 744 | ||
735 | vcc = ATM_SD(sock); | 745 | vcc = ATM_SD(sock); |
736 | switch (optname) { | 746 | switch (optname) { |
737 | case SO_ATMQOS: | 747 | case SO_ATMQOS: |
738 | if (!test_bit(ATM_VF_HASQOS,&vcc->flags)) | 748 | if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) |
739 | return -EINVAL; | 749 | return -EINVAL; |
740 | return copy_to_user(optval,&vcc->qos,sizeof(vcc->qos)) ? | 750 | return copy_to_user(optval, &vcc->qos, sizeof(vcc->qos)) |
741 | -EFAULT : 0; | 751 | ? -EFAULT : 0; |
742 | case SO_SETCLP: | 752 | case SO_SETCLP: |
743 | return put_user(vcc->atm_options & ATM_ATMOPT_CLP ? 1 : | 753 | return put_user(vcc->atm_options & ATM_ATMOPT_CLP ? 1 : 0, |
744 | 0,(unsigned long __user *)optval) ? -EFAULT : 0; | 754 | (unsigned long __user *)optval) ? -EFAULT : 0; |
745 | case SO_ATMPVC: | 755 | case SO_ATMPVC: |
746 | { | 756 | { |
747 | struct sockaddr_atmpvc pvc; | 757 | struct sockaddr_atmpvc pvc; |
748 | 758 | ||
749 | if (!vcc->dev || | 759 | if (!vcc->dev || !test_bit(ATM_VF_ADDR, &vcc->flags)) |
750 | !test_bit(ATM_VF_ADDR,&vcc->flags)) | 760 | return -ENOTCONN; |
751 | return -ENOTCONN; | 761 | pvc.sap_family = AF_ATMPVC; |
752 | pvc.sap_family = AF_ATMPVC; | 762 | pvc.sap_addr.itf = vcc->dev->number; |
753 | pvc.sap_addr.itf = vcc->dev->number; | 763 | pvc.sap_addr.vpi = vcc->vpi; |
754 | pvc.sap_addr.vpi = vcc->vpi; | 764 | pvc.sap_addr.vci = vcc->vci; |
755 | pvc.sap_addr.vci = vcc->vci; | 765 | return copy_to_user(optval, &pvc, sizeof(pvc)) ? -EFAULT : 0; |
756 | return copy_to_user(optval,&pvc,sizeof(pvc)) ? | 766 | } |
757 | -EFAULT : 0; | 767 | default: |
758 | } | 768 | if (level == SOL_SOCKET) |
759 | default: | 769 | return -EINVAL; |
760 | if (level == SOL_SOCKET) return -EINVAL; | ||
761 | break; | 770 | break; |
762 | } | 771 | } |
763 | if (!vcc->dev || !vcc->dev->ops->getsockopt) return -EINVAL; | 772 | if (!vcc->dev || !vcc->dev->ops->getsockopt) |
773 | return -EINVAL; | ||
764 | return vcc->dev->ops->getsockopt(vcc, level, optname, optval, len); | 774 | return vcc->dev->ops->getsockopt(vcc, level, optname, optval, len); |
765 | } | 775 | } |
766 | 776 | ||
@@ -768,23 +778,27 @@ static int __init atm_init(void) | |||
768 | { | 778 | { |
769 | int error; | 779 | int error; |
770 | 780 | ||
771 | if ((error = proto_register(&vcc_proto, 0)) < 0) | 781 | error = proto_register(&vcc_proto, 0); |
782 | if (error < 0) | ||
772 | goto out; | 783 | goto out; |
773 | 784 | error = atmpvc_init(); | |
774 | if ((error = atmpvc_init()) < 0) { | 785 | if (error < 0) { |
775 | printk(KERN_ERR "atmpvc_init() failed with %d\n", error); | 786 | pr_err("atmpvc_init() failed with %d\n", error); |
776 | goto out_unregister_vcc_proto; | 787 | goto out_unregister_vcc_proto; |
777 | } | 788 | } |
778 | if ((error = atmsvc_init()) < 0) { | 789 | error = atmsvc_init(); |
779 | printk(KERN_ERR "atmsvc_init() failed with %d\n", error); | 790 | if (error < 0) { |
791 | pr_err("atmsvc_init() failed with %d\n", error); | ||
780 | goto out_atmpvc_exit; | 792 | goto out_atmpvc_exit; |
781 | } | 793 | } |
782 | if ((error = atm_proc_init()) < 0) { | 794 | error = atm_proc_init(); |
783 | printk(KERN_ERR "atm_proc_init() failed with %d\n",error); | 795 | if (error < 0) { |
796 | pr_err("atm_proc_init() failed with %d\n", error); | ||
784 | goto out_atmsvc_exit; | 797 | goto out_atmsvc_exit; |
785 | } | 798 | } |
786 | if ((error = atm_sysfs_init()) < 0) { | 799 | error = atm_sysfs_init(); |
787 | printk(KERN_ERR "atm_sysfs_init() failed with %d\n",error); | 800 | if (error < 0) { |
801 | pr_err("atm_sysfs_init() failed with %d\n", error); | ||
788 | goto out_atmproc_exit; | 802 | goto out_atmproc_exit; |
789 | } | 803 | } |
790 | out: | 804 | out: |
diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c index 2ea40995dced..62dc8bfe6fe7 100644 --- a/net/atm/ioctl.c +++ b/net/atm/ioctl.c | |||
@@ -3,6 +3,7 @@ | |||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ |
4 | /* 2003 John Levon <levon@movementarian.org> */ | 4 | /* 2003 John Levon <levon@movementarian.org> */ |
5 | 5 | ||
6 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
6 | 7 | ||
7 | #include <linux/module.h> | 8 | #include <linux/module.h> |
8 | #include <linux/kmod.h> | 9 | #include <linux/kmod.h> |
@@ -36,6 +37,7 @@ void register_atm_ioctl(struct atm_ioctl *ioctl) | |||
36 | list_add_tail(&ioctl->list, &ioctl_list); | 37 | list_add_tail(&ioctl->list, &ioctl_list); |
37 | mutex_unlock(&ioctl_mutex); | 38 | mutex_unlock(&ioctl_mutex); |
38 | } | 39 | } |
40 | EXPORT_SYMBOL(register_atm_ioctl); | ||
39 | 41 | ||
40 | void deregister_atm_ioctl(struct atm_ioctl *ioctl) | 42 | void deregister_atm_ioctl(struct atm_ioctl *ioctl) |
41 | { | 43 | { |
@@ -43,129 +45,128 @@ void deregister_atm_ioctl(struct atm_ioctl *ioctl) | |||
43 | list_del(&ioctl->list); | 45 | list_del(&ioctl->list); |
44 | mutex_unlock(&ioctl_mutex); | 46 | mutex_unlock(&ioctl_mutex); |
45 | } | 47 | } |
46 | |||
47 | EXPORT_SYMBOL(register_atm_ioctl); | ||
48 | EXPORT_SYMBOL(deregister_atm_ioctl); | 48 | EXPORT_SYMBOL(deregister_atm_ioctl); |
49 | 49 | ||
50 | static int do_vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg, int compat) | 50 | static int do_vcc_ioctl(struct socket *sock, unsigned int cmd, |
51 | unsigned long arg, int compat) | ||
51 | { | 52 | { |
52 | struct sock *sk = sock->sk; | 53 | struct sock *sk = sock->sk; |
53 | struct atm_vcc *vcc; | 54 | struct atm_vcc *vcc; |
54 | int error; | 55 | int error; |
55 | struct list_head * pos; | 56 | struct list_head *pos; |
56 | void __user *argp = (void __user *)arg; | 57 | void __user *argp = (void __user *)arg; |
57 | 58 | ||
58 | vcc = ATM_SD(sock); | 59 | vcc = ATM_SD(sock); |
59 | switch (cmd) { | 60 | switch (cmd) { |
60 | case SIOCOUTQ: | 61 | case SIOCOUTQ: |
61 | if (sock->state != SS_CONNECTED || | 62 | if (sock->state != SS_CONNECTED || |
62 | !test_bit(ATM_VF_READY, &vcc->flags)) { | 63 | !test_bit(ATM_VF_READY, &vcc->flags)) { |
63 | error = -EINVAL; | 64 | error = -EINVAL; |
64 | goto done; | 65 | goto done; |
65 | } | 66 | } |
66 | error = put_user(sk->sk_sndbuf - sk_wmem_alloc_get(sk), | 67 | error = put_user(sk->sk_sndbuf - sk_wmem_alloc_get(sk), |
67 | (int __user *) argp) ? -EFAULT : 0; | 68 | (int __user *)argp) ? -EFAULT : 0; |
69 | goto done; | ||
70 | case SIOCINQ: | ||
71 | { | ||
72 | struct sk_buff *skb; | ||
73 | |||
74 | if (sock->state != SS_CONNECTED) { | ||
75 | error = -EINVAL; | ||
68 | goto done; | 76 | goto done; |
69 | case SIOCINQ: | 77 | } |
70 | { | 78 | skb = skb_peek(&sk->sk_receive_queue); |
71 | struct sk_buff *skb; | 79 | error = put_user(skb ? skb->len : 0, |
72 | 80 | (int __user *)argp) ? -EFAULT : 0; | |
73 | if (sock->state != SS_CONNECTED) { | 81 | goto done; |
74 | error = -EINVAL; | 82 | } |
75 | goto done; | 83 | case SIOCGSTAMP: /* borrowed from IP */ |
76 | } | ||
77 | skb = skb_peek(&sk->sk_receive_queue); | ||
78 | error = put_user(skb ? skb->len : 0, | ||
79 | (int __user *)argp) ? -EFAULT : 0; | ||
80 | goto done; | ||
81 | } | ||
82 | case SIOCGSTAMP: /* borrowed from IP */ | ||
83 | #ifdef CONFIG_COMPAT | 84 | #ifdef CONFIG_COMPAT |
84 | if (compat) | 85 | if (compat) |
85 | error = compat_sock_get_timestamp(sk, argp); | 86 | error = compat_sock_get_timestamp(sk, argp); |
86 | else | 87 | else |
87 | #endif | 88 | #endif |
88 | error = sock_get_timestamp(sk, argp); | 89 | error = sock_get_timestamp(sk, argp); |
89 | goto done; | 90 | goto done; |
90 | case SIOCGSTAMPNS: /* borrowed from IP */ | 91 | case SIOCGSTAMPNS: /* borrowed from IP */ |
91 | #ifdef CONFIG_COMPAT | 92 | #ifdef CONFIG_COMPAT |
92 | if (compat) | 93 | if (compat) |
93 | error = compat_sock_get_timestampns(sk, argp); | 94 | error = compat_sock_get_timestampns(sk, argp); |
94 | else | 95 | else |
95 | #endif | 96 | #endif |
96 | error = sock_get_timestampns(sk, argp); | 97 | error = sock_get_timestampns(sk, argp); |
98 | goto done; | ||
99 | case ATM_SETSC: | ||
100 | if (net_ratelimit()) | ||
101 | pr_warning("ATM_SETSC is obsolete; used by %s:%d\n", | ||
102 | current->comm, task_pid_nr(current)); | ||
103 | error = 0; | ||
104 | goto done; | ||
105 | case ATMSIGD_CTRL: | ||
106 | if (!capable(CAP_NET_ADMIN)) { | ||
107 | error = -EPERM; | ||
97 | goto done; | 108 | goto done; |
98 | case ATM_SETSC: | 109 | } |
99 | if (net_ratelimit()) | 110 | /* |
100 | printk(KERN_WARNING "ATM_SETSC is obsolete; used by %s:%d\n", | 111 | * The user/kernel protocol for exchanging signalling |
101 | current->comm, task_pid_nr(current)); | 112 | * info uses kernel pointers as opaque references, |
102 | error = 0; | 113 | * so the holder of the file descriptor can scribble |
114 | * on the kernel... so we should make sure that we | ||
115 | * have the same privileges that /proc/kcore needs | ||
116 | */ | ||
117 | if (!capable(CAP_SYS_RAWIO)) { | ||
118 | error = -EPERM; | ||
103 | goto done; | 119 | goto done; |
104 | case ATMSIGD_CTRL: | 120 | } |
105 | if (!capable(CAP_NET_ADMIN)) { | ||
106 | error = -EPERM; | ||
107 | goto done; | ||
108 | } | ||
109 | /* | ||
110 | * The user/kernel protocol for exchanging signalling | ||
111 | * info uses kernel pointers as opaque references, | ||
112 | * so the holder of the file descriptor can scribble | ||
113 | * on the kernel... so we should make sure that we | ||
114 | * have the same privileges that /proc/kcore needs | ||
115 | */ | ||
116 | if (!capable(CAP_SYS_RAWIO)) { | ||
117 | error = -EPERM; | ||
118 | goto done; | ||
119 | } | ||
120 | #ifdef CONFIG_COMPAT | 121 | #ifdef CONFIG_COMPAT |
121 | /* WTF? I don't even want to _think_ about making this | 122 | /* WTF? I don't even want to _think_ about making this |
122 | work for 32-bit userspace. TBH I don't really want | 123 | work for 32-bit userspace. TBH I don't really want |
123 | to think about it at all. dwmw2. */ | 124 | to think about it at all. dwmw2. */ |
124 | if (compat) { | 125 | if (compat) { |
125 | if (net_ratelimit()) | 126 | if (net_ratelimit()) |
126 | printk(KERN_WARNING "32-bit task cannot be atmsigd\n"); | 127 | pr_warning("32-bit task cannot be atmsigd\n"); |
127 | error = -EINVAL; | 128 | error = -EINVAL; |
128 | goto done; | 129 | goto done; |
129 | } | 130 | } |
130 | #endif | 131 | #endif |
131 | error = sigd_attach(vcc); | 132 | error = sigd_attach(vcc); |
132 | if (!error) | 133 | if (!error) |
133 | sock->state = SS_CONNECTED; | 134 | sock->state = SS_CONNECTED; |
135 | goto done; | ||
136 | case ATM_SETBACKEND: | ||
137 | case ATM_NEWBACKENDIF: | ||
138 | { | ||
139 | atm_backend_t backend; | ||
140 | error = get_user(backend, (atm_backend_t __user *)argp); | ||
141 | if (error) | ||
134 | goto done; | 142 | goto done; |
135 | case ATM_SETBACKEND: | 143 | switch (backend) { |
136 | case ATM_NEWBACKENDIF: | 144 | case ATM_BACKEND_PPP: |
137 | { | 145 | request_module("pppoatm"); |
138 | atm_backend_t backend; | ||
139 | error = get_user(backend, (atm_backend_t __user *) argp); | ||
140 | if (error) | ||
141 | goto done; | ||
142 | switch (backend) { | ||
143 | case ATM_BACKEND_PPP: | ||
144 | request_module("pppoatm"); | ||
145 | break; | ||
146 | case ATM_BACKEND_BR2684: | ||
147 | request_module("br2684"); | ||
148 | break; | ||
149 | } | ||
150 | } | ||
151 | break; | ||
152 | case ATMMPC_CTRL: | ||
153 | case ATMMPC_DATA: | ||
154 | request_module("mpoa"); | ||
155 | break; | ||
156 | case ATMARPD_CTRL: | ||
157 | request_module("clip"); | ||
158 | break; | 146 | break; |
159 | case ATMLEC_CTRL: | 147 | case ATM_BACKEND_BR2684: |
160 | request_module("lec"); | 148 | request_module("br2684"); |
161 | break; | 149 | break; |
150 | } | ||
151 | break; | ||
152 | } | ||
153 | case ATMMPC_CTRL: | ||
154 | case ATMMPC_DATA: | ||
155 | request_module("mpoa"); | ||
156 | break; | ||
157 | case ATMARPD_CTRL: | ||
158 | request_module("clip"); | ||
159 | break; | ||
160 | case ATMLEC_CTRL: | ||
161 | request_module("lec"); | ||
162 | break; | ||
162 | } | 163 | } |
163 | 164 | ||
164 | error = -ENOIOCTLCMD; | 165 | error = -ENOIOCTLCMD; |
165 | 166 | ||
166 | mutex_lock(&ioctl_mutex); | 167 | mutex_lock(&ioctl_mutex); |
167 | list_for_each(pos, &ioctl_list) { | 168 | list_for_each(pos, &ioctl_list) { |
168 | struct atm_ioctl * ic = list_entry(pos, struct atm_ioctl, list); | 169 | struct atm_ioctl *ic = list_entry(pos, struct atm_ioctl, list); |
169 | if (try_module_get(ic->owner)) { | 170 | if (try_module_get(ic->owner)) { |
170 | error = ic->ioctl(sock, cmd, arg); | 171 | error = ic->ioctl(sock, cmd, arg); |
171 | module_put(ic->owner); | 172 | module_put(ic->owner); |
@@ -184,7 +185,6 @@ done: | |||
184 | return error; | 185 | return error; |
185 | } | 186 | } |
186 | 187 | ||
187 | |||
188 | int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 188 | int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
189 | { | 189 | { |
190 | return do_vcc_ioctl(sock, cmd, arg, 0); | 190 | return do_vcc_ioctl(sock, cmd, arg, 0); |
@@ -287,8 +287,8 @@ static int do_atmif_sioc(struct socket *sock, unsigned int cmd, | |||
287 | sioc = compat_alloc_user_space(sizeof(*sioc)); | 287 | sioc = compat_alloc_user_space(sizeof(*sioc)); |
288 | sioc32 = compat_ptr(arg); | 288 | sioc32 = compat_ptr(arg); |
289 | 289 | ||
290 | if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) | 290 | if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) || |
291 | || get_user(data, &sioc32->arg)) | 291 | get_user(data, &sioc32->arg)) |
292 | return -EFAULT; | 292 | return -EFAULT; |
293 | datap = compat_ptr(data); | 293 | datap = compat_ptr(data); |
294 | if (put_user(datap, &sioc->arg)) | 294 | if (put_user(datap, &sioc->arg)) |
diff --git a/net/atm/lec.c b/net/atm/lec.c index 42749b7b917c..5da5753157f9 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c | |||
@@ -4,6 +4,8 @@ | |||
4 | * Marko Kiiskila <mkiiskila@yahoo.com> | 4 | * Marko Kiiskila <mkiiskila@yahoo.com> |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
8 | |||
7 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
8 | #include <linux/bitops.h> | 10 | #include <linux/bitops.h> |
9 | #include <linux/capability.h> | 11 | #include <linux/capability.h> |
@@ -16,7 +18,7 @@ | |||
16 | #include <linux/skbuff.h> | 18 | #include <linux/skbuff.h> |
17 | #include <linux/ip.h> | 19 | #include <linux/ip.h> |
18 | #include <asm/byteorder.h> | 20 | #include <asm/byteorder.h> |
19 | #include <asm/uaccess.h> | 21 | #include <linux/uaccess.h> |
20 | #include <net/arp.h> | 22 | #include <net/arp.h> |
21 | #include <net/dst.h> | 23 | #include <net/dst.h> |
22 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
@@ -85,17 +87,19 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, | |||
85 | int is_rdesc, | 87 | int is_rdesc, |
86 | struct lec_arp_table **ret_entry); | 88 | struct lec_arp_table **ret_entry); |
87 | static void lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, | 89 | static void lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, |
88 | const unsigned char *atm_addr, unsigned long remoteflag, | 90 | const unsigned char *atm_addr, |
91 | unsigned long remoteflag, | ||
89 | unsigned int targetless_le_arp); | 92 | unsigned int targetless_le_arp); |
90 | static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id); | 93 | static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id); |
91 | static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc); | 94 | static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc); |
92 | static void lec_set_flush_tran_id(struct lec_priv *priv, | 95 | static void lec_set_flush_tran_id(struct lec_priv *priv, |
93 | const unsigned char *atm_addr, | 96 | const unsigned char *atm_addr, |
94 | unsigned long tran_id); | 97 | unsigned long tran_id); |
95 | static void lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, | 98 | static void lec_vcc_added(struct lec_priv *priv, |
99 | const struct atmlec_ioc *ioc_data, | ||
96 | struct atm_vcc *vcc, | 100 | struct atm_vcc *vcc, |
97 | void (*old_push) (struct atm_vcc *vcc, | 101 | void (*old_push)(struct atm_vcc *vcc, |
98 | struct sk_buff *skb)); | 102 | struct sk_buff *skb)); |
99 | static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); | 103 | static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); |
100 | 104 | ||
101 | /* must be done under lec_arp_lock */ | 105 | /* must be done under lec_arp_lock */ |
@@ -110,7 +114,6 @@ static inline void lec_arp_put(struct lec_arp_table *entry) | |||
110 | kfree(entry); | 114 | kfree(entry); |
111 | } | 115 | } |
112 | 116 | ||
113 | |||
114 | static struct lane2_ops lane2_ops = { | 117 | static struct lane2_ops lane2_ops = { |
115 | lane2_resolve, /* resolve, spec 3.1.3 */ | 118 | lane2_resolve, /* resolve, spec 3.1.3 */ |
116 | lane2_associate_req, /* associate_req, spec 3.1.4 */ | 119 | lane2_associate_req, /* associate_req, spec 3.1.4 */ |
@@ -148,7 +151,8 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) | |||
148 | mesg = (struct atmlec_msg *)skb2->data; | 151 | mesg = (struct atmlec_msg *)skb2->data; |
149 | mesg->type = l_topology_change; | 152 | mesg->type = l_topology_change; |
150 | buff += 4; | 153 | buff += 4; |
151 | mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ | 154 | mesg->content.normal.flag = *buff & 0x01; |
155 | /* 0x01 is topology change */ | ||
152 | 156 | ||
153 | priv = netdev_priv(dev); | 157 | priv = netdev_priv(dev); |
154 | atm_force_charge(priv->lecd, skb2->truesize); | 158 | atm_force_charge(priv->lecd, skb2->truesize); |
@@ -242,7 +246,7 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb) | |||
242 | 246 | ||
243 | static void lec_tx_timeout(struct net_device *dev) | 247 | static void lec_tx_timeout(struct net_device *dev) |
244 | { | 248 | { |
245 | printk(KERN_INFO "%s: tx timeout\n", dev->name); | 249 | pr_info("%s\n", dev->name); |
246 | dev->trans_start = jiffies; | 250 | dev->trans_start = jiffies; |
247 | netif_wake_queue(dev); | 251 | netif_wake_queue(dev); |
248 | } | 252 | } |
@@ -261,14 +265,10 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, | |||
261 | unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ | 265 | unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ |
262 | #endif | 266 | #endif |
263 | int is_rdesc; | 267 | int is_rdesc; |
264 | #if DUMP_PACKETS > 0 | ||
265 | char buf[300]; | ||
266 | int i = 0; | ||
267 | #endif /* DUMP_PACKETS >0 */ | ||
268 | 268 | ||
269 | pr_debug("lec_start_xmit called\n"); | 269 | pr_debug("called\n"); |
270 | if (!priv->lecd) { | 270 | if (!priv->lecd) { |
271 | printk("%s:No lecd attached\n", dev->name); | 271 | pr_info("%s:No lecd attached\n", dev->name); |
272 | dev->stats.tx_errors++; | 272 | dev->stats.tx_errors++; |
273 | netif_stop_queue(dev); | 273 | netif_stop_queue(dev); |
274 | kfree_skb(skb); | 274 | kfree_skb(skb); |
@@ -276,8 +276,8 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, | |||
276 | } | 276 | } |
277 | 277 | ||
278 | pr_debug("skbuff head:%lx data:%lx tail:%lx end:%lx\n", | 278 | pr_debug("skbuff head:%lx data:%lx tail:%lx end:%lx\n", |
279 | (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb), | 279 | (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb), |
280 | (long)skb_end_pointer(skb)); | 280 | (long)skb_end_pointer(skb)); |
281 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 281 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
282 | if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) | 282 | if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) |
283 | lec_handle_bridge(skb, dev); | 283 | lec_handle_bridge(skb, dev); |
@@ -285,8 +285,7 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, | |||
285 | 285 | ||
286 | /* Make sure we have room for lec_id */ | 286 | /* Make sure we have room for lec_id */ |
287 | if (skb_headroom(skb) < 2) { | 287 | if (skb_headroom(skb) < 2) { |
288 | 288 | pr_debug("reallocating skb\n"); | |
289 | pr_debug("lec_start_xmit: reallocating skb\n"); | ||
290 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); | 289 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); |
291 | kfree_skb(skb); | 290 | kfree_skb(skb); |
292 | if (skb2 == NULL) | 291 | if (skb2 == NULL) |
@@ -313,23 +312,17 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, | |||
313 | } | 312 | } |
314 | #endif | 313 | #endif |
315 | 314 | ||
316 | #if DUMP_PACKETS > 0 | ||
317 | printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name, | ||
318 | skb->len, priv->lecid); | ||
319 | #if DUMP_PACKETS >= 2 | 315 | #if DUMP_PACKETS >= 2 |
320 | for (i = 0; i < skb->len && i < 99; i++) { | 316 | #define MAX_DUMP_SKB 99 |
321 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); | ||
322 | } | ||
323 | #elif DUMP_PACKETS >= 1 | 317 | #elif DUMP_PACKETS >= 1 |
324 | for (i = 0; i < skb->len && i < 30; i++) { | 318 | #define MAX_DUMP_SKB 30 |
325 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); | 319 | #endif |
326 | } | 320 | #if DUMP_PACKETS >= 1 |
321 | printk(KERN_DEBUG "%s: send datalen:%ld lecid:%4.4x\n", | ||
322 | dev->name, skb->len, priv->lecid); | ||
323 | print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1, | ||
324 | skb->data, min(skb->len, MAX_DUMP_SKB), true); | ||
327 | #endif /* DUMP_PACKETS >= 1 */ | 325 | #endif /* DUMP_PACKETS >= 1 */ |
328 | if (i == skb->len) | ||
329 | printk("%s\n", buf); | ||
330 | else | ||
331 | printk("%s...\n", buf); | ||
332 | #endif /* DUMP_PACKETS > 0 */ | ||
333 | 326 | ||
334 | /* Minimum ethernet-frame size */ | 327 | /* Minimum ethernet-frame size */ |
335 | #ifdef CONFIG_TR | 328 | #ifdef CONFIG_TR |
@@ -367,31 +360,28 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, | |||
367 | #endif | 360 | #endif |
368 | entry = NULL; | 361 | entry = NULL; |
369 | vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); | 362 | vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); |
370 | pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n", dev->name, | 363 | pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n", |
371 | vcc, vcc ? vcc->flags : 0, entry); | 364 | dev->name, vcc, vcc ? vcc->flags : 0, entry); |
372 | if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { | 365 | if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { |
373 | if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { | 366 | if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { |
374 | pr_debug("%s:lec_start_xmit: queuing packet, ", | 367 | pr_debug("%s:queuing packet, MAC address %pM\n", |
375 | dev->name); | 368 | dev->name, lec_h->h_dest); |
376 | pr_debug("MAC address %pM\n", lec_h->h_dest); | ||
377 | skb_queue_tail(&entry->tx_wait, skb); | 369 | skb_queue_tail(&entry->tx_wait, skb); |
378 | } else { | 370 | } else { |
379 | pr_debug | 371 | pr_debug("%s:tx queue full or no arp entry, dropping, MAC address: %pM\n", |
380 | ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", | 372 | dev->name, lec_h->h_dest); |
381 | dev->name); | ||
382 | pr_debug("MAC address %pM\n", lec_h->h_dest); | ||
383 | dev->stats.tx_dropped++; | 373 | dev->stats.tx_dropped++; |
384 | dev_kfree_skb(skb); | 374 | dev_kfree_skb(skb); |
385 | } | 375 | } |
386 | goto out; | 376 | goto out; |
387 | } | 377 | } |
388 | #if DUMP_PACKETS > 0 | 378 | #if DUMP_PACKETS > 0 |
389 | printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); | 379 | printk(KERN_DEBUG "%s:sending to vpi:%d vci:%d\n", |
380 | dev->name, vcc->vpi, vcc->vci); | ||
390 | #endif /* DUMP_PACKETS > 0 */ | 381 | #endif /* DUMP_PACKETS > 0 */ |
391 | 382 | ||
392 | while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { | 383 | while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { |
393 | pr_debug("lec.c: emptying tx queue, "); | 384 | pr_debug("emptying tx queue, MAC address %pM\n", lec_h->h_dest); |
394 | pr_debug("MAC address %pM\n", lec_h->h_dest); | ||
395 | lec_send(vcc, skb2); | 385 | lec_send(vcc, skb2); |
396 | } | 386 | } |
397 | 387 | ||
@@ -444,14 +434,12 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | |||
444 | pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type); | 434 | pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type); |
445 | switch (mesg->type) { | 435 | switch (mesg->type) { |
446 | case l_set_mac_addr: | 436 | case l_set_mac_addr: |
447 | for (i = 0; i < 6; i++) { | 437 | for (i = 0; i < 6; i++) |
448 | dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; | 438 | dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; |
449 | } | ||
450 | break; | 439 | break; |
451 | case l_del_mac_addr: | 440 | case l_del_mac_addr: |
452 | for (i = 0; i < 6; i++) { | 441 | for (i = 0; i < 6; i++) |
453 | dev->dev_addr[i] = 0; | 442 | dev->dev_addr[i] = 0; |
454 | } | ||
455 | break; | 443 | break; |
456 | case l_addr_delete: | 444 | case l_addr_delete: |
457 | lec_addr_delete(priv, mesg->content.normal.atm_addr, | 445 | lec_addr_delete(priv, mesg->content.normal.atm_addr, |
@@ -477,10 +465,10 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | |||
477 | mesg->content.normal.atm_addr, | 465 | mesg->content.normal.atm_addr, |
478 | mesg->content.normal.flag, | 466 | mesg->content.normal.flag, |
479 | mesg->content.normal.targetless_le_arp); | 467 | mesg->content.normal.targetless_le_arp); |
480 | pr_debug("lec: in l_arp_update\n"); | 468 | pr_debug("in l_arp_update\n"); |
481 | if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ | 469 | if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ |
482 | pr_debug("lec: LANE2 3.1.5, got tlvs, size %d\n", | 470 | pr_debug("LANE2 3.1.5, got tlvs, size %d\n", |
483 | mesg->sizeoftlvs); | 471 | mesg->sizeoftlvs); |
484 | lane2_associate_ind(dev, mesg->content.normal.mac_addr, | 472 | lane2_associate_ind(dev, mesg->content.normal.mac_addr, |
485 | tmp, mesg->sizeoftlvs); | 473 | tmp, mesg->sizeoftlvs); |
486 | } | 474 | } |
@@ -499,13 +487,14 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | |||
499 | priv->flush_timeout = (mesg->content.config.flush_timeout * HZ); | 487 | priv->flush_timeout = (mesg->content.config.flush_timeout * HZ); |
500 | priv->path_switching_delay = | 488 | priv->path_switching_delay = |
501 | (mesg->content.config.path_switching_delay * HZ); | 489 | (mesg->content.config.path_switching_delay * HZ); |
502 | priv->lane_version = mesg->content.config.lane_version; /* LANE2 */ | 490 | priv->lane_version = mesg->content.config.lane_version; |
491 | /* LANE2 */ | ||
503 | priv->lane2_ops = NULL; | 492 | priv->lane2_ops = NULL; |
504 | if (priv->lane_version > 1) | 493 | if (priv->lane_version > 1) |
505 | priv->lane2_ops = &lane2_ops; | 494 | priv->lane2_ops = &lane2_ops; |
506 | if (dev_set_mtu(dev, mesg->content.config.mtu)) | 495 | if (dev_set_mtu(dev, mesg->content.config.mtu)) |
507 | printk("%s: change_mtu to %d failed\n", dev->name, | 496 | pr_info("%s: change_mtu to %d failed\n", |
508 | mesg->content.config.mtu); | 497 | dev->name, mesg->content.config.mtu); |
509 | priv->is_proxy = mesg->content.config.is_proxy; | 498 | priv->is_proxy = mesg->content.config.is_proxy; |
510 | break; | 499 | break; |
511 | case l_flush_tran_id: | 500 | case l_flush_tran_id: |
@@ -518,40 +507,35 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | |||
518 | break; | 507 | break; |
519 | case l_should_bridge: | 508 | case l_should_bridge: |
520 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 509 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
521 | { | 510 | { |
522 | pr_debug("%s: bridge zeppelin asks about %pM\n", | 511 | pr_debug("%s: bridge zeppelin asks about %pM\n", |
523 | dev->name, mesg->content.proxy.mac_addr); | 512 | dev->name, mesg->content.proxy.mac_addr); |
524 | 513 | ||
525 | if (br_fdb_test_addr_hook == NULL) | 514 | if (br_fdb_test_addr_hook == NULL) |
526 | break; | 515 | break; |
527 | 516 | ||
528 | if (br_fdb_test_addr_hook(dev, | 517 | if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) { |
529 | mesg->content.proxy.mac_addr)) { | 518 | /* hit from bridge table, send LE_ARP_RESPONSE */ |
530 | /* hit from bridge table, send LE_ARP_RESPONSE */ | 519 | struct sk_buff *skb2; |
531 | struct sk_buff *skb2; | 520 | struct sock *sk; |
532 | struct sock *sk; | 521 | |
533 | 522 | pr_debug("%s: entry found, responding to zeppelin\n", | |
534 | pr_debug | 523 | dev->name); |
535 | ("%s: entry found, responding to zeppelin\n", | 524 | skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); |
536 | dev->name); | 525 | if (skb2 == NULL) |
537 | skb2 = | 526 | break; |
538 | alloc_skb(sizeof(struct atmlec_msg), | 527 | skb2->len = sizeof(struct atmlec_msg); |
539 | GFP_ATOMIC); | 528 | skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg)); |
540 | if (skb2 == NULL) | 529 | atm_force_charge(priv->lecd, skb2->truesize); |
541 | break; | 530 | sk = sk_atm(priv->lecd); |
542 | skb2->len = sizeof(struct atmlec_msg); | 531 | skb_queue_tail(&sk->sk_receive_queue, skb2); |
543 | skb_copy_to_linear_data(skb2, mesg, | 532 | sk->sk_data_ready(sk, skb2->len); |
544 | sizeof(*mesg)); | ||
545 | atm_force_charge(priv->lecd, skb2->truesize); | ||
546 | sk = sk_atm(priv->lecd); | ||
547 | skb_queue_tail(&sk->sk_receive_queue, skb2); | ||
548 | sk->sk_data_ready(sk, skb2->len); | ||
549 | } | ||
550 | } | 533 | } |
534 | } | ||
551 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ | 535 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ |
552 | break; | 536 | break; |
553 | default: | 537 | default: |
554 | printk("%s: Unknown message type %d\n", dev->name, mesg->type); | 538 | pr_info("%s: Unknown message type %d\n", dev->name, mesg->type); |
555 | dev_kfree_skb(skb); | 539 | dev_kfree_skb(skb); |
556 | return -EINVAL; | 540 | return -EINVAL; |
557 | } | 541 | } |
@@ -572,14 +556,13 @@ static void lec_atm_close(struct atm_vcc *vcc) | |||
572 | lec_arp_destroy(priv); | 556 | lec_arp_destroy(priv); |
573 | 557 | ||
574 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) | 558 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) |
575 | printk("%s lec_atm_close: closing with messages pending\n", | 559 | pr_info("%s closing with messages pending\n", dev->name); |
576 | dev->name); | 560 | while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) { |
577 | while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { | ||
578 | atm_return(vcc, skb->truesize); | 561 | atm_return(vcc, skb->truesize); |
579 | dev_kfree_skb(skb); | 562 | dev_kfree_skb(skb); |
580 | } | 563 | } |
581 | 564 | ||
582 | printk("%s: Shut down!\n", dev->name); | 565 | pr_info("%s: Shut down!\n", dev->name); |
583 | module_put(THIS_MODULE); | 566 | module_put(THIS_MODULE); |
584 | } | 567 | } |
585 | 568 | ||
@@ -608,9 +591,8 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, | |||
608 | struct sk_buff *skb; | 591 | struct sk_buff *skb; |
609 | struct atmlec_msg *mesg; | 592 | struct atmlec_msg *mesg; |
610 | 593 | ||
611 | if (!priv || !priv->lecd) { | 594 | if (!priv || !priv->lecd) |
612 | return -1; | 595 | return -1; |
613 | } | ||
614 | skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); | 596 | skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); |
615 | if (!skb) | 597 | if (!skb) |
616 | return -1; | 598 | return -1; |
@@ -633,7 +615,7 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, | |||
633 | sk->sk_data_ready(sk, skb->len); | 615 | sk->sk_data_ready(sk, skb->len); |
634 | 616 | ||
635 | if (data != NULL) { | 617 | if (data != NULL) { |
636 | pr_debug("lec: about to send %d bytes of data\n", data->len); | 618 | pr_debug("about to send %d bytes of data\n", data->len); |
637 | atm_force_charge(priv->lecd, data->truesize); | 619 | atm_force_charge(priv->lecd, data->truesize); |
638 | skb_queue_tail(&sk->sk_receive_queue, data); | 620 | skb_queue_tail(&sk->sk_receive_queue, data); |
639 | sk->sk_data_ready(sk, skb->len); | 621 | sk->sk_data_ready(sk, skb->len); |
@@ -691,36 +673,28 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
691 | struct net_device *dev = (struct net_device *)vcc->proto_data; | 673 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
692 | struct lec_priv *priv = netdev_priv(dev); | 674 | struct lec_priv *priv = netdev_priv(dev); |
693 | 675 | ||
694 | #if DUMP_PACKETS >0 | 676 | #if DUMP_PACKETS > 0 |
695 | int i = 0; | 677 | printk(KERN_DEBUG "%s: vcc vpi:%d vci:%d\n", |
696 | char buf[300]; | 678 | dev->name, vcc->vpi, vcc->vci); |
697 | |||
698 | printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name, | ||
699 | vcc->vpi, vcc->vci); | ||
700 | #endif | 679 | #endif |
701 | if (!skb) { | 680 | if (!skb) { |
702 | pr_debug("%s: null skb\n", dev->name); | 681 | pr_debug("%s: null skb\n", dev->name); |
703 | lec_vcc_close(priv, vcc); | 682 | lec_vcc_close(priv, vcc); |
704 | return; | 683 | return; |
705 | } | 684 | } |
706 | #if DUMP_PACKETS > 0 | ||
707 | printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name, | ||
708 | skb->len, priv->lecid); | ||
709 | #if DUMP_PACKETS >= 2 | 685 | #if DUMP_PACKETS >= 2 |
710 | for (i = 0; i < skb->len && i < 99; i++) { | 686 | #define MAX_SKB_DUMP 99 |
711 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); | ||
712 | } | ||
713 | #elif DUMP_PACKETS >= 1 | 687 | #elif DUMP_PACKETS >= 1 |
714 | for (i = 0; i < skb->len && i < 30; i++) { | 688 | #define MAX_SKB_DUMP 30 |
715 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); | 689 | #endif |
716 | } | 690 | #if DUMP_PACKETS > 0 |
717 | #endif /* DUMP_PACKETS >= 1 */ | 691 | printk(KERN_DEBUG "%s: rcv datalen:%ld lecid:%4.4x\n", |
718 | if (i == skb->len) | 692 | dev->name, skb->len, priv->lecid); |
719 | printk("%s\n", buf); | 693 | print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1, |
720 | else | 694 | skb->data, min(MAX_SKB_DUMP, skb->len), true); |
721 | printk("%s...\n", buf); | ||
722 | #endif /* DUMP_PACKETS > 0 */ | 695 | #endif /* DUMP_PACKETS > 0 */ |
723 | if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { /* Control frame, to daemon */ | 696 | if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { |
697 | /* Control frame, to daemon */ | ||
724 | struct sock *sk = sk_atm(vcc); | 698 | struct sock *sk = sk_atm(vcc); |
725 | 699 | ||
726 | pr_debug("%s: To daemon\n", dev->name); | 700 | pr_debug("%s: To daemon\n", dev->name); |
@@ -778,9 +752,8 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
778 | dev_kfree_skb(skb); | 752 | dev_kfree_skb(skb); |
779 | return; | 753 | return; |
780 | } | 754 | } |
781 | if (!hlist_empty(&priv->lec_arp_empty_ones)) { | 755 | if (!hlist_empty(&priv->lec_arp_empty_ones)) |
782 | lec_arp_check_empties(priv, vcc, skb); | 756 | lec_arp_check_empties(priv, vcc, skb); |
783 | } | ||
784 | skb_pull(skb, 2); /* skip lec_id */ | 757 | skb_pull(skb, 2); /* skip lec_id */ |
785 | #ifdef CONFIG_TR | 758 | #ifdef CONFIG_TR |
786 | if (priv->is_trdev) | 759 | if (priv->is_trdev) |
@@ -801,7 +774,7 @@ static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) | |||
801 | struct net_device *dev = skb->dev; | 774 | struct net_device *dev = skb->dev; |
802 | 775 | ||
803 | if (vpriv == NULL) { | 776 | if (vpriv == NULL) { |
804 | printk("lec_pop(): vpriv = NULL!?!?!?\n"); | 777 | pr_info("vpriv = NULL!?!?!?\n"); |
805 | return; | 778 | return; |
806 | } | 779 | } |
807 | 780 | ||
@@ -822,15 +795,13 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) | |||
822 | 795 | ||
823 | /* Lecd must be up in this case */ | 796 | /* Lecd must be up in this case */ |
824 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); | 797 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); |
825 | if (bytes_left != 0) { | 798 | if (bytes_left != 0) |
826 | printk | 799 | pr_info("copy from user failed for %d bytes\n", bytes_left); |
827 | ("lec: lec_vcc_attach, copy from user failed for %d bytes\n", | ||
828 | bytes_left); | ||
829 | } | ||
830 | if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || | 800 | if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || |
831 | !dev_lec[ioc_data.dev_num]) | 801 | !dev_lec[ioc_data.dev_num]) |
832 | return -EINVAL; | 802 | return -EINVAL; |
833 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) | 803 | vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL); |
804 | if (!vpriv) | ||
834 | return -ENOMEM; | 805 | return -ENOMEM; |
835 | vpriv->xoff = 0; | 806 | vpriv->xoff = 0; |
836 | vpriv->old_pop = vcc->pop; | 807 | vpriv->old_pop = vcc->pop; |
@@ -921,9 +892,8 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) | |||
921 | priv->flush_timeout = (4 * HZ); | 892 | priv->flush_timeout = (4 * HZ); |
922 | priv->path_switching_delay = (6 * HZ); | 893 | priv->path_switching_delay = (6 * HZ); |
923 | 894 | ||
924 | if (dev_lec[i]->flags & IFF_UP) { | 895 | if (dev_lec[i]->flags & IFF_UP) |
925 | netif_start_queue(dev_lec[i]); | 896 | netif_start_queue(dev_lec[i]); |
926 | } | ||
927 | __module_get(THIS_MODULE); | 897 | __module_get(THIS_MODULE); |
928 | return i; | 898 | return i; |
929 | } | 899 | } |
@@ -1125,7 +1095,9 @@ static int lec_seq_show(struct seq_file *seq, void *v) | |||
1125 | else { | 1095 | else { |
1126 | struct lec_state *state = seq->private; | 1096 | struct lec_state *state = seq->private; |
1127 | struct net_device *dev = state->dev; | 1097 | struct net_device *dev = state->dev; |
1128 | struct lec_arp_table *entry = hlist_entry(state->node, struct lec_arp_table, next); | 1098 | struct lec_arp_table *entry = hlist_entry(state->node, |
1099 | struct lec_arp_table, | ||
1100 | next); | ||
1129 | 1101 | ||
1130 | seq_printf(seq, "%s ", dev->name); | 1102 | seq_printf(seq, "%s ", dev->name); |
1131 | lec_info(seq, entry); | 1103 | lec_info(seq, entry); |
@@ -1199,13 +1171,13 @@ static int __init lane_module_init(void) | |||
1199 | 1171 | ||
1200 | p = proc_create("lec", S_IRUGO, atm_proc_root, &lec_seq_fops); | 1172 | p = proc_create("lec", S_IRUGO, atm_proc_root, &lec_seq_fops); |
1201 | if (!p) { | 1173 | if (!p) { |
1202 | printk(KERN_ERR "Unable to initialize /proc/net/atm/lec\n"); | 1174 | pr_err("Unable to initialize /proc/net/atm/lec\n"); |
1203 | return -ENOMEM; | 1175 | return -ENOMEM; |
1204 | } | 1176 | } |
1205 | #endif | 1177 | #endif |
1206 | 1178 | ||
1207 | register_atm_ioctl(&lane_ioctl_ops); | 1179 | register_atm_ioctl(&lane_ioctl_ops); |
1208 | printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); | 1180 | pr_info("lec.c: " __DATE__ " " __TIME__ " initialized\n"); |
1209 | return 0; | 1181 | return 0; |
1210 | } | 1182 | } |
1211 | 1183 | ||
@@ -1294,13 +1266,13 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst, | |||
1294 | struct lec_priv *priv = netdev_priv(dev); | 1266 | struct lec_priv *priv = netdev_priv(dev); |
1295 | 1267 | ||
1296 | if (compare_ether_addr(lan_dst, dev->dev_addr)) | 1268 | if (compare_ether_addr(lan_dst, dev->dev_addr)) |
1297 | return (0); /* not our mac address */ | 1269 | return 0; /* not our mac address */ |
1298 | 1270 | ||
1299 | kfree(priv->tlvs); /* NULL if there was no previous association */ | 1271 | kfree(priv->tlvs); /* NULL if there was no previous association */ |
1300 | 1272 | ||
1301 | priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); | 1273 | priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); |
1302 | if (priv->tlvs == NULL) | 1274 | if (priv->tlvs == NULL) |
1303 | return (0); | 1275 | return 0; |
1304 | priv->sizeoftlvs = sizeoftlvs; | 1276 | priv->sizeoftlvs = sizeoftlvs; |
1305 | 1277 | ||
1306 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); | 1278 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); |
@@ -1310,12 +1282,12 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst, | |||
1310 | skb_copy_to_linear_data(skb, tlvs, sizeoftlvs); | 1282 | skb_copy_to_linear_data(skb, tlvs, sizeoftlvs); |
1311 | retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); | 1283 | retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); |
1312 | if (retval != 0) | 1284 | if (retval != 0) |
1313 | printk("lec.c: lane2_associate_req() failed\n"); | 1285 | pr_info("lec.c: lane2_associate_req() failed\n"); |
1314 | /* | 1286 | /* |
1315 | * If the previous association has changed we must | 1287 | * If the previous association has changed we must |
1316 | * somehow notify other LANE entities about the change | 1288 | * somehow notify other LANE entities about the change |
1317 | */ | 1289 | */ |
1318 | return (1); | 1290 | return 1; |
1319 | } | 1291 | } |
1320 | 1292 | ||
1321 | /* | 1293 | /* |
@@ -1348,12 +1320,12 @@ static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr, | |||
1348 | entry->sizeoftlvs = sizeoftlvs; | 1320 | entry->sizeoftlvs = sizeoftlvs; |
1349 | #endif | 1321 | #endif |
1350 | #if 0 | 1322 | #if 0 |
1351 | printk("lec.c: lane2_associate_ind()\n"); | 1323 | pr_info("\n"); |
1352 | printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); | 1324 | pr_info("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); |
1353 | while (i < sizeoftlvs) | 1325 | while (i < sizeoftlvs) |
1354 | printk("%02x ", tlvs[i++]); | 1326 | pr_cont("%02x ", tlvs[i++]); |
1355 | 1327 | ||
1356 | printk("\n"); | 1328 | pr_cont("\n"); |
1357 | #endif | 1329 | #endif |
1358 | 1330 | ||
1359 | /* tell MPOA about the TLVs we saw */ | 1331 | /* tell MPOA about the TLVs we saw */ |
@@ -1373,15 +1345,15 @@ static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr, | |||
1373 | 1345 | ||
1374 | #include <linux/types.h> | 1346 | #include <linux/types.h> |
1375 | #include <linux/timer.h> | 1347 | #include <linux/timer.h> |
1376 | #include <asm/param.h> | 1348 | #include <linux/param.h> |
1377 | #include <asm/atomic.h> | 1349 | #include <asm/atomic.h> |
1378 | #include <linux/inetdevice.h> | 1350 | #include <linux/inetdevice.h> |
1379 | #include <net/route.h> | 1351 | #include <net/route.h> |
1380 | 1352 | ||
1381 | #if 0 | 1353 | #if 0 |
1382 | #define pr_debug(format,args...) | 1354 | #define pr_debug(format, args...) |
1383 | /* | 1355 | /* |
1384 | #define pr_debug printk | 1356 | #define pr_debug printk |
1385 | */ | 1357 | */ |
1386 | #endif | 1358 | #endif |
1387 | #define DEBUG_ARP_TABLE 0 | 1359 | #define DEBUG_ARP_TABLE 0 |
@@ -1395,7 +1367,7 @@ static void lec_arp_expire_arp(unsigned long data); | |||
1395 | * Arp table funcs | 1367 | * Arp table funcs |
1396 | */ | 1368 | */ |
1397 | 1369 | ||
1398 | #define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE -1)) | 1370 | #define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE - 1)) |
1399 | 1371 | ||
1400 | /* | 1372 | /* |
1401 | * Initialization of arp-cache | 1373 | * Initialization of arp-cache |
@@ -1404,9 +1376,8 @@ static void lec_arp_init(struct lec_priv *priv) | |||
1404 | { | 1376 | { |
1405 | unsigned short i; | 1377 | unsigned short i; |
1406 | 1378 | ||
1407 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1379 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) |
1408 | INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); | 1380 | INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); |
1409 | } | ||
1410 | INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); | 1381 | INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); |
1411 | INIT_HLIST_HEAD(&priv->lec_no_forward); | 1382 | INIT_HLIST_HEAD(&priv->lec_no_forward); |
1412 | INIT_HLIST_HEAD(&priv->mcast_fwds); | 1383 | INIT_HLIST_HEAD(&priv->mcast_fwds); |
@@ -1450,10 +1421,7 @@ lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry) | |||
1450 | tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])]; | 1421 | tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])]; |
1451 | hlist_add_head(&entry->next, tmp); | 1422 | hlist_add_head(&entry->next, tmp); |
1452 | 1423 | ||
1453 | pr_debug("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", | 1424 | pr_debug("Added entry:%pM\n", entry->mac_addr); |
1454 | 0xff & entry->mac_addr[0], 0xff & entry->mac_addr[1], | ||
1455 | 0xff & entry->mac_addr[2], 0xff & entry->mac_addr[3], | ||
1456 | 0xff & entry->mac_addr[4], 0xff & entry->mac_addr[5]); | ||
1457 | } | 1425 | } |
1458 | 1426 | ||
1459 | /* | 1427 | /* |
@@ -1466,20 +1434,23 @@ lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove) | |||
1466 | struct lec_arp_table *entry; | 1434 | struct lec_arp_table *entry; |
1467 | int i, remove_vcc = 1; | 1435 | int i, remove_vcc = 1; |
1468 | 1436 | ||
1469 | if (!to_remove) { | 1437 | if (!to_remove) |
1470 | return -1; | 1438 | return -1; |
1471 | } | ||
1472 | 1439 | ||
1473 | hlist_del(&to_remove->next); | 1440 | hlist_del(&to_remove->next); |
1474 | del_timer(&to_remove->timer); | 1441 | del_timer(&to_remove->timer); |
1475 | 1442 | ||
1476 | /* If this is the only MAC connected to this VCC, also tear down the VCC */ | 1443 | /* |
1444 | * If this is the only MAC connected to this VCC, | ||
1445 | * also tear down the VCC | ||
1446 | */ | ||
1477 | if (to_remove->status >= ESI_FLUSH_PENDING) { | 1447 | if (to_remove->status >= ESI_FLUSH_PENDING) { |
1478 | /* | 1448 | /* |
1479 | * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT | 1449 | * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT |
1480 | */ | 1450 | */ |
1481 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1451 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
1482 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { | 1452 | hlist_for_each_entry(entry, node, |
1453 | &priv->lec_arp_tables[i], next) { | ||
1483 | if (memcmp(to_remove->atm_addr, | 1454 | if (memcmp(to_remove->atm_addr, |
1484 | entry->atm_addr, ATM_ESA_LEN) == 0) { | 1455 | entry->atm_addr, ATM_ESA_LEN) == 0) { |
1485 | remove_vcc = 0; | 1456 | remove_vcc = 0; |
@@ -1492,10 +1463,7 @@ lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove) | |||
1492 | } | 1463 | } |
1493 | skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ | 1464 | skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ |
1494 | 1465 | ||
1495 | pr_debug("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", | 1466 | pr_debug("Removed entry:%pM\n", to_remove->mac_addr); |
1496 | 0xff & to_remove->mac_addr[0], 0xff & to_remove->mac_addr[1], | ||
1497 | 0xff & to_remove->mac_addr[2], 0xff & to_remove->mac_addr[3], | ||
1498 | 0xff & to_remove->mac_addr[4], 0xff & to_remove->mac_addr[5]); | ||
1499 | return 0; | 1467 | return 0; |
1500 | } | 1468 | } |
1501 | 1469 | ||
@@ -1513,9 +1481,8 @@ static const char *get_status_string(unsigned char st) | |||
1513 | return "ESI_FLUSH_PENDING"; | 1481 | return "ESI_FLUSH_PENDING"; |
1514 | case ESI_FORWARD_DIRECT: | 1482 | case ESI_FORWARD_DIRECT: |
1515 | return "ESI_FORWARD_DIRECT"; | 1483 | return "ESI_FORWARD_DIRECT"; |
1516 | default: | ||
1517 | return "<UNKNOWN>"; | ||
1518 | } | 1484 | } |
1485 | return "<UNKNOWN>"; | ||
1519 | } | 1486 | } |
1520 | 1487 | ||
1521 | static void dump_arp_table(struct lec_priv *priv) | 1488 | static void dump_arp_table(struct lec_priv *priv) |
@@ -1525,18 +1492,15 @@ static void dump_arp_table(struct lec_priv *priv) | |||
1525 | char buf[256]; | 1492 | char buf[256]; |
1526 | int i, j, offset; | 1493 | int i, j, offset; |
1527 | 1494 | ||
1528 | printk("Dump %p:\n", priv); | 1495 | pr_info("Dump %p:\n", priv); |
1529 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1496 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
1530 | hlist_for_each_entry(rulla, node, &priv->lec_arp_tables[i], next) { | 1497 | hlist_for_each_entry(rulla, node, |
1498 | &priv->lec_arp_tables[i], next) { | ||
1531 | offset = 0; | 1499 | offset = 0; |
1532 | offset += sprintf(buf, "%d: %p\n", i, rulla); | 1500 | offset += sprintf(buf, "%d: %p\n", i, rulla); |
1533 | offset += sprintf(buf + offset, "Mac:"); | 1501 | offset += sprintf(buf + offset, "Mac: %pM", |
1534 | for (j = 0; j < ETH_ALEN; j++) { | 1502 | rulla->mac_addr); |
1535 | offset += sprintf(buf + offset, | 1503 | offset += sprintf(buf + offset, " Atm:"); |
1536 | "%2.2x ", | ||
1537 | rulla->mac_addr[j] & 0xff); | ||
1538 | } | ||
1539 | offset += sprintf(buf + offset, "Atm:"); | ||
1540 | for (j = 0; j < ATM_ESA_LEN; j++) { | 1504 | for (j = 0; j < ATM_ESA_LEN; j++) { |
1541 | offset += sprintf(buf + offset, | 1505 | offset += sprintf(buf + offset, |
1542 | "%2.2x ", | 1506 | "%2.2x ", |
@@ -1556,20 +1520,16 @@ static void dump_arp_table(struct lec_priv *priv) | |||
1556 | "Flags:%x, Packets_flooded:%x, Status: %s ", | 1520 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
1557 | rulla->flags, rulla->packets_flooded, | 1521 | rulla->flags, rulla->packets_flooded, |
1558 | get_status_string(rulla->status)); | 1522 | get_status_string(rulla->status)); |
1559 | printk("%s\n", buf); | 1523 | pr_info("%s\n", buf); |
1560 | } | 1524 | } |
1561 | } | 1525 | } |
1562 | 1526 | ||
1563 | if (!hlist_empty(&priv->lec_no_forward)) | 1527 | if (!hlist_empty(&priv->lec_no_forward)) |
1564 | printk("No forward\n"); | 1528 | pr_info("No forward\n"); |
1565 | hlist_for_each_entry(rulla, node, &priv->lec_no_forward, next) { | 1529 | hlist_for_each_entry(rulla, node, &priv->lec_no_forward, next) { |
1566 | offset = 0; | 1530 | offset = 0; |
1567 | offset += sprintf(buf + offset, "Mac:"); | 1531 | offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr); |
1568 | for (j = 0; j < ETH_ALEN; j++) { | 1532 | offset += sprintf(buf + offset, " Atm:"); |
1569 | offset += sprintf(buf + offset, "%2.2x ", | ||
1570 | rulla->mac_addr[j] & 0xff); | ||
1571 | } | ||
1572 | offset += sprintf(buf + offset, "Atm:"); | ||
1573 | for (j = 0; j < ATM_ESA_LEN; j++) { | 1533 | for (j = 0; j < ATM_ESA_LEN; j++) { |
1574 | offset += sprintf(buf + offset, "%2.2x ", | 1534 | offset += sprintf(buf + offset, "%2.2x ", |
1575 | rulla->atm_addr[j] & 0xff); | 1535 | rulla->atm_addr[j] & 0xff); |
@@ -1586,19 +1546,15 @@ static void dump_arp_table(struct lec_priv *priv) | |||
1586 | "Flags:%x, Packets_flooded:%x, Status: %s ", | 1546 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
1587 | rulla->flags, rulla->packets_flooded, | 1547 | rulla->flags, rulla->packets_flooded, |
1588 | get_status_string(rulla->status)); | 1548 | get_status_string(rulla->status)); |
1589 | printk("%s\n", buf); | 1549 | pr_info("%s\n", buf); |
1590 | } | 1550 | } |
1591 | 1551 | ||
1592 | if (!hlist_empty(&priv->lec_arp_empty_ones)) | 1552 | if (!hlist_empty(&priv->lec_arp_empty_ones)) |
1593 | printk("Empty ones\n"); | 1553 | pr_info("Empty ones\n"); |
1594 | hlist_for_each_entry(rulla, node, &priv->lec_arp_empty_ones, next) { | 1554 | hlist_for_each_entry(rulla, node, &priv->lec_arp_empty_ones, next) { |
1595 | offset = 0; | 1555 | offset = 0; |
1596 | offset += sprintf(buf + offset, "Mac:"); | 1556 | offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr); |
1597 | for (j = 0; j < ETH_ALEN; j++) { | 1557 | offset += sprintf(buf + offset, " Atm:"); |
1598 | offset += sprintf(buf + offset, "%2.2x ", | ||
1599 | rulla->mac_addr[j] & 0xff); | ||
1600 | } | ||
1601 | offset += sprintf(buf + offset, "Atm:"); | ||
1602 | for (j = 0; j < ATM_ESA_LEN; j++) { | 1558 | for (j = 0; j < ATM_ESA_LEN; j++) { |
1603 | offset += sprintf(buf + offset, "%2.2x ", | 1559 | offset += sprintf(buf + offset, "%2.2x ", |
1604 | rulla->atm_addr[j] & 0xff); | 1560 | rulla->atm_addr[j] & 0xff); |
@@ -1615,19 +1571,15 @@ static void dump_arp_table(struct lec_priv *priv) | |||
1615 | "Flags:%x, Packets_flooded:%x, Status: %s ", | 1571 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
1616 | rulla->flags, rulla->packets_flooded, | 1572 | rulla->flags, rulla->packets_flooded, |
1617 | get_status_string(rulla->status)); | 1573 | get_status_string(rulla->status)); |
1618 | printk("%s", buf); | 1574 | pr_info("%s", buf); |
1619 | } | 1575 | } |
1620 | 1576 | ||
1621 | if (!hlist_empty(&priv->mcast_fwds)) | 1577 | if (!hlist_empty(&priv->mcast_fwds)) |
1622 | printk("Multicast Forward VCCs\n"); | 1578 | pr_info("Multicast Forward VCCs\n"); |
1623 | hlist_for_each_entry(rulla, node, &priv->mcast_fwds, next) { | 1579 | hlist_for_each_entry(rulla, node, &priv->mcast_fwds, next) { |
1624 | offset = 0; | 1580 | offset = 0; |
1625 | offset += sprintf(buf + offset, "Mac:"); | 1581 | offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr); |
1626 | for (j = 0; j < ETH_ALEN; j++) { | 1582 | offset += sprintf(buf + offset, " Atm:"); |
1627 | offset += sprintf(buf + offset, "%2.2x ", | ||
1628 | rulla->mac_addr[j] & 0xff); | ||
1629 | } | ||
1630 | offset += sprintf(buf + offset, "Atm:"); | ||
1631 | for (j = 0; j < ATM_ESA_LEN; j++) { | 1583 | for (j = 0; j < ATM_ESA_LEN; j++) { |
1632 | offset += sprintf(buf + offset, "%2.2x ", | 1584 | offset += sprintf(buf + offset, "%2.2x ", |
1633 | rulla->atm_addr[j] & 0xff); | 1585 | rulla->atm_addr[j] & 0xff); |
@@ -1644,7 +1596,7 @@ static void dump_arp_table(struct lec_priv *priv) | |||
1644 | "Flags:%x, Packets_flooded:%x, Status: %s ", | 1596 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
1645 | rulla->flags, rulla->packets_flooded, | 1597 | rulla->flags, rulla->packets_flooded, |
1646 | get_status_string(rulla->status)); | 1598 | get_status_string(rulla->status)); |
1647 | printk("%s\n", buf); | 1599 | pr_info("%s\n", buf); |
1648 | } | 1600 | } |
1649 | 1601 | ||
1650 | } | 1602 | } |
@@ -1670,14 +1622,16 @@ static void lec_arp_destroy(struct lec_priv *priv) | |||
1670 | 1622 | ||
1671 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1623 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
1672 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1624 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
1673 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { | 1625 | hlist_for_each_entry_safe(entry, node, next, |
1626 | &priv->lec_arp_tables[i], next) { | ||
1674 | lec_arp_remove(priv, entry); | 1627 | lec_arp_remove(priv, entry); |
1675 | lec_arp_put(entry); | 1628 | lec_arp_put(entry); |
1676 | } | 1629 | } |
1677 | INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); | 1630 | INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); |
1678 | } | 1631 | } |
1679 | 1632 | ||
1680 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { | 1633 | hlist_for_each_entry_safe(entry, node, next, |
1634 | &priv->lec_arp_empty_ones, next) { | ||
1681 | del_timer_sync(&entry->timer); | 1635 | del_timer_sync(&entry->timer); |
1682 | lec_arp_clear_vccs(entry); | 1636 | lec_arp_clear_vccs(entry); |
1683 | hlist_del(&entry->next); | 1637 | hlist_del(&entry->next); |
@@ -1685,7 +1639,8 @@ static void lec_arp_destroy(struct lec_priv *priv) | |||
1685 | } | 1639 | } |
1686 | INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); | 1640 | INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); |
1687 | 1641 | ||
1688 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) { | 1642 | hlist_for_each_entry_safe(entry, node, next, |
1643 | &priv->lec_no_forward, next) { | ||
1689 | del_timer_sync(&entry->timer); | 1644 | del_timer_sync(&entry->timer); |
1690 | lec_arp_clear_vccs(entry); | 1645 | lec_arp_clear_vccs(entry); |
1691 | hlist_del(&entry->next); | 1646 | hlist_del(&entry->next); |
@@ -1714,15 +1669,12 @@ static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, | |||
1714 | struct hlist_head *head; | 1669 | struct hlist_head *head; |
1715 | struct lec_arp_table *entry; | 1670 | struct lec_arp_table *entry; |
1716 | 1671 | ||
1717 | pr_debug("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", | 1672 | pr_debug("%pM\n", mac_addr); |
1718 | mac_addr[0] & 0xff, mac_addr[1] & 0xff, mac_addr[2] & 0xff, | ||
1719 | mac_addr[3] & 0xff, mac_addr[4] & 0xff, mac_addr[5] & 0xff); | ||
1720 | 1673 | ||
1721 | head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])]; | 1674 | head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])]; |
1722 | hlist_for_each_entry(entry, node, head, next) { | 1675 | hlist_for_each_entry(entry, node, head, next) { |
1723 | if (!compare_ether_addr(mac_addr, entry->mac_addr)) { | 1676 | if (!compare_ether_addr(mac_addr, entry->mac_addr)) |
1724 | return entry; | 1677 | return entry; |
1725 | } | ||
1726 | } | 1678 | } |
1727 | return NULL; | 1679 | return NULL; |
1728 | } | 1680 | } |
@@ -1734,7 +1686,7 @@ static struct lec_arp_table *make_entry(struct lec_priv *priv, | |||
1734 | 1686 | ||
1735 | to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); | 1687 | to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); |
1736 | if (!to_return) { | 1688 | if (!to_return) { |
1737 | printk("LEC: Arp entry kmalloc failed\n"); | 1689 | pr_info("LEC: Arp entry kmalloc failed\n"); |
1738 | return NULL; | 1690 | return NULL; |
1739 | } | 1691 | } |
1740 | memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); | 1692 | memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); |
@@ -1755,7 +1707,7 @@ static void lec_arp_expire_arp(unsigned long data) | |||
1755 | 1707 | ||
1756 | entry = (struct lec_arp_table *)data; | 1708 | entry = (struct lec_arp_table *)data; |
1757 | 1709 | ||
1758 | pr_debug("lec_arp_expire_arp\n"); | 1710 | pr_debug("\n"); |
1759 | if (entry->status == ESI_ARP_PENDING) { | 1711 | if (entry->status == ESI_ARP_PENDING) { |
1760 | if (entry->no_tries <= entry->priv->max_retry_count) { | 1712 | if (entry->no_tries <= entry->priv->max_retry_count) { |
1761 | if (entry->is_rdesc) | 1713 | if (entry->is_rdesc) |
@@ -1779,10 +1731,10 @@ static void lec_arp_expire_vcc(unsigned long data) | |||
1779 | 1731 | ||
1780 | del_timer(&to_remove->timer); | 1732 | del_timer(&to_remove->timer); |
1781 | 1733 | ||
1782 | pr_debug("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n", | 1734 | pr_debug("%p %p: vpi:%d vci:%d\n", |
1783 | to_remove, priv, | 1735 | to_remove, priv, |
1784 | to_remove->vcc ? to_remove->recv_vcc->vpi : 0, | 1736 | to_remove->vcc ? to_remove->recv_vcc->vpi : 0, |
1785 | to_remove->vcc ? to_remove->recv_vcc->vci : 0); | 1737 | to_remove->vcc ? to_remove->recv_vcc->vci : 0); |
1786 | 1738 | ||
1787 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1739 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
1788 | hlist_del(&to_remove->next); | 1740 | hlist_del(&to_remove->next); |
@@ -1792,6 +1744,50 @@ static void lec_arp_expire_vcc(unsigned long data) | |||
1792 | lec_arp_put(to_remove); | 1744 | lec_arp_put(to_remove); |
1793 | } | 1745 | } |
1794 | 1746 | ||
1747 | static bool __lec_arp_check_expire(struct lec_arp_table *entry, | ||
1748 | unsigned long now, | ||
1749 | struct lec_priv *priv) | ||
1750 | { | ||
1751 | unsigned long time_to_check; | ||
1752 | |||
1753 | if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change) | ||
1754 | time_to_check = priv->forward_delay_time; | ||
1755 | else | ||
1756 | time_to_check = priv->aging_time; | ||
1757 | |||
1758 | pr_debug("About to expire: %lx - %lx > %lx\n", | ||
1759 | now, entry->last_used, time_to_check); | ||
1760 | if (time_after(now, entry->last_used + time_to_check) && | ||
1761 | !(entry->flags & LEC_PERMANENT_FLAG) && | ||
1762 | !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */ | ||
1763 | /* Remove entry */ | ||
1764 | pr_debug("Entry timed out\n"); | ||
1765 | lec_arp_remove(priv, entry); | ||
1766 | lec_arp_put(entry); | ||
1767 | } else { | ||
1768 | /* Something else */ | ||
1769 | if ((entry->status == ESI_VC_PENDING || | ||
1770 | entry->status == ESI_ARP_PENDING) && | ||
1771 | time_after_eq(now, entry->timestamp + | ||
1772 | priv->max_unknown_frame_time)) { | ||
1773 | entry->timestamp = jiffies; | ||
1774 | entry->packets_flooded = 0; | ||
1775 | if (entry->status == ESI_VC_PENDING) | ||
1776 | send_to_lecd(priv, l_svc_setup, | ||
1777 | entry->mac_addr, | ||
1778 | entry->atm_addr, | ||
1779 | NULL); | ||
1780 | } | ||
1781 | if (entry->status == ESI_FLUSH_PENDING && | ||
1782 | time_after_eq(now, entry->timestamp + | ||
1783 | priv->path_switching_delay)) { | ||
1784 | lec_arp_hold(entry); | ||
1785 | return true; | ||
1786 | } | ||
1787 | } | ||
1788 | |||
1789 | return false; | ||
1790 | } | ||
1795 | /* | 1791 | /* |
1796 | * Expire entries. | 1792 | * Expire entries. |
1797 | * 1. Re-set timer | 1793 | * 1. Re-set timer |
@@ -1816,62 +1812,28 @@ static void lec_arp_check_expire(struct work_struct *work) | |||
1816 | struct hlist_node *node, *next; | 1812 | struct hlist_node *node, *next; |
1817 | struct lec_arp_table *entry; | 1813 | struct lec_arp_table *entry; |
1818 | unsigned long now; | 1814 | unsigned long now; |
1819 | unsigned long time_to_check; | ||
1820 | int i; | 1815 | int i; |
1821 | 1816 | ||
1822 | pr_debug("lec_arp_check_expire %p\n", priv); | 1817 | pr_debug("%p\n", priv); |
1823 | now = jiffies; | 1818 | now = jiffies; |
1824 | restart: | 1819 | restart: |
1825 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1820 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
1826 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1821 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
1827 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { | 1822 | hlist_for_each_entry_safe(entry, node, next, |
1828 | if ((entry->flags) & LEC_REMOTE_FLAG && | 1823 | &priv->lec_arp_tables[i], next) { |
1829 | priv->topology_change) | 1824 | if (__lec_arp_check_expire(entry, now, priv)) { |
1830 | time_to_check = priv->forward_delay_time; | 1825 | struct sk_buff *skb; |
1831 | else | 1826 | struct atm_vcc *vcc = entry->vcc; |
1832 | time_to_check = priv->aging_time; | 1827 | |
1833 | 1828 | spin_unlock_irqrestore(&priv->lec_arp_lock, | |
1834 | pr_debug("About to expire: %lx - %lx > %lx\n", | 1829 | flags); |
1835 | now, entry->last_used, time_to_check); | 1830 | while ((skb = skb_dequeue(&entry->tx_wait))) |
1836 | if (time_after(now, entry->last_used + time_to_check) | 1831 | lec_send(vcc, skb); |
1837 | && !(entry->flags & LEC_PERMANENT_FLAG) | 1832 | entry->last_used = jiffies; |
1838 | && !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */ | 1833 | entry->status = ESI_FORWARD_DIRECT; |
1839 | /* Remove entry */ | ||
1840 | pr_debug("LEC:Entry timed out\n"); | ||
1841 | lec_arp_remove(priv, entry); | ||
1842 | lec_arp_put(entry); | 1834 | lec_arp_put(entry); |
1843 | } else { | 1835 | |
1844 | /* Something else */ | 1836 | goto restart; |
1845 | if ((entry->status == ESI_VC_PENDING || | ||
1846 | entry->status == ESI_ARP_PENDING) | ||
1847 | && time_after_eq(now, | ||
1848 | entry->timestamp + | ||
1849 | priv-> | ||
1850 | max_unknown_frame_time)) { | ||
1851 | entry->timestamp = jiffies; | ||
1852 | entry->packets_flooded = 0; | ||
1853 | if (entry->status == ESI_VC_PENDING) | ||
1854 | send_to_lecd(priv, l_svc_setup, | ||
1855 | entry->mac_addr, | ||
1856 | entry->atm_addr, | ||
1857 | NULL); | ||
1858 | } | ||
1859 | if (entry->status == ESI_FLUSH_PENDING | ||
1860 | && | ||
1861 | time_after_eq(now, entry->timestamp + | ||
1862 | priv->path_switching_delay)) { | ||
1863 | struct sk_buff *skb; | ||
1864 | struct atm_vcc *vcc = entry->vcc; | ||
1865 | |||
1866 | lec_arp_hold(entry); | ||
1867 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | ||
1868 | while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) | ||
1869 | lec_send(vcc, skb); | ||
1870 | entry->last_used = jiffies; | ||
1871 | entry->status = ESI_FORWARD_DIRECT; | ||
1872 | lec_arp_put(entry); | ||
1873 | goto restart; | ||
1874 | } | ||
1875 | } | 1837 | } |
1876 | } | 1838 | } |
1877 | } | 1839 | } |
@@ -1885,7 +1847,8 @@ restart: | |||
1885 | * | 1847 | * |
1886 | */ | 1848 | */ |
1887 | static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, | 1849 | static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, |
1888 | const unsigned char *mac_to_find, int is_rdesc, | 1850 | const unsigned char *mac_to_find, |
1851 | int is_rdesc, | ||
1889 | struct lec_arp_table **ret_entry) | 1852 | struct lec_arp_table **ret_entry) |
1890 | { | 1853 | { |
1891 | unsigned long flags; | 1854 | unsigned long flags; |
@@ -1921,9 +1884,8 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, | |||
1921 | * If the LE_ARP cache entry is still pending, reset count to 0 | 1884 | * If the LE_ARP cache entry is still pending, reset count to 0 |
1922 | * so another LE_ARP request can be made for this frame. | 1885 | * so another LE_ARP request can be made for this frame. |
1923 | */ | 1886 | */ |
1924 | if (entry->status == ESI_ARP_PENDING) { | 1887 | if (entry->status == ESI_ARP_PENDING) |
1925 | entry->no_tries = 0; | 1888 | entry->no_tries = 0; |
1926 | } | ||
1927 | /* | 1889 | /* |
1928 | * Data direct VC not yet set up, check to see if the unknown | 1890 | * Data direct VC not yet set up, check to see if the unknown |
1929 | * frame count is greater than the limit. If the limit has | 1891 | * frame count is greater than the limit. If the limit has |
@@ -1934,7 +1896,7 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, | |||
1934 | entry->packets_flooded < | 1896 | entry->packets_flooded < |
1935 | priv->maximum_unknown_frame_count) { | 1897 | priv->maximum_unknown_frame_count) { |
1936 | entry->packets_flooded++; | 1898 | entry->packets_flooded++; |
1937 | pr_debug("LEC_ARP: Flooding..\n"); | 1899 | pr_debug("Flooding..\n"); |
1938 | found = priv->mcast_vcc; | 1900 | found = priv->mcast_vcc; |
1939 | goto out; | 1901 | goto out; |
1940 | } | 1902 | } |
@@ -1945,13 +1907,13 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, | |||
1945 | */ | 1907 | */ |
1946 | lec_arp_hold(entry); | 1908 | lec_arp_hold(entry); |
1947 | *ret_entry = entry; | 1909 | *ret_entry = entry; |
1948 | pr_debug("lec: entry->status %d entry->vcc %p\n", entry->status, | 1910 | pr_debug("entry->status %d entry->vcc %p\n", entry->status, |
1949 | entry->vcc); | 1911 | entry->vcc); |
1950 | found = NULL; | 1912 | found = NULL; |
1951 | } else { | 1913 | } else { |
1952 | /* No matching entry was found */ | 1914 | /* No matching entry was found */ |
1953 | entry = make_entry(priv, mac_to_find); | 1915 | entry = make_entry(priv, mac_to_find); |
1954 | pr_debug("LEC_ARP: Making entry\n"); | 1916 | pr_debug("Making entry\n"); |
1955 | if (!entry) { | 1917 | if (!entry) { |
1956 | found = priv->mcast_vcc; | 1918 | found = priv->mcast_vcc; |
1957 | goto out; | 1919 | goto out; |
@@ -1988,13 +1950,14 @@ lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr, | |||
1988 | struct lec_arp_table *entry; | 1950 | struct lec_arp_table *entry; |
1989 | int i; | 1951 | int i; |
1990 | 1952 | ||
1991 | pr_debug("lec_addr_delete\n"); | 1953 | pr_debug("\n"); |
1992 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1954 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
1993 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1955 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
1994 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { | 1956 | hlist_for_each_entry_safe(entry, node, next, |
1995 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) | 1957 | &priv->lec_arp_tables[i], next) { |
1996 | && (permanent || | 1958 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) && |
1997 | !(entry->flags & LEC_PERMANENT_FLAG))) { | 1959 | (permanent || |
1960 | !(entry->flags & LEC_PERMANENT_FLAG))) { | ||
1998 | lec_arp_remove(priv, entry); | 1961 | lec_arp_remove(priv, entry); |
1999 | lec_arp_put(entry); | 1962 | lec_arp_put(entry); |
2000 | } | 1963 | } |
@@ -2019,10 +1982,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, | |||
2019 | struct lec_arp_table *entry, *tmp; | 1982 | struct lec_arp_table *entry, *tmp; |
2020 | int i; | 1983 | int i; |
2021 | 1984 | ||
2022 | pr_debug("lec:%s", (targetless_le_arp) ? "targetless " : " "); | 1985 | pr_debug("%smac:%pM\n", |
2023 | pr_debug("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", | 1986 | (targetless_le_arp) ? "targetless " : "", mac_addr); |
2024 | mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], | ||
2025 | mac_addr[4], mac_addr[5]); | ||
2026 | 1987 | ||
2027 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1988 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
2028 | entry = lec_arp_find(priv, mac_addr); | 1989 | entry = lec_arp_find(priv, mac_addr); |
@@ -2032,7 +1993,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, | |||
2032 | * we have no entry in the cache. 7.1.30 | 1993 | * we have no entry in the cache. 7.1.30 |
2033 | */ | 1994 | */ |
2034 | if (!hlist_empty(&priv->lec_arp_empty_ones)) { | 1995 | if (!hlist_empty(&priv->lec_arp_empty_ones)) { |
2035 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { | 1996 | hlist_for_each_entry_safe(entry, node, next, |
1997 | &priv->lec_arp_empty_ones, next) { | ||
2036 | if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) { | 1998 | if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) { |
2037 | hlist_del(&entry->next); | 1999 | hlist_del(&entry->next); |
2038 | del_timer(&entry->timer); | 2000 | del_timer(&entry->timer); |
@@ -2076,7 +2038,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, | |||
2076 | memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); | 2038 | memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); |
2077 | del_timer(&entry->timer); | 2039 | del_timer(&entry->timer); |
2078 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2040 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
2079 | hlist_for_each_entry(tmp, node, &priv->lec_arp_tables[i], next) { | 2041 | hlist_for_each_entry(tmp, node, |
2042 | &priv->lec_arp_tables[i], next) { | ||
2080 | if (entry != tmp && | 2043 | if (entry != tmp && |
2081 | !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) { | 2044 | !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) { |
2082 | /* Vcc to this host exists */ | 2045 | /* Vcc to this host exists */ |
@@ -2121,14 +2084,13 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, | |||
2121 | int i, found_entry = 0; | 2084 | int i, found_entry = 0; |
2122 | 2085 | ||
2123 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2086 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
2087 | /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */ | ||
2124 | if (ioc_data->receive == 2) { | 2088 | if (ioc_data->receive == 2) { |
2125 | /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */ | ||
2126 | |||
2127 | pr_debug("LEC_ARP: Attaching mcast forward\n"); | 2089 | pr_debug("LEC_ARP: Attaching mcast forward\n"); |
2128 | #if 0 | 2090 | #if 0 |
2129 | entry = lec_arp_find(priv, bus_mac); | 2091 | entry = lec_arp_find(priv, bus_mac); |
2130 | if (!entry) { | 2092 | if (!entry) { |
2131 | printk("LEC_ARP: Multicast entry not found!\n"); | 2093 | pr_info("LEC_ARP: Multicast entry not found!\n"); |
2132 | goto out; | 2094 | goto out; |
2133 | } | 2095 | } |
2134 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); | 2096 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); |
@@ -2149,19 +2111,17 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, | |||
2149 | * Vcc which we don't want to make default vcc, | 2111 | * Vcc which we don't want to make default vcc, |
2150 | * attach it anyway. | 2112 | * attach it anyway. |
2151 | */ | 2113 | */ |
2152 | pr_debug | 2114 | pr_debug("LEC_ARP:Attaching data direct, not default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", |
2153 | ("LEC_ARP:Attaching data direct, not default: " | 2115 | ioc_data->atm_addr[0], ioc_data->atm_addr[1], |
2154 | "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", | 2116 | ioc_data->atm_addr[2], ioc_data->atm_addr[3], |
2155 | ioc_data->atm_addr[0], ioc_data->atm_addr[1], | 2117 | ioc_data->atm_addr[4], ioc_data->atm_addr[5], |
2156 | ioc_data->atm_addr[2], ioc_data->atm_addr[3], | 2118 | ioc_data->atm_addr[6], ioc_data->atm_addr[7], |
2157 | ioc_data->atm_addr[4], ioc_data->atm_addr[5], | 2119 | ioc_data->atm_addr[8], ioc_data->atm_addr[9], |
2158 | ioc_data->atm_addr[6], ioc_data->atm_addr[7], | 2120 | ioc_data->atm_addr[10], ioc_data->atm_addr[11], |
2159 | ioc_data->atm_addr[8], ioc_data->atm_addr[9], | 2121 | ioc_data->atm_addr[12], ioc_data->atm_addr[13], |
2160 | ioc_data->atm_addr[10], ioc_data->atm_addr[11], | 2122 | ioc_data->atm_addr[14], ioc_data->atm_addr[15], |
2161 | ioc_data->atm_addr[12], ioc_data->atm_addr[13], | 2123 | ioc_data->atm_addr[16], ioc_data->atm_addr[17], |
2162 | ioc_data->atm_addr[14], ioc_data->atm_addr[15], | 2124 | ioc_data->atm_addr[18], ioc_data->atm_addr[19]); |
2163 | ioc_data->atm_addr[16], ioc_data->atm_addr[17], | ||
2164 | ioc_data->atm_addr[18], ioc_data->atm_addr[19]); | ||
2165 | entry = make_entry(priv, bus_mac); | 2125 | entry = make_entry(priv, bus_mac); |
2166 | if (entry == NULL) | 2126 | if (entry == NULL) |
2167 | goto out; | 2127 | goto out; |
@@ -2177,29 +2137,28 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, | |||
2177 | dump_arp_table(priv); | 2137 | dump_arp_table(priv); |
2178 | goto out; | 2138 | goto out; |
2179 | } | 2139 | } |
2180 | pr_debug | 2140 | pr_debug("LEC_ARP:Attaching data direct, default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", |
2181 | ("LEC_ARP:Attaching data direct, default: " | 2141 | ioc_data->atm_addr[0], ioc_data->atm_addr[1], |
2182 | "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", | 2142 | ioc_data->atm_addr[2], ioc_data->atm_addr[3], |
2183 | ioc_data->atm_addr[0], ioc_data->atm_addr[1], | 2143 | ioc_data->atm_addr[4], ioc_data->atm_addr[5], |
2184 | ioc_data->atm_addr[2], ioc_data->atm_addr[3], | 2144 | ioc_data->atm_addr[6], ioc_data->atm_addr[7], |
2185 | ioc_data->atm_addr[4], ioc_data->atm_addr[5], | 2145 | ioc_data->atm_addr[8], ioc_data->atm_addr[9], |
2186 | ioc_data->atm_addr[6], ioc_data->atm_addr[7], | 2146 | ioc_data->atm_addr[10], ioc_data->atm_addr[11], |
2187 | ioc_data->atm_addr[8], ioc_data->atm_addr[9], | 2147 | ioc_data->atm_addr[12], ioc_data->atm_addr[13], |
2188 | ioc_data->atm_addr[10], ioc_data->atm_addr[11], | 2148 | ioc_data->atm_addr[14], ioc_data->atm_addr[15], |
2189 | ioc_data->atm_addr[12], ioc_data->atm_addr[13], | 2149 | ioc_data->atm_addr[16], ioc_data->atm_addr[17], |
2190 | ioc_data->atm_addr[14], ioc_data->atm_addr[15], | 2150 | ioc_data->atm_addr[18], ioc_data->atm_addr[19]); |
2191 | ioc_data->atm_addr[16], ioc_data->atm_addr[17], | ||
2192 | ioc_data->atm_addr[18], ioc_data->atm_addr[19]); | ||
2193 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2151 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
2194 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { | 2152 | hlist_for_each_entry(entry, node, |
2153 | &priv->lec_arp_tables[i], next) { | ||
2195 | if (memcmp | 2154 | if (memcmp |
2196 | (ioc_data->atm_addr, entry->atm_addr, | 2155 | (ioc_data->atm_addr, entry->atm_addr, |
2197 | ATM_ESA_LEN) == 0) { | 2156 | ATM_ESA_LEN) == 0) { |
2198 | pr_debug("LEC_ARP: Attaching data direct\n"); | 2157 | pr_debug("LEC_ARP: Attaching data direct\n"); |
2199 | pr_debug("Currently -> Vcc: %d, Rvcc:%d\n", | 2158 | pr_debug("Currently -> Vcc: %d, Rvcc:%d\n", |
2200 | entry->vcc ? entry->vcc->vci : 0, | 2159 | entry->vcc ? entry->vcc->vci : 0, |
2201 | entry->recv_vcc ? entry->recv_vcc-> | 2160 | entry->recv_vcc ? entry->recv_vcc-> |
2202 | vci : 0); | 2161 | vci : 0); |
2203 | found_entry = 1; | 2162 | found_entry = 1; |
2204 | del_timer(&entry->timer); | 2163 | del_timer(&entry->timer); |
2205 | entry->vcc = vcc; | 2164 | entry->vcc = vcc; |
@@ -2271,19 +2230,21 @@ static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id) | |||
2271 | struct lec_arp_table *entry; | 2230 | struct lec_arp_table *entry; |
2272 | int i; | 2231 | int i; |
2273 | 2232 | ||
2274 | pr_debug("LEC:lec_flush_complete %lx\n", tran_id); | 2233 | pr_debug("%lx\n", tran_id); |
2275 | restart: | 2234 | restart: |
2276 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2235 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
2277 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2236 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
2278 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { | 2237 | hlist_for_each_entry(entry, node, |
2279 | if (entry->flush_tran_id == tran_id | 2238 | &priv->lec_arp_tables[i], next) { |
2280 | && entry->status == ESI_FLUSH_PENDING) { | 2239 | if (entry->flush_tran_id == tran_id && |
2240 | entry->status == ESI_FLUSH_PENDING) { | ||
2281 | struct sk_buff *skb; | 2241 | struct sk_buff *skb; |
2282 | struct atm_vcc *vcc = entry->vcc; | 2242 | struct atm_vcc *vcc = entry->vcc; |
2283 | 2243 | ||
2284 | lec_arp_hold(entry); | 2244 | lec_arp_hold(entry); |
2285 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2245 | spin_unlock_irqrestore(&priv->lec_arp_lock, |
2286 | while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) | 2246 | flags); |
2247 | while ((skb = skb_dequeue(&entry->tx_wait))) | ||
2287 | lec_send(vcc, skb); | 2248 | lec_send(vcc, skb); |
2288 | entry->last_used = jiffies; | 2249 | entry->last_used = jiffies; |
2289 | entry->status = ESI_FORWARD_DIRECT; | 2250 | entry->status = ESI_FORWARD_DIRECT; |
@@ -2308,11 +2269,12 @@ lec_set_flush_tran_id(struct lec_priv *priv, | |||
2308 | 2269 | ||
2309 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2270 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
2310 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) | 2271 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) |
2311 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { | 2272 | hlist_for_each_entry(entry, node, |
2273 | &priv->lec_arp_tables[i], next) { | ||
2312 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { | 2274 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { |
2313 | entry->flush_tran_id = tran_id; | 2275 | entry->flush_tran_id = tran_id; |
2314 | pr_debug("Set flush transaction id to %lx for %p\n", | 2276 | pr_debug("Set flush transaction id to %lx for %p\n", |
2315 | tran_id, entry); | 2277 | tran_id, entry); |
2316 | } | 2278 | } |
2317 | } | 2279 | } |
2318 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2280 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
@@ -2328,7 +2290,8 @@ static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc) | |||
2328 | struct lec_vcc_priv *vpriv; | 2290 | struct lec_vcc_priv *vpriv; |
2329 | int err = 0; | 2291 | int err = 0; |
2330 | 2292 | ||
2331 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) | 2293 | vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL); |
2294 | if (!vpriv) | ||
2332 | return -ENOMEM; | 2295 | return -ENOMEM; |
2333 | vpriv->xoff = 0; | 2296 | vpriv->xoff = 0; |
2334 | vpriv->old_pop = vcc->pop; | 2297 | vpriv->old_pop = vcc->pop; |
@@ -2368,18 +2331,19 @@ static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) | |||
2368 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2331 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
2369 | 2332 | ||
2370 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2333 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
2371 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { | 2334 | hlist_for_each_entry_safe(entry, node, next, |
2335 | &priv->lec_arp_tables[i], next) { | ||
2372 | if (vcc == entry->vcc) { | 2336 | if (vcc == entry->vcc) { |
2373 | lec_arp_remove(priv, entry); | 2337 | lec_arp_remove(priv, entry); |
2374 | lec_arp_put(entry); | 2338 | lec_arp_put(entry); |
2375 | if (priv->mcast_vcc == vcc) { | 2339 | if (priv->mcast_vcc == vcc) |
2376 | priv->mcast_vcc = NULL; | 2340 | priv->mcast_vcc = NULL; |
2377 | } | ||
2378 | } | 2341 | } |
2379 | } | 2342 | } |
2380 | } | 2343 | } |
2381 | 2344 | ||
2382 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { | 2345 | hlist_for_each_entry_safe(entry, node, next, |
2346 | &priv->lec_arp_empty_ones, next) { | ||
2383 | if (entry->vcc == vcc) { | 2347 | if (entry->vcc == vcc) { |
2384 | lec_arp_clear_vccs(entry); | 2348 | lec_arp_clear_vccs(entry); |
2385 | del_timer(&entry->timer); | 2349 | del_timer(&entry->timer); |
@@ -2388,7 +2352,8 @@ static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) | |||
2388 | } | 2352 | } |
2389 | } | 2353 | } |
2390 | 2354 | ||
2391 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) { | 2355 | hlist_for_each_entry_safe(entry, node, next, |
2356 | &priv->lec_no_forward, next) { | ||
2392 | if (entry->recv_vcc == vcc) { | 2357 | if (entry->recv_vcc == vcc) { |
2393 | lec_arp_clear_vccs(entry); | 2358 | lec_arp_clear_vccs(entry); |
2394 | del_timer(&entry->timer); | 2359 | del_timer(&entry->timer); |
@@ -2429,14 +2394,16 @@ lec_arp_check_empties(struct lec_priv *priv, | |||
2429 | src = hdr->h_source; | 2394 | src = hdr->h_source; |
2430 | 2395 | ||
2431 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2396 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
2432 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { | 2397 | hlist_for_each_entry_safe(entry, node, next, |
2398 | &priv->lec_arp_empty_ones, next) { | ||
2433 | if (vcc == entry->vcc) { | 2399 | if (vcc == entry->vcc) { |
2434 | del_timer(&entry->timer); | 2400 | del_timer(&entry->timer); |
2435 | memcpy(entry->mac_addr, src, ETH_ALEN); | 2401 | memcpy(entry->mac_addr, src, ETH_ALEN); |
2436 | entry->status = ESI_FORWARD_DIRECT; | 2402 | entry->status = ESI_FORWARD_DIRECT; |
2437 | entry->last_used = jiffies; | 2403 | entry->last_used = jiffies; |
2438 | /* We might have got an entry */ | 2404 | /* We might have got an entry */ |
2439 | if ((tmp = lec_arp_find(priv, src))) { | 2405 | tmp = lec_arp_find(priv, src); |
2406 | if (tmp) { | ||
2440 | lec_arp_remove(priv, tmp); | 2407 | lec_arp_remove(priv, tmp); |
2441 | lec_arp_put(tmp); | 2408 | lec_arp_put(tmp); |
2442 | } | 2409 | } |
diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 38a6cb0863f0..a6521c8aa88b 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
2 | |||
1 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
2 | #include <linux/string.h> | 4 | #include <linux/string.h> |
3 | #include <linux/timer.h> | 5 | #include <linux/timer.h> |
@@ -13,8 +15,8 @@ | |||
13 | #include <net/sock.h> | 15 | #include <net/sock.h> |
14 | #include <linux/skbuff.h> | 16 | #include <linux/skbuff.h> |
15 | #include <linux/ip.h> | 17 | #include <linux/ip.h> |
18 | #include <linux/uaccess.h> | ||
16 | #include <asm/byteorder.h> | 19 | #include <asm/byteorder.h> |
17 | #include <asm/uaccess.h> | ||
18 | #include <net/checksum.h> /* for ip_fast_csum() */ | 20 | #include <net/checksum.h> /* for ip_fast_csum() */ |
19 | #include <net/arp.h> | 21 | #include <net/arp.h> |
20 | #include <net/dst.h> | 22 | #include <net/dst.h> |
@@ -36,31 +38,47 @@ | |||
36 | */ | 38 | */ |
37 | 39 | ||
38 | #if 0 | 40 | #if 0 |
39 | #define dprintk printk /* debug */ | 41 | #define dprintk(format, args...) \ |
42 | printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args) | ||
43 | #define dprintk_cont(format, args...) printk(KERN_CONT format, ##args) | ||
40 | #else | 44 | #else |
41 | #define dprintk(format,args...) | 45 | #define dprintk(format, args...) \ |
46 | do { if (0) \ | ||
47 | printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\ | ||
48 | } while (0) | ||
49 | #define dprintk_cont(format, args...) \ | ||
50 | do { if (0) printk(KERN_CONT format, ##args); } while (0) | ||
42 | #endif | 51 | #endif |
43 | 52 | ||
44 | #if 0 | 53 | #if 0 |
45 | #define ddprintk printk /* more debug */ | 54 | #define ddprintk(format, args...) \ |
55 | printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args) | ||
56 | #define ddprintk_cont(format, args...) printk(KERN_CONT format, ##args) | ||
46 | #else | 57 | #else |
47 | #define ddprintk(format,args...) | 58 | #define ddprintk(format, args...) \ |
59 | do { if (0) \ | ||
60 | printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\ | ||
61 | } while (0) | ||
62 | #define ddprintk_cont(format, args...) \ | ||
63 | do { if (0) printk(KERN_CONT format, ##args); } while (0) | ||
48 | #endif | 64 | #endif |
49 | 65 | ||
50 | |||
51 | |||
52 | #define MPOA_TAG_LEN 4 | 66 | #define MPOA_TAG_LEN 4 |
53 | 67 | ||
54 | /* mpc_daemon -> kernel */ | 68 | /* mpc_daemon -> kernel */ |
55 | static void MPOA_trigger_rcvd (struct k_message *msg, struct mpoa_client *mpc); | 69 | static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc); |
56 | static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc); | 70 | static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc); |
57 | static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc); | 71 | static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc); |
58 | static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc); | 72 | static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc); |
59 | static void mps_death(struct k_message *msg, struct mpoa_client *mpc); | 73 | static void mps_death(struct k_message *msg, struct mpoa_client *mpc); |
60 | static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action); | 74 | static void clean_up(struct k_message *msg, struct mpoa_client *mpc, |
61 | static void MPOA_cache_impos_rcvd(struct k_message *msg, struct mpoa_client *mpc); | 75 | int action); |
62 | static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); | 76 | static void MPOA_cache_impos_rcvd(struct k_message *msg, |
63 | static void set_mps_mac_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); | 77 | struct mpoa_client *mpc); |
78 | static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, | ||
79 | struct mpoa_client *mpc); | ||
80 | static void set_mps_mac_addr_rcvd(struct k_message *mesg, | ||
81 | struct mpoa_client *mpc); | ||
64 | 82 | ||
65 | static const uint8_t *copy_macs(struct mpoa_client *mpc, | 83 | static const uint8_t *copy_macs(struct mpoa_client *mpc, |
66 | const uint8_t *router_mac, | 84 | const uint8_t *router_mac, |
@@ -74,10 +92,11 @@ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb); | |||
74 | 92 | ||
75 | static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb); | 93 | static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb); |
76 | static netdev_tx_t mpc_send_packet(struct sk_buff *skb, | 94 | static netdev_tx_t mpc_send_packet(struct sk_buff *skb, |
77 | struct net_device *dev); | 95 | struct net_device *dev); |
78 | static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned long event, void *dev); | 96 | static int mpoa_event_listener(struct notifier_block *mpoa_notifier, |
97 | unsigned long event, void *dev); | ||
79 | static void mpc_timer_refresh(void); | 98 | static void mpc_timer_refresh(void); |
80 | static void mpc_cache_check( unsigned long checking_time ); | 99 | static void mpc_cache_check(unsigned long checking_time); |
81 | 100 | ||
82 | static struct llc_snap_hdr llc_snap_mpoa_ctrl = { | 101 | static struct llc_snap_hdr llc_snap_mpoa_ctrl = { |
83 | 0xaa, 0xaa, 0x03, | 102 | 0xaa, 0xaa, 0x03, |
@@ -167,7 +186,7 @@ struct atm_mpoa_qos *atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos) | |||
167 | 186 | ||
168 | entry = kmalloc(sizeof(struct atm_mpoa_qos), GFP_KERNEL); | 187 | entry = kmalloc(sizeof(struct atm_mpoa_qos), GFP_KERNEL); |
169 | if (entry == NULL) { | 188 | if (entry == NULL) { |
170 | printk("mpoa: atm_mpoa_add_qos: out of memory\n"); | 189 | pr_info("mpoa: out of memory\n"); |
171 | return entry; | 190 | return entry; |
172 | } | 191 | } |
173 | 192 | ||
@@ -185,10 +204,9 @@ struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip) | |||
185 | struct atm_mpoa_qos *qos; | 204 | struct atm_mpoa_qos *qos; |
186 | 205 | ||
187 | qos = qos_head; | 206 | qos = qos_head; |
188 | while( qos != NULL ){ | 207 | while (qos) { |
189 | if(qos->ipaddr == dst_ip) { | 208 | if (qos->ipaddr == dst_ip) |
190 | break; | 209 | break; |
191 | } | ||
192 | qos = qos->next; | 210 | qos = qos->next; |
193 | } | 211 | } |
194 | 212 | ||
@@ -200,10 +218,10 @@ struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip) | |||
200 | */ | 218 | */ |
201 | int atm_mpoa_delete_qos(struct atm_mpoa_qos *entry) | 219 | int atm_mpoa_delete_qos(struct atm_mpoa_qos *entry) |
202 | { | 220 | { |
203 | |||
204 | struct atm_mpoa_qos *curr; | 221 | struct atm_mpoa_qos *curr; |
205 | 222 | ||
206 | if (entry == NULL) return 0; | 223 | if (entry == NULL) |
224 | return 0; | ||
207 | if (entry == qos_head) { | 225 | if (entry == qos_head) { |
208 | qos_head = qos_head->next; | 226 | qos_head = qos_head->next; |
209 | kfree(entry); | 227 | kfree(entry); |
@@ -234,9 +252,17 @@ void atm_mpoa_disp_qos(struct seq_file *m) | |||
234 | 252 | ||
235 | while (qos != NULL) { | 253 | while (qos != NULL) { |
236 | seq_printf(m, "%pI4\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n", | 254 | seq_printf(m, "%pI4\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n", |
237 | &qos->ipaddr, | 255 | &qos->ipaddr, |
238 | qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu, | 256 | qos->qos.txtp.max_pcr, |
239 | qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu); | 257 | qos->qos.txtp.pcr, |
258 | qos->qos.txtp.min_pcr, | ||
259 | qos->qos.txtp.max_cdv, | ||
260 | qos->qos.txtp.max_sdu, | ||
261 | qos->qos.rxtp.max_pcr, | ||
262 | qos->qos.rxtp.pcr, | ||
263 | qos->qos.rxtp.min_pcr, | ||
264 | qos->qos.rxtp.max_cdv, | ||
265 | qos->qos.rxtp.max_sdu); | ||
240 | qos = qos->next; | 266 | qos = qos->next; |
241 | } | 267 | } |
242 | } | 268 | } |
@@ -256,7 +282,7 @@ static struct mpoa_client *alloc_mpc(void) | |||
256 | { | 282 | { |
257 | struct mpoa_client *mpc; | 283 | struct mpoa_client *mpc; |
258 | 284 | ||
259 | mpc = kzalloc(sizeof (struct mpoa_client), GFP_KERNEL); | 285 | mpc = kzalloc(sizeof(struct mpoa_client), GFP_KERNEL); |
260 | if (mpc == NULL) | 286 | if (mpc == NULL) |
261 | return NULL; | 287 | return NULL; |
262 | rwlock_init(&mpc->ingress_lock); | 288 | rwlock_init(&mpc->ingress_lock); |
@@ -266,7 +292,7 @@ static struct mpoa_client *alloc_mpc(void) | |||
266 | 292 | ||
267 | mpc->parameters.mpc_p1 = MPC_P1; | 293 | mpc->parameters.mpc_p1 = MPC_P1; |
268 | mpc->parameters.mpc_p2 = MPC_P2; | 294 | mpc->parameters.mpc_p2 = MPC_P2; |
269 | memset(mpc->parameters.mpc_p3,0,sizeof(mpc->parameters.mpc_p3)); | 295 | memset(mpc->parameters.mpc_p3, 0, sizeof(mpc->parameters.mpc_p3)); |
270 | mpc->parameters.mpc_p4 = MPC_P4; | 296 | mpc->parameters.mpc_p4 = MPC_P4; |
271 | mpc->parameters.mpc_p5 = MPC_P5; | 297 | mpc->parameters.mpc_p5 = MPC_P5; |
272 | mpc->parameters.mpc_p6 = MPC_P6; | 298 | mpc->parameters.mpc_p6 = MPC_P6; |
@@ -286,9 +312,9 @@ static struct mpoa_client *alloc_mpc(void) | |||
286 | static void start_mpc(struct mpoa_client *mpc, struct net_device *dev) | 312 | static void start_mpc(struct mpoa_client *mpc, struct net_device *dev) |
287 | { | 313 | { |
288 | 314 | ||
289 | dprintk("mpoa: (%s) start_mpc:\n", mpc->dev->name); | 315 | dprintk("(%s)\n", mpc->dev->name); |
290 | if (!dev->netdev_ops) | 316 | if (!dev->netdev_ops) |
291 | printk("mpoa: (%s) start_mpc not starting\n", dev->name); | 317 | pr_info("(%s) not starting\n", dev->name); |
292 | else { | 318 | else { |
293 | mpc->old_ops = dev->netdev_ops; | 319 | mpc->old_ops = dev->netdev_ops; |
294 | mpc->new_ops = *mpc->old_ops; | 320 | mpc->new_ops = *mpc->old_ops; |
@@ -300,14 +326,14 @@ static void start_mpc(struct mpoa_client *mpc, struct net_device *dev) | |||
300 | static void stop_mpc(struct mpoa_client *mpc) | 326 | static void stop_mpc(struct mpoa_client *mpc) |
301 | { | 327 | { |
302 | struct net_device *dev = mpc->dev; | 328 | struct net_device *dev = mpc->dev; |
303 | dprintk("mpoa: (%s) stop_mpc:", mpc->dev->name); | 329 | dprintk("(%s)", mpc->dev->name); |
304 | 330 | ||
305 | /* Lets not nullify lec device's dev->hard_start_xmit */ | 331 | /* Lets not nullify lec device's dev->hard_start_xmit */ |
306 | if (dev->netdev_ops != &mpc->new_ops) { | 332 | if (dev->netdev_ops != &mpc->new_ops) { |
307 | dprintk(" mpc already stopped, not fatal\n"); | 333 | dprintk_cont(" mpc already stopped, not fatal\n"); |
308 | return; | 334 | return; |
309 | } | 335 | } |
310 | dprintk("\n"); | 336 | dprintk_cont("\n"); |
311 | 337 | ||
312 | dev->netdev_ops = mpc->old_ops; | 338 | dev->netdev_ops = mpc->old_ops; |
313 | mpc->old_ops = NULL; | 339 | mpc->old_ops = NULL; |
@@ -319,25 +345,18 @@ static const char *mpoa_device_type_string(char type) __attribute__ ((unused)); | |||
319 | 345 | ||
320 | static const char *mpoa_device_type_string(char type) | 346 | static const char *mpoa_device_type_string(char type) |
321 | { | 347 | { |
322 | switch(type) { | 348 | switch (type) { |
323 | case NON_MPOA: | 349 | case NON_MPOA: |
324 | return "non-MPOA device"; | 350 | return "non-MPOA device"; |
325 | break; | ||
326 | case MPS: | 351 | case MPS: |
327 | return "MPS"; | 352 | return "MPS"; |
328 | break; | ||
329 | case MPC: | 353 | case MPC: |
330 | return "MPC"; | 354 | return "MPC"; |
331 | break; | ||
332 | case MPS_AND_MPC: | 355 | case MPS_AND_MPC: |
333 | return "both MPS and MPC"; | 356 | return "both MPS and MPC"; |
334 | break; | ||
335 | default: | ||
336 | return "unspecified (non-MPOA) device"; | ||
337 | break; | ||
338 | } | 357 | } |
339 | 358 | ||
340 | return ""; /* not reached */ | 359 | return "unspecified (non-MPOA) device"; |
341 | } | 360 | } |
342 | 361 | ||
343 | /* | 362 | /* |
@@ -362,26 +381,28 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, | |||
362 | struct mpoa_client *mpc; | 381 | struct mpoa_client *mpc; |
363 | 382 | ||
364 | mpoa_device_type = number_of_mps_macs = 0; /* silence gcc */ | 383 | mpoa_device_type = number_of_mps_macs = 0; /* silence gcc */ |
365 | dprintk("mpoa: (%s) lane2_assoc_ind: received TLV(s), ", dev->name); | 384 | dprintk("(%s) received TLV(s), ", dev->name); |
366 | dprintk("total length of all TLVs %d\n", sizeoftlvs); | 385 | dprintk("total length of all TLVs %d\n", sizeoftlvs); |
367 | mpc = find_mpc_by_lec(dev); /* Sampo-Fix: moved here from below */ | 386 | mpc = find_mpc_by_lec(dev); /* Sampo-Fix: moved here from below */ |
368 | if (mpc == NULL) { | 387 | if (mpc == NULL) { |
369 | printk("mpoa: (%s) lane2_assoc_ind: no mpc\n", dev->name); | 388 | pr_info("(%s) no mpc\n", dev->name); |
370 | return; | 389 | return; |
371 | } | 390 | } |
372 | end_of_tlvs = tlvs + sizeoftlvs; | 391 | end_of_tlvs = tlvs + sizeoftlvs; |
373 | while (end_of_tlvs - tlvs >= 5) { | 392 | while (end_of_tlvs - tlvs >= 5) { |
374 | type = (tlvs[0] << 24) | (tlvs[1] << 16) | (tlvs[2] << 8) | tlvs[3]; | 393 | type = ((tlvs[0] << 24) | (tlvs[1] << 16) | |
394 | (tlvs[2] << 8) | tlvs[3]); | ||
375 | length = tlvs[4]; | 395 | length = tlvs[4]; |
376 | tlvs += 5; | 396 | tlvs += 5; |
377 | dprintk(" type 0x%x length %02x\n", type, length); | 397 | dprintk(" type 0x%x length %02x\n", type, length); |
378 | if (tlvs + length > end_of_tlvs) { | 398 | if (tlvs + length > end_of_tlvs) { |
379 | printk("TLV value extends past its buffer, aborting parse\n"); | 399 | pr_info("TLV value extends past its buffer, aborting parse\n"); |
380 | return; | 400 | return; |
381 | } | 401 | } |
382 | 402 | ||
383 | if (type == 0) { | 403 | if (type == 0) { |
384 | printk("mpoa: (%s) lane2_assoc_ind: TLV type was 0, returning\n", dev->name); | 404 | pr_info("mpoa: (%s) TLV type was 0, returning\n", |
405 | dev->name); | ||
385 | return; | 406 | return; |
386 | } | 407 | } |
387 | 408 | ||
@@ -391,39 +412,48 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, | |||
391 | } | 412 | } |
392 | mpoa_device_type = *tlvs++; | 413 | mpoa_device_type = *tlvs++; |
393 | number_of_mps_macs = *tlvs++; | 414 | number_of_mps_macs = *tlvs++; |
394 | dprintk("mpoa: (%s) MPOA device type '%s', ", dev->name, mpoa_device_type_string(mpoa_device_type)); | 415 | dprintk("(%s) MPOA device type '%s', ", |
416 | dev->name, mpoa_device_type_string(mpoa_device_type)); | ||
395 | if (mpoa_device_type == MPS_AND_MPC && | 417 | if (mpoa_device_type == MPS_AND_MPC && |
396 | length < (42 + number_of_mps_macs*ETH_ALEN)) { /* :) */ | 418 | length < (42 + number_of_mps_macs*ETH_ALEN)) { /* :) */ |
397 | printk("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n", | 419 | pr_info("(%s) short MPOA Device Type TLV\n", |
398 | dev->name); | 420 | dev->name); |
399 | continue; | 421 | continue; |
400 | } | 422 | } |
401 | if ((mpoa_device_type == MPS || mpoa_device_type == MPC) | 423 | if ((mpoa_device_type == MPS || mpoa_device_type == MPC) && |
402 | && length < 22 + number_of_mps_macs*ETH_ALEN) { | 424 | length < 22 + number_of_mps_macs*ETH_ALEN) { |
403 | printk("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n", | 425 | pr_info("(%s) short MPOA Device Type TLV\n", dev->name); |
404 | dev->name); | ||
405 | continue; | 426 | continue; |
406 | } | 427 | } |
407 | if (mpoa_device_type != MPS && mpoa_device_type != MPS_AND_MPC) { | 428 | if (mpoa_device_type != MPS && |
408 | dprintk("ignoring non-MPS device\n"); | 429 | mpoa_device_type != MPS_AND_MPC) { |
409 | if (mpoa_device_type == MPC) tlvs += 20; | 430 | dprintk("ignoring non-MPS device "); |
431 | if (mpoa_device_type == MPC) | ||
432 | tlvs += 20; | ||
410 | continue; /* we are only interested in MPSs */ | 433 | continue; /* we are only interested in MPSs */ |
411 | } | 434 | } |
412 | if (number_of_mps_macs == 0 && mpoa_device_type == MPS_AND_MPC) { | 435 | if (number_of_mps_macs == 0 && |
413 | printk("\nmpoa: (%s) lane2_assoc_ind: MPS_AND_MPC has zero MACs\n", dev->name); | 436 | mpoa_device_type == MPS_AND_MPC) { |
437 | pr_info("(%s) MPS_AND_MPC has zero MACs\n", dev->name); | ||
414 | continue; /* someone should read the spec */ | 438 | continue; /* someone should read the spec */ |
415 | } | 439 | } |
416 | dprintk("this MPS has %d MAC addresses\n", number_of_mps_macs); | 440 | dprintk_cont("this MPS has %d MAC addresses\n", |
441 | number_of_mps_macs); | ||
417 | 442 | ||
418 | /* ok, now we can go and tell our daemon the control address of MPS */ | 443 | /* |
444 | * ok, now we can go and tell our daemon | ||
445 | * the control address of MPS | ||
446 | */ | ||
419 | send_set_mps_ctrl_addr(tlvs, mpc); | 447 | send_set_mps_ctrl_addr(tlvs, mpc); |
420 | 448 | ||
421 | tlvs = copy_macs(mpc, mac_addr, tlvs, number_of_mps_macs, mpoa_device_type); | 449 | tlvs = copy_macs(mpc, mac_addr, tlvs, |
422 | if (tlvs == NULL) return; | 450 | number_of_mps_macs, mpoa_device_type); |
451 | if (tlvs == NULL) | ||
452 | return; | ||
423 | } | 453 | } |
424 | if (end_of_tlvs - tlvs != 0) | 454 | if (end_of_tlvs - tlvs != 0) |
425 | printk("mpoa: (%s) lane2_assoc_ind: ignoring %Zd bytes of trailing TLV carbage\n", | 455 | pr_info("(%s) ignoring %Zd bytes of trailing TLV garbage\n", |
426 | dev->name, end_of_tlvs - tlvs); | 456 | dev->name, end_of_tlvs - tlvs); |
427 | return; | 457 | return; |
428 | } | 458 | } |
429 | 459 | ||
@@ -441,11 +471,12 @@ static const uint8_t *copy_macs(struct mpoa_client *mpc, | |||
441 | num_macs = (mps_macs > 1) ? mps_macs : 1; | 471 | num_macs = (mps_macs > 1) ? mps_macs : 1; |
442 | 472 | ||
443 | if (mpc->number_of_mps_macs != num_macs) { /* need to reallocate? */ | 473 | if (mpc->number_of_mps_macs != num_macs) { /* need to reallocate? */ |
444 | if (mpc->number_of_mps_macs != 0) kfree(mpc->mps_macs); | 474 | if (mpc->number_of_mps_macs != 0) |
475 | kfree(mpc->mps_macs); | ||
445 | mpc->number_of_mps_macs = 0; | 476 | mpc->number_of_mps_macs = 0; |
446 | mpc->mps_macs = kmalloc(num_macs*ETH_ALEN, GFP_KERNEL); | 477 | mpc->mps_macs = kmalloc(num_macs * ETH_ALEN, GFP_KERNEL); |
447 | if (mpc->mps_macs == NULL) { | 478 | if (mpc->mps_macs == NULL) { |
448 | printk("mpoa: (%s) copy_macs: out of mem\n", mpc->dev->name); | 479 | pr_info("(%s) out of mem\n", mpc->dev->name); |
449 | return NULL; | 480 | return NULL; |
450 | } | 481 | } |
451 | } | 482 | } |
@@ -478,24 +509,30 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) | |||
478 | iph = (struct iphdr *)buff; | 509 | iph = (struct iphdr *)buff; |
479 | ipaddr = iph->daddr; | 510 | ipaddr = iph->daddr; |
480 | 511 | ||
481 | ddprintk("mpoa: (%s) send_via_shortcut: ipaddr 0x%x\n", mpc->dev->name, ipaddr); | 512 | ddprintk("(%s) ipaddr 0x%x\n", |
513 | mpc->dev->name, ipaddr); | ||
482 | 514 | ||
483 | entry = mpc->in_ops->get(ipaddr, mpc); | 515 | entry = mpc->in_ops->get(ipaddr, mpc); |
484 | if (entry == NULL) { | 516 | if (entry == NULL) { |
485 | entry = mpc->in_ops->add_entry(ipaddr, mpc); | 517 | entry = mpc->in_ops->add_entry(ipaddr, mpc); |
486 | if (entry != NULL) mpc->in_ops->put(entry); | 518 | if (entry != NULL) |
519 | mpc->in_ops->put(entry); | ||
487 | return 1; | 520 | return 1; |
488 | } | 521 | } |
489 | if (mpc->in_ops->cache_hit(entry, mpc) != OPEN){ /* threshold not exceeded or VCC not ready */ | 522 | /* threshold not exceeded or VCC not ready */ |
490 | ddprintk("mpoa: (%s) send_via_shortcut: cache_hit: returns != OPEN\n", mpc->dev->name); | 523 | if (mpc->in_ops->cache_hit(entry, mpc) != OPEN) { |
524 | ddprintk("(%s) cache_hit: returns != OPEN\n", | ||
525 | mpc->dev->name); | ||
491 | mpc->in_ops->put(entry); | 526 | mpc->in_ops->put(entry); |
492 | return 1; | 527 | return 1; |
493 | } | 528 | } |
494 | 529 | ||
495 | ddprintk("mpoa: (%s) send_via_shortcut: using shortcut\n", mpc->dev->name); | 530 | ddprintk("(%s) using shortcut\n", |
531 | mpc->dev->name); | ||
496 | /* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */ | 532 | /* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */ |
497 | if (iph->ttl <= 1) { | 533 | if (iph->ttl <= 1) { |
498 | ddprintk("mpoa: (%s) send_via_shortcut: IP ttl = %u, using LANE\n", mpc->dev->name, iph->ttl); | 534 | ddprintk("(%s) IP ttl = %u, using LANE\n", |
535 | mpc->dev->name, iph->ttl); | ||
499 | mpc->in_ops->put(entry); | 536 | mpc->in_ops->put(entry); |
500 | return 1; | 537 | return 1; |
501 | } | 538 | } |
@@ -504,15 +541,18 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) | |||
504 | iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); | 541 | iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); |
505 | 542 | ||
506 | if (entry->ctrl_info.tag != 0) { | 543 | if (entry->ctrl_info.tag != 0) { |
507 | ddprintk("mpoa: (%s) send_via_shortcut: adding tag 0x%x\n", mpc->dev->name, entry->ctrl_info.tag); | 544 | ddprintk("(%s) adding tag 0x%x\n", |
545 | mpc->dev->name, entry->ctrl_info.tag); | ||
508 | tagged_llc_snap_hdr.tag = entry->ctrl_info.tag; | 546 | tagged_llc_snap_hdr.tag = entry->ctrl_info.tag; |
509 | skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ | 547 | skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ |
510 | skb_push(skb, sizeof(tagged_llc_snap_hdr)); /* add LLC/SNAP header */ | 548 | skb_push(skb, sizeof(tagged_llc_snap_hdr)); |
549 | /* add LLC/SNAP header */ | ||
511 | skb_copy_to_linear_data(skb, &tagged_llc_snap_hdr, | 550 | skb_copy_to_linear_data(skb, &tagged_llc_snap_hdr, |
512 | sizeof(tagged_llc_snap_hdr)); | 551 | sizeof(tagged_llc_snap_hdr)); |
513 | } else { | 552 | } else { |
514 | skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ | 553 | skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ |
515 | skb_push(skb, sizeof(struct llc_snap_hdr)); /* add LLC/SNAP header + tag */ | 554 | skb_push(skb, sizeof(struct llc_snap_hdr)); |
555 | /* add LLC/SNAP header + tag */ | ||
516 | skb_copy_to_linear_data(skb, &llc_snap_mpoa_data, | 556 | skb_copy_to_linear_data(skb, &llc_snap_mpoa_data, |
517 | sizeof(struct llc_snap_hdr)); | 557 | sizeof(struct llc_snap_hdr)); |
518 | } | 558 | } |
@@ -537,8 +577,8 @@ static netdev_tx_t mpc_send_packet(struct sk_buff *skb, | |||
537 | int i = 0; | 577 | int i = 0; |
538 | 578 | ||
539 | mpc = find_mpc_by_lec(dev); /* this should NEVER fail */ | 579 | mpc = find_mpc_by_lec(dev); /* this should NEVER fail */ |
540 | if(mpc == NULL) { | 580 | if (mpc == NULL) { |
541 | printk("mpoa: (%s) mpc_send_packet: no MPC found\n", dev->name); | 581 | pr_info("(%s) no MPC found\n", dev->name); |
542 | goto non_ip; | 582 | goto non_ip; |
543 | } | 583 | } |
544 | 584 | ||
@@ -554,14 +594,15 @@ static netdev_tx_t mpc_send_packet(struct sk_buff *skb, | |||
554 | goto non_ip; | 594 | goto non_ip; |
555 | 595 | ||
556 | while (i < mpc->number_of_mps_macs) { | 596 | while (i < mpc->number_of_mps_macs) { |
557 | if (!compare_ether_addr(eth->h_dest, (mpc->mps_macs + i*ETH_ALEN))) | 597 | if (!compare_ether_addr(eth->h_dest, |
558 | if ( send_via_shortcut(skb, mpc) == 0 ) /* try shortcut */ | 598 | (mpc->mps_macs + i*ETH_ALEN))) |
559 | return NETDEV_TX_OK; /* success! */ | 599 | if (send_via_shortcut(skb, mpc) == 0) /* try shortcut */ |
600 | return NETDEV_TX_OK; | ||
560 | i++; | 601 | i++; |
561 | } | 602 | } |
562 | 603 | ||
563 | non_ip: | 604 | non_ip: |
564 | return mpc->old_ops->ndo_start_xmit(skb,dev); | 605 | return mpc->old_ops->ndo_start_xmit(skb, dev); |
565 | } | 606 | } |
566 | 607 | ||
567 | static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg) | 608 | static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg) |
@@ -574,7 +615,8 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg) | |||
574 | 615 | ||
575 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); | 616 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); |
576 | if (bytes_left != 0) { | 617 | if (bytes_left != 0) { |
577 | printk("mpoa: mpc_vcc_attach: Short read (missed %d bytes) from userland\n", bytes_left); | 618 | pr_info("mpoa:Short read (missed %d bytes) from userland\n", |
619 | bytes_left); | ||
578 | return -EFAULT; | 620 | return -EFAULT; |
579 | } | 621 | } |
580 | ipaddr = ioc_data.ipaddr; | 622 | ipaddr = ioc_data.ipaddr; |
@@ -587,18 +629,20 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg) | |||
587 | 629 | ||
588 | if (ioc_data.type == MPC_SOCKET_INGRESS) { | 630 | if (ioc_data.type == MPC_SOCKET_INGRESS) { |
589 | in_entry = mpc->in_ops->get(ipaddr, mpc); | 631 | in_entry = mpc->in_ops->get(ipaddr, mpc); |
590 | if (in_entry == NULL || in_entry->entry_state < INGRESS_RESOLVED) { | 632 | if (in_entry == NULL || |
591 | printk("mpoa: (%s) mpc_vcc_attach: did not find RESOLVED entry from ingress cache\n", | 633 | in_entry->entry_state < INGRESS_RESOLVED) { |
634 | pr_info("(%s) did not find RESOLVED entry from ingress cache\n", | ||
592 | mpc->dev->name); | 635 | mpc->dev->name); |
593 | if (in_entry != NULL) mpc->in_ops->put(in_entry); | 636 | if (in_entry != NULL) |
637 | mpc->in_ops->put(in_entry); | ||
594 | return -EINVAL; | 638 | return -EINVAL; |
595 | } | 639 | } |
596 | printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %pI4\n", | 640 | pr_info("(%s) attaching ingress SVC, entry = %pI4\n", |
597 | mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); | 641 | mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); |
598 | in_entry->shortcut = vcc; | 642 | in_entry->shortcut = vcc; |
599 | mpc->in_ops->put(in_entry); | 643 | mpc->in_ops->put(in_entry); |
600 | } else { | 644 | } else { |
601 | printk("mpoa: (%s) mpc_vcc_attach: attaching egress SVC\n", mpc->dev->name); | 645 | pr_info("(%s) attaching egress SVC\n", mpc->dev->name); |
602 | } | 646 | } |
603 | 647 | ||
604 | vcc->proto_data = mpc->dev; | 648 | vcc->proto_data = mpc->dev; |
@@ -618,27 +662,27 @@ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev) | |||
618 | 662 | ||
619 | mpc = find_mpc_by_lec(dev); | 663 | mpc = find_mpc_by_lec(dev); |
620 | if (mpc == NULL) { | 664 | if (mpc == NULL) { |
621 | printk("mpoa: (%s) mpc_vcc_close: close for unknown MPC\n", dev->name); | 665 | pr_info("(%s) close for unknown MPC\n", dev->name); |
622 | return; | 666 | return; |
623 | } | 667 | } |
624 | 668 | ||
625 | dprintk("mpoa: (%s) mpc_vcc_close:\n", dev->name); | 669 | dprintk("(%s)\n", dev->name); |
626 | in_entry = mpc->in_ops->get_by_vcc(vcc, mpc); | 670 | in_entry = mpc->in_ops->get_by_vcc(vcc, mpc); |
627 | if (in_entry) { | 671 | if (in_entry) { |
628 | dprintk("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %pI4\n", | 672 | dprintk("(%s) ingress SVC closed ip = %pI4\n", |
629 | mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); | 673 | mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); |
630 | in_entry->shortcut = NULL; | 674 | in_entry->shortcut = NULL; |
631 | mpc->in_ops->put(in_entry); | 675 | mpc->in_ops->put(in_entry); |
632 | } | 676 | } |
633 | eg_entry = mpc->eg_ops->get_by_vcc(vcc, mpc); | 677 | eg_entry = mpc->eg_ops->get_by_vcc(vcc, mpc); |
634 | if (eg_entry) { | 678 | if (eg_entry) { |
635 | dprintk("mpoa: (%s) mpc_vcc_close: egress SVC closed\n", mpc->dev->name); | 679 | dprintk("(%s) egress SVC closed\n", mpc->dev->name); |
636 | eg_entry->shortcut = NULL; | 680 | eg_entry->shortcut = NULL; |
637 | mpc->eg_ops->put(eg_entry); | 681 | mpc->eg_ops->put(eg_entry); |
638 | } | 682 | } |
639 | 683 | ||
640 | if (in_entry == NULL && eg_entry == NULL) | 684 | if (in_entry == NULL && eg_entry == NULL) |
641 | dprintk("mpoa: (%s) mpc_vcc_close: unused vcc closed\n", dev->name); | 685 | dprintk("(%s) unused vcc closed\n", dev->name); |
642 | 686 | ||
643 | return; | 687 | return; |
644 | } | 688 | } |
@@ -652,18 +696,19 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
652 | __be32 tag; | 696 | __be32 tag; |
653 | char *tmp; | 697 | char *tmp; |
654 | 698 | ||
655 | ddprintk("mpoa: (%s) mpc_push:\n", dev->name); | 699 | ddprintk("(%s)\n", dev->name); |
656 | if (skb == NULL) { | 700 | if (skb == NULL) { |
657 | dprintk("mpoa: (%s) mpc_push: null skb, closing VCC\n", dev->name); | 701 | dprintk("(%s) null skb, closing VCC\n", dev->name); |
658 | mpc_vcc_close(vcc, dev); | 702 | mpc_vcc_close(vcc, dev); |
659 | return; | 703 | return; |
660 | } | 704 | } |
661 | 705 | ||
662 | skb->dev = dev; | 706 | skb->dev = dev; |
663 | if (memcmp(skb->data, &llc_snap_mpoa_ctrl, sizeof(struct llc_snap_hdr)) == 0) { | 707 | if (memcmp(skb->data, &llc_snap_mpoa_ctrl, |
708 | sizeof(struct llc_snap_hdr)) == 0) { | ||
664 | struct sock *sk = sk_atm(vcc); | 709 | struct sock *sk = sk_atm(vcc); |
665 | 710 | ||
666 | dprintk("mpoa: (%s) mpc_push: control packet arrived\n", dev->name); | 711 | dprintk("(%s) control packet arrived\n", dev->name); |
667 | /* Pass control packets to daemon */ | 712 | /* Pass control packets to daemon */ |
668 | skb_queue_tail(&sk->sk_receive_queue, skb); | 713 | skb_queue_tail(&sk->sk_receive_queue, skb); |
669 | sk->sk_data_ready(sk, skb->len); | 714 | sk->sk_data_ready(sk, skb->len); |
@@ -675,20 +720,22 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
675 | 720 | ||
676 | mpc = find_mpc_by_lec(dev); | 721 | mpc = find_mpc_by_lec(dev); |
677 | if (mpc == NULL) { | 722 | if (mpc == NULL) { |
678 | printk("mpoa: (%s) mpc_push: unknown MPC\n", dev->name); | 723 | pr_info("(%s) unknown MPC\n", dev->name); |
679 | return; | 724 | return; |
680 | } | 725 | } |
681 | 726 | ||
682 | if (memcmp(skb->data, &llc_snap_mpoa_data_tagged, sizeof(struct llc_snap_hdr)) == 0) { /* MPOA tagged data */ | 727 | if (memcmp(skb->data, &llc_snap_mpoa_data_tagged, |
683 | ddprintk("mpoa: (%s) mpc_push: tagged data packet arrived\n", dev->name); | 728 | sizeof(struct llc_snap_hdr)) == 0) { /* MPOA tagged data */ |
729 | ddprintk("(%s) tagged data packet arrived\n", dev->name); | ||
684 | 730 | ||
685 | } else if (memcmp(skb->data, &llc_snap_mpoa_data, sizeof(struct llc_snap_hdr)) == 0) { /* MPOA data */ | 731 | } else if (memcmp(skb->data, &llc_snap_mpoa_data, |
686 | printk("mpoa: (%s) mpc_push: non-tagged data packet arrived\n", dev->name); | 732 | sizeof(struct llc_snap_hdr)) == 0) { /* MPOA data */ |
687 | printk(" mpc_push: non-tagged data unsupported, purging\n"); | 733 | pr_info("(%s) Unsupported non-tagged data packet arrived. Purging\n", |
734 | dev->name); | ||
688 | dev_kfree_skb_any(skb); | 735 | dev_kfree_skb_any(skb); |
689 | return; | 736 | return; |
690 | } else { | 737 | } else { |
691 | printk("mpoa: (%s) mpc_push: garbage arrived, purging\n", dev->name); | 738 | pr_info("(%s) garbage arrived, purging\n", dev->name); |
692 | dev_kfree_skb_any(skb); | 739 | dev_kfree_skb_any(skb); |
693 | return; | 740 | return; |
694 | } | 741 | } |
@@ -698,8 +745,8 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
698 | 745 | ||
699 | eg = mpc->eg_ops->get_by_tag(tag, mpc); | 746 | eg = mpc->eg_ops->get_by_tag(tag, mpc); |
700 | if (eg == NULL) { | 747 | if (eg == NULL) { |
701 | printk("mpoa: (%s) mpc_push: Didn't find egress cache entry, tag = %u\n", | 748 | pr_info("mpoa: (%s) Didn't find egress cache entry, tag = %u\n", |
702 | dev->name,tag); | 749 | dev->name, tag); |
703 | purge_egress_shortcut(vcc, NULL); | 750 | purge_egress_shortcut(vcc, NULL); |
704 | dev_kfree_skb_any(skb); | 751 | dev_kfree_skb_any(skb); |
705 | return; | 752 | return; |
@@ -711,13 +758,15 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
711 | */ | 758 | */ |
712 | if (eg->shortcut == NULL) { | 759 | if (eg->shortcut == NULL) { |
713 | eg->shortcut = vcc; | 760 | eg->shortcut = vcc; |
714 | printk("mpoa: (%s) mpc_push: egress SVC in use\n", dev->name); | 761 | pr_info("(%s) egress SVC in use\n", dev->name); |
715 | } | 762 | } |
716 | 763 | ||
717 | skb_pull(skb, sizeof(struct llc_snap_hdr) + sizeof(tag)); /* get rid of LLC/SNAP header */ | 764 | skb_pull(skb, sizeof(struct llc_snap_hdr) + sizeof(tag)); |
718 | new_skb = skb_realloc_headroom(skb, eg->ctrl_info.DH_length); /* LLC/SNAP is shorter than MAC header :( */ | 765 | /* get rid of LLC/SNAP header */ |
766 | new_skb = skb_realloc_headroom(skb, eg->ctrl_info.DH_length); | ||
767 | /* LLC/SNAP is shorter than MAC header :( */ | ||
719 | dev_kfree_skb_any(skb); | 768 | dev_kfree_skb_any(skb); |
720 | if (new_skb == NULL){ | 769 | if (new_skb == NULL) { |
721 | mpc->eg_ops->put(eg); | 770 | mpc->eg_ops->put(eg); |
722 | return; | 771 | return; |
723 | } | 772 | } |
@@ -750,7 +799,7 @@ static struct atm_dev mpc_dev = { | |||
750 | /* members not explicitly initialised will be 0 */ | 799 | /* members not explicitly initialised will be 0 */ |
751 | }; | 800 | }; |
752 | 801 | ||
753 | static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) | 802 | static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg) |
754 | { | 803 | { |
755 | struct mpoa_client *mpc; | 804 | struct mpoa_client *mpc; |
756 | struct lec_priv *priv; | 805 | struct lec_priv *priv; |
@@ -770,15 +819,16 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) | |||
770 | 819 | ||
771 | mpc = find_mpc_by_itfnum(arg); | 820 | mpc = find_mpc_by_itfnum(arg); |
772 | if (mpc == NULL) { | 821 | if (mpc == NULL) { |
773 | dprintk("mpoa: mpoad_attach: allocating new mpc for itf %d\n", arg); | 822 | dprintk("allocating new mpc for itf %d\n", arg); |
774 | mpc = alloc_mpc(); | 823 | mpc = alloc_mpc(); |
775 | if (mpc == NULL) | 824 | if (mpc == NULL) |
776 | return -ENOMEM; | 825 | return -ENOMEM; |
777 | mpc->dev_num = arg; | 826 | mpc->dev_num = arg; |
778 | mpc->dev = find_lec_by_itfnum(arg); /* NULL if there was no lec */ | 827 | mpc->dev = find_lec_by_itfnum(arg); |
828 | /* NULL if there was no lec */ | ||
779 | } | 829 | } |
780 | if (mpc->mpoad_vcc) { | 830 | if (mpc->mpoad_vcc) { |
781 | printk("mpoa: mpoad_attach: mpoad is already present for itf %d\n", arg); | 831 | pr_info("mpoad is already present for itf %d\n", arg); |
782 | return -EADDRINUSE; | 832 | return -EADDRINUSE; |
783 | } | 833 | } |
784 | 834 | ||
@@ -794,8 +844,8 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) | |||
794 | mpc->mpoad_vcc = vcc; | 844 | mpc->mpoad_vcc = vcc; |
795 | vcc->dev = &mpc_dev; | 845 | vcc->dev = &mpc_dev; |
796 | vcc_insert_socket(sk_atm(vcc)); | 846 | vcc_insert_socket(sk_atm(vcc)); |
797 | set_bit(ATM_VF_META,&vcc->flags); | 847 | set_bit(ATM_VF_META, &vcc->flags); |
798 | set_bit(ATM_VF_READY,&vcc->flags); | 848 | set_bit(ATM_VF_READY, &vcc->flags); |
799 | 849 | ||
800 | if (mpc->dev) { | 850 | if (mpc->dev) { |
801 | char empty[ATM_ESA_LEN]; | 851 | char empty[ATM_ESA_LEN]; |
@@ -805,7 +855,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) | |||
805 | /* set address if mpcd e.g. gets killed and restarted. | 855 | /* set address if mpcd e.g. gets killed and restarted. |
806 | * If we do not do it now we have to wait for the next LE_ARP | 856 | * If we do not do it now we have to wait for the next LE_ARP |
807 | */ | 857 | */ |
808 | if ( memcmp(mpc->mps_ctrl_addr, empty, ATM_ESA_LEN) != 0 ) | 858 | if (memcmp(mpc->mps_ctrl_addr, empty, ATM_ESA_LEN) != 0) |
809 | send_set_mps_ctrl_addr(mpc->mps_ctrl_addr, mpc); | 859 | send_set_mps_ctrl_addr(mpc->mps_ctrl_addr, mpc); |
810 | } | 860 | } |
811 | 861 | ||
@@ -817,7 +867,7 @@ static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc) | |||
817 | { | 867 | { |
818 | struct k_message mesg; | 868 | struct k_message mesg; |
819 | 869 | ||
820 | memcpy (mpc->mps_ctrl_addr, addr, ATM_ESA_LEN); | 870 | memcpy(mpc->mps_ctrl_addr, addr, ATM_ESA_LEN); |
821 | 871 | ||
822 | mesg.type = SET_MPS_CTRL_ADDR; | 872 | mesg.type = SET_MPS_CTRL_ADDR; |
823 | memcpy(mesg.MPS_ctrl, addr, ATM_ESA_LEN); | 873 | memcpy(mesg.MPS_ctrl, addr, ATM_ESA_LEN); |
@@ -833,11 +883,11 @@ static void mpoad_close(struct atm_vcc *vcc) | |||
833 | 883 | ||
834 | mpc = find_mpc_by_vcc(vcc); | 884 | mpc = find_mpc_by_vcc(vcc); |
835 | if (mpc == NULL) { | 885 | if (mpc == NULL) { |
836 | printk("mpoa: mpoad_close: did not find MPC\n"); | 886 | pr_info("did not find MPC\n"); |
837 | return; | 887 | return; |
838 | } | 888 | } |
839 | if (!mpc->mpoad_vcc) { | 889 | if (!mpc->mpoad_vcc) { |
840 | printk("mpoa: mpoad_close: close for non-present mpoad\n"); | 890 | pr_info("close for non-present mpoad\n"); |
841 | return; | 891 | return; |
842 | } | 892 | } |
843 | 893 | ||
@@ -857,7 +907,7 @@ static void mpoad_close(struct atm_vcc *vcc) | |||
857 | kfree_skb(skb); | 907 | kfree_skb(skb); |
858 | } | 908 | } |
859 | 909 | ||
860 | printk("mpoa: (%s) going down\n", | 910 | pr_info("(%s) going down\n", |
861 | (mpc->dev) ? mpc->dev->name : "<unknown>"); | 911 | (mpc->dev) ? mpc->dev->name : "<unknown>"); |
862 | module_put(THIS_MODULE); | 912 | module_put(THIS_MODULE); |
863 | 913 | ||
@@ -871,61 +921,61 @@ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb) | |||
871 | { | 921 | { |
872 | 922 | ||
873 | struct mpoa_client *mpc = find_mpc_by_vcc(vcc); | 923 | struct mpoa_client *mpc = find_mpc_by_vcc(vcc); |
874 | struct k_message *mesg = (struct k_message*)skb->data; | 924 | struct k_message *mesg = (struct k_message *)skb->data; |
875 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); | 925 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); |
876 | 926 | ||
877 | if (mpc == NULL) { | 927 | if (mpc == NULL) { |
878 | printk("mpoa: msg_from_mpoad: no mpc found\n"); | 928 | pr_info("no mpc found\n"); |
879 | return 0; | 929 | return 0; |
880 | } | 930 | } |
881 | dprintk("mpoa: (%s) msg_from_mpoad:", (mpc->dev) ? mpc->dev->name : "<unknown>"); | 931 | dprintk("(%s)", mpc->dev ? mpc->dev->name : "<unknown>"); |
882 | switch(mesg->type) { | 932 | switch (mesg->type) { |
883 | case MPOA_RES_REPLY_RCVD: | 933 | case MPOA_RES_REPLY_RCVD: |
884 | dprintk(" mpoa_res_reply_rcvd\n"); | 934 | dprintk_cont("mpoa_res_reply_rcvd\n"); |
885 | MPOA_res_reply_rcvd(mesg, mpc); | 935 | MPOA_res_reply_rcvd(mesg, mpc); |
886 | break; | 936 | break; |
887 | case MPOA_TRIGGER_RCVD: | 937 | case MPOA_TRIGGER_RCVD: |
888 | dprintk(" mpoa_trigger_rcvd\n"); | 938 | dprintk_cont("mpoa_trigger_rcvd\n"); |
889 | MPOA_trigger_rcvd(mesg, mpc); | 939 | MPOA_trigger_rcvd(mesg, mpc); |
890 | break; | 940 | break; |
891 | case INGRESS_PURGE_RCVD: | 941 | case INGRESS_PURGE_RCVD: |
892 | dprintk(" nhrp_purge_rcvd\n"); | 942 | dprintk_cont("nhrp_purge_rcvd\n"); |
893 | ingress_purge_rcvd(mesg, mpc); | 943 | ingress_purge_rcvd(mesg, mpc); |
894 | break; | 944 | break; |
895 | case EGRESS_PURGE_RCVD: | 945 | case EGRESS_PURGE_RCVD: |
896 | dprintk(" egress_purge_reply_rcvd\n"); | 946 | dprintk_cont("egress_purge_reply_rcvd\n"); |
897 | egress_purge_rcvd(mesg, mpc); | 947 | egress_purge_rcvd(mesg, mpc); |
898 | break; | 948 | break; |
899 | case MPS_DEATH: | 949 | case MPS_DEATH: |
900 | dprintk(" mps_death\n"); | 950 | dprintk_cont("mps_death\n"); |
901 | mps_death(mesg, mpc); | 951 | mps_death(mesg, mpc); |
902 | break; | 952 | break; |
903 | case CACHE_IMPOS_RCVD: | 953 | case CACHE_IMPOS_RCVD: |
904 | dprintk(" cache_impos_rcvd\n"); | 954 | dprintk_cont("cache_impos_rcvd\n"); |
905 | MPOA_cache_impos_rcvd(mesg, mpc); | 955 | MPOA_cache_impos_rcvd(mesg, mpc); |
906 | break; | 956 | break; |
907 | case SET_MPC_CTRL_ADDR: | 957 | case SET_MPC_CTRL_ADDR: |
908 | dprintk(" set_mpc_ctrl_addr\n"); | 958 | dprintk_cont("set_mpc_ctrl_addr\n"); |
909 | set_mpc_ctrl_addr_rcvd(mesg, mpc); | 959 | set_mpc_ctrl_addr_rcvd(mesg, mpc); |
910 | break; | 960 | break; |
911 | case SET_MPS_MAC_ADDR: | 961 | case SET_MPS_MAC_ADDR: |
912 | dprintk(" set_mps_mac_addr\n"); | 962 | dprintk_cont("set_mps_mac_addr\n"); |
913 | set_mps_mac_addr_rcvd(mesg, mpc); | 963 | set_mps_mac_addr_rcvd(mesg, mpc); |
914 | break; | 964 | break; |
915 | case CLEAN_UP_AND_EXIT: | 965 | case CLEAN_UP_AND_EXIT: |
916 | dprintk(" clean_up_and_exit\n"); | 966 | dprintk_cont("clean_up_and_exit\n"); |
917 | clean_up(mesg, mpc, DIE); | 967 | clean_up(mesg, mpc, DIE); |
918 | break; | 968 | break; |
919 | case RELOAD: | 969 | case RELOAD: |
920 | dprintk(" reload\n"); | 970 | dprintk_cont("reload\n"); |
921 | clean_up(mesg, mpc, RELOAD); | 971 | clean_up(mesg, mpc, RELOAD); |
922 | break; | 972 | break; |
923 | case SET_MPC_PARAMS: | 973 | case SET_MPC_PARAMS: |
924 | dprintk(" set_mpc_params\n"); | 974 | dprintk_cont("set_mpc_params\n"); |
925 | mpc->parameters = mesg->content.params; | 975 | mpc->parameters = mesg->content.params; |
926 | break; | 976 | break; |
927 | default: | 977 | default: |
928 | dprintk(" unknown message %d\n", mesg->type); | 978 | dprintk_cont("unknown message %d\n", mesg->type); |
929 | break; | 979 | break; |
930 | } | 980 | } |
931 | kfree_skb(skb); | 981 | kfree_skb(skb); |
@@ -940,7 +990,7 @@ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc) | |||
940 | struct sock *sk; | 990 | struct sock *sk; |
941 | 991 | ||
942 | if (mpc == NULL || !mpc->mpoad_vcc) { | 992 | if (mpc == NULL || !mpc->mpoad_vcc) { |
943 | printk("mpoa: msg_to_mpoad: mesg %d to a non-existent mpoad\n", mesg->type); | 993 | pr_info("mesg %d to a non-existent mpoad\n", mesg->type); |
944 | return -ENXIO; | 994 | return -ENXIO; |
945 | } | 995 | } |
946 | 996 | ||
@@ -958,7 +1008,8 @@ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc) | |||
958 | return 0; | 1008 | return 0; |
959 | } | 1009 | } |
960 | 1010 | ||
961 | static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned long event, void *dev_ptr) | 1011 | static int mpoa_event_listener(struct notifier_block *mpoa_notifier, |
1012 | unsigned long event, void *dev_ptr) | ||
962 | { | 1013 | { |
963 | struct net_device *dev; | 1014 | struct net_device *dev; |
964 | struct mpoa_client *mpc; | 1015 | struct mpoa_client *mpc; |
@@ -980,25 +1031,24 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo | |||
980 | priv->lane2_ops->associate_indicator = lane2_assoc_ind; | 1031 | priv->lane2_ops->associate_indicator = lane2_assoc_ind; |
981 | mpc = find_mpc_by_itfnum(priv->itfnum); | 1032 | mpc = find_mpc_by_itfnum(priv->itfnum); |
982 | if (mpc == NULL) { | 1033 | if (mpc == NULL) { |
983 | dprintk("mpoa: mpoa_event_listener: allocating new mpc for %s\n", | 1034 | dprintk("allocating new mpc for %s\n", dev->name); |
984 | dev->name); | ||
985 | mpc = alloc_mpc(); | 1035 | mpc = alloc_mpc(); |
986 | if (mpc == NULL) { | 1036 | if (mpc == NULL) { |
987 | printk("mpoa: mpoa_event_listener: no new mpc"); | 1037 | pr_info("no new mpc"); |
988 | break; | 1038 | break; |
989 | } | 1039 | } |
990 | } | 1040 | } |
991 | mpc->dev_num = priv->itfnum; | 1041 | mpc->dev_num = priv->itfnum; |
992 | mpc->dev = dev; | 1042 | mpc->dev = dev; |
993 | dev_hold(dev); | 1043 | dev_hold(dev); |
994 | dprintk("mpoa: (%s) was initialized\n", dev->name); | 1044 | dprintk("(%s) was initialized\n", dev->name); |
995 | break; | 1045 | break; |
996 | case NETDEV_UNREGISTER: | 1046 | case NETDEV_UNREGISTER: |
997 | /* the lec device was deallocated */ | 1047 | /* the lec device was deallocated */ |
998 | mpc = find_mpc_by_lec(dev); | 1048 | mpc = find_mpc_by_lec(dev); |
999 | if (mpc == NULL) | 1049 | if (mpc == NULL) |
1000 | break; | 1050 | break; |
1001 | dprintk("mpoa: device (%s) was deallocated\n", dev->name); | 1051 | dprintk("device (%s) was deallocated\n", dev->name); |
1002 | stop_mpc(mpc); | 1052 | stop_mpc(mpc); |
1003 | dev_put(mpc->dev); | 1053 | dev_put(mpc->dev); |
1004 | mpc->dev = NULL; | 1054 | mpc->dev = NULL; |
@@ -1008,9 +1058,8 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo | |||
1008 | mpc = find_mpc_by_lec(dev); | 1058 | mpc = find_mpc_by_lec(dev); |
1009 | if (mpc == NULL) | 1059 | if (mpc == NULL) |
1010 | break; | 1060 | break; |
1011 | if (mpc->mpoad_vcc != NULL) { | 1061 | if (mpc->mpoad_vcc != NULL) |
1012 | start_mpc(mpc, dev); | 1062 | start_mpc(mpc, dev); |
1013 | } | ||
1014 | break; | 1063 | break; |
1015 | case NETDEV_DOWN: | 1064 | case NETDEV_DOWN: |
1016 | /* the dev was ifconfig'ed down */ | 1065 | /* the dev was ifconfig'ed down */ |
@@ -1020,9 +1069,8 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo | |||
1020 | mpc = find_mpc_by_lec(dev); | 1069 | mpc = find_mpc_by_lec(dev); |
1021 | if (mpc == NULL) | 1070 | if (mpc == NULL) |
1022 | break; | 1071 | break; |
1023 | if (mpc->mpoad_vcc != NULL) { | 1072 | if (mpc->mpoad_vcc != NULL) |
1024 | stop_mpc(mpc); | 1073 | stop_mpc(mpc); |
1025 | } | ||
1026 | break; | 1074 | break; |
1027 | case NETDEV_REBOOT: | 1075 | case NETDEV_REBOOT: |
1028 | case NETDEV_CHANGE: | 1076 | case NETDEV_CHANGE: |
@@ -1049,7 +1097,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1049 | in_cache_entry *entry; | 1097 | in_cache_entry *entry; |
1050 | 1098 | ||
1051 | entry = mpc->in_ops->get(dst_ip, mpc); | 1099 | entry = mpc->in_ops->get(dst_ip, mpc); |
1052 | if(entry == NULL){ | 1100 | if (entry == NULL) { |
1053 | entry = mpc->in_ops->add_entry(dst_ip, mpc); | 1101 | entry = mpc->in_ops->add_entry(dst_ip, mpc); |
1054 | entry->entry_state = INGRESS_RESOLVING; | 1102 | entry->entry_state = INGRESS_RESOLVING; |
1055 | msg->type = SND_MPOA_RES_RQST; | 1103 | msg->type = SND_MPOA_RES_RQST; |
@@ -1060,7 +1108,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1060 | return; | 1108 | return; |
1061 | } | 1109 | } |
1062 | 1110 | ||
1063 | if(entry->entry_state == INGRESS_INVALID){ | 1111 | if (entry->entry_state == INGRESS_INVALID) { |
1064 | entry->entry_state = INGRESS_RESOLVING; | 1112 | entry->entry_state = INGRESS_RESOLVING; |
1065 | msg->type = SND_MPOA_RES_RQST; | 1113 | msg->type = SND_MPOA_RES_RQST; |
1066 | msg->content.in_info = entry->ctrl_info; | 1114 | msg->content.in_info = entry->ctrl_info; |
@@ -1070,7 +1118,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1070 | return; | 1118 | return; |
1071 | } | 1119 | } |
1072 | 1120 | ||
1073 | printk("mpoa: (%s) MPOA_trigger_rcvd: entry already in resolving state\n", | 1121 | pr_info("(%s) entry already in resolving state\n", |
1074 | (mpc->dev) ? mpc->dev->name : "<unknown>"); | 1122 | (mpc->dev) ? mpc->dev->name : "<unknown>"); |
1075 | mpc->in_ops->put(entry); | 1123 | mpc->in_ops->put(entry); |
1076 | return; | 1124 | return; |
@@ -1080,23 +1128,25 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1080 | * Things get complicated because we have to check if there's an egress | 1128 | * Things get complicated because we have to check if there's an egress |
1081 | * shortcut with suitable traffic parameters we could use. | 1129 | * shortcut with suitable traffic parameters we could use. |
1082 | */ | 1130 | */ |
1083 | static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_client *client, in_cache_entry *entry) | 1131 | static void check_qos_and_open_shortcut(struct k_message *msg, |
1132 | struct mpoa_client *client, | ||
1133 | in_cache_entry *entry) | ||
1084 | { | 1134 | { |
1085 | __be32 dst_ip = msg->content.in_info.in_dst_ip; | 1135 | __be32 dst_ip = msg->content.in_info.in_dst_ip; |
1086 | struct atm_mpoa_qos *qos = atm_mpoa_search_qos(dst_ip); | 1136 | struct atm_mpoa_qos *qos = atm_mpoa_search_qos(dst_ip); |
1087 | eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip(dst_ip, client); | 1137 | eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip(dst_ip, client); |
1088 | 1138 | ||
1089 | if(eg_entry && eg_entry->shortcut){ | 1139 | if (eg_entry && eg_entry->shortcut) { |
1090 | if(eg_entry->shortcut->qos.txtp.traffic_class & | 1140 | if (eg_entry->shortcut->qos.txtp.traffic_class & |
1091 | msg->qos.txtp.traffic_class & | 1141 | msg->qos.txtp.traffic_class & |
1092 | (qos ? qos->qos.txtp.traffic_class : ATM_UBR | ATM_CBR)){ | 1142 | (qos ? qos->qos.txtp.traffic_class : ATM_UBR | ATM_CBR)) { |
1093 | if(eg_entry->shortcut->qos.txtp.traffic_class == ATM_UBR) | 1143 | if (eg_entry->shortcut->qos.txtp.traffic_class == ATM_UBR) |
1094 | entry->shortcut = eg_entry->shortcut; | 1144 | entry->shortcut = eg_entry->shortcut; |
1095 | else if(eg_entry->shortcut->qos.txtp.max_pcr > 0) | 1145 | else if (eg_entry->shortcut->qos.txtp.max_pcr > 0) |
1096 | entry->shortcut = eg_entry->shortcut; | 1146 | entry->shortcut = eg_entry->shortcut; |
1097 | } | 1147 | } |
1098 | if(entry->shortcut){ | 1148 | if (entry->shortcut) { |
1099 | dprintk("mpoa: (%s) using egress SVC to reach %pI4\n", | 1149 | dprintk("(%s) using egress SVC to reach %pI4\n", |
1100 | client->dev->name, &dst_ip); | 1150 | client->dev->name, &dst_ip); |
1101 | client->eg_ops->put(eg_entry); | 1151 | client->eg_ops->put(eg_entry); |
1102 | return; | 1152 | return; |
@@ -1107,12 +1157,13 @@ static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_clien | |||
1107 | 1157 | ||
1108 | /* No luck in the egress cache we must open an ingress SVC */ | 1158 | /* No luck in the egress cache we must open an ingress SVC */ |
1109 | msg->type = OPEN_INGRESS_SVC; | 1159 | msg->type = OPEN_INGRESS_SVC; |
1110 | if (qos && (qos->qos.txtp.traffic_class == msg->qos.txtp.traffic_class)) | 1160 | if (qos && |
1111 | { | 1161 | (qos->qos.txtp.traffic_class == msg->qos.txtp.traffic_class)) { |
1112 | msg->qos = qos->qos; | 1162 | msg->qos = qos->qos; |
1113 | printk("mpoa: (%s) trying to get a CBR shortcut\n",client->dev->name); | 1163 | pr_info("(%s) trying to get a CBR shortcut\n", |
1114 | } | 1164 | client->dev->name); |
1115 | else memset(&msg->qos,0,sizeof(struct atm_qos)); | 1165 | } else |
1166 | memset(&msg->qos, 0, sizeof(struct atm_qos)); | ||
1116 | msg_to_mpoad(msg, client); | 1167 | msg_to_mpoad(msg, client); |
1117 | return; | 1168 | return; |
1118 | } | 1169 | } |
@@ -1122,17 +1173,19 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1122 | __be32 dst_ip = msg->content.in_info.in_dst_ip; | 1173 | __be32 dst_ip = msg->content.in_info.in_dst_ip; |
1123 | in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); | 1174 | in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); |
1124 | 1175 | ||
1125 | dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %pI4\n", | 1176 | dprintk("(%s) ip %pI4\n", |
1126 | mpc->dev->name, &dst_ip); | 1177 | mpc->dev->name, &dst_ip); |
1127 | ddprintk("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p", mpc->dev->name, entry); | 1178 | ddprintk("(%s) entry = %p", |
1128 | if(entry == NULL){ | 1179 | mpc->dev->name, entry); |
1129 | printk("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc->dev->name); | 1180 | if (entry == NULL) { |
1181 | pr_info("(%s) ARGH, received res. reply for an entry that doesn't exist.\n", | ||
1182 | mpc->dev->name); | ||
1130 | return; | 1183 | return; |
1131 | } | 1184 | } |
1132 | ddprintk(" entry_state = %d ", entry->entry_state); | 1185 | ddprintk_cont(" entry_state = %d ", entry->entry_state); |
1133 | 1186 | ||
1134 | if (entry->entry_state == INGRESS_RESOLVED) { | 1187 | if (entry->entry_state == INGRESS_RESOLVED) { |
1135 | printk("\nmpoa: (%s) MPOA_res_reply_rcvd for RESOLVED entry!\n", mpc->dev->name); | 1188 | pr_info("(%s) RESOLVED entry!\n", mpc->dev->name); |
1136 | mpc->in_ops->put(entry); | 1189 | mpc->in_ops->put(entry); |
1137 | return; | 1190 | return; |
1138 | } | 1191 | } |
@@ -1141,17 +1194,18 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1141 | do_gettimeofday(&(entry->tv)); | 1194 | do_gettimeofday(&(entry->tv)); |
1142 | do_gettimeofday(&(entry->reply_wait)); /* Used in refreshing func from now on */ | 1195 | do_gettimeofday(&(entry->reply_wait)); /* Used in refreshing func from now on */ |
1143 | entry->refresh_time = 0; | 1196 | entry->refresh_time = 0; |
1144 | ddprintk("entry->shortcut = %p\n", entry->shortcut); | 1197 | ddprintk_cont("entry->shortcut = %p\n", entry->shortcut); |
1145 | 1198 | ||
1146 | if(entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL){ | 1199 | if (entry->entry_state == INGRESS_RESOLVING && |
1200 | entry->shortcut != NULL) { | ||
1147 | entry->entry_state = INGRESS_RESOLVED; | 1201 | entry->entry_state = INGRESS_RESOLVED; |
1148 | mpc->in_ops->put(entry); | 1202 | mpc->in_ops->put(entry); |
1149 | return; /* Shortcut already open... */ | 1203 | return; /* Shortcut already open... */ |
1150 | } | 1204 | } |
1151 | 1205 | ||
1152 | if (entry->shortcut != NULL) { | 1206 | if (entry->shortcut != NULL) { |
1153 | printk("mpoa: (%s) MPOA_res_reply_rcvd: entry->shortcut != NULL, impossible!\n", | 1207 | pr_info("(%s) entry->shortcut != NULL, impossible!\n", |
1154 | mpc->dev->name); | 1208 | mpc->dev->name); |
1155 | mpc->in_ops->put(entry); | 1209 | mpc->in_ops->put(entry); |
1156 | return; | 1210 | return; |
1157 | } | 1211 | } |
@@ -1170,14 +1224,14 @@ static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1170 | __be32 mask = msg->ip_mask; | 1224 | __be32 mask = msg->ip_mask; |
1171 | in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); | 1225 | in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); |
1172 | 1226 | ||
1173 | if(entry == NULL){ | 1227 | if (entry == NULL) { |
1174 | printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ip = %pI4\n", | 1228 | pr_info("(%s) purge for a non-existing entry, ip = %pI4\n", |
1175 | mpc->dev->name, &dst_ip); | 1229 | mpc->dev->name, &dst_ip); |
1176 | return; | 1230 | return; |
1177 | } | 1231 | } |
1178 | 1232 | ||
1179 | do { | 1233 | do { |
1180 | dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %pI4\n", | 1234 | dprintk("(%s) removing an ingress entry, ip = %pI4\n", |
1181 | mpc->dev->name, &dst_ip); | 1235 | mpc->dev->name, &dst_ip); |
1182 | write_lock_bh(&mpc->ingress_lock); | 1236 | write_lock_bh(&mpc->ingress_lock); |
1183 | mpc->in_ops->remove_entry(entry, mpc); | 1237 | mpc->in_ops->remove_entry(entry, mpc); |
@@ -1195,7 +1249,8 @@ static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) | |||
1195 | eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(cache_id, mpc); | 1249 | eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(cache_id, mpc); |
1196 | 1250 | ||
1197 | if (entry == NULL) { | 1251 | if (entry == NULL) { |
1198 | dprintk("mpoa: (%s) egress_purge_rcvd: purge for a non-existing entry\n", mpc->dev->name); | 1252 | dprintk("(%s) purge for a non-existing entry\n", |
1253 | mpc->dev->name); | ||
1199 | return; | 1254 | return; |
1200 | } | 1255 | } |
1201 | 1256 | ||
@@ -1214,15 +1269,15 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry) | |||
1214 | struct k_message *purge_msg; | 1269 | struct k_message *purge_msg; |
1215 | struct sk_buff *skb; | 1270 | struct sk_buff *skb; |
1216 | 1271 | ||
1217 | dprintk("mpoa: purge_egress_shortcut: entering\n"); | 1272 | dprintk("entering\n"); |
1218 | if (vcc == NULL) { | 1273 | if (vcc == NULL) { |
1219 | printk("mpoa: purge_egress_shortcut: vcc == NULL\n"); | 1274 | pr_info("vcc == NULL\n"); |
1220 | return; | 1275 | return; |
1221 | } | 1276 | } |
1222 | 1277 | ||
1223 | skb = alloc_skb(sizeof(struct k_message), GFP_ATOMIC); | 1278 | skb = alloc_skb(sizeof(struct k_message), GFP_ATOMIC); |
1224 | if (skb == NULL) { | 1279 | if (skb == NULL) { |
1225 | printk("mpoa: purge_egress_shortcut: out of memory\n"); | 1280 | pr_info("out of memory\n"); |
1226 | return; | 1281 | return; |
1227 | } | 1282 | } |
1228 | 1283 | ||
@@ -1238,7 +1293,7 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry) | |||
1238 | sk = sk_atm(vcc); | 1293 | sk = sk_atm(vcc); |
1239 | skb_queue_tail(&sk->sk_receive_queue, skb); | 1294 | skb_queue_tail(&sk->sk_receive_queue, skb); |
1240 | sk->sk_data_ready(sk, skb->len); | 1295 | sk->sk_data_ready(sk, skb->len); |
1241 | dprintk("mpoa: purge_egress_shortcut: exiting:\n"); | 1296 | dprintk("exiting\n"); |
1242 | 1297 | ||
1243 | return; | 1298 | return; |
1244 | } | 1299 | } |
@@ -1247,14 +1302,14 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry) | |||
1247 | * Our MPS died. Tell our daemon to send NHRP data plane purge to each | 1302 | * Our MPS died. Tell our daemon to send NHRP data plane purge to each |
1248 | * of the egress shortcuts we have. | 1303 | * of the egress shortcuts we have. |
1249 | */ | 1304 | */ |
1250 | static void mps_death( struct k_message * msg, struct mpoa_client * mpc ) | 1305 | static void mps_death(struct k_message *msg, struct mpoa_client *mpc) |
1251 | { | 1306 | { |
1252 | eg_cache_entry *entry; | 1307 | eg_cache_entry *entry; |
1253 | 1308 | ||
1254 | dprintk("mpoa: (%s) mps_death:\n", mpc->dev->name); | 1309 | dprintk("(%s)\n", mpc->dev->name); |
1255 | 1310 | ||
1256 | if(memcmp(msg->MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN)){ | 1311 | if (memcmp(msg->MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN)) { |
1257 | printk("mpoa: (%s) mps_death: wrong MPS\n", mpc->dev->name); | 1312 | pr_info("(%s) wrong MPS\n", mpc->dev->name); |
1258 | return; | 1313 | return; |
1259 | } | 1314 | } |
1260 | 1315 | ||
@@ -1273,20 +1328,21 @@ static void mps_death( struct k_message * msg, struct mpoa_client * mpc ) | |||
1273 | return; | 1328 | return; |
1274 | } | 1329 | } |
1275 | 1330 | ||
1276 | static void MPOA_cache_impos_rcvd( struct k_message * msg, struct mpoa_client * mpc) | 1331 | static void MPOA_cache_impos_rcvd(struct k_message *msg, |
1332 | struct mpoa_client *mpc) | ||
1277 | { | 1333 | { |
1278 | uint16_t holding_time; | 1334 | uint16_t holding_time; |
1279 | eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(msg->content.eg_info.cache_id, mpc); | 1335 | eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(msg->content.eg_info.cache_id, mpc); |
1280 | 1336 | ||
1281 | holding_time = msg->content.eg_info.holding_time; | 1337 | holding_time = msg->content.eg_info.holding_time; |
1282 | dprintk("mpoa: (%s) MPOA_cache_impos_rcvd: entry = %p, holding_time = %u\n", | 1338 | dprintk("(%s) entry = %p, holding_time = %u\n", |
1283 | mpc->dev->name, entry, holding_time); | 1339 | mpc->dev->name, entry, holding_time); |
1284 | if(entry == NULL && holding_time) { | 1340 | if (entry == NULL && holding_time) { |
1285 | entry = mpc->eg_ops->add_entry(msg, mpc); | 1341 | entry = mpc->eg_ops->add_entry(msg, mpc); |
1286 | mpc->eg_ops->put(entry); | 1342 | mpc->eg_ops->put(entry); |
1287 | return; | 1343 | return; |
1288 | } | 1344 | } |
1289 | if(holding_time){ | 1345 | if (holding_time) { |
1290 | mpc->eg_ops->update(entry, holding_time); | 1346 | mpc->eg_ops->update(entry, holding_time); |
1291 | return; | 1347 | return; |
1292 | } | 1348 | } |
@@ -1300,7 +1356,8 @@ static void MPOA_cache_impos_rcvd( struct k_message * msg, struct mpoa_client * | |||
1300 | return; | 1356 | return; |
1301 | } | 1357 | } |
1302 | 1358 | ||
1303 | static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc) | 1359 | static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, |
1360 | struct mpoa_client *mpc) | ||
1304 | { | 1361 | { |
1305 | struct lec_priv *priv; | 1362 | struct lec_priv *priv; |
1306 | int i, retval ; | 1363 | int i, retval ; |
@@ -1315,34 +1372,39 @@ static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *m | |||
1315 | memcpy(&tlv[7], mesg->MPS_ctrl, ATM_ESA_LEN); /* MPC ctrl ATM addr */ | 1372 | memcpy(&tlv[7], mesg->MPS_ctrl, ATM_ESA_LEN); /* MPC ctrl ATM addr */ |
1316 | memcpy(mpc->our_ctrl_addr, mesg->MPS_ctrl, ATM_ESA_LEN); | 1373 | memcpy(mpc->our_ctrl_addr, mesg->MPS_ctrl, ATM_ESA_LEN); |
1317 | 1374 | ||
1318 | dprintk("mpoa: (%s) setting MPC ctrl ATM address to ", | 1375 | dprintk("(%s) setting MPC ctrl ATM address to", |
1319 | (mpc->dev) ? mpc->dev->name : "<unknown>"); | 1376 | mpc->dev ? mpc->dev->name : "<unknown>"); |
1320 | for (i = 7; i < sizeof(tlv); i++) | 1377 | for (i = 7; i < sizeof(tlv); i++) |
1321 | dprintk("%02x ", tlv[i]); | 1378 | dprintk_cont(" %02x", tlv[i]); |
1322 | dprintk("\n"); | 1379 | dprintk_cont("\n"); |
1323 | 1380 | ||
1324 | if (mpc->dev) { | 1381 | if (mpc->dev) { |
1325 | priv = netdev_priv(mpc->dev); | 1382 | priv = netdev_priv(mpc->dev); |
1326 | retval = priv->lane2_ops->associate_req(mpc->dev, mpc->dev->dev_addr, tlv, sizeof(tlv)); | 1383 | retval = priv->lane2_ops->associate_req(mpc->dev, |
1384 | mpc->dev->dev_addr, | ||
1385 | tlv, sizeof(tlv)); | ||
1327 | if (retval == 0) | 1386 | if (retval == 0) |
1328 | printk("mpoa: (%s) MPOA device type TLV association failed\n", mpc->dev->name); | 1387 | pr_info("(%s) MPOA device type TLV association failed\n", |
1388 | mpc->dev->name); | ||
1329 | retval = priv->lane2_ops->resolve(mpc->dev, NULL, 1, NULL, NULL); | 1389 | retval = priv->lane2_ops->resolve(mpc->dev, NULL, 1, NULL, NULL); |
1330 | if (retval < 0) | 1390 | if (retval < 0) |
1331 | printk("mpoa: (%s) targetless LE_ARP request failed\n", mpc->dev->name); | 1391 | pr_info("(%s) targetless LE_ARP request failed\n", |
1392 | mpc->dev->name); | ||
1332 | } | 1393 | } |
1333 | 1394 | ||
1334 | return; | 1395 | return; |
1335 | } | 1396 | } |
1336 | 1397 | ||
1337 | static void set_mps_mac_addr_rcvd(struct k_message *msg, struct mpoa_client *client) | 1398 | static void set_mps_mac_addr_rcvd(struct k_message *msg, |
1399 | struct mpoa_client *client) | ||
1338 | { | 1400 | { |
1339 | 1401 | ||
1340 | if(client->number_of_mps_macs) | 1402 | if (client->number_of_mps_macs) |
1341 | kfree(client->mps_macs); | 1403 | kfree(client->mps_macs); |
1342 | client->number_of_mps_macs = 0; | 1404 | client->number_of_mps_macs = 0; |
1343 | client->mps_macs = kmemdup(msg->MPS_ctrl, ETH_ALEN, GFP_KERNEL); | 1405 | client->mps_macs = kmemdup(msg->MPS_ctrl, ETH_ALEN, GFP_KERNEL); |
1344 | if (client->mps_macs == NULL) { | 1406 | if (client->mps_macs == NULL) { |
1345 | printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n"); | 1407 | pr_info("out of memory\n"); |
1346 | return; | 1408 | return; |
1347 | } | 1409 | } |
1348 | client->number_of_mps_macs = 1; | 1410 | client->number_of_mps_macs = 1; |
@@ -1363,11 +1425,11 @@ static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action) | |||
1363 | /* FIXME: This knows too much of the cache structure */ | 1425 | /* FIXME: This knows too much of the cache structure */ |
1364 | read_lock_irq(&mpc->egress_lock); | 1426 | read_lock_irq(&mpc->egress_lock); |
1365 | entry = mpc->eg_cache; | 1427 | entry = mpc->eg_cache; |
1366 | while (entry != NULL){ | 1428 | while (entry != NULL) { |
1367 | msg->content.eg_info = entry->ctrl_info; | 1429 | msg->content.eg_info = entry->ctrl_info; |
1368 | dprintk("mpoa: cache_id %u\n", entry->ctrl_info.cache_id); | 1430 | dprintk("cache_id %u\n", entry->ctrl_info.cache_id); |
1369 | msg_to_mpoad(msg, mpc); | 1431 | msg_to_mpoad(msg, mpc); |
1370 | entry = entry->next; | 1432 | entry = entry->next; |
1371 | } | 1433 | } |
1372 | read_unlock_irq(&mpc->egress_lock); | 1434 | read_unlock_irq(&mpc->egress_lock); |
1373 | 1435 | ||
@@ -1386,20 +1448,22 @@ static void mpc_timer_refresh(void) | |||
1386 | return; | 1448 | return; |
1387 | } | 1449 | } |
1388 | 1450 | ||
1389 | static void mpc_cache_check( unsigned long checking_time ) | 1451 | static void mpc_cache_check(unsigned long checking_time) |
1390 | { | 1452 | { |
1391 | struct mpoa_client *mpc = mpcs; | 1453 | struct mpoa_client *mpc = mpcs; |
1392 | static unsigned long previous_resolving_check_time; | 1454 | static unsigned long previous_resolving_check_time; |
1393 | static unsigned long previous_refresh_time; | 1455 | static unsigned long previous_refresh_time; |
1394 | 1456 | ||
1395 | while( mpc != NULL ){ | 1457 | while (mpc != NULL) { |
1396 | mpc->in_ops->clear_count(mpc); | 1458 | mpc->in_ops->clear_count(mpc); |
1397 | mpc->eg_ops->clear_expired(mpc); | 1459 | mpc->eg_ops->clear_expired(mpc); |
1398 | if(checking_time - previous_resolving_check_time > mpc->parameters.mpc_p4 * HZ ){ | 1460 | if (checking_time - previous_resolving_check_time > |
1461 | mpc->parameters.mpc_p4 * HZ) { | ||
1399 | mpc->in_ops->check_resolving(mpc); | 1462 | mpc->in_ops->check_resolving(mpc); |
1400 | previous_resolving_check_time = checking_time; | 1463 | previous_resolving_check_time = checking_time; |
1401 | } | 1464 | } |
1402 | if(checking_time - previous_refresh_time > mpc->parameters.mpc_p5 * HZ ){ | 1465 | if (checking_time - previous_refresh_time > |
1466 | mpc->parameters.mpc_p5 * HZ) { | ||
1403 | mpc->in_ops->refresh(mpc); | 1467 | mpc->in_ops->refresh(mpc); |
1404 | previous_refresh_time = checking_time; | 1468 | previous_refresh_time = checking_time; |
1405 | } | 1469 | } |
@@ -1410,7 +1474,8 @@ static void mpc_cache_check( unsigned long checking_time ) | |||
1410 | return; | 1474 | return; |
1411 | } | 1475 | } |
1412 | 1476 | ||
1413 | static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 1477 | static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, |
1478 | unsigned long arg) | ||
1414 | { | 1479 | { |
1415 | int err = 0; | 1480 | int err = 0; |
1416 | struct atm_vcc *vcc = ATM_SD(sock); | 1481 | struct atm_vcc *vcc = ATM_SD(sock); |
@@ -1422,21 +1487,20 @@ static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long a | |||
1422 | return -EPERM; | 1487 | return -EPERM; |
1423 | 1488 | ||
1424 | switch (cmd) { | 1489 | switch (cmd) { |
1425 | case ATMMPC_CTRL: | 1490 | case ATMMPC_CTRL: |
1426 | err = atm_mpoa_mpoad_attach(vcc, (int)arg); | 1491 | err = atm_mpoa_mpoad_attach(vcc, (int)arg); |
1427 | if (err >= 0) | 1492 | if (err >= 0) |
1428 | sock->state = SS_CONNECTED; | 1493 | sock->state = SS_CONNECTED; |
1429 | break; | 1494 | break; |
1430 | case ATMMPC_DATA: | 1495 | case ATMMPC_DATA: |
1431 | err = atm_mpoa_vcc_attach(vcc, (void __user *)arg); | 1496 | err = atm_mpoa_vcc_attach(vcc, (void __user *)arg); |
1432 | break; | 1497 | break; |
1433 | default: | 1498 | default: |
1434 | break; | 1499 | break; |
1435 | } | 1500 | } |
1436 | return err; | 1501 | return err; |
1437 | } | 1502 | } |
1438 | 1503 | ||
1439 | |||
1440 | static struct atm_ioctl atm_ioctl_ops = { | 1504 | static struct atm_ioctl atm_ioctl_ops = { |
1441 | .owner = THIS_MODULE, | 1505 | .owner = THIS_MODULE, |
1442 | .ioctl = atm_mpoa_ioctl, | 1506 | .ioctl = atm_mpoa_ioctl, |
@@ -1447,9 +1511,9 @@ static __init int atm_mpoa_init(void) | |||
1447 | register_atm_ioctl(&atm_ioctl_ops); | 1511 | register_atm_ioctl(&atm_ioctl_ops); |
1448 | 1512 | ||
1449 | if (mpc_proc_init() != 0) | 1513 | if (mpc_proc_init() != 0) |
1450 | printk(KERN_INFO "mpoa: failed to initialize /proc/mpoa\n"); | 1514 | pr_info("failed to initialize /proc/mpoa\n"); |
1451 | 1515 | ||
1452 | printk("mpc.c: " __DATE__ " " __TIME__ " initialized\n"); | 1516 | pr_info("mpc.c: " __DATE__ " " __TIME__ " initialized\n"); |
1453 | 1517 | ||
1454 | return 0; | 1518 | return 0; |
1455 | } | 1519 | } |
@@ -1476,15 +1540,15 @@ static void __exit atm_mpoa_cleanup(void) | |||
1476 | if (priv->lane2_ops != NULL) | 1540 | if (priv->lane2_ops != NULL) |
1477 | priv->lane2_ops->associate_indicator = NULL; | 1541 | priv->lane2_ops->associate_indicator = NULL; |
1478 | } | 1542 | } |
1479 | ddprintk("mpoa: cleanup_module: about to clear caches\n"); | 1543 | ddprintk("about to clear caches\n"); |
1480 | mpc->in_ops->destroy_cache(mpc); | 1544 | mpc->in_ops->destroy_cache(mpc); |
1481 | mpc->eg_ops->destroy_cache(mpc); | 1545 | mpc->eg_ops->destroy_cache(mpc); |
1482 | ddprintk("mpoa: cleanup_module: caches cleared\n"); | 1546 | ddprintk("caches cleared\n"); |
1483 | kfree(mpc->mps_macs); | 1547 | kfree(mpc->mps_macs); |
1484 | memset(mpc, 0, sizeof(struct mpoa_client)); | 1548 | memset(mpc, 0, sizeof(struct mpoa_client)); |
1485 | ddprintk("mpoa: cleanup_module: about to kfree %p\n", mpc); | 1549 | ddprintk("about to kfree %p\n", mpc); |
1486 | kfree(mpc); | 1550 | kfree(mpc); |
1487 | ddprintk("mpoa: cleanup_module: next mpc is at %p\n", tmp); | 1551 | ddprintk("next mpc is at %p\n", tmp); |
1488 | mpc = tmp; | 1552 | mpc = tmp; |
1489 | } | 1553 | } |
1490 | 1554 | ||
@@ -1492,7 +1556,7 @@ static void __exit atm_mpoa_cleanup(void) | |||
1492 | qos_head = NULL; | 1556 | qos_head = NULL; |
1493 | while (qos != NULL) { | 1557 | while (qos != NULL) { |
1494 | nextqos = qos->next; | 1558 | nextqos = qos->next; |
1495 | dprintk("mpoa: cleanup_module: freeing qos entry %p\n", qos); | 1559 | dprintk("freeing qos entry %p\n", qos); |
1496 | kfree(qos); | 1560 | kfree(qos); |
1497 | qos = nextqos; | 1561 | qos = nextqos; |
1498 | } | 1562 | } |
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c index 4504a4b339bb..4c141810eb6d 100644 --- a/net/atm/mpoa_caches.c +++ b/net/atm/mpoa_caches.c | |||
@@ -11,15 +11,23 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #if 0 | 13 | #if 0 |
14 | #define dprintk printk /* debug */ | 14 | #define dprintk(format, args...) \ |
15 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */ | ||
15 | #else | 16 | #else |
16 | #define dprintk(format,args...) | 17 | #define dprintk(format, args...) \ |
18 | do { if (0) \ | ||
19 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ | ||
20 | } while (0) | ||
17 | #endif | 21 | #endif |
18 | 22 | ||
19 | #if 0 | 23 | #if 0 |
20 | #define ddprintk printk /* more debug */ | 24 | #define ddprintk(format, args...) \ |
25 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */ | ||
21 | #else | 26 | #else |
22 | #define ddprintk(format,args...) | 27 | #define ddprintk(format, args...) \ |
28 | do { if (0) \ | ||
29 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ | ||
30 | } while (0) | ||
23 | #endif | 31 | #endif |
24 | 32 | ||
25 | static in_cache_entry *in_cache_get(__be32 dst_ip, | 33 | static in_cache_entry *in_cache_get(__be32 dst_ip, |
@@ -29,8 +37,8 @@ static in_cache_entry *in_cache_get(__be32 dst_ip, | |||
29 | 37 | ||
30 | read_lock_bh(&client->ingress_lock); | 38 | read_lock_bh(&client->ingress_lock); |
31 | entry = client->in_cache; | 39 | entry = client->in_cache; |
32 | while(entry != NULL){ | 40 | while (entry != NULL) { |
33 | if( entry->ctrl_info.in_dst_ip == dst_ip ){ | 41 | if (entry->ctrl_info.in_dst_ip == dst_ip) { |
34 | atomic_inc(&entry->use); | 42 | atomic_inc(&entry->use); |
35 | read_unlock_bh(&client->ingress_lock); | 43 | read_unlock_bh(&client->ingress_lock); |
36 | return entry; | 44 | return entry; |
@@ -50,8 +58,8 @@ static in_cache_entry *in_cache_get_with_mask(__be32 dst_ip, | |||
50 | 58 | ||
51 | read_lock_bh(&client->ingress_lock); | 59 | read_lock_bh(&client->ingress_lock); |
52 | entry = client->in_cache; | 60 | entry = client->in_cache; |
53 | while(entry != NULL){ | 61 | while (entry != NULL) { |
54 | if((entry->ctrl_info.in_dst_ip & mask) == (dst_ip & mask )){ | 62 | if ((entry->ctrl_info.in_dst_ip & mask) == (dst_ip & mask)) { |
55 | atomic_inc(&entry->use); | 63 | atomic_inc(&entry->use); |
56 | read_unlock_bh(&client->ingress_lock); | 64 | read_unlock_bh(&client->ingress_lock); |
57 | return entry; | 65 | return entry; |
@@ -65,14 +73,14 @@ static in_cache_entry *in_cache_get_with_mask(__be32 dst_ip, | |||
65 | } | 73 | } |
66 | 74 | ||
67 | static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc, | 75 | static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc, |
68 | struct mpoa_client *client ) | 76 | struct mpoa_client *client) |
69 | { | 77 | { |
70 | in_cache_entry *entry; | 78 | in_cache_entry *entry; |
71 | 79 | ||
72 | read_lock_bh(&client->ingress_lock); | 80 | read_lock_bh(&client->ingress_lock); |
73 | entry = client->in_cache; | 81 | entry = client->in_cache; |
74 | while(entry != NULL){ | 82 | while (entry != NULL) { |
75 | if(entry->shortcut == vcc) { | 83 | if (entry->shortcut == vcc) { |
76 | atomic_inc(&entry->use); | 84 | atomic_inc(&entry->use); |
77 | read_unlock_bh(&client->ingress_lock); | 85 | read_unlock_bh(&client->ingress_lock); |
78 | return entry; | 86 | return entry; |
@@ -90,14 +98,14 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip, | |||
90 | in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL); | 98 | in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL); |
91 | 99 | ||
92 | if (entry == NULL) { | 100 | if (entry == NULL) { |
93 | printk("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n"); | 101 | pr_info("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n"); |
94 | return NULL; | 102 | return NULL; |
95 | } | 103 | } |
96 | 104 | ||
97 | dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %pI4\n", &dst_ip); | 105 | dprintk("adding an ingress entry, ip = %pI4\n", &dst_ip); |
98 | 106 | ||
99 | atomic_set(&entry->use, 1); | 107 | atomic_set(&entry->use, 1); |
100 | dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n"); | 108 | dprintk("new_in_cache_entry: about to lock\n"); |
101 | write_lock_bh(&client->ingress_lock); | 109 | write_lock_bh(&client->ingress_lock); |
102 | entry->next = client->in_cache; | 110 | entry->next = client->in_cache; |
103 | entry->prev = NULL; | 111 | entry->prev = NULL; |
@@ -115,7 +123,7 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip, | |||
115 | atomic_inc(&entry->use); | 123 | atomic_inc(&entry->use); |
116 | 124 | ||
117 | write_unlock_bh(&client->ingress_lock); | 125 | write_unlock_bh(&client->ingress_lock); |
118 | dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: unlocked\n"); | 126 | dprintk("new_in_cache_entry: unlocked\n"); |
119 | 127 | ||
120 | return entry; | 128 | return entry; |
121 | } | 129 | } |
@@ -126,39 +134,41 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc) | |||
126 | struct k_message msg; | 134 | struct k_message msg; |
127 | 135 | ||
128 | entry->count++; | 136 | entry->count++; |
129 | if(entry->entry_state == INGRESS_RESOLVED && entry->shortcut != NULL) | 137 | if (entry->entry_state == INGRESS_RESOLVED && entry->shortcut != NULL) |
130 | return OPEN; | 138 | return OPEN; |
131 | 139 | ||
132 | if(entry->entry_state == INGRESS_REFRESHING){ | 140 | if (entry->entry_state == INGRESS_REFRESHING) { |
133 | if(entry->count > mpc->parameters.mpc_p1){ | 141 | if (entry->count > mpc->parameters.mpc_p1) { |
134 | msg.type = SND_MPOA_RES_RQST; | 142 | msg.type = SND_MPOA_RES_RQST; |
135 | msg.content.in_info = entry->ctrl_info; | 143 | msg.content.in_info = entry->ctrl_info; |
136 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN); | 144 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN); |
137 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); | 145 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); |
138 | if (qos != NULL) msg.qos = qos->qos; | 146 | if (qos != NULL) |
147 | msg.qos = qos->qos; | ||
139 | msg_to_mpoad(&msg, mpc); | 148 | msg_to_mpoad(&msg, mpc); |
140 | do_gettimeofday(&(entry->reply_wait)); | 149 | do_gettimeofday(&(entry->reply_wait)); |
141 | entry->entry_state = INGRESS_RESOLVING; | 150 | entry->entry_state = INGRESS_RESOLVING; |
142 | } | 151 | } |
143 | if(entry->shortcut != NULL) | 152 | if (entry->shortcut != NULL) |
144 | return OPEN; | 153 | return OPEN; |
145 | return CLOSED; | 154 | return CLOSED; |
146 | } | 155 | } |
147 | 156 | ||
148 | if(entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL) | 157 | if (entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL) |
149 | return OPEN; | 158 | return OPEN; |
150 | 159 | ||
151 | if( entry->count > mpc->parameters.mpc_p1 && | 160 | if (entry->count > mpc->parameters.mpc_p1 && |
152 | entry->entry_state == INGRESS_INVALID){ | 161 | entry->entry_state == INGRESS_INVALID) { |
153 | dprintk("mpoa: (%s) mpoa_caches.c: threshold exceeded for ip %pI4, sending MPOA res req\n", | 162 | dprintk("(%s) threshold exceeded for ip %pI4, sending MPOA res req\n", |
154 | mpc->dev->name, &entry->ctrl_info.in_dst_ip); | 163 | mpc->dev->name, &entry->ctrl_info.in_dst_ip); |
155 | entry->entry_state = INGRESS_RESOLVING; | 164 | entry->entry_state = INGRESS_RESOLVING; |
156 | msg.type = SND_MPOA_RES_RQST; | 165 | msg.type = SND_MPOA_RES_RQST; |
157 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN ); | 166 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN); |
158 | msg.content.in_info = entry->ctrl_info; | 167 | msg.content.in_info = entry->ctrl_info; |
159 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); | 168 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); |
160 | if (qos != NULL) msg.qos = qos->qos; | 169 | if (qos != NULL) |
161 | msg_to_mpoad( &msg, mpc); | 170 | msg.qos = qos->qos; |
171 | msg_to_mpoad(&msg, mpc); | ||
162 | do_gettimeofday(&(entry->reply_wait)); | 172 | do_gettimeofday(&(entry->reply_wait)); |
163 | } | 173 | } |
164 | 174 | ||
@@ -185,7 +195,7 @@ static void in_cache_remove_entry(in_cache_entry *entry, | |||
185 | struct k_message msg; | 195 | struct k_message msg; |
186 | 196 | ||
187 | vcc = entry->shortcut; | 197 | vcc = entry->shortcut; |
188 | dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %pI4\n", | 198 | dprintk("removing an ingress entry, ip = %pI4\n", |
189 | &entry->ctrl_info.in_dst_ip); | 199 | &entry->ctrl_info.in_dst_ip); |
190 | 200 | ||
191 | if (entry->prev != NULL) | 201 | if (entry->prev != NULL) |
@@ -195,14 +205,15 @@ static void in_cache_remove_entry(in_cache_entry *entry, | |||
195 | if (entry->next != NULL) | 205 | if (entry->next != NULL) |
196 | entry->next->prev = entry->prev; | 206 | entry->next->prev = entry->prev; |
197 | client->in_ops->put(entry); | 207 | client->in_ops->put(entry); |
198 | if(client->in_cache == NULL && client->eg_cache == NULL){ | 208 | if (client->in_cache == NULL && client->eg_cache == NULL) { |
199 | msg.type = STOP_KEEP_ALIVE_SM; | 209 | msg.type = STOP_KEEP_ALIVE_SM; |
200 | msg_to_mpoad(&msg,client); | 210 | msg_to_mpoad(&msg, client); |
201 | } | 211 | } |
202 | 212 | ||
203 | /* Check if the egress side still uses this VCC */ | 213 | /* Check if the egress side still uses this VCC */ |
204 | if (vcc != NULL) { | 214 | if (vcc != NULL) { |
205 | eg_cache_entry *eg_entry = client->eg_ops->get_by_vcc(vcc, client); | 215 | eg_cache_entry *eg_entry = client->eg_ops->get_by_vcc(vcc, |
216 | client); | ||
206 | if (eg_entry != NULL) { | 217 | if (eg_entry != NULL) { |
207 | client->eg_ops->put(eg_entry); | 218 | client->eg_ops->put(eg_entry); |
208 | return; | 219 | return; |
@@ -213,7 +224,6 @@ static void in_cache_remove_entry(in_cache_entry *entry, | |||
213 | return; | 224 | return; |
214 | } | 225 | } |
215 | 226 | ||
216 | |||
217 | /* Call this every MPC-p2 seconds... Not exactly correct solution, | 227 | /* Call this every MPC-p2 seconds... Not exactly correct solution, |
218 | but an easy one... */ | 228 | but an easy one... */ |
219 | static void clear_count_and_expired(struct mpoa_client *client) | 229 | static void clear_count_and_expired(struct mpoa_client *client) |
@@ -225,12 +235,12 @@ static void clear_count_and_expired(struct mpoa_client *client) | |||
225 | 235 | ||
226 | write_lock_bh(&client->ingress_lock); | 236 | write_lock_bh(&client->ingress_lock); |
227 | entry = client->in_cache; | 237 | entry = client->in_cache; |
228 | while(entry != NULL){ | 238 | while (entry != NULL) { |
229 | entry->count=0; | 239 | entry->count = 0; |
230 | next_entry = entry->next; | 240 | next_entry = entry->next; |
231 | if((now.tv_sec - entry->tv.tv_sec) | 241 | if ((now.tv_sec - entry->tv.tv_sec) |
232 | > entry->ctrl_info.holding_time){ | 242 | > entry->ctrl_info.holding_time) { |
233 | dprintk("mpoa: mpoa_caches.c: holding time expired, ip = %pI4\n", | 243 | dprintk("holding time expired, ip = %pI4\n", |
234 | &entry->ctrl_info.in_dst_ip); | 244 | &entry->ctrl_info.in_dst_ip); |
235 | client->in_ops->remove_entry(entry, client); | 245 | client->in_ops->remove_entry(entry, client); |
236 | } | 246 | } |
@@ -250,33 +260,38 @@ static void check_resolving_entries(struct mpoa_client *client) | |||
250 | struct timeval now; | 260 | struct timeval now; |
251 | struct k_message msg; | 261 | struct k_message msg; |
252 | 262 | ||
253 | do_gettimeofday( &now ); | 263 | do_gettimeofday(&now); |
254 | 264 | ||
255 | read_lock_bh(&client->ingress_lock); | 265 | read_lock_bh(&client->ingress_lock); |
256 | entry = client->in_cache; | 266 | entry = client->in_cache; |
257 | while( entry != NULL ){ | 267 | while (entry != NULL) { |
258 | if(entry->entry_state == INGRESS_RESOLVING){ | 268 | if (entry->entry_state == INGRESS_RESOLVING) { |
259 | if(now.tv_sec - entry->hold_down.tv_sec < client->parameters.mpc_p6){ | 269 | if ((now.tv_sec - entry->hold_down.tv_sec) < |
260 | entry = entry->next; /* Entry in hold down */ | 270 | client->parameters.mpc_p6) { |
271 | entry = entry->next; /* Entry in hold down */ | ||
261 | continue; | 272 | continue; |
262 | } | 273 | } |
263 | if( (now.tv_sec - entry->reply_wait.tv_sec) > | 274 | if ((now.tv_sec - entry->reply_wait.tv_sec) > |
264 | entry->retry_time ){ | 275 | entry->retry_time) { |
265 | entry->retry_time = MPC_C1*( entry->retry_time ); | 276 | entry->retry_time = MPC_C1 * (entry->retry_time); |
266 | if(entry->retry_time > client->parameters.mpc_p5){ | 277 | /* |
267 | /* Retry time maximum exceeded, put entry in hold down. */ | 278 | * Retry time maximum exceeded, |
279 | * put entry in hold down. | ||
280 | */ | ||
281 | if (entry->retry_time > client->parameters.mpc_p5) { | ||
268 | do_gettimeofday(&(entry->hold_down)); | 282 | do_gettimeofday(&(entry->hold_down)); |
269 | entry->retry_time = client->parameters.mpc_p4; | 283 | entry->retry_time = client->parameters.mpc_p4; |
270 | entry = entry->next; | 284 | entry = entry->next; |
271 | continue; | 285 | continue; |
272 | } | 286 | } |
273 | /* Ask daemon to send a resolution request. */ | 287 | /* Ask daemon to send a resolution request. */ |
274 | memset(&(entry->hold_down),0,sizeof(struct timeval)); | 288 | memset(&(entry->hold_down), 0, sizeof(struct timeval)); |
275 | msg.type = SND_MPOA_RES_RTRY; | 289 | msg.type = SND_MPOA_RES_RTRY; |
276 | memcpy(msg.MPS_ctrl, client->mps_ctrl_addr, ATM_ESA_LEN); | 290 | memcpy(msg.MPS_ctrl, client->mps_ctrl_addr, ATM_ESA_LEN); |
277 | msg.content.in_info = entry->ctrl_info; | 291 | msg.content.in_info = entry->ctrl_info; |
278 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); | 292 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); |
279 | if (qos != NULL) msg.qos = qos->qos; | 293 | if (qos != NULL) |
294 | msg.qos = qos->qos; | ||
280 | msg_to_mpoad(&msg, client); | 295 | msg_to_mpoad(&msg, client); |
281 | do_gettimeofday(&(entry->reply_wait)); | 296 | do_gettimeofday(&(entry->reply_wait)); |
282 | } | 297 | } |
@@ -292,16 +307,17 @@ static void refresh_entries(struct mpoa_client *client) | |||
292 | struct timeval now; | 307 | struct timeval now; |
293 | struct in_cache_entry *entry = client->in_cache; | 308 | struct in_cache_entry *entry = client->in_cache; |
294 | 309 | ||
295 | ddprintk("mpoa: mpoa_caches.c: refresh_entries\n"); | 310 | ddprintk("refresh_entries\n"); |
296 | do_gettimeofday(&now); | 311 | do_gettimeofday(&now); |
297 | 312 | ||
298 | read_lock_bh(&client->ingress_lock); | 313 | read_lock_bh(&client->ingress_lock); |
299 | while( entry != NULL ){ | 314 | while (entry != NULL) { |
300 | if( entry->entry_state == INGRESS_RESOLVED ){ | 315 | if (entry->entry_state == INGRESS_RESOLVED) { |
301 | if(!(entry->refresh_time)) | 316 | if (!(entry->refresh_time)) |
302 | entry->refresh_time = (2*(entry->ctrl_info.holding_time))/3; | 317 | entry->refresh_time = (2 * (entry->ctrl_info.holding_time))/3; |
303 | if( (now.tv_sec - entry->reply_wait.tv_sec) > entry->refresh_time ){ | 318 | if ((now.tv_sec - entry->reply_wait.tv_sec) > |
304 | dprintk("mpoa: mpoa_caches.c: refreshing an entry.\n"); | 319 | entry->refresh_time) { |
320 | dprintk("refreshing an entry.\n"); | ||
305 | entry->entry_state = INGRESS_REFRESHING; | 321 | entry->entry_state = INGRESS_REFRESHING; |
306 | 322 | ||
307 | } | 323 | } |
@@ -314,21 +330,22 @@ static void refresh_entries(struct mpoa_client *client) | |||
314 | static void in_destroy_cache(struct mpoa_client *mpc) | 330 | static void in_destroy_cache(struct mpoa_client *mpc) |
315 | { | 331 | { |
316 | write_lock_irq(&mpc->ingress_lock); | 332 | write_lock_irq(&mpc->ingress_lock); |
317 | while(mpc->in_cache != NULL) | 333 | while (mpc->in_cache != NULL) |
318 | mpc->in_ops->remove_entry(mpc->in_cache, mpc); | 334 | mpc->in_ops->remove_entry(mpc->in_cache, mpc); |
319 | write_unlock_irq(&mpc->ingress_lock); | 335 | write_unlock_irq(&mpc->ingress_lock); |
320 | 336 | ||
321 | return; | 337 | return; |
322 | } | 338 | } |
323 | 339 | ||
324 | static eg_cache_entry *eg_cache_get_by_cache_id(__be32 cache_id, struct mpoa_client *mpc) | 340 | static eg_cache_entry *eg_cache_get_by_cache_id(__be32 cache_id, |
341 | struct mpoa_client *mpc) | ||
325 | { | 342 | { |
326 | eg_cache_entry *entry; | 343 | eg_cache_entry *entry; |
327 | 344 | ||
328 | read_lock_irq(&mpc->egress_lock); | 345 | read_lock_irq(&mpc->egress_lock); |
329 | entry = mpc->eg_cache; | 346 | entry = mpc->eg_cache; |
330 | while(entry != NULL){ | 347 | while (entry != NULL) { |
331 | if(entry->ctrl_info.cache_id == cache_id){ | 348 | if (entry->ctrl_info.cache_id == cache_id) { |
332 | atomic_inc(&entry->use); | 349 | atomic_inc(&entry->use); |
333 | read_unlock_irq(&mpc->egress_lock); | 350 | read_unlock_irq(&mpc->egress_lock); |
334 | return entry; | 351 | return entry; |
@@ -348,7 +365,7 @@ static eg_cache_entry *eg_cache_get_by_tag(__be32 tag, struct mpoa_client *mpc) | |||
348 | 365 | ||
349 | read_lock_irqsave(&mpc->egress_lock, flags); | 366 | read_lock_irqsave(&mpc->egress_lock, flags); |
350 | entry = mpc->eg_cache; | 367 | entry = mpc->eg_cache; |
351 | while (entry != NULL){ | 368 | while (entry != NULL) { |
352 | if (entry->ctrl_info.tag == tag) { | 369 | if (entry->ctrl_info.tag == tag) { |
353 | atomic_inc(&entry->use); | 370 | atomic_inc(&entry->use); |
354 | read_unlock_irqrestore(&mpc->egress_lock, flags); | 371 | read_unlock_irqrestore(&mpc->egress_lock, flags); |
@@ -362,14 +379,15 @@ static eg_cache_entry *eg_cache_get_by_tag(__be32 tag, struct mpoa_client *mpc) | |||
362 | } | 379 | } |
363 | 380 | ||
364 | /* This can be called from any context since it saves CPU flags */ | 381 | /* This can be called from any context since it saves CPU flags */ |
365 | static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, struct mpoa_client *mpc) | 382 | static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, |
383 | struct mpoa_client *mpc) | ||
366 | { | 384 | { |
367 | unsigned long flags; | 385 | unsigned long flags; |
368 | eg_cache_entry *entry; | 386 | eg_cache_entry *entry; |
369 | 387 | ||
370 | read_lock_irqsave(&mpc->egress_lock, flags); | 388 | read_lock_irqsave(&mpc->egress_lock, flags); |
371 | entry = mpc->eg_cache; | 389 | entry = mpc->eg_cache; |
372 | while (entry != NULL){ | 390 | while (entry != NULL) { |
373 | if (entry->shortcut == vcc) { | 391 | if (entry->shortcut == vcc) { |
374 | atomic_inc(&entry->use); | 392 | atomic_inc(&entry->use); |
375 | read_unlock_irqrestore(&mpc->egress_lock, flags); | 393 | read_unlock_irqrestore(&mpc->egress_lock, flags); |
@@ -382,14 +400,15 @@ static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, struct mpoa_clie | |||
382 | return NULL; | 400 | return NULL; |
383 | } | 401 | } |
384 | 402 | ||
385 | static eg_cache_entry *eg_cache_get_by_src_ip(__be32 ipaddr, struct mpoa_client *mpc) | 403 | static eg_cache_entry *eg_cache_get_by_src_ip(__be32 ipaddr, |
404 | struct mpoa_client *mpc) | ||
386 | { | 405 | { |
387 | eg_cache_entry *entry; | 406 | eg_cache_entry *entry; |
388 | 407 | ||
389 | read_lock_irq(&mpc->egress_lock); | 408 | read_lock_irq(&mpc->egress_lock); |
390 | entry = mpc->eg_cache; | 409 | entry = mpc->eg_cache; |
391 | while(entry != NULL){ | 410 | while (entry != NULL) { |
392 | if(entry->latest_ip_addr == ipaddr) { | 411 | if (entry->latest_ip_addr == ipaddr) { |
393 | atomic_inc(&entry->use); | 412 | atomic_inc(&entry->use); |
394 | read_unlock_irq(&mpc->egress_lock); | 413 | read_unlock_irq(&mpc->egress_lock); |
395 | return entry; | 414 | return entry; |
@@ -421,7 +440,7 @@ static void eg_cache_remove_entry(eg_cache_entry *entry, | |||
421 | struct k_message msg; | 440 | struct k_message msg; |
422 | 441 | ||
423 | vcc = entry->shortcut; | 442 | vcc = entry->shortcut; |
424 | dprintk("mpoa: mpoa_caches.c: removing an egress entry.\n"); | 443 | dprintk("removing an egress entry.\n"); |
425 | if (entry->prev != NULL) | 444 | if (entry->prev != NULL) |
426 | entry->prev->next = entry->next; | 445 | entry->prev->next = entry->next; |
427 | else | 446 | else |
@@ -429,9 +448,9 @@ static void eg_cache_remove_entry(eg_cache_entry *entry, | |||
429 | if (entry->next != NULL) | 448 | if (entry->next != NULL) |
430 | entry->next->prev = entry->prev; | 449 | entry->next->prev = entry->prev; |
431 | client->eg_ops->put(entry); | 450 | client->eg_ops->put(entry); |
432 | if(client->in_cache == NULL && client->eg_cache == NULL){ | 451 | if (client->in_cache == NULL && client->eg_cache == NULL) { |
433 | msg.type = STOP_KEEP_ALIVE_SM; | 452 | msg.type = STOP_KEEP_ALIVE_SM; |
434 | msg_to_mpoad(&msg,client); | 453 | msg_to_mpoad(&msg, client); |
435 | } | 454 | } |
436 | 455 | ||
437 | /* Check if the ingress side still uses this VCC */ | 456 | /* Check if the ingress side still uses this VCC */ |
@@ -447,20 +466,21 @@ static void eg_cache_remove_entry(eg_cache_entry *entry, | |||
447 | return; | 466 | return; |
448 | } | 467 | } |
449 | 468 | ||
450 | static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client) | 469 | static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, |
470 | struct mpoa_client *client) | ||
451 | { | 471 | { |
452 | eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL); | 472 | eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL); |
453 | 473 | ||
454 | if (entry == NULL) { | 474 | if (entry == NULL) { |
455 | printk("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n"); | 475 | pr_info("out of memory\n"); |
456 | return NULL; | 476 | return NULL; |
457 | } | 477 | } |
458 | 478 | ||
459 | dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %pI4, this should be our IP\n", | 479 | dprintk("adding an egress entry, ip = %pI4, this should be our IP\n", |
460 | &msg->content.eg_info.eg_dst_ip); | 480 | &msg->content.eg_info.eg_dst_ip); |
461 | 481 | ||
462 | atomic_set(&entry->use, 1); | 482 | atomic_set(&entry->use, 1); |
463 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n"); | 483 | dprintk("new_eg_cache_entry: about to lock\n"); |
464 | write_lock_irq(&client->egress_lock); | 484 | write_lock_irq(&client->egress_lock); |
465 | entry->next = client->eg_cache; | 485 | entry->next = client->eg_cache; |
466 | entry->prev = NULL; | 486 | entry->prev = NULL; |
@@ -472,18 +492,18 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_cli | |||
472 | entry->ctrl_info = msg->content.eg_info; | 492 | entry->ctrl_info = msg->content.eg_info; |
473 | do_gettimeofday(&(entry->tv)); | 493 | do_gettimeofday(&(entry->tv)); |
474 | entry->entry_state = EGRESS_RESOLVED; | 494 | entry->entry_state = EGRESS_RESOLVED; |
475 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry cache_id %lu\n", ntohl(entry->ctrl_info.cache_id)); | 495 | dprintk("new_eg_cache_entry cache_id %u\n", |
476 | dprintk("mpoa: mpoa_caches.c: mps_ip = %pI4\n", | 496 | ntohl(entry->ctrl_info.cache_id)); |
477 | &entry->ctrl_info.mps_ip); | 497 | dprintk("mps_ip = %pI4\n", &entry->ctrl_info.mps_ip); |
478 | atomic_inc(&entry->use); | 498 | atomic_inc(&entry->use); |
479 | 499 | ||
480 | write_unlock_irq(&client->egress_lock); | 500 | write_unlock_irq(&client->egress_lock); |
481 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: unlocked\n"); | 501 | dprintk("new_eg_cache_entry: unlocked\n"); |
482 | 502 | ||
483 | return entry; | 503 | return entry; |
484 | } | 504 | } |
485 | 505 | ||
486 | static void update_eg_cache_entry(eg_cache_entry * entry, uint16_t holding_time) | 506 | static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) |
487 | { | 507 | { |
488 | do_gettimeofday(&(entry->tv)); | 508 | do_gettimeofday(&(entry->tv)); |
489 | entry->entry_state = EGRESS_RESOLVED; | 509 | entry->entry_state = EGRESS_RESOLVED; |
@@ -502,13 +522,14 @@ static void clear_expired(struct mpoa_client *client) | |||
502 | 522 | ||
503 | write_lock_irq(&client->egress_lock); | 523 | write_lock_irq(&client->egress_lock); |
504 | entry = client->eg_cache; | 524 | entry = client->eg_cache; |
505 | while(entry != NULL){ | 525 | while (entry != NULL) { |
506 | next_entry = entry->next; | 526 | next_entry = entry->next; |
507 | if((now.tv_sec - entry->tv.tv_sec) | 527 | if ((now.tv_sec - entry->tv.tv_sec) |
508 | > entry->ctrl_info.holding_time){ | 528 | > entry->ctrl_info.holding_time) { |
509 | msg.type = SND_EGRESS_PURGE; | 529 | msg.type = SND_EGRESS_PURGE; |
510 | msg.content.eg_info = entry->ctrl_info; | 530 | msg.content.eg_info = entry->ctrl_info; |
511 | dprintk("mpoa: mpoa_caches.c: egress_cache: holding time expired, cache_id = %lu.\n",ntohl(entry->ctrl_info.cache_id)); | 531 | dprintk("egress_cache: holding time expired, cache_id = %u.\n", |
532 | ntohl(entry->ctrl_info.cache_id)); | ||
512 | msg_to_mpoad(&msg, client); | 533 | msg_to_mpoad(&msg, client); |
513 | client->eg_ops->remove_entry(entry, client); | 534 | client->eg_ops->remove_entry(entry, client); |
514 | } | 535 | } |
@@ -522,7 +543,7 @@ static void clear_expired(struct mpoa_client *client) | |||
522 | static void eg_destroy_cache(struct mpoa_client *mpc) | 543 | static void eg_destroy_cache(struct mpoa_client *mpc) |
523 | { | 544 | { |
524 | write_lock_irq(&mpc->egress_lock); | 545 | write_lock_irq(&mpc->egress_lock); |
525 | while(mpc->eg_cache != NULL) | 546 | while (mpc->eg_cache != NULL) |
526 | mpc->eg_ops->remove_entry(mpc->eg_cache, mpc); | 547 | mpc->eg_ops->remove_entry(mpc->eg_cache, mpc); |
527 | write_unlock_irq(&mpc->egress_lock); | 548 | write_unlock_irq(&mpc->egress_lock); |
528 | 549 | ||
@@ -530,7 +551,6 @@ static void eg_destroy_cache(struct mpoa_client *mpc) | |||
530 | } | 551 | } |
531 | 552 | ||
532 | 553 | ||
533 | |||
534 | static struct in_cache_ops ingress_ops = { | 554 | static struct in_cache_ops ingress_ops = { |
535 | in_cache_add_entry, /* add_entry */ | 555 | in_cache_add_entry, /* add_entry */ |
536 | in_cache_get, /* get */ | 556 | in_cache_get, /* get */ |
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c index 1a0f5ccea9c4..b9bdb98427e4 100644 --- a/net/atm/mpoa_proc.c +++ b/net/atm/mpoa_proc.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
1 | 2 | ||
2 | #ifdef CONFIG_PROC_FS | 3 | #ifdef CONFIG_PROC_FS |
3 | #include <linux/errno.h> | 4 | #include <linux/errno.h> |
@@ -8,7 +9,7 @@ | |||
8 | #include <linux/proc_fs.h> | 9 | #include <linux/proc_fs.h> |
9 | #include <linux/time.h> | 10 | #include <linux/time.h> |
10 | #include <linux/seq_file.h> | 11 | #include <linux/seq_file.h> |
11 | #include <asm/uaccess.h> | 12 | #include <linux/uaccess.h> |
12 | #include <linux/atmmpc.h> | 13 | #include <linux/atmmpc.h> |
13 | #include <linux/atm.h> | 14 | #include <linux/atm.h> |
14 | #include "mpc.h" | 15 | #include "mpc.h" |
@@ -20,9 +21,23 @@ | |||
20 | */ | 21 | */ |
21 | 22 | ||
22 | #if 1 | 23 | #if 1 |
23 | #define dprintk printk /* debug */ | 24 | #define dprintk(format, args...) \ |
25 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */ | ||
24 | #else | 26 | #else |
25 | #define dprintk(format,args...) | 27 | #define dprintk(format, args...) \ |
28 | do { if (0) \ | ||
29 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ | ||
30 | } while (0) | ||
31 | #endif | ||
32 | |||
33 | #if 0 | ||
34 | #define ddprintk(format, args...) \ | ||
35 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */ | ||
36 | #else | ||
37 | #define ddprintk(format, args...) \ | ||
38 | do { if (0) \ | ||
39 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ | ||
40 | } while (0) | ||
26 | #endif | 41 | #endif |
27 | 42 | ||
28 | #define STAT_FILE_NAME "mpc" /* Our statistic file's name */ | 43 | #define STAT_FILE_NAME "mpc" /* Our statistic file's name */ |
@@ -51,42 +66,37 @@ static const struct file_operations mpc_file_operations = { | |||
51 | /* | 66 | /* |
52 | * Returns the state of an ingress cache entry as a string | 67 | * Returns the state of an ingress cache entry as a string |
53 | */ | 68 | */ |
54 | static const char *ingress_state_string(int state){ | 69 | static const char *ingress_state_string(int state) |
55 | switch(state) { | 70 | { |
71 | switch (state) { | ||
56 | case INGRESS_RESOLVING: | 72 | case INGRESS_RESOLVING: |
57 | return "resolving "; | 73 | return "resolving "; |
58 | break; | ||
59 | case INGRESS_RESOLVED: | 74 | case INGRESS_RESOLVED: |
60 | return "resolved "; | 75 | return "resolved "; |
61 | break; | ||
62 | case INGRESS_INVALID: | 76 | case INGRESS_INVALID: |
63 | return "invalid "; | 77 | return "invalid "; |
64 | break; | ||
65 | case INGRESS_REFRESHING: | 78 | case INGRESS_REFRESHING: |
66 | return "refreshing "; | 79 | return "refreshing "; |
67 | break; | ||
68 | default: | ||
69 | return ""; | ||
70 | } | 80 | } |
81 | |||
82 | return ""; | ||
71 | } | 83 | } |
72 | 84 | ||
73 | /* | 85 | /* |
74 | * Returns the state of an egress cache entry as a string | 86 | * Returns the state of an egress cache entry as a string |
75 | */ | 87 | */ |
76 | static const char *egress_state_string(int state){ | 88 | static const char *egress_state_string(int state) |
77 | switch(state) { | 89 | { |
90 | switch (state) { | ||
78 | case EGRESS_RESOLVED: | 91 | case EGRESS_RESOLVED: |
79 | return "resolved "; | 92 | return "resolved "; |
80 | break; | ||
81 | case EGRESS_PURGE: | 93 | case EGRESS_PURGE: |
82 | return "purge "; | 94 | return "purge "; |
83 | break; | ||
84 | case EGRESS_INVALID: | 95 | case EGRESS_INVALID: |
85 | return "invalid "; | 96 | return "invalid "; |
86 | break; | ||
87 | default: | ||
88 | return ""; | ||
89 | } | 97 | } |
98 | |||
99 | return ""; | ||
90 | } | 100 | } |
91 | 101 | ||
92 | /* | 102 | /* |
@@ -123,7 +133,6 @@ static void mpc_stop(struct seq_file *m, void *v) | |||
123 | static int mpc_show(struct seq_file *m, void *v) | 133 | static int mpc_show(struct seq_file *m, void *v) |
124 | { | 134 | { |
125 | struct mpoa_client *mpc = v; | 135 | struct mpoa_client *mpc = v; |
126 | unsigned char *temp; | ||
127 | int i; | 136 | int i; |
128 | in_cache_entry *in_entry; | 137 | in_cache_entry *in_entry; |
129 | eg_cache_entry *eg_entry; | 138 | eg_cache_entry *eg_entry; |
@@ -140,15 +149,17 @@ static int mpc_show(struct seq_file *m, void *v) | |||
140 | do_gettimeofday(&now); | 149 | do_gettimeofday(&now); |
141 | 150 | ||
142 | for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) { | 151 | for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) { |
143 | temp = (unsigned char *)&in_entry->ctrl_info.in_dst_ip; | 152 | sprintf(ip_string, "%pI4", &in_entry->ctrl_info.in_dst_ip); |
144 | sprintf(ip_string,"%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]); | ||
145 | seq_printf(m, "%-16s%s%-14lu%-12u", | 153 | seq_printf(m, "%-16s%s%-14lu%-12u", |
146 | ip_string, | 154 | ip_string, |
147 | ingress_state_string(in_entry->entry_state), | 155 | ingress_state_string(in_entry->entry_state), |
148 | in_entry->ctrl_info.holding_time-(now.tv_sec-in_entry->tv.tv_sec), | 156 | in_entry->ctrl_info.holding_time - |
149 | in_entry->packets_fwded); | 157 | (now.tv_sec-in_entry->tv.tv_sec), |
158 | in_entry->packets_fwded); | ||
150 | if (in_entry->shortcut) | 159 | if (in_entry->shortcut) |
151 | seq_printf(m, " %-3d %-3d",in_entry->shortcut->vpi,in_entry->shortcut->vci); | 160 | seq_printf(m, " %-3d %-3d", |
161 | in_entry->shortcut->vpi, | ||
162 | in_entry->shortcut->vci); | ||
152 | seq_printf(m, "\n"); | 163 | seq_printf(m, "\n"); |
153 | } | 164 | } |
154 | 165 | ||
@@ -156,21 +167,23 @@ static int mpc_show(struct seq_file *m, void *v) | |||
156 | seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n"); | 167 | seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n"); |
157 | for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) { | 168 | for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) { |
158 | unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr; | 169 | unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr; |
159 | for(i = 0; i < ATM_ESA_LEN; i++) | 170 | for (i = 0; i < ATM_ESA_LEN; i++) |
160 | seq_printf(m, "%02x", p[i]); | 171 | seq_printf(m, "%02x", p[i]); |
161 | seq_printf(m, "\n%-16lu%s%-14lu%-15u", | 172 | seq_printf(m, "\n%-16lu%s%-14lu%-15u", |
162 | (unsigned long)ntohl(eg_entry->ctrl_info.cache_id), | 173 | (unsigned long)ntohl(eg_entry->ctrl_info.cache_id), |
163 | egress_state_string(eg_entry->entry_state), | 174 | egress_state_string(eg_entry->entry_state), |
164 | (eg_entry->ctrl_info.holding_time-(now.tv_sec-eg_entry->tv.tv_sec)), | 175 | (eg_entry->ctrl_info.holding_time - |
176 | (now.tv_sec-eg_entry->tv.tv_sec)), | ||
165 | eg_entry->packets_rcvd); | 177 | eg_entry->packets_rcvd); |
166 | 178 | ||
167 | /* latest IP address */ | 179 | /* latest IP address */ |
168 | temp = (unsigned char *)&eg_entry->latest_ip_addr; | 180 | sprintf(ip_string, "%pI4", &eg_entry->latest_ip_addr); |
169 | sprintf(ip_string, "%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]); | ||
170 | seq_printf(m, "%-16s", ip_string); | 181 | seq_printf(m, "%-16s", ip_string); |
171 | 182 | ||
172 | if (eg_entry->shortcut) | 183 | if (eg_entry->shortcut) |
173 | seq_printf(m, " %-3d %-3d",eg_entry->shortcut->vpi,eg_entry->shortcut->vci); | 184 | seq_printf(m, " %-3d %-3d", |
185 | eg_entry->shortcut->vpi, | ||
186 | eg_entry->shortcut->vci); | ||
174 | seq_printf(m, "\n"); | 187 | seq_printf(m, "\n"); |
175 | } | 188 | } |
176 | seq_printf(m, "\n"); | 189 | seq_printf(m, "\n"); |
@@ -258,12 +271,9 @@ static int parse_qos(const char *buff) | |||
258 | qos.rxtp.max_pcr = rx_pcr; | 271 | qos.rxtp.max_pcr = rx_pcr; |
259 | qos.rxtp.max_sdu = rx_sdu; | 272 | qos.rxtp.max_sdu = rx_sdu; |
260 | qos.aal = ATM_AAL5; | 273 | qos.aal = ATM_AAL5; |
261 | dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n", | 274 | dprintk("parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n", |
262 | qos.txtp.max_pcr, | 275 | qos.txtp.max_pcr, qos.txtp.max_sdu, |
263 | qos.txtp.max_sdu, | 276 | qos.rxtp.max_pcr, qos.rxtp.max_sdu); |
264 | qos.rxtp.max_pcr, | ||
265 | qos.rxtp.max_sdu | ||
266 | ); | ||
267 | 277 | ||
268 | atm_mpoa_add_qos(ipaddr, &qos); | 278 | atm_mpoa_add_qos(ipaddr, &qos); |
269 | return 1; | 279 | return 1; |
@@ -278,7 +288,7 @@ int mpc_proc_init(void) | |||
278 | 288 | ||
279 | p = proc_create(STAT_FILE_NAME, 0, atm_proc_root, &mpc_file_operations); | 289 | p = proc_create(STAT_FILE_NAME, 0, atm_proc_root, &mpc_file_operations); |
280 | if (!p) { | 290 | if (!p) { |
281 | printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME); | 291 | pr_err("Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME); |
282 | return -ENOMEM; | 292 | return -ENOMEM; |
283 | } | 293 | } |
284 | return 0; | 294 | return 0; |
@@ -289,10 +299,9 @@ int mpc_proc_init(void) | |||
289 | */ | 299 | */ |
290 | void mpc_proc_clean(void) | 300 | void mpc_proc_clean(void) |
291 | { | 301 | { |
292 | remove_proc_entry(STAT_FILE_NAME,atm_proc_root); | 302 | remove_proc_entry(STAT_FILE_NAME, atm_proc_root); |
293 | } | 303 | } |
294 | 304 | ||
295 | |||
296 | #endif /* CONFIG_PROC_FS */ | 305 | #endif /* CONFIG_PROC_FS */ |
297 | 306 | ||
298 | 307 | ||
diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c index 0af84cd4f65b..400839273c67 100644 --- a/net/atm/pppoatm.c +++ b/net/atm/pppoatm.c | |||
@@ -33,6 +33,8 @@ | |||
33 | * These hooks are not yet available in ppp_generic | 33 | * These hooks are not yet available in ppp_generic |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
37 | |||
36 | #include <linux/module.h> | 38 | #include <linux/module.h> |
37 | #include <linux/init.h> | 39 | #include <linux/init.h> |
38 | #include <linux/skbuff.h> | 40 | #include <linux/skbuff.h> |
@@ -132,7 +134,7 @@ static void pppoatm_unassign_vcc(struct atm_vcc *atmvcc) | |||
132 | static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb) | 134 | static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb) |
133 | { | 135 | { |
134 | struct pppoatm_vcc *pvcc = atmvcc_to_pvcc(atmvcc); | 136 | struct pppoatm_vcc *pvcc = atmvcc_to_pvcc(atmvcc); |
135 | pr_debug("pppoatm push\n"); | 137 | pr_debug("\n"); |
136 | if (skb == NULL) { /* VCC was closed */ | 138 | if (skb == NULL) { /* VCC was closed */ |
137 | pr_debug("removing ATMPPP VCC %p\n", pvcc); | 139 | pr_debug("removing ATMPPP VCC %p\n", pvcc); |
138 | pppoatm_unassign_vcc(atmvcc); | 140 | pppoatm_unassign_vcc(atmvcc); |
@@ -165,17 +167,17 @@ static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb) | |||
165 | pvcc->chan.mtu += LLC_LEN; | 167 | pvcc->chan.mtu += LLC_LEN; |
166 | break; | 168 | break; |
167 | } | 169 | } |
168 | pr_debug("Couldn't autodetect yet " | 170 | pr_debug("Couldn't autodetect yet (skb: %02X %02X %02X %02X %02X %02X)\n", |
169 | "(skb: %02X %02X %02X %02X %02X %02X)\n", | 171 | skb->data[0], skb->data[1], skb->data[2], |
170 | skb->data[0], skb->data[1], skb->data[2], | 172 | skb->data[3], skb->data[4], skb->data[5]); |
171 | skb->data[3], skb->data[4], skb->data[5]); | ||
172 | goto error; | 173 | goto error; |
173 | case e_vc: | 174 | case e_vc: |
174 | break; | 175 | break; |
175 | } | 176 | } |
176 | ppp_input(&pvcc->chan, skb); | 177 | ppp_input(&pvcc->chan, skb); |
177 | return; | 178 | return; |
178 | error: | 179 | |
180 | error: | ||
179 | kfree_skb(skb); | 181 | kfree_skb(skb); |
180 | ppp_input_error(&pvcc->chan, 0); | 182 | ppp_input_error(&pvcc->chan, 0); |
181 | } | 183 | } |
@@ -194,7 +196,7 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) | |||
194 | { | 196 | { |
195 | struct pppoatm_vcc *pvcc = chan_to_pvcc(chan); | 197 | struct pppoatm_vcc *pvcc = chan_to_pvcc(chan); |
196 | ATM_SKB(skb)->vcc = pvcc->atmvcc; | 198 | ATM_SKB(skb)->vcc = pvcc->atmvcc; |
197 | pr_debug("pppoatm_send (skb=0x%p, vcc=0x%p)\n", skb, pvcc->atmvcc); | 199 | pr_debug("(skb=0x%p, vcc=0x%p)\n", skb, pvcc->atmvcc); |
198 | if (skb->data[0] == '\0' && (pvcc->flags & SC_COMP_PROT)) | 200 | if (skb->data[0] == '\0' && (pvcc->flags & SC_COMP_PROT)) |
199 | (void) skb_pull(skb, 1); | 201 | (void) skb_pull(skb, 1); |
200 | switch (pvcc->encaps) { /* LLC encapsulation needed */ | 202 | switch (pvcc->encaps) { /* LLC encapsulation needed */ |
@@ -208,7 +210,8 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) | |||
208 | goto nospace; | 210 | goto nospace; |
209 | } | 211 | } |
210 | kfree_skb(skb); | 212 | kfree_skb(skb); |
211 | if ((skb = n) == NULL) | 213 | skb = n; |
214 | if (skb == NULL) | ||
212 | return DROP_PACKET; | 215 | return DROP_PACKET; |
213 | } else if (!atm_may_send(pvcc->atmvcc, skb->truesize)) | 216 | } else if (!atm_may_send(pvcc->atmvcc, skb->truesize)) |
214 | goto nospace; | 217 | goto nospace; |
@@ -226,11 +229,11 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) | |||
226 | 229 | ||
227 | atomic_add(skb->truesize, &sk_atm(ATM_SKB(skb)->vcc)->sk_wmem_alloc); | 230 | atomic_add(skb->truesize, &sk_atm(ATM_SKB(skb)->vcc)->sk_wmem_alloc); |
228 | ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options; | 231 | ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options; |
229 | pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, ATM_SKB(skb)->vcc, | 232 | pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", |
230 | ATM_SKB(skb)->vcc->dev); | 233 | skb, ATM_SKB(skb)->vcc, ATM_SKB(skb)->vcc->dev); |
231 | return ATM_SKB(skb)->vcc->send(ATM_SKB(skb)->vcc, skb) | 234 | return ATM_SKB(skb)->vcc->send(ATM_SKB(skb)->vcc, skb) |
232 | ? DROP_PACKET : 1; | 235 | ? DROP_PACKET : 1; |
233 | nospace: | 236 | nospace: |
234 | /* | 237 | /* |
235 | * We don't have space to send this SKB now, but we might have | 238 | * We don't have space to send this SKB now, but we might have |
236 | * already applied SC_COMP_PROT compression, so may need to undo | 239 | * already applied SC_COMP_PROT compression, so may need to undo |
@@ -289,7 +292,8 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, void __user *arg) | |||
289 | (be.encaps == e_vc ? 0 : LLC_LEN); | 292 | (be.encaps == e_vc ? 0 : LLC_LEN); |
290 | pvcc->wakeup_tasklet = tasklet_proto; | 293 | pvcc->wakeup_tasklet = tasklet_proto; |
291 | pvcc->wakeup_tasklet.data = (unsigned long) &pvcc->chan; | 294 | pvcc->wakeup_tasklet.data = (unsigned long) &pvcc->chan; |
292 | if ((err = ppp_register_channel(&pvcc->chan)) != 0) { | 295 | err = ppp_register_channel(&pvcc->chan); |
296 | if (err != 0) { | ||
293 | kfree(pvcc); | 297 | kfree(pvcc); |
294 | return err; | 298 | return err; |
295 | } | 299 | } |
diff --git a/net/atm/proc.c b/net/atm/proc.c index ab8419a324b6..476779d845eb 100644 --- a/net/atm/proc.c +++ b/net/atm/proc.c | |||
@@ -24,15 +24,15 @@ | |||
24 | #include <linux/init.h> /* for __init */ | 24 | #include <linux/init.h> /* for __init */ |
25 | #include <net/net_namespace.h> | 25 | #include <net/net_namespace.h> |
26 | #include <net/atmclip.h> | 26 | #include <net/atmclip.h> |
27 | #include <asm/uaccess.h> | 27 | #include <linux/uaccess.h> |
28 | #include <linux/param.h> /* for HZ */ | ||
28 | #include <asm/atomic.h> | 29 | #include <asm/atomic.h> |
29 | #include <asm/param.h> /* for HZ */ | ||
30 | #include "resources.h" | 30 | #include "resources.h" |
31 | #include "common.h" /* atm_proc_init prototype */ | 31 | #include "common.h" /* atm_proc_init prototype */ |
32 | #include "signaling.h" /* to get sigd - ugly too */ | 32 | #include "signaling.h" /* to get sigd - ugly too */ |
33 | 33 | ||
34 | static ssize_t proc_dev_atm_read(struct file *file,char __user *buf,size_t count, | 34 | static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, |
35 | loff_t *pos); | 35 | size_t count, loff_t *pos); |
36 | 36 | ||
37 | static const struct file_operations proc_atm_dev_ops = { | 37 | static const struct file_operations proc_atm_dev_ops = { |
38 | .owner = THIS_MODULE, | 38 | .owner = THIS_MODULE, |
@@ -43,9 +43,9 @@ static void add_stats(struct seq_file *seq, const char *aal, | |||
43 | const struct k_atm_aal_stats *stats) | 43 | const struct k_atm_aal_stats *stats) |
44 | { | 44 | { |
45 | seq_printf(seq, "%s ( %d %d %d %d %d )", aal, | 45 | seq_printf(seq, "%s ( %d %d %d %d %d )", aal, |
46 | atomic_read(&stats->tx),atomic_read(&stats->tx_err), | 46 | atomic_read(&stats->tx), atomic_read(&stats->tx_err), |
47 | atomic_read(&stats->rx),atomic_read(&stats->rx_err), | 47 | atomic_read(&stats->rx), atomic_read(&stats->rx_err), |
48 | atomic_read(&stats->rx_drop)); | 48 | atomic_read(&stats->rx_drop)); |
49 | } | 49 | } |
50 | 50 | ||
51 | static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev) | 51 | static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev) |
@@ -151,8 +151,8 @@ static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
151 | 151 | ||
152 | static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) | 152 | static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) |
153 | { | 153 | { |
154 | static const char *const class_name[] = | 154 | static const char *const class_name[] = { |
155 | {"off","UBR","CBR","VBR","ABR"}; | 155 | "off", "UBR", "CBR", "VBR", "ABR"}; |
156 | static const char *const aal_name[] = { | 156 | static const char *const aal_name[] = { |
157 | "---", "1", "2", "3/4", /* 0- 3 */ | 157 | "---", "1", "2", "3/4", /* 0- 3 */ |
158 | "???", "5", "???", "???", /* 4- 7 */ | 158 | "???", "5", "???", "???", /* 4- 7 */ |
@@ -160,11 +160,12 @@ static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) | |||
160 | "???", "0", "???", "???"}; /* 12-15 */ | 160 | "???", "0", "???", "???"}; /* 12-15 */ |
161 | 161 | ||
162 | seq_printf(seq, "%3d %3d %5d %-3s %7d %-5s %7d %-6s", | 162 | seq_printf(seq, "%3d %3d %5d %-3s %7d %-5s %7d %-6s", |
163 | vcc->dev->number,vcc->vpi,vcc->vci, | 163 | vcc->dev->number, vcc->vpi, vcc->vci, |
164 | vcc->qos.aal >= ARRAY_SIZE(aal_name) ? "err" : | 164 | vcc->qos.aal >= ARRAY_SIZE(aal_name) ? "err" : |
165 | aal_name[vcc->qos.aal],vcc->qos.rxtp.min_pcr, | 165 | aal_name[vcc->qos.aal], vcc->qos.rxtp.min_pcr, |
166 | class_name[vcc->qos.rxtp.traffic_class],vcc->qos.txtp.min_pcr, | 166 | class_name[vcc->qos.rxtp.traffic_class], |
167 | class_name[vcc->qos.txtp.traffic_class]); | 167 | vcc->qos.txtp.min_pcr, |
168 | class_name[vcc->qos.txtp.traffic_class]); | ||
168 | if (test_bit(ATM_VF_IS_CLIP, &vcc->flags)) { | 169 | if (test_bit(ATM_VF_IS_CLIP, &vcc->flags)) { |
169 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); | 170 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); |
170 | struct net_device *dev; | 171 | struct net_device *dev; |
@@ -195,19 +196,20 @@ static void vcc_info(struct seq_file *seq, struct atm_vcc *vcc) | |||
195 | seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi, | 196 | seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi, |
196 | vcc->vci); | 197 | vcc->vci); |
197 | switch (sk->sk_family) { | 198 | switch (sk->sk_family) { |
198 | case AF_ATMPVC: | 199 | case AF_ATMPVC: |
199 | seq_printf(seq, "PVC"); | 200 | seq_printf(seq, "PVC"); |
200 | break; | 201 | break; |
201 | case AF_ATMSVC: | 202 | case AF_ATMSVC: |
202 | seq_printf(seq, "SVC"); | 203 | seq_printf(seq, "SVC"); |
203 | break; | 204 | break; |
204 | default: | 205 | default: |
205 | seq_printf(seq, "%3d", sk->sk_family); | 206 | seq_printf(seq, "%3d", sk->sk_family); |
206 | } | 207 | } |
207 | seq_printf(seq, " %04lx %5d %7d/%7d %7d/%7d [%d]\n", vcc->flags, sk->sk_err, | 208 | seq_printf(seq, " %04lx %5d %7d/%7d %7d/%7d [%d]\n", |
208 | sk_wmem_alloc_get(sk), sk->sk_sndbuf, | 209 | vcc->flags, sk->sk_err, |
209 | sk_rmem_alloc_get(sk), sk->sk_rcvbuf, | 210 | sk_wmem_alloc_get(sk), sk->sk_sndbuf, |
210 | atomic_read(&sk->sk_refcnt)); | 211 | sk_rmem_alloc_get(sk), sk->sk_rcvbuf, |
212 | atomic_read(&sk->sk_refcnt)); | ||
211 | } | 213 | } |
212 | 214 | ||
213 | static void svc_info(struct seq_file *seq, struct atm_vcc *vcc) | 215 | static void svc_info(struct seq_file *seq, struct atm_vcc *vcc) |
@@ -376,32 +378,35 @@ static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, | |||
376 | unsigned long page; | 378 | unsigned long page; |
377 | int length; | 379 | int length; |
378 | 380 | ||
379 | if (count == 0) return 0; | 381 | if (count == 0) |
382 | return 0; | ||
380 | page = get_zeroed_page(GFP_KERNEL); | 383 | page = get_zeroed_page(GFP_KERNEL); |
381 | if (!page) return -ENOMEM; | 384 | if (!page) |
385 | return -ENOMEM; | ||
382 | dev = PDE(file->f_path.dentry->d_inode)->data; | 386 | dev = PDE(file->f_path.dentry->d_inode)->data; |
383 | if (!dev->ops->proc_read) | 387 | if (!dev->ops->proc_read) |
384 | length = -EINVAL; | 388 | length = -EINVAL; |
385 | else { | 389 | else { |
386 | length = dev->ops->proc_read(dev,pos,(char *) page); | 390 | length = dev->ops->proc_read(dev, pos, (char *)page); |
387 | if (length > count) length = -EINVAL; | 391 | if (length > count) |
392 | length = -EINVAL; | ||
388 | } | 393 | } |
389 | if (length >= 0) { | 394 | if (length >= 0) { |
390 | if (copy_to_user(buf,(char *) page,length)) length = -EFAULT; | 395 | if (copy_to_user(buf, (char *)page, length)) |
396 | length = -EFAULT; | ||
391 | (*pos)++; | 397 | (*pos)++; |
392 | } | 398 | } |
393 | free_page(page); | 399 | free_page(page); |
394 | return length; | 400 | return length; |
395 | } | 401 | } |
396 | 402 | ||
397 | |||
398 | struct proc_dir_entry *atm_proc_root; | 403 | struct proc_dir_entry *atm_proc_root; |
399 | EXPORT_SYMBOL(atm_proc_root); | 404 | EXPORT_SYMBOL(atm_proc_root); |
400 | 405 | ||
401 | 406 | ||
402 | int atm_proc_dev_register(struct atm_dev *dev) | 407 | int atm_proc_dev_register(struct atm_dev *dev) |
403 | { | 408 | { |
404 | int digits,num; | 409 | int digits, num; |
405 | int error; | 410 | int error; |
406 | 411 | ||
407 | /* No proc info */ | 412 | /* No proc info */ |
@@ -410,26 +415,28 @@ int atm_proc_dev_register(struct atm_dev *dev) | |||
410 | 415 | ||
411 | error = -ENOMEM; | 416 | error = -ENOMEM; |
412 | digits = 0; | 417 | digits = 0; |
413 | for (num = dev->number; num; num /= 10) digits++; | 418 | for (num = dev->number; num; num /= 10) |
414 | if (!digits) digits++; | 419 | digits++; |
420 | if (!digits) | ||
421 | digits++; | ||
415 | 422 | ||
416 | dev->proc_name = kmalloc(strlen(dev->type) + digits + 2, GFP_KERNEL); | 423 | dev->proc_name = kmalloc(strlen(dev->type) + digits + 2, GFP_KERNEL); |
417 | if (!dev->proc_name) | 424 | if (!dev->proc_name) |
418 | goto err_out; | 425 | goto err_out; |
419 | sprintf(dev->proc_name,"%s:%d",dev->type, dev->number); | 426 | sprintf(dev->proc_name, "%s:%d", dev->type, dev->number); |
420 | 427 | ||
421 | dev->proc_entry = proc_create_data(dev->proc_name, 0, atm_proc_root, | 428 | dev->proc_entry = proc_create_data(dev->proc_name, 0, atm_proc_root, |
422 | &proc_atm_dev_ops, dev); | 429 | &proc_atm_dev_ops, dev); |
423 | if (!dev->proc_entry) | 430 | if (!dev->proc_entry) |
424 | goto err_free_name; | 431 | goto err_free_name; |
425 | return 0; | 432 | return 0; |
433 | |||
426 | err_free_name: | 434 | err_free_name: |
427 | kfree(dev->proc_name); | 435 | kfree(dev->proc_name); |
428 | err_out: | 436 | err_out: |
429 | return error; | 437 | return error; |
430 | } | 438 | } |
431 | 439 | ||
432 | |||
433 | void atm_proc_dev_deregister(struct atm_dev *dev) | 440 | void atm_proc_dev_deregister(struct atm_dev *dev) |
434 | { | 441 | { |
435 | if (!dev->ops->proc_read) | 442 | if (!dev->ops->proc_read) |
diff --git a/net/atm/pvc.c b/net/atm/pvc.c index 8d74e62b0d79..437ee70c5e62 100644 --- a/net/atm/pvc.c +++ b/net/atm/pvc.c | |||
@@ -17,32 +17,35 @@ | |||
17 | #include "common.h" /* common for PVCs and SVCs */ | 17 | #include "common.h" /* common for PVCs and SVCs */ |
18 | 18 | ||
19 | 19 | ||
20 | static int pvc_shutdown(struct socket *sock,int how) | 20 | static int pvc_shutdown(struct socket *sock, int how) |
21 | { | 21 | { |
22 | return 0; | 22 | return 0; |
23 | } | 23 | } |
24 | 24 | ||
25 | 25 | static int pvc_bind(struct socket *sock, struct sockaddr *sockaddr, | |
26 | static int pvc_bind(struct socket *sock,struct sockaddr *sockaddr, | 26 | int sockaddr_len) |
27 | int sockaddr_len) | ||
28 | { | 27 | { |
29 | struct sock *sk = sock->sk; | 28 | struct sock *sk = sock->sk; |
30 | struct sockaddr_atmpvc *addr; | 29 | struct sockaddr_atmpvc *addr; |
31 | struct atm_vcc *vcc; | 30 | struct atm_vcc *vcc; |
32 | int error; | 31 | int error; |
33 | 32 | ||
34 | if (sockaddr_len != sizeof(struct sockaddr_atmpvc)) return -EINVAL; | 33 | if (sockaddr_len != sizeof(struct sockaddr_atmpvc)) |
35 | addr = (struct sockaddr_atmpvc *) sockaddr; | 34 | return -EINVAL; |
36 | if (addr->sap_family != AF_ATMPVC) return -EAFNOSUPPORT; | 35 | addr = (struct sockaddr_atmpvc *)sockaddr; |
36 | if (addr->sap_family != AF_ATMPVC) | ||
37 | return -EAFNOSUPPORT; | ||
37 | lock_sock(sk); | 38 | lock_sock(sk); |
38 | vcc = ATM_SD(sock); | 39 | vcc = ATM_SD(sock); |
39 | if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) { | 40 | if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) { |
40 | error = -EBADFD; | 41 | error = -EBADFD; |
41 | goto out; | 42 | goto out; |
42 | } | 43 | } |
43 | if (test_bit(ATM_VF_PARTIAL,&vcc->flags)) { | 44 | if (test_bit(ATM_VF_PARTIAL, &vcc->flags)) { |
44 | if (vcc->vpi != ATM_VPI_UNSPEC) addr->sap_addr.vpi = vcc->vpi; | 45 | if (vcc->vpi != ATM_VPI_UNSPEC) |
45 | if (vcc->vci != ATM_VCI_UNSPEC) addr->sap_addr.vci = vcc->vci; | 46 | addr->sap_addr.vpi = vcc->vpi; |
47 | if (vcc->vci != ATM_VCI_UNSPEC) | ||
48 | addr->sap_addr.vci = vcc->vci; | ||
46 | } | 49 | } |
47 | error = vcc_connect(sock, addr->sap_addr.itf, addr->sap_addr.vpi, | 50 | error = vcc_connect(sock, addr->sap_addr.itf, addr->sap_addr.vpi, |
48 | addr->sap_addr.vci); | 51 | addr->sap_addr.vci); |
@@ -51,11 +54,10 @@ out: | |||
51 | return error; | 54 | return error; |
52 | } | 55 | } |
53 | 56 | ||
54 | 57 | static int pvc_connect(struct socket *sock, struct sockaddr *sockaddr, | |
55 | static int pvc_connect(struct socket *sock,struct sockaddr *sockaddr, | 58 | int sockaddr_len, int flags) |
56 | int sockaddr_len,int flags) | ||
57 | { | 59 | { |
58 | return pvc_bind(sock,sockaddr,sockaddr_len); | 60 | return pvc_bind(sock, sockaddr, sockaddr_len); |
59 | } | 61 | } |
60 | 62 | ||
61 | static int pvc_setsockopt(struct socket *sock, int level, int optname, | 63 | static int pvc_setsockopt(struct socket *sock, int level, int optname, |
@@ -70,7 +72,6 @@ static int pvc_setsockopt(struct socket *sock, int level, int optname, | |||
70 | return error; | 72 | return error; |
71 | } | 73 | } |
72 | 74 | ||
73 | |||
74 | static int pvc_getsockopt(struct socket *sock, int level, int optname, | 75 | static int pvc_getsockopt(struct socket *sock, int level, int optname, |
75 | char __user *optval, int __user *optlen) | 76 | char __user *optval, int __user *optlen) |
76 | { | 77 | { |
@@ -83,16 +84,16 @@ static int pvc_getsockopt(struct socket *sock, int level, int optname, | |||
83 | return error; | 84 | return error; |
84 | } | 85 | } |
85 | 86 | ||
86 | 87 | static int pvc_getname(struct socket *sock, struct sockaddr *sockaddr, | |
87 | static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr, | 88 | int *sockaddr_len, int peer) |
88 | int *sockaddr_len,int peer) | ||
89 | { | 89 | { |
90 | struct sockaddr_atmpvc *addr; | 90 | struct sockaddr_atmpvc *addr; |
91 | struct atm_vcc *vcc = ATM_SD(sock); | 91 | struct atm_vcc *vcc = ATM_SD(sock); |
92 | 92 | ||
93 | if (!vcc->dev || !test_bit(ATM_VF_ADDR,&vcc->flags)) return -ENOTCONN; | 93 | if (!vcc->dev || !test_bit(ATM_VF_ADDR, &vcc->flags)) |
94 | return -ENOTCONN; | ||
94 | *sockaddr_len = sizeof(struct sockaddr_atmpvc); | 95 | *sockaddr_len = sizeof(struct sockaddr_atmpvc); |
95 | addr = (struct sockaddr_atmpvc *) sockaddr; | 96 | addr = (struct sockaddr_atmpvc *)sockaddr; |
96 | addr->sap_family = AF_ATMPVC; | 97 | addr->sap_family = AF_ATMPVC; |
97 | addr->sap_addr.itf = vcc->dev->number; | 98 | addr->sap_addr.itf = vcc->dev->number; |
98 | addr->sap_addr.vpi = vcc->vpi; | 99 | addr->sap_addr.vpi = vcc->vpi; |
@@ -100,7 +101,6 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr, | |||
100 | return 0; | 101 | return 0; |
101 | } | 102 | } |
102 | 103 | ||
103 | |||
104 | static const struct proto_ops pvc_proto_ops = { | 104 | static const struct proto_ops pvc_proto_ops = { |
105 | .family = PF_ATMPVC, | 105 | .family = PF_ATMPVC, |
106 | .owner = THIS_MODULE, | 106 | .owner = THIS_MODULE, |
@@ -137,7 +137,6 @@ static int pvc_create(struct net *net, struct socket *sock, int protocol, | |||
137 | return vcc_create(net, sock, protocol, PF_ATMPVC); | 137 | return vcc_create(net, sock, protocol, PF_ATMPVC); |
138 | } | 138 | } |
139 | 139 | ||
140 | |||
141 | static const struct net_proto_family pvc_family_ops = { | 140 | static const struct net_proto_family pvc_family_ops = { |
142 | .family = PF_ATMPVC, | 141 | .family = PF_ATMPVC, |
143 | .create = pvc_create, | 142 | .create = pvc_create, |
diff --git a/net/atm/raw.c b/net/atm/raw.c index cbfcc71a17b1..d0c4bd047dc4 100644 --- a/net/atm/raw.c +++ b/net/atm/raw.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ |
4 | 4 | ||
5 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
5 | 6 | ||
6 | #include <linux/module.h> | 7 | #include <linux/module.h> |
7 | #include <linux/atmdev.h> | 8 | #include <linux/atmdev.h> |
@@ -17,7 +18,7 @@ | |||
17 | * SKB == NULL indicates that the link is being closed | 18 | * SKB == NULL indicates that the link is being closed |
18 | */ | 19 | */ |
19 | 20 | ||
20 | static void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb) | 21 | static void atm_push_raw(struct atm_vcc *vcc, struct sk_buff *skb) |
21 | { | 22 | { |
22 | if (skb) { | 23 | if (skb) { |
23 | struct sock *sk = sk_atm(vcc); | 24 | struct sock *sk = sk_atm(vcc); |
@@ -27,36 +28,33 @@ static void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb) | |||
27 | } | 28 | } |
28 | } | 29 | } |
29 | 30 | ||
30 | 31 | static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb) | |
31 | static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb) | ||
32 | { | 32 | { |
33 | struct sock *sk = sk_atm(vcc); | 33 | struct sock *sk = sk_atm(vcc); |
34 | 34 | ||
35 | pr_debug("APopR (%d) %d -= %d\n", vcc->vci, | 35 | pr_debug("(%d) %d -= %d\n", |
36 | sk_wmem_alloc_get(sk), skb->truesize); | 36 | vcc->vci, sk_wmem_alloc_get(sk), skb->truesize); |
37 | atomic_sub(skb->truesize, &sk->sk_wmem_alloc); | 37 | atomic_sub(skb->truesize, &sk->sk_wmem_alloc); |
38 | dev_kfree_skb_any(skb); | 38 | dev_kfree_skb_any(skb); |
39 | sk->sk_write_space(sk); | 39 | sk->sk_write_space(sk); |
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | static int atm_send_aal0(struct atm_vcc *vcc, struct sk_buff *skb) | |
43 | static int atm_send_aal0(struct atm_vcc *vcc,struct sk_buff *skb) | ||
44 | { | 43 | { |
45 | /* | 44 | /* |
46 | * Note that if vpi/vci are _ANY or _UNSPEC the below will | 45 | * Note that if vpi/vci are _ANY or _UNSPEC the below will |
47 | * still work | 46 | * still work |
48 | */ | 47 | */ |
49 | if (!capable(CAP_NET_ADMIN) && | 48 | if (!capable(CAP_NET_ADMIN) && |
50 | (((u32 *) skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) != | 49 | (((u32 *)skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) != |
51 | ((vcc->vpi << ATM_HDR_VPI_SHIFT) | (vcc->vci << ATM_HDR_VCI_SHIFT))) | 50 | ((vcc->vpi << ATM_HDR_VPI_SHIFT) | |
52 | { | 51 | (vcc->vci << ATM_HDR_VCI_SHIFT))) { |
53 | kfree_skb(skb); | 52 | kfree_skb(skb); |
54 | return -EADDRNOTAVAIL; | 53 | return -EADDRNOTAVAIL; |
55 | } | 54 | } |
56 | return vcc->dev->ops->send(vcc,skb); | 55 | return vcc->dev->ops->send(vcc, skb); |
57 | } | 56 | } |
58 | 57 | ||
59 | |||
60 | int atm_init_aal0(struct atm_vcc *vcc) | 58 | int atm_init_aal0(struct atm_vcc *vcc) |
61 | { | 59 | { |
62 | vcc->push = atm_push_raw; | 60 | vcc->push = atm_push_raw; |
@@ -66,7 +64,6 @@ int atm_init_aal0(struct atm_vcc *vcc) | |||
66 | return 0; | 64 | return 0; |
67 | } | 65 | } |
68 | 66 | ||
69 | |||
70 | int atm_init_aal34(struct atm_vcc *vcc) | 67 | int atm_init_aal34(struct atm_vcc *vcc) |
71 | { | 68 | { |
72 | vcc->push = atm_push_raw; | 69 | vcc->push = atm_push_raw; |
@@ -76,7 +73,6 @@ int atm_init_aal34(struct atm_vcc *vcc) | |||
76 | return 0; | 73 | return 0; |
77 | } | 74 | } |
78 | 75 | ||
79 | |||
80 | int atm_init_aal5(struct atm_vcc *vcc) | 76 | int atm_init_aal5(struct atm_vcc *vcc) |
81 | { | 77 | { |
82 | vcc->push = atm_push_raw; | 78 | vcc->push = atm_push_raw; |
@@ -85,6 +81,4 @@ int atm_init_aal5(struct atm_vcc *vcc) | |||
85 | vcc->send = vcc->dev->ops->send; | 81 | vcc->send = vcc->dev->ops->send; |
86 | return 0; | 82 | return 0; |
87 | } | 83 | } |
88 | |||
89 | |||
90 | EXPORT_SYMBOL(atm_init_aal5); | 84 | EXPORT_SYMBOL(atm_init_aal5); |
diff --git a/net/atm/resources.c b/net/atm/resources.c index 56b7322ff461..447ed89205d8 100644 --- a/net/atm/resources.c +++ b/net/atm/resources.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * 2002/01 - don't free the whole struct sock on sk->destruct time, | 7 | * 2002/01 - don't free the whole struct sock on sk->destruct time, |
8 | * use the default destruct function initialized by sock_init_data */ | 8 | * use the default destruct function initialized by sock_init_data */ |
9 | 9 | ||
10 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
10 | 11 | ||
11 | #include <linux/ctype.h> | 12 | #include <linux/ctype.h> |
12 | #include <linux/string.h> | 13 | #include <linux/string.h> |
@@ -70,7 +71,7 @@ struct atm_dev *atm_dev_lookup(int number) | |||
70 | mutex_unlock(&atm_dev_mutex); | 71 | mutex_unlock(&atm_dev_mutex); |
71 | return dev; | 72 | return dev; |
72 | } | 73 | } |
73 | 74 | EXPORT_SYMBOL(atm_dev_lookup); | |
74 | 75 | ||
75 | struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | 76 | struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, |
76 | int number, unsigned long *flags) | 77 | int number, unsigned long *flags) |
@@ -79,13 +80,13 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | |||
79 | 80 | ||
80 | dev = __alloc_atm_dev(type); | 81 | dev = __alloc_atm_dev(type); |
81 | if (!dev) { | 82 | if (!dev) { |
82 | printk(KERN_ERR "atm_dev_register: no space for dev %s\n", | 83 | pr_err("no space for dev %s\n", type); |
83 | type); | ||
84 | return NULL; | 84 | return NULL; |
85 | } | 85 | } |
86 | mutex_lock(&atm_dev_mutex); | 86 | mutex_lock(&atm_dev_mutex); |
87 | if (number != -1) { | 87 | if (number != -1) { |
88 | if ((inuse = __atm_dev_lookup(number))) { | 88 | inuse = __atm_dev_lookup(number); |
89 | if (inuse) { | ||
89 | atm_dev_put(inuse); | 90 | atm_dev_put(inuse); |
90 | mutex_unlock(&atm_dev_mutex); | 91 | mutex_unlock(&atm_dev_mutex); |
91 | kfree(dev); | 92 | kfree(dev); |
@@ -109,16 +110,12 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | |||
109 | atomic_set(&dev->refcnt, 1); | 110 | atomic_set(&dev->refcnt, 1); |
110 | 111 | ||
111 | if (atm_proc_dev_register(dev) < 0) { | 112 | if (atm_proc_dev_register(dev) < 0) { |
112 | printk(KERN_ERR "atm_dev_register: " | 113 | pr_err("atm_proc_dev_register failed for dev %s\n", type); |
113 | "atm_proc_dev_register failed for dev %s\n", | ||
114 | type); | ||
115 | goto out_fail; | 114 | goto out_fail; |
116 | } | 115 | } |
117 | 116 | ||
118 | if (atm_register_sysfs(dev) < 0) { | 117 | if (atm_register_sysfs(dev) < 0) { |
119 | printk(KERN_ERR "atm_dev_register: " | 118 | pr_err("atm_register_sysfs failed for dev %s\n", type); |
120 | "atm_register_sysfs failed for dev %s\n", | ||
121 | type); | ||
122 | atm_proc_dev_deregister(dev); | 119 | atm_proc_dev_deregister(dev); |
123 | goto out_fail; | 120 | goto out_fail; |
124 | } | 121 | } |
@@ -134,7 +131,7 @@ out_fail: | |||
134 | dev = NULL; | 131 | dev = NULL; |
135 | goto out; | 132 | goto out; |
136 | } | 133 | } |
137 | 134 | EXPORT_SYMBOL(atm_dev_register); | |
138 | 135 | ||
139 | void atm_dev_deregister(struct atm_dev *dev) | 136 | void atm_dev_deregister(struct atm_dev *dev) |
140 | { | 137 | { |
@@ -156,7 +153,7 @@ void atm_dev_deregister(struct atm_dev *dev) | |||
156 | 153 | ||
157 | atm_dev_put(dev); | 154 | atm_dev_put(dev); |
158 | } | 155 | } |
159 | 156 | EXPORT_SYMBOL(atm_dev_deregister); | |
160 | 157 | ||
161 | static void copy_aal_stats(struct k_atm_aal_stats *from, | 158 | static void copy_aal_stats(struct k_atm_aal_stats *from, |
162 | struct atm_aal_stats *to) | 159 | struct atm_aal_stats *to) |
@@ -166,7 +163,6 @@ static void copy_aal_stats(struct k_atm_aal_stats *from, | |||
166 | #undef __HANDLE_ITEM | 163 | #undef __HANDLE_ITEM |
167 | } | 164 | } |
168 | 165 | ||
169 | |||
170 | static void subtract_aal_stats(struct k_atm_aal_stats *from, | 166 | static void subtract_aal_stats(struct k_atm_aal_stats *from, |
171 | struct atm_aal_stats *to) | 167 | struct atm_aal_stats *to) |
172 | { | 168 | { |
@@ -175,8 +171,8 @@ static void subtract_aal_stats(struct k_atm_aal_stats *from, | |||
175 | #undef __HANDLE_ITEM | 171 | #undef __HANDLE_ITEM |
176 | } | 172 | } |
177 | 173 | ||
178 | 174 | static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats __user *arg, | |
179 | static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats __user *arg, int zero) | 175 | int zero) |
180 | { | 176 | { |
181 | struct atm_dev_stats tmp; | 177 | struct atm_dev_stats tmp; |
182 | int error = 0; | 178 | int error = 0; |
@@ -194,7 +190,6 @@ static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats __user *arg, in | |||
194 | return error ? -EFAULT : 0; | 190 | return error ? -EFAULT : 0; |
195 | } | 191 | } |
196 | 192 | ||
197 | |||
198 | int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat) | 193 | int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat) |
199 | { | 194 | { |
200 | void __user *buf; | 195 | void __user *buf; |
@@ -210,50 +205,49 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat) | |||
210 | #endif | 205 | #endif |
211 | 206 | ||
212 | switch (cmd) { | 207 | switch (cmd) { |
213 | case ATM_GETNAMES: | 208 | case ATM_GETNAMES: |
214 | 209 | if (compat) { | |
215 | if (compat) { | ||
216 | #ifdef CONFIG_COMPAT | 210 | #ifdef CONFIG_COMPAT |
217 | struct compat_atm_iobuf __user *ciobuf = arg; | 211 | struct compat_atm_iobuf __user *ciobuf = arg; |
218 | compat_uptr_t cbuf; | 212 | compat_uptr_t cbuf; |
219 | iobuf_len = &ciobuf->length; | 213 | iobuf_len = &ciobuf->length; |
220 | if (get_user(cbuf, &ciobuf->buffer)) | 214 | if (get_user(cbuf, &ciobuf->buffer)) |
221 | return -EFAULT; | 215 | return -EFAULT; |
222 | buf = compat_ptr(cbuf); | 216 | buf = compat_ptr(cbuf); |
223 | #endif | 217 | #endif |
224 | } else { | 218 | } else { |
225 | struct atm_iobuf __user *iobuf = arg; | 219 | struct atm_iobuf __user *iobuf = arg; |
226 | iobuf_len = &iobuf->length; | 220 | iobuf_len = &iobuf->length; |
227 | if (get_user(buf, &iobuf->buffer)) | 221 | if (get_user(buf, &iobuf->buffer)) |
228 | return -EFAULT; | ||
229 | } | ||
230 | if (get_user(len, iobuf_len)) | ||
231 | return -EFAULT; | 222 | return -EFAULT; |
232 | mutex_lock(&atm_dev_mutex); | 223 | } |
233 | list_for_each(p, &atm_devs) | 224 | if (get_user(len, iobuf_len)) |
234 | size += sizeof(int); | 225 | return -EFAULT; |
235 | if (size > len) { | 226 | mutex_lock(&atm_dev_mutex); |
236 | mutex_unlock(&atm_dev_mutex); | 227 | list_for_each(p, &atm_devs) |
237 | return -E2BIG; | 228 | size += sizeof(int); |
238 | } | 229 | if (size > len) { |
239 | tmp_buf = kmalloc(size, GFP_ATOMIC); | ||
240 | if (!tmp_buf) { | ||
241 | mutex_unlock(&atm_dev_mutex); | ||
242 | return -ENOMEM; | ||
243 | } | ||
244 | tmp_p = tmp_buf; | ||
245 | list_for_each(p, &atm_devs) { | ||
246 | dev = list_entry(p, struct atm_dev, dev_list); | ||
247 | *tmp_p++ = dev->number; | ||
248 | } | ||
249 | mutex_unlock(&atm_dev_mutex); | 230 | mutex_unlock(&atm_dev_mutex); |
250 | error = ((copy_to_user(buf, tmp_buf, size)) || | 231 | return -E2BIG; |
251 | put_user(size, iobuf_len)) | 232 | } |
252 | ? -EFAULT : 0; | 233 | tmp_buf = kmalloc(size, GFP_ATOMIC); |
253 | kfree(tmp_buf); | 234 | if (!tmp_buf) { |
254 | return error; | 235 | mutex_unlock(&atm_dev_mutex); |
255 | default: | 236 | return -ENOMEM; |
256 | break; | 237 | } |
238 | tmp_p = tmp_buf; | ||
239 | list_for_each(p, &atm_devs) { | ||
240 | dev = list_entry(p, struct atm_dev, dev_list); | ||
241 | *tmp_p++ = dev->number; | ||
242 | } | ||
243 | mutex_unlock(&atm_dev_mutex); | ||
244 | error = ((copy_to_user(buf, tmp_buf, size)) || | ||
245 | put_user(size, iobuf_len)) | ||
246 | ? -EFAULT : 0; | ||
247 | kfree(tmp_buf); | ||
248 | return error; | ||
249 | default: | ||
250 | break; | ||
257 | } | 251 | } |
258 | 252 | ||
259 | if (compat) { | 253 | if (compat) { |
@@ -282,166 +276,167 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat) | |||
282 | if (get_user(number, &sioc->number)) | 276 | if (get_user(number, &sioc->number)) |
283 | return -EFAULT; | 277 | return -EFAULT; |
284 | } | 278 | } |
285 | if (!(dev = try_then_request_module(atm_dev_lookup(number), | 279 | |
286 | "atm-device-%d", number))) | 280 | dev = try_then_request_module(atm_dev_lookup(number), "atm-device-%d", |
281 | number); | ||
282 | if (!dev) | ||
287 | return -ENODEV; | 283 | return -ENODEV; |
288 | 284 | ||
289 | switch (cmd) { | 285 | switch (cmd) { |
290 | case ATM_GETTYPE: | 286 | case ATM_GETTYPE: |
291 | size = strlen(dev->type) + 1; | 287 | size = strlen(dev->type) + 1; |
292 | if (copy_to_user(buf, dev->type, size)) { | 288 | if (copy_to_user(buf, dev->type, size)) { |
293 | error = -EFAULT; | 289 | error = -EFAULT; |
294 | goto done; | 290 | goto done; |
295 | } | 291 | } |
296 | break; | 292 | break; |
297 | case ATM_GETESI: | 293 | case ATM_GETESI: |
298 | size = ESI_LEN; | 294 | size = ESI_LEN; |
299 | if (copy_to_user(buf, dev->esi, size)) { | 295 | if (copy_to_user(buf, dev->esi, size)) { |
300 | error = -EFAULT; | 296 | error = -EFAULT; |
301 | goto done; | 297 | goto done; |
302 | } | 298 | } |
303 | break; | 299 | break; |
304 | case ATM_SETESI: | 300 | case ATM_SETESI: |
305 | { | 301 | { |
306 | int i; | 302 | int i; |
307 | 303 | ||
308 | for (i = 0; i < ESI_LEN; i++) | 304 | for (i = 0; i < ESI_LEN; i++) |
309 | if (dev->esi[i]) { | 305 | if (dev->esi[i]) { |
310 | error = -EEXIST; | 306 | error = -EEXIST; |
311 | goto done; | ||
312 | } | ||
313 | } | ||
314 | /* fall through */ | ||
315 | case ATM_SETESIF: | ||
316 | { | ||
317 | unsigned char esi[ESI_LEN]; | ||
318 | |||
319 | if (!capable(CAP_NET_ADMIN)) { | ||
320 | error = -EPERM; | ||
321 | goto done; | ||
322 | } | ||
323 | if (copy_from_user(esi, buf, ESI_LEN)) { | ||
324 | error = -EFAULT; | ||
325 | goto done; | ||
326 | } | ||
327 | memcpy(dev->esi, esi, ESI_LEN); | ||
328 | error = ESI_LEN; | ||
329 | goto done; | ||
330 | } | ||
331 | case ATM_GETSTATZ: | ||
332 | if (!capable(CAP_NET_ADMIN)) { | ||
333 | error = -EPERM; | ||
334 | goto done; | ||
335 | } | ||
336 | /* fall through */ | ||
337 | case ATM_GETSTAT: | ||
338 | size = sizeof(struct atm_dev_stats); | ||
339 | error = fetch_stats(dev, buf, cmd == ATM_GETSTATZ); | ||
340 | if (error) | ||
341 | goto done; | ||
342 | break; | ||
343 | case ATM_GETCIRANGE: | ||
344 | size = sizeof(struct atm_cirange); | ||
345 | if (copy_to_user(buf, &dev->ci_range, size)) { | ||
346 | error = -EFAULT; | ||
347 | goto done; | ||
348 | } | ||
349 | break; | ||
350 | case ATM_GETLINKRATE: | ||
351 | size = sizeof(int); | ||
352 | if (copy_to_user(buf, &dev->link_rate, size)) { | ||
353 | error = -EFAULT; | ||
354 | goto done; | ||
355 | } | ||
356 | break; | ||
357 | case ATM_RSTADDR: | ||
358 | if (!capable(CAP_NET_ADMIN)) { | ||
359 | error = -EPERM; | ||
360 | goto done; | ||
361 | } | ||
362 | atm_reset_addr(dev, ATM_ADDR_LOCAL); | ||
363 | break; | ||
364 | case ATM_ADDADDR: | ||
365 | case ATM_DELADDR: | ||
366 | case ATM_ADDLECSADDR: | ||
367 | case ATM_DELLECSADDR: | ||
368 | if (!capable(CAP_NET_ADMIN)) { | ||
369 | error = -EPERM; | ||
370 | goto done; | ||
371 | } | ||
372 | { | ||
373 | struct sockaddr_atmsvc addr; | ||
374 | |||
375 | if (copy_from_user(&addr, buf, sizeof(addr))) { | ||
376 | error = -EFAULT; | ||
377 | goto done; | ||
378 | } | ||
379 | if (cmd == ATM_ADDADDR || cmd == ATM_ADDLECSADDR) | ||
380 | error = atm_add_addr(dev, &addr, | ||
381 | (cmd == ATM_ADDADDR ? | ||
382 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); | ||
383 | else | ||
384 | error = atm_del_addr(dev, &addr, | ||
385 | (cmd == ATM_DELADDR ? | ||
386 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); | ||
387 | goto done; | 307 | goto done; |
388 | } | 308 | } |
389 | case ATM_GETADDR: | 309 | } |
390 | case ATM_GETLECSADDR: | 310 | /* fall through */ |
391 | error = atm_get_addr(dev, buf, len, | 311 | case ATM_SETESIF: |
392 | (cmd == ATM_GETADDR ? | 312 | { |
313 | unsigned char esi[ESI_LEN]; | ||
314 | |||
315 | if (!capable(CAP_NET_ADMIN)) { | ||
316 | error = -EPERM; | ||
317 | goto done; | ||
318 | } | ||
319 | if (copy_from_user(esi, buf, ESI_LEN)) { | ||
320 | error = -EFAULT; | ||
321 | goto done; | ||
322 | } | ||
323 | memcpy(dev->esi, esi, ESI_LEN); | ||
324 | error = ESI_LEN; | ||
325 | goto done; | ||
326 | } | ||
327 | case ATM_GETSTATZ: | ||
328 | if (!capable(CAP_NET_ADMIN)) { | ||
329 | error = -EPERM; | ||
330 | goto done; | ||
331 | } | ||
332 | /* fall through */ | ||
333 | case ATM_GETSTAT: | ||
334 | size = sizeof(struct atm_dev_stats); | ||
335 | error = fetch_stats(dev, buf, cmd == ATM_GETSTATZ); | ||
336 | if (error) | ||
337 | goto done; | ||
338 | break; | ||
339 | case ATM_GETCIRANGE: | ||
340 | size = sizeof(struct atm_cirange); | ||
341 | if (copy_to_user(buf, &dev->ci_range, size)) { | ||
342 | error = -EFAULT; | ||
343 | goto done; | ||
344 | } | ||
345 | break; | ||
346 | case ATM_GETLINKRATE: | ||
347 | size = sizeof(int); | ||
348 | if (copy_to_user(buf, &dev->link_rate, size)) { | ||
349 | error = -EFAULT; | ||
350 | goto done; | ||
351 | } | ||
352 | break; | ||
353 | case ATM_RSTADDR: | ||
354 | if (!capable(CAP_NET_ADMIN)) { | ||
355 | error = -EPERM; | ||
356 | goto done; | ||
357 | } | ||
358 | atm_reset_addr(dev, ATM_ADDR_LOCAL); | ||
359 | break; | ||
360 | case ATM_ADDADDR: | ||
361 | case ATM_DELADDR: | ||
362 | case ATM_ADDLECSADDR: | ||
363 | case ATM_DELLECSADDR: | ||
364 | { | ||
365 | struct sockaddr_atmsvc addr; | ||
366 | |||
367 | if (!capable(CAP_NET_ADMIN)) { | ||
368 | error = -EPERM; | ||
369 | goto done; | ||
370 | } | ||
371 | |||
372 | if (copy_from_user(&addr, buf, sizeof(addr))) { | ||
373 | error = -EFAULT; | ||
374 | goto done; | ||
375 | } | ||
376 | if (cmd == ATM_ADDADDR || cmd == ATM_ADDLECSADDR) | ||
377 | error = atm_add_addr(dev, &addr, | ||
378 | (cmd == ATM_ADDADDR ? | ||
393 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); | 379 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); |
394 | if (error < 0) | 380 | else |
395 | goto done; | 381 | error = atm_del_addr(dev, &addr, |
396 | size = error; | 382 | (cmd == ATM_DELADDR ? |
397 | /* may return 0, but later on size == 0 means "don't | 383 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); |
398 | write the length" */ | 384 | goto done; |
399 | error = put_user(size, sioc_len) | 385 | } |
400 | ? -EFAULT : 0; | 386 | case ATM_GETADDR: |
387 | case ATM_GETLECSADDR: | ||
388 | error = atm_get_addr(dev, buf, len, | ||
389 | (cmd == ATM_GETADDR ? | ||
390 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); | ||
391 | if (error < 0) | ||
392 | goto done; | ||
393 | size = error; | ||
394 | /* may return 0, but later on size == 0 means "don't | ||
395 | write the length" */ | ||
396 | error = put_user(size, sioc_len) ? -EFAULT : 0; | ||
397 | goto done; | ||
398 | case ATM_SETLOOP: | ||
399 | if (__ATM_LM_XTRMT((int) (unsigned long) buf) && | ||
400 | __ATM_LM_XTLOC((int) (unsigned long) buf) > | ||
401 | __ATM_LM_XTRMT((int) (unsigned long) buf)) { | ||
402 | error = -EINVAL; | ||
401 | goto done; | 403 | goto done; |
402 | case ATM_SETLOOP: | 404 | } |
403 | if (__ATM_LM_XTRMT((int) (unsigned long) buf) && | 405 | /* fall through */ |
404 | __ATM_LM_XTLOC((int) (unsigned long) buf) > | 406 | case ATM_SETCIRANGE: |
405 | __ATM_LM_XTRMT((int) (unsigned long) buf)) { | 407 | case SONET_GETSTATZ: |
408 | case SONET_SETDIAG: | ||
409 | case SONET_CLRDIAG: | ||
410 | case SONET_SETFRAMING: | ||
411 | if (!capable(CAP_NET_ADMIN)) { | ||
412 | error = -EPERM; | ||
413 | goto done; | ||
414 | } | ||
415 | /* fall through */ | ||
416 | default: | ||
417 | if (compat) { | ||
418 | #ifdef CONFIG_COMPAT | ||
419 | if (!dev->ops->compat_ioctl) { | ||
406 | error = -EINVAL; | 420 | error = -EINVAL; |
407 | goto done; | 421 | goto done; |
408 | } | 422 | } |
409 | /* fall through */ | 423 | size = dev->ops->compat_ioctl(dev, cmd, buf); |
410 | case ATM_SETCIRANGE: | ||
411 | case SONET_GETSTATZ: | ||
412 | case SONET_SETDIAG: | ||
413 | case SONET_CLRDIAG: | ||
414 | case SONET_SETFRAMING: | ||
415 | if (!capable(CAP_NET_ADMIN)) { | ||
416 | error = -EPERM; | ||
417 | goto done; | ||
418 | } | ||
419 | /* fall through */ | ||
420 | default: | ||
421 | if (compat) { | ||
422 | #ifdef CONFIG_COMPAT | ||
423 | if (!dev->ops->compat_ioctl) { | ||
424 | error = -EINVAL; | ||
425 | goto done; | ||
426 | } | ||
427 | size = dev->ops->compat_ioctl(dev, cmd, buf); | ||
428 | #endif | 424 | #endif |
429 | } else { | 425 | } else { |
430 | if (!dev->ops->ioctl) { | 426 | if (!dev->ops->ioctl) { |
431 | error = -EINVAL; | 427 | error = -EINVAL; |
432 | goto done; | ||
433 | } | ||
434 | size = dev->ops->ioctl(dev, cmd, buf); | ||
435 | } | ||
436 | if (size < 0) { | ||
437 | error = (size == -ENOIOCTLCMD ? -EINVAL : size); | ||
438 | goto done; | 428 | goto done; |
439 | } | 429 | } |
430 | size = dev->ops->ioctl(dev, cmd, buf); | ||
431 | } | ||
432 | if (size < 0) { | ||
433 | error = (size == -ENOIOCTLCMD ? -EINVAL : size); | ||
434 | goto done; | ||
435 | } | ||
440 | } | 436 | } |
441 | 437 | ||
442 | if (size) | 438 | if (size) |
443 | error = put_user(size, sioc_len) | 439 | error = put_user(size, sioc_len) ? -EFAULT : 0; |
444 | ? -EFAULT : 0; | ||
445 | else | 440 | else |
446 | error = 0; | 441 | error = 0; |
447 | done: | 442 | done: |
@@ -449,7 +444,7 @@ done: | |||
449 | return error; | 444 | return error; |
450 | } | 445 | } |
451 | 446 | ||
452 | static __inline__ void *dev_get_idx(loff_t left) | 447 | static inline void *dev_get_idx(loff_t left) |
453 | { | 448 | { |
454 | struct list_head *p; | 449 | struct list_head *p; |
455 | 450 | ||
@@ -478,8 +473,3 @@ void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
478 | ? atm_devs.next : ((struct list_head *)v)->next; | 473 | ? atm_devs.next : ((struct list_head *)v)->next; |
479 | return (v == &atm_devs) ? NULL : v; | 474 | return (v == &atm_devs) ? NULL : v; |
480 | } | 475 | } |
481 | |||
482 | |||
483 | EXPORT_SYMBOL(atm_dev_register); | ||
484 | EXPORT_SYMBOL(atm_dev_deregister); | ||
485 | EXPORT_SYMBOL(atm_dev_lookup); | ||
diff --git a/net/atm/signaling.c b/net/atm/signaling.c index 229921400522..ad1d28ae512b 100644 --- a/net/atm/signaling.c +++ b/net/atm/signaling.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ |
4 | 4 | ||
5 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
5 | 6 | ||
6 | #include <linux/errno.h> /* error codes */ | 7 | #include <linux/errno.h> /* error codes */ |
7 | #include <linux/kernel.h> /* printk */ | 8 | #include <linux/kernel.h> /* printk */ |
@@ -17,7 +18,6 @@ | |||
17 | #include "resources.h" | 18 | #include "resources.h" |
18 | #include "signaling.h" | 19 | #include "signaling.h" |
19 | 20 | ||
20 | |||
21 | #undef WAIT_FOR_DEMON /* #define this if system calls on SVC sockets | 21 | #undef WAIT_FOR_DEMON /* #define this if system calls on SVC sockets |
22 | should block until the demon runs. | 22 | should block until the demon runs. |
23 | Danger: may cause nasty hangs if the demon | 23 | Danger: may cause nasty hangs if the demon |
@@ -28,60 +28,59 @@ struct atm_vcc *sigd = NULL; | |||
28 | static DECLARE_WAIT_QUEUE_HEAD(sigd_sleep); | 28 | static DECLARE_WAIT_QUEUE_HEAD(sigd_sleep); |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | |||
32 | static void sigd_put_skb(struct sk_buff *skb) | 31 | static void sigd_put_skb(struct sk_buff *skb) |
33 | { | 32 | { |
34 | #ifdef WAIT_FOR_DEMON | 33 | #ifdef WAIT_FOR_DEMON |
35 | DECLARE_WAITQUEUE(wait,current); | 34 | DECLARE_WAITQUEUE(wait, current); |
36 | 35 | ||
37 | add_wait_queue(&sigd_sleep,&wait); | 36 | add_wait_queue(&sigd_sleep, &wait); |
38 | while (!sigd) { | 37 | while (!sigd) { |
39 | set_current_state(TASK_UNINTERRUPTIBLE); | 38 | set_current_state(TASK_UNINTERRUPTIBLE); |
40 | pr_debug("atmsvc: waiting for signaling demon...\n"); | 39 | pr_debug("atmsvc: waiting for signaling daemon...\n"); |
41 | schedule(); | 40 | schedule(); |
42 | } | 41 | } |
43 | current->state = TASK_RUNNING; | 42 | current->state = TASK_RUNNING; |
44 | remove_wait_queue(&sigd_sleep,&wait); | 43 | remove_wait_queue(&sigd_sleep, &wait); |
45 | #else | 44 | #else |
46 | if (!sigd) { | 45 | if (!sigd) { |
47 | pr_debug("atmsvc: no signaling demon\n"); | 46 | pr_debug("atmsvc: no signaling daemon\n"); |
48 | kfree_skb(skb); | 47 | kfree_skb(skb); |
49 | return; | 48 | return; |
50 | } | 49 | } |
51 | #endif | 50 | #endif |
52 | atm_force_charge(sigd,skb->truesize); | 51 | atm_force_charge(sigd, skb->truesize); |
53 | skb_queue_tail(&sk_atm(sigd)->sk_receive_queue,skb); | 52 | skb_queue_tail(&sk_atm(sigd)->sk_receive_queue, skb); |
54 | sk_atm(sigd)->sk_data_ready(sk_atm(sigd), skb->len); | 53 | sk_atm(sigd)->sk_data_ready(sk_atm(sigd), skb->len); |
55 | } | 54 | } |
56 | 55 | ||
57 | 56 | static void modify_qos(struct atm_vcc *vcc, struct atmsvc_msg *msg) | |
58 | static void modify_qos(struct atm_vcc *vcc,struct atmsvc_msg *msg) | ||
59 | { | 57 | { |
60 | struct sk_buff *skb; | 58 | struct sk_buff *skb; |
61 | 59 | ||
62 | if (test_bit(ATM_VF_RELEASED,&vcc->flags) || | 60 | if (test_bit(ATM_VF_RELEASED, &vcc->flags) || |
63 | !test_bit(ATM_VF_READY,&vcc->flags)) | 61 | !test_bit(ATM_VF_READY, &vcc->flags)) |
64 | return; | 62 | return; |
65 | msg->type = as_error; | 63 | msg->type = as_error; |
66 | if (!vcc->dev->ops->change_qos) msg->reply = -EOPNOTSUPP; | 64 | if (!vcc->dev->ops->change_qos) |
65 | msg->reply = -EOPNOTSUPP; | ||
67 | else { | 66 | else { |
68 | /* should lock VCC */ | 67 | /* should lock VCC */ |
69 | msg->reply = vcc->dev->ops->change_qos(vcc,&msg->qos, | 68 | msg->reply = vcc->dev->ops->change_qos(vcc, &msg->qos, |
70 | msg->reply); | 69 | msg->reply); |
71 | if (!msg->reply) msg->type = as_okay; | 70 | if (!msg->reply) |
71 | msg->type = as_okay; | ||
72 | } | 72 | } |
73 | /* | 73 | /* |
74 | * Should probably just turn around the old skb. But the, the buffer | 74 | * Should probably just turn around the old skb. But the, the buffer |
75 | * space accounting needs to follow the change too. Maybe later. | 75 | * space accounting needs to follow the change too. Maybe later. |
76 | */ | 76 | */ |
77 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg),GFP_KERNEL))) | 77 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg), GFP_KERNEL))) |
78 | schedule(); | 78 | schedule(); |
79 | *(struct atmsvc_msg *) skb_put(skb,sizeof(struct atmsvc_msg)) = *msg; | 79 | *(struct atmsvc_msg *)skb_put(skb, sizeof(struct atmsvc_msg)) = *msg; |
80 | sigd_put_skb(skb); | 80 | sigd_put_skb(skb); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb) | |
84 | static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb) | ||
85 | { | 84 | { |
86 | struct atmsvc_msg *msg; | 85 | struct atmsvc_msg *msg; |
87 | struct atm_vcc *session_vcc; | 86 | struct atm_vcc *session_vcc; |
@@ -90,69 +89,68 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb) | |||
90 | msg = (struct atmsvc_msg *) skb->data; | 89 | msg = (struct atmsvc_msg *) skb->data; |
91 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); | 90 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); |
92 | vcc = *(struct atm_vcc **) &msg->vcc; | 91 | vcc = *(struct atm_vcc **) &msg->vcc; |
93 | pr_debug("sigd_send %d (0x%lx)\n",(int) msg->type, | 92 | pr_debug("%d (0x%lx)\n", (int)msg->type, (unsigned long)vcc); |
94 | (unsigned long) vcc); | ||
95 | sk = sk_atm(vcc); | 93 | sk = sk_atm(vcc); |
96 | 94 | ||
97 | switch (msg->type) { | 95 | switch (msg->type) { |
98 | case as_okay: | 96 | case as_okay: |
99 | sk->sk_err = -msg->reply; | 97 | sk->sk_err = -msg->reply; |
100 | clear_bit(ATM_VF_WAITING, &vcc->flags); | 98 | clear_bit(ATM_VF_WAITING, &vcc->flags); |
101 | if (!*vcc->local.sas_addr.prv && | 99 | if (!*vcc->local.sas_addr.prv && !*vcc->local.sas_addr.pub) { |
102 | !*vcc->local.sas_addr.pub) { | 100 | vcc->local.sas_family = AF_ATMSVC; |
103 | vcc->local.sas_family = AF_ATMSVC; | 101 | memcpy(vcc->local.sas_addr.prv, |
104 | memcpy(vcc->local.sas_addr.prv, | 102 | msg->local.sas_addr.prv, ATM_ESA_LEN); |
105 | msg->local.sas_addr.prv,ATM_ESA_LEN); | 103 | memcpy(vcc->local.sas_addr.pub, |
106 | memcpy(vcc->local.sas_addr.pub, | 104 | msg->local.sas_addr.pub, ATM_E164_LEN + 1); |
107 | msg->local.sas_addr.pub,ATM_E164_LEN+1); | 105 | } |
108 | } | 106 | session_vcc = vcc->session ? vcc->session : vcc; |
109 | session_vcc = vcc->session ? vcc->session : vcc; | 107 | if (session_vcc->vpi || session_vcc->vci) |
110 | if (session_vcc->vpi || session_vcc->vci) break; | ||
111 | session_vcc->itf = msg->pvc.sap_addr.itf; | ||
112 | session_vcc->vpi = msg->pvc.sap_addr.vpi; | ||
113 | session_vcc->vci = msg->pvc.sap_addr.vci; | ||
114 | if (session_vcc->vpi || session_vcc->vci) | ||
115 | session_vcc->qos = msg->qos; | ||
116 | break; | ||
117 | case as_error: | ||
118 | clear_bit(ATM_VF_REGIS,&vcc->flags); | ||
119 | clear_bit(ATM_VF_READY,&vcc->flags); | ||
120 | sk->sk_err = -msg->reply; | ||
121 | clear_bit(ATM_VF_WAITING, &vcc->flags); | ||
122 | break; | 108 | break; |
123 | case as_indicate: | 109 | session_vcc->itf = msg->pvc.sap_addr.itf; |
124 | vcc = *(struct atm_vcc **) &msg->listen_vcc; | 110 | session_vcc->vpi = msg->pvc.sap_addr.vpi; |
125 | sk = sk_atm(vcc); | 111 | session_vcc->vci = msg->pvc.sap_addr.vci; |
126 | pr_debug("as_indicate!!!\n"); | 112 | if (session_vcc->vpi || session_vcc->vci) |
127 | lock_sock(sk); | 113 | session_vcc->qos = msg->qos; |
128 | if (sk_acceptq_is_full(sk)) { | 114 | break; |
129 | sigd_enq(NULL,as_reject,vcc,NULL,NULL); | 115 | case as_error: |
130 | dev_kfree_skb(skb); | 116 | clear_bit(ATM_VF_REGIS, &vcc->flags); |
131 | goto as_indicate_complete; | 117 | clear_bit(ATM_VF_READY, &vcc->flags); |
132 | } | 118 | sk->sk_err = -msg->reply; |
133 | sk->sk_ack_backlog++; | 119 | clear_bit(ATM_VF_WAITING, &vcc->flags); |
134 | skb_queue_tail(&sk->sk_receive_queue, skb); | 120 | break; |
135 | pr_debug("waking sk->sk_sleep 0x%p\n", sk->sk_sleep); | 121 | case as_indicate: |
136 | sk->sk_state_change(sk); | 122 | vcc = *(struct atm_vcc **)&msg->listen_vcc; |
123 | sk = sk_atm(vcc); | ||
124 | pr_debug("as_indicate!!!\n"); | ||
125 | lock_sock(sk); | ||
126 | if (sk_acceptq_is_full(sk)) { | ||
127 | sigd_enq(NULL, as_reject, vcc, NULL, NULL); | ||
128 | dev_kfree_skb(skb); | ||
129 | goto as_indicate_complete; | ||
130 | } | ||
131 | sk->sk_ack_backlog++; | ||
132 | skb_queue_tail(&sk->sk_receive_queue, skb); | ||
133 | pr_debug("waking sk->sk_sleep 0x%p\n", sk->sk_sleep); | ||
134 | sk->sk_state_change(sk); | ||
137 | as_indicate_complete: | 135 | as_indicate_complete: |
138 | release_sock(sk); | 136 | release_sock(sk); |
139 | return 0; | 137 | return 0; |
140 | case as_close: | 138 | case as_close: |
141 | set_bit(ATM_VF_RELEASED,&vcc->flags); | 139 | set_bit(ATM_VF_RELEASED, &vcc->flags); |
142 | vcc_release_async(vcc, msg->reply); | 140 | vcc_release_async(vcc, msg->reply); |
143 | goto out; | 141 | goto out; |
144 | case as_modify: | 142 | case as_modify: |
145 | modify_qos(vcc,msg); | 143 | modify_qos(vcc, msg); |
146 | break; | 144 | break; |
147 | case as_addparty: | 145 | case as_addparty: |
148 | case as_dropparty: | 146 | case as_dropparty: |
149 | sk->sk_err_soft = msg->reply; /* < 0 failure, otherwise ep_ref */ | 147 | sk->sk_err_soft = msg->reply; |
150 | clear_bit(ATM_VF_WAITING, &vcc->flags); | 148 | /* < 0 failure, otherwise ep_ref */ |
151 | break; | 149 | clear_bit(ATM_VF_WAITING, &vcc->flags); |
152 | default: | 150 | break; |
153 | printk(KERN_ALERT "sigd_send: bad message type %d\n", | 151 | default: |
154 | (int) msg->type); | 152 | pr_alert("bad message type %d\n", (int)msg->type); |
155 | return -EINVAL; | 153 | return -EINVAL; |
156 | } | 154 | } |
157 | sk->sk_state_change(sk); | 155 | sk->sk_state_change(sk); |
158 | out: | 156 | out: |
@@ -160,48 +158,52 @@ out: | |||
160 | return 0; | 158 | return 0; |
161 | } | 159 | } |
162 | 160 | ||
163 | 161 | void sigd_enq2(struct atm_vcc *vcc, enum atmsvc_msg_type type, | |
164 | void sigd_enq2(struct atm_vcc *vcc,enum atmsvc_msg_type type, | 162 | struct atm_vcc *listen_vcc, const struct sockaddr_atmpvc *pvc, |
165 | struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, | 163 | const struct sockaddr_atmsvc *svc, const struct atm_qos *qos, |
166 | const struct sockaddr_atmsvc *svc,const struct atm_qos *qos,int reply) | 164 | int reply) |
167 | { | 165 | { |
168 | struct sk_buff *skb; | 166 | struct sk_buff *skb; |
169 | struct atmsvc_msg *msg; | 167 | struct atmsvc_msg *msg; |
170 | static unsigned session = 0; | 168 | static unsigned session = 0; |
171 | 169 | ||
172 | pr_debug("sigd_enq %d (0x%p)\n",(int) type,vcc); | 170 | pr_debug("%d (0x%p)\n", (int)type, vcc); |
173 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg),GFP_KERNEL))) | 171 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg), GFP_KERNEL))) |
174 | schedule(); | 172 | schedule(); |
175 | msg = (struct atmsvc_msg *) skb_put(skb,sizeof(struct atmsvc_msg)); | 173 | msg = (struct atmsvc_msg *)skb_put(skb, sizeof(struct atmsvc_msg)); |
176 | memset(msg,0,sizeof(*msg)); | 174 | memset(msg, 0, sizeof(*msg)); |
177 | msg->type = type; | 175 | msg->type = type; |
178 | *(struct atm_vcc **) &msg->vcc = vcc; | 176 | *(struct atm_vcc **) &msg->vcc = vcc; |
179 | *(struct atm_vcc **) &msg->listen_vcc = listen_vcc; | 177 | *(struct atm_vcc **) &msg->listen_vcc = listen_vcc; |
180 | msg->reply = reply; | 178 | msg->reply = reply; |
181 | if (qos) msg->qos = *qos; | 179 | if (qos) |
182 | if (vcc) msg->sap = vcc->sap; | 180 | msg->qos = *qos; |
183 | if (svc) msg->svc = *svc; | 181 | if (vcc) |
184 | if (vcc) msg->local = vcc->local; | 182 | msg->sap = vcc->sap; |
185 | if (pvc) msg->pvc = *pvc; | 183 | if (svc) |
184 | msg->svc = *svc; | ||
185 | if (vcc) | ||
186 | msg->local = vcc->local; | ||
187 | if (pvc) | ||
188 | msg->pvc = *pvc; | ||
186 | if (vcc) { | 189 | if (vcc) { |
187 | if (type == as_connect && test_bit(ATM_VF_SESSION, &vcc->flags)) | 190 | if (type == as_connect && test_bit(ATM_VF_SESSION, &vcc->flags)) |
188 | msg->session = ++session; | 191 | msg->session = ++session; |
189 | /* every new pmp connect gets the next session number */ | 192 | /* every new pmp connect gets the next session number */ |
190 | } | 193 | } |
191 | sigd_put_skb(skb); | 194 | sigd_put_skb(skb); |
192 | if (vcc) set_bit(ATM_VF_REGIS,&vcc->flags); | 195 | if (vcc) |
196 | set_bit(ATM_VF_REGIS, &vcc->flags); | ||
193 | } | 197 | } |
194 | 198 | ||
195 | 199 | void sigd_enq(struct atm_vcc *vcc, enum atmsvc_msg_type type, | |
196 | void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type, | 200 | struct atm_vcc *listen_vcc, const struct sockaddr_atmpvc *pvc, |
197 | struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, | 201 | const struct sockaddr_atmsvc *svc) |
198 | const struct sockaddr_atmsvc *svc) | ||
199 | { | 202 | { |
200 | sigd_enq2(vcc,type,listen_vcc,pvc,svc,vcc ? &vcc->qos : NULL,0); | 203 | sigd_enq2(vcc, type, listen_vcc, pvc, svc, vcc ? &vcc->qos : NULL, 0); |
201 | /* other ISP applications may use "reply" */ | 204 | /* other ISP applications may use "reply" */ |
202 | } | 205 | } |
203 | 206 | ||
204 | |||
205 | static void purge_vcc(struct atm_vcc *vcc) | 207 | static void purge_vcc(struct atm_vcc *vcc) |
206 | { | 208 | { |
207 | if (sk_atm(vcc)->sk_family == PF_ATMSVC && | 209 | if (sk_atm(vcc)->sk_family == PF_ATMSVC && |
@@ -212,21 +214,20 @@ static void purge_vcc(struct atm_vcc *vcc) | |||
212 | } | 214 | } |
213 | } | 215 | } |
214 | 216 | ||
215 | |||
216 | static void sigd_close(struct atm_vcc *vcc) | 217 | static void sigd_close(struct atm_vcc *vcc) |
217 | { | 218 | { |
218 | struct hlist_node *node; | 219 | struct hlist_node *node; |
219 | struct sock *s; | 220 | struct sock *s; |
220 | int i; | 221 | int i; |
221 | 222 | ||
222 | pr_debug("sigd_close\n"); | 223 | pr_debug("\n"); |
223 | sigd = NULL; | 224 | sigd = NULL; |
224 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) | 225 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) |
225 | printk(KERN_ERR "sigd_close: closing with requests pending\n"); | 226 | pr_err("closing with requests pending\n"); |
226 | skb_queue_purge(&sk_atm(vcc)->sk_receive_queue); | 227 | skb_queue_purge(&sk_atm(vcc)->sk_receive_queue); |
227 | 228 | ||
228 | read_lock(&vcc_sklist_lock); | 229 | read_lock(&vcc_sklist_lock); |
229 | for(i = 0; i < VCC_HTABLE_SIZE; ++i) { | 230 | for (i = 0; i < VCC_HTABLE_SIZE; ++i) { |
230 | struct hlist_head *head = &vcc_hash[i]; | 231 | struct hlist_head *head = &vcc_hash[i]; |
231 | 232 | ||
232 | sk_for_each(s, node, head) { | 233 | sk_for_each(s, node, head) { |
@@ -238,13 +239,11 @@ static void sigd_close(struct atm_vcc *vcc) | |||
238 | read_unlock(&vcc_sklist_lock); | 239 | read_unlock(&vcc_sklist_lock); |
239 | } | 240 | } |
240 | 241 | ||
241 | |||
242 | static struct atmdev_ops sigd_dev_ops = { | 242 | static struct atmdev_ops sigd_dev_ops = { |
243 | .close = sigd_close, | 243 | .close = sigd_close, |
244 | .send = sigd_send | 244 | .send = sigd_send |
245 | }; | 245 | }; |
246 | 246 | ||
247 | |||
248 | static struct atm_dev sigd_dev = { | 247 | static struct atm_dev sigd_dev = { |
249 | .ops = &sigd_dev_ops, | 248 | .ops = &sigd_dev_ops, |
250 | .type = "sig", | 249 | .type = "sig", |
@@ -252,16 +251,16 @@ static struct atm_dev sigd_dev = { | |||
252 | .lock = __SPIN_LOCK_UNLOCKED(sigd_dev.lock) | 251 | .lock = __SPIN_LOCK_UNLOCKED(sigd_dev.lock) |
253 | }; | 252 | }; |
254 | 253 | ||
255 | |||
256 | int sigd_attach(struct atm_vcc *vcc) | 254 | int sigd_attach(struct atm_vcc *vcc) |
257 | { | 255 | { |
258 | if (sigd) return -EADDRINUSE; | 256 | if (sigd) |
259 | pr_debug("sigd_attach\n"); | 257 | return -EADDRINUSE; |
258 | pr_debug("\n"); | ||
260 | sigd = vcc; | 259 | sigd = vcc; |
261 | vcc->dev = &sigd_dev; | 260 | vcc->dev = &sigd_dev; |
262 | vcc_insert_socket(sk_atm(vcc)); | 261 | vcc_insert_socket(sk_atm(vcc)); |
263 | set_bit(ATM_VF_META,&vcc->flags); | 262 | set_bit(ATM_VF_META, &vcc->flags); |
264 | set_bit(ATM_VF_READY,&vcc->flags); | 263 | set_bit(ATM_VF_READY, &vcc->flags); |
265 | #ifdef WAIT_FOR_DEMON | 264 | #ifdef WAIT_FOR_DEMON |
266 | wake_up(&sigd_sleep); | 265 | wake_up(&sigd_sleep); |
267 | #endif | 266 | #endif |
diff --git a/net/atm/svc.c b/net/atm/svc.c index 66e1d9b3e5de..3ba9a45a51ac 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ |
4 | 4 | ||
5 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
5 | 6 | ||
6 | #include <linux/string.h> | 7 | #include <linux/string.h> |
7 | #include <linux/net.h> /* struct socket, struct proto_ops */ | 8 | #include <linux/net.h> /* struct socket, struct proto_ops */ |
@@ -18,14 +19,15 @@ | |||
18 | #include <linux/atmdev.h> | 19 | #include <linux/atmdev.h> |
19 | #include <linux/bitops.h> | 20 | #include <linux/bitops.h> |
20 | #include <net/sock.h> /* for sock_no_* */ | 21 | #include <net/sock.h> /* for sock_no_* */ |
21 | #include <asm/uaccess.h> | 22 | #include <linux/uaccess.h> |
22 | 23 | ||
23 | #include "resources.h" | 24 | #include "resources.h" |
24 | #include "common.h" /* common for PVCs and SVCs */ | 25 | #include "common.h" /* common for PVCs and SVCs */ |
25 | #include "signaling.h" | 26 | #include "signaling.h" |
26 | #include "addr.h" | 27 | #include "addr.h" |
27 | 28 | ||
28 | static int svc_create(struct net *net, struct socket *sock, int protocol, int kern); | 29 | static int svc_create(struct net *net, struct socket *sock, int protocol, |
30 | int kern); | ||
29 | 31 | ||
30 | /* | 32 | /* |
31 | * Note: since all this is still nicely synchronized with the signaling demon, | 33 | * Note: since all this is still nicely synchronized with the signaling demon, |
@@ -34,25 +36,25 @@ static int svc_create(struct net *net, struct socket *sock, int protocol, int ke | |||
34 | */ | 36 | */ |
35 | 37 | ||
36 | 38 | ||
37 | static int svc_shutdown(struct socket *sock,int how) | 39 | static int svc_shutdown(struct socket *sock, int how) |
38 | { | 40 | { |
39 | return 0; | 41 | return 0; |
40 | } | 42 | } |
41 | 43 | ||
42 | |||
43 | static void svc_disconnect(struct atm_vcc *vcc) | 44 | static void svc_disconnect(struct atm_vcc *vcc) |
44 | { | 45 | { |
45 | DEFINE_WAIT(wait); | 46 | DEFINE_WAIT(wait); |
46 | struct sk_buff *skb; | 47 | struct sk_buff *skb; |
47 | struct sock *sk = sk_atm(vcc); | 48 | struct sock *sk = sk_atm(vcc); |
48 | 49 | ||
49 | pr_debug("svc_disconnect %p\n",vcc); | 50 | pr_debug("%p\n", vcc); |
50 | if (test_bit(ATM_VF_REGIS,&vcc->flags)) { | 51 | if (test_bit(ATM_VF_REGIS, &vcc->flags)) { |
51 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 52 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
52 | sigd_enq(vcc,as_close,NULL,NULL,NULL); | 53 | sigd_enq(vcc, as_close, NULL, NULL, NULL); |
53 | while (!test_bit(ATM_VF_RELEASED,&vcc->flags) && sigd) { | 54 | while (!test_bit(ATM_VF_RELEASED, &vcc->flags) && sigd) { |
54 | schedule(); | 55 | schedule(); |
55 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 56 | prepare_to_wait(sk->sk_sleep, &wait, |
57 | TASK_UNINTERRUPTIBLE); | ||
56 | } | 58 | } |
57 | finish_wait(sk->sk_sleep, &wait); | 59 | finish_wait(sk->sk_sleep, &wait); |
58 | } | 60 | } |
@@ -61,35 +63,35 @@ static void svc_disconnect(struct atm_vcc *vcc) | |||
61 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { | 63 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { |
62 | atm_return(vcc, skb->truesize); | 64 | atm_return(vcc, skb->truesize); |
63 | pr_debug("LISTEN REL\n"); | 65 | pr_debug("LISTEN REL\n"); |
64 | sigd_enq2(NULL,as_reject,vcc,NULL,NULL,&vcc->qos,0); | 66 | sigd_enq2(NULL, as_reject, vcc, NULL, NULL, &vcc->qos, 0); |
65 | dev_kfree_skb(skb); | 67 | dev_kfree_skb(skb); |
66 | } | 68 | } |
67 | clear_bit(ATM_VF_REGIS, &vcc->flags); | 69 | clear_bit(ATM_VF_REGIS, &vcc->flags); |
68 | /* ... may retry later */ | 70 | /* ... may retry later */ |
69 | } | 71 | } |
70 | 72 | ||
71 | |||
72 | static int svc_release(struct socket *sock) | 73 | static int svc_release(struct socket *sock) |
73 | { | 74 | { |
74 | struct sock *sk = sock->sk; | 75 | struct sock *sk = sock->sk; |
75 | struct atm_vcc *vcc; | 76 | struct atm_vcc *vcc; |
76 | 77 | ||
77 | if (sk) { | 78 | if (sk) { |
78 | vcc = ATM_SD(sock); | 79 | vcc = ATM_SD(sock); |
79 | pr_debug("svc_release %p\n", vcc); | 80 | pr_debug("%p\n", vcc); |
80 | clear_bit(ATM_VF_READY, &vcc->flags); | 81 | clear_bit(ATM_VF_READY, &vcc->flags); |
81 | /* VCC pointer is used as a reference, so we must not free it | 82 | /* |
82 | (thereby subjecting it to re-use) before all pending connections | 83 | * VCC pointer is used as a reference, |
83 | are closed */ | 84 | * so we must not free it (thereby subjecting it to re-use) |
85 | * before all pending connections are closed | ||
86 | */ | ||
84 | svc_disconnect(vcc); | 87 | svc_disconnect(vcc); |
85 | vcc_release(sock); | 88 | vcc_release(sock); |
86 | } | 89 | } |
87 | return 0; | 90 | return 0; |
88 | } | 91 | } |
89 | 92 | ||
90 | 93 | static int svc_bind(struct socket *sock, struct sockaddr *sockaddr, | |
91 | static int svc_bind(struct socket *sock,struct sockaddr *sockaddr, | 94 | int sockaddr_len) |
92 | int sockaddr_len) | ||
93 | { | 95 | { |
94 | DEFINE_WAIT(wait); | 96 | DEFINE_WAIT(wait); |
95 | struct sock *sk = sock->sk; | 97 | struct sock *sk = sock->sk; |
@@ -114,38 +116,37 @@ static int svc_bind(struct socket *sock,struct sockaddr *sockaddr, | |||
114 | error = -EAFNOSUPPORT; | 116 | error = -EAFNOSUPPORT; |
115 | goto out; | 117 | goto out; |
116 | } | 118 | } |
117 | clear_bit(ATM_VF_BOUND,&vcc->flags); | 119 | clear_bit(ATM_VF_BOUND, &vcc->flags); |
118 | /* failing rebind will kill old binding */ | 120 | /* failing rebind will kill old binding */ |
119 | /* @@@ check memory (de)allocation on rebind */ | 121 | /* @@@ check memory (de)allocation on rebind */ |
120 | if (!test_bit(ATM_VF_HASQOS,&vcc->flags)) { | 122 | if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) { |
121 | error = -EBADFD; | 123 | error = -EBADFD; |
122 | goto out; | 124 | goto out; |
123 | } | 125 | } |
124 | vcc->local = *addr; | 126 | vcc->local = *addr; |
125 | set_bit(ATM_VF_WAITING, &vcc->flags); | 127 | set_bit(ATM_VF_WAITING, &vcc->flags); |
126 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 128 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
127 | sigd_enq(vcc,as_bind,NULL,NULL,&vcc->local); | 129 | sigd_enq(vcc, as_bind, NULL, NULL, &vcc->local); |
128 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { | 130 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { |
129 | schedule(); | 131 | schedule(); |
130 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 132 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
131 | } | 133 | } |
132 | finish_wait(sk->sk_sleep, &wait); | 134 | finish_wait(sk->sk_sleep, &wait); |
133 | clear_bit(ATM_VF_REGIS,&vcc->flags); /* doesn't count */ | 135 | clear_bit(ATM_VF_REGIS, &vcc->flags); /* doesn't count */ |
134 | if (!sigd) { | 136 | if (!sigd) { |
135 | error = -EUNATCH; | 137 | error = -EUNATCH; |
136 | goto out; | 138 | goto out; |
137 | } | 139 | } |
138 | if (!sk->sk_err) | 140 | if (!sk->sk_err) |
139 | set_bit(ATM_VF_BOUND,&vcc->flags); | 141 | set_bit(ATM_VF_BOUND, &vcc->flags); |
140 | error = -sk->sk_err; | 142 | error = -sk->sk_err; |
141 | out: | 143 | out: |
142 | release_sock(sk); | 144 | release_sock(sk); |
143 | return error; | 145 | return error; |
144 | } | 146 | } |
145 | 147 | ||
146 | 148 | static int svc_connect(struct socket *sock, struct sockaddr *sockaddr, | |
147 | static int svc_connect(struct socket *sock,struct sockaddr *sockaddr, | 149 | int sockaddr_len, int flags) |
148 | int sockaddr_len,int flags) | ||
149 | { | 150 | { |
150 | DEFINE_WAIT(wait); | 151 | DEFINE_WAIT(wait); |
151 | struct sock *sk = sock->sk; | 152 | struct sock *sk = sock->sk; |
@@ -153,7 +154,7 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr, | |||
153 | struct atm_vcc *vcc = ATM_SD(sock); | 154 | struct atm_vcc *vcc = ATM_SD(sock); |
154 | int error; | 155 | int error; |
155 | 156 | ||
156 | pr_debug("svc_connect %p\n",vcc); | 157 | pr_debug("%p\n", vcc); |
157 | lock_sock(sk); | 158 | lock_sock(sk); |
158 | if (sockaddr_len != sizeof(struct sockaddr_atmsvc)) { | 159 | if (sockaddr_len != sizeof(struct sockaddr_atmsvc)) { |
159 | error = -EINVAL; | 160 | error = -EINVAL; |
@@ -201,7 +202,7 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr, | |||
201 | vcc->remote = *addr; | 202 | vcc->remote = *addr; |
202 | set_bit(ATM_VF_WAITING, &vcc->flags); | 203 | set_bit(ATM_VF_WAITING, &vcc->flags); |
203 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 204 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
204 | sigd_enq(vcc,as_connect,NULL,NULL,&vcc->remote); | 205 | sigd_enq(vcc, as_connect, NULL, NULL, &vcc->remote); |
205 | if (flags & O_NONBLOCK) { | 206 | if (flags & O_NONBLOCK) { |
206 | finish_wait(sk->sk_sleep, &wait); | 207 | finish_wait(sk->sk_sleep, &wait); |
207 | sock->state = SS_CONNECTING; | 208 | sock->state = SS_CONNECTING; |
@@ -212,7 +213,8 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr, | |||
212 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { | 213 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { |
213 | schedule(); | 214 | schedule(); |
214 | if (!signal_pending(current)) { | 215 | if (!signal_pending(current)) { |
215 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 216 | prepare_to_wait(sk->sk_sleep, &wait, |
217 | TASK_INTERRUPTIBLE); | ||
216 | continue; | 218 | continue; |
217 | } | 219 | } |
218 | pr_debug("*ABORT*\n"); | 220 | pr_debug("*ABORT*\n"); |
@@ -228,20 +230,22 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr, | |||
228 | * Kernel <--okay---- Demon | 230 | * Kernel <--okay---- Demon |
229 | * Kernel <--close--- Demon | 231 | * Kernel <--close--- Demon |
230 | */ | 232 | */ |
231 | sigd_enq(vcc,as_close,NULL,NULL,NULL); | 233 | sigd_enq(vcc, as_close, NULL, NULL, NULL); |
232 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { | 234 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { |
233 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 235 | prepare_to_wait(sk->sk_sleep, &wait, |
236 | TASK_INTERRUPTIBLE); | ||
234 | schedule(); | 237 | schedule(); |
235 | } | 238 | } |
236 | if (!sk->sk_err) | 239 | if (!sk->sk_err) |
237 | while (!test_bit(ATM_VF_RELEASED,&vcc->flags) | 240 | while (!test_bit(ATM_VF_RELEASED, &vcc->flags) && |
238 | && sigd) { | 241 | sigd) { |
239 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 242 | prepare_to_wait(sk->sk_sleep, &wait, |
243 | TASK_INTERRUPTIBLE); | ||
240 | schedule(); | 244 | schedule(); |
241 | } | 245 | } |
242 | clear_bit(ATM_VF_REGIS,&vcc->flags); | 246 | clear_bit(ATM_VF_REGIS, &vcc->flags); |
243 | clear_bit(ATM_VF_RELEASED,&vcc->flags); | 247 | clear_bit(ATM_VF_RELEASED, &vcc->flags); |
244 | clear_bit(ATM_VF_CLOSE,&vcc->flags); | 248 | clear_bit(ATM_VF_CLOSE, &vcc->flags); |
245 | /* we're gone now but may connect later */ | 249 | /* we're gone now but may connect later */ |
246 | error = -EINTR; | 250 | error = -EINTR; |
247 | break; | 251 | break; |
@@ -269,37 +273,37 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr, | |||
269 | /* | 273 | /* |
270 | * #endif | 274 | * #endif |
271 | */ | 275 | */ |
272 | if (!(error = vcc_connect(sock, vcc->itf, vcc->vpi, vcc->vci))) | 276 | error = vcc_connect(sock, vcc->itf, vcc->vpi, vcc->vci); |
277 | if (!error) | ||
273 | sock->state = SS_CONNECTED; | 278 | sock->state = SS_CONNECTED; |
274 | else | 279 | else |
275 | (void) svc_disconnect(vcc); | 280 | (void)svc_disconnect(vcc); |
276 | out: | 281 | out: |
277 | release_sock(sk); | 282 | release_sock(sk); |
278 | return error; | 283 | return error; |
279 | } | 284 | } |
280 | 285 | ||
281 | 286 | static int svc_listen(struct socket *sock, int backlog) | |
282 | static int svc_listen(struct socket *sock,int backlog) | ||
283 | { | 287 | { |
284 | DEFINE_WAIT(wait); | 288 | DEFINE_WAIT(wait); |
285 | struct sock *sk = sock->sk; | 289 | struct sock *sk = sock->sk; |
286 | struct atm_vcc *vcc = ATM_SD(sock); | 290 | struct atm_vcc *vcc = ATM_SD(sock); |
287 | int error; | 291 | int error; |
288 | 292 | ||
289 | pr_debug("svc_listen %p\n",vcc); | 293 | pr_debug("%p\n", vcc); |
290 | lock_sock(sk); | 294 | lock_sock(sk); |
291 | /* let server handle listen on unbound sockets */ | 295 | /* let server handle listen on unbound sockets */ |
292 | if (test_bit(ATM_VF_SESSION,&vcc->flags)) { | 296 | if (test_bit(ATM_VF_SESSION, &vcc->flags)) { |
293 | error = -EINVAL; | 297 | error = -EINVAL; |
294 | goto out; | 298 | goto out; |
295 | } | 299 | } |
296 | if (test_bit(ATM_VF_LISTEN, &vcc->flags)) { | 300 | if (test_bit(ATM_VF_LISTEN, &vcc->flags)) { |
297 | error = -EADDRINUSE; | 301 | error = -EADDRINUSE; |
298 | goto out; | 302 | goto out; |
299 | } | 303 | } |
300 | set_bit(ATM_VF_WAITING, &vcc->flags); | 304 | set_bit(ATM_VF_WAITING, &vcc->flags); |
301 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 305 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
302 | sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local); | 306 | sigd_enq(vcc, as_listen, NULL, NULL, &vcc->local); |
303 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { | 307 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { |
304 | schedule(); | 308 | schedule(); |
305 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 309 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
@@ -309,7 +313,7 @@ static int svc_listen(struct socket *sock,int backlog) | |||
309 | error = -EUNATCH; | 313 | error = -EUNATCH; |
310 | goto out; | 314 | goto out; |
311 | } | 315 | } |
312 | set_bit(ATM_VF_LISTEN,&vcc->flags); | 316 | set_bit(ATM_VF_LISTEN, &vcc->flags); |
313 | vcc_insert_socket(sk); | 317 | vcc_insert_socket(sk); |
314 | sk->sk_max_ack_backlog = backlog > 0 ? backlog : ATM_BACKLOG_DEFAULT; | 318 | sk->sk_max_ack_backlog = backlog > 0 ? backlog : ATM_BACKLOG_DEFAULT; |
315 | error = -sk->sk_err; | 319 | error = -sk->sk_err; |
@@ -318,8 +322,7 @@ out: | |||
318 | return error; | 322 | return error; |
319 | } | 323 | } |
320 | 324 | ||
321 | 325 | static int svc_accept(struct socket *sock, struct socket *newsock, int flags) | |
322 | static int svc_accept(struct socket *sock,struct socket *newsock,int flags) | ||
323 | { | 326 | { |
324 | struct sock *sk = sock->sk; | 327 | struct sock *sk = sock->sk; |
325 | struct sk_buff *skb; | 328 | struct sk_buff *skb; |
@@ -336,15 +339,16 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) | |||
336 | 339 | ||
337 | new_vcc = ATM_SD(newsock); | 340 | new_vcc = ATM_SD(newsock); |
338 | 341 | ||
339 | pr_debug("svc_accept %p -> %p\n",old_vcc,new_vcc); | 342 | pr_debug("%p -> %p\n", old_vcc, new_vcc); |
340 | while (1) { | 343 | while (1) { |
341 | DEFINE_WAIT(wait); | 344 | DEFINE_WAIT(wait); |
342 | 345 | ||
343 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 346 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
344 | while (!(skb = skb_dequeue(&sk->sk_receive_queue)) && | 347 | while (!(skb = skb_dequeue(&sk->sk_receive_queue)) && |
345 | sigd) { | 348 | sigd) { |
346 | if (test_bit(ATM_VF_RELEASED,&old_vcc->flags)) break; | 349 | if (test_bit(ATM_VF_RELEASED, &old_vcc->flags)) |
347 | if (test_bit(ATM_VF_CLOSE,&old_vcc->flags)) { | 350 | break; |
351 | if (test_bit(ATM_VF_CLOSE, &old_vcc->flags)) { | ||
348 | error = -sk->sk_err; | 352 | error = -sk->sk_err; |
349 | break; | 353 | break; |
350 | } | 354 | } |
@@ -359,7 +363,8 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) | |||
359 | error = -ERESTARTSYS; | 363 | error = -ERESTARTSYS; |
360 | break; | 364 | break; |
361 | } | 365 | } |
362 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 366 | prepare_to_wait(sk->sk_sleep, &wait, |
367 | TASK_INTERRUPTIBLE); | ||
363 | } | 368 | } |
364 | finish_wait(sk->sk_sleep, &wait); | 369 | finish_wait(sk->sk_sleep, &wait); |
365 | if (error) | 370 | if (error) |
@@ -368,31 +373,34 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) | |||
368 | error = -EUNATCH; | 373 | error = -EUNATCH; |
369 | goto out; | 374 | goto out; |
370 | } | 375 | } |
371 | msg = (struct atmsvc_msg *) skb->data; | 376 | msg = (struct atmsvc_msg *)skb->data; |
372 | new_vcc->qos = msg->qos; | 377 | new_vcc->qos = msg->qos; |
373 | set_bit(ATM_VF_HASQOS,&new_vcc->flags); | 378 | set_bit(ATM_VF_HASQOS, &new_vcc->flags); |
374 | new_vcc->remote = msg->svc; | 379 | new_vcc->remote = msg->svc; |
375 | new_vcc->local = msg->local; | 380 | new_vcc->local = msg->local; |
376 | new_vcc->sap = msg->sap; | 381 | new_vcc->sap = msg->sap; |
377 | error = vcc_connect(newsock, msg->pvc.sap_addr.itf, | 382 | error = vcc_connect(newsock, msg->pvc.sap_addr.itf, |
378 | msg->pvc.sap_addr.vpi, msg->pvc.sap_addr.vci); | 383 | msg->pvc.sap_addr.vpi, |
384 | msg->pvc.sap_addr.vci); | ||
379 | dev_kfree_skb(skb); | 385 | dev_kfree_skb(skb); |
380 | sk->sk_ack_backlog--; | 386 | sk->sk_ack_backlog--; |
381 | if (error) { | 387 | if (error) { |
382 | sigd_enq2(NULL,as_reject,old_vcc,NULL,NULL, | 388 | sigd_enq2(NULL, as_reject, old_vcc, NULL, NULL, |
383 | &old_vcc->qos,error); | 389 | &old_vcc->qos, error); |
384 | error = error == -EAGAIN ? -EBUSY : error; | 390 | error = error == -EAGAIN ? -EBUSY : error; |
385 | goto out; | 391 | goto out; |
386 | } | 392 | } |
387 | /* wait should be short, so we ignore the non-blocking flag */ | 393 | /* wait should be short, so we ignore the non-blocking flag */ |
388 | set_bit(ATM_VF_WAITING, &new_vcc->flags); | 394 | set_bit(ATM_VF_WAITING, &new_vcc->flags); |
389 | prepare_to_wait(sk_atm(new_vcc)->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 395 | prepare_to_wait(sk_atm(new_vcc)->sk_sleep, &wait, |
390 | sigd_enq(new_vcc,as_accept,old_vcc,NULL,NULL); | 396 | TASK_UNINTERRUPTIBLE); |
397 | sigd_enq(new_vcc, as_accept, old_vcc, NULL, NULL); | ||
391 | while (test_bit(ATM_VF_WAITING, &new_vcc->flags) && sigd) { | 398 | while (test_bit(ATM_VF_WAITING, &new_vcc->flags) && sigd) { |
392 | release_sock(sk); | 399 | release_sock(sk); |
393 | schedule(); | 400 | schedule(); |
394 | lock_sock(sk); | 401 | lock_sock(sk); |
395 | prepare_to_wait(sk_atm(new_vcc)->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 402 | prepare_to_wait(sk_atm(new_vcc)->sk_sleep, &wait, |
403 | TASK_UNINTERRUPTIBLE); | ||
396 | } | 404 | } |
397 | finish_wait(sk_atm(new_vcc)->sk_sleep, &wait); | 405 | finish_wait(sk_atm(new_vcc)->sk_sleep, &wait); |
398 | if (!sigd) { | 406 | if (!sigd) { |
@@ -412,39 +420,37 @@ out: | |||
412 | return error; | 420 | return error; |
413 | } | 421 | } |
414 | 422 | ||
415 | 423 | static int svc_getname(struct socket *sock, struct sockaddr *sockaddr, | |
416 | static int svc_getname(struct socket *sock,struct sockaddr *sockaddr, | 424 | int *sockaddr_len, int peer) |
417 | int *sockaddr_len,int peer) | ||
418 | { | 425 | { |
419 | struct sockaddr_atmsvc *addr; | 426 | struct sockaddr_atmsvc *addr; |
420 | 427 | ||
421 | *sockaddr_len = sizeof(struct sockaddr_atmsvc); | 428 | *sockaddr_len = sizeof(struct sockaddr_atmsvc); |
422 | addr = (struct sockaddr_atmsvc *) sockaddr; | 429 | addr = (struct sockaddr_atmsvc *) sockaddr; |
423 | memcpy(addr,peer ? &ATM_SD(sock)->remote : &ATM_SD(sock)->local, | 430 | memcpy(addr, peer ? &ATM_SD(sock)->remote : &ATM_SD(sock)->local, |
424 | sizeof(struct sockaddr_atmsvc)); | 431 | sizeof(struct sockaddr_atmsvc)); |
425 | return 0; | 432 | return 0; |
426 | } | 433 | } |
427 | 434 | ||
428 | 435 | int svc_change_qos(struct atm_vcc *vcc, struct atm_qos *qos) | |
429 | int svc_change_qos(struct atm_vcc *vcc,struct atm_qos *qos) | ||
430 | { | 436 | { |
431 | struct sock *sk = sk_atm(vcc); | 437 | struct sock *sk = sk_atm(vcc); |
432 | DEFINE_WAIT(wait); | 438 | DEFINE_WAIT(wait); |
433 | 439 | ||
434 | set_bit(ATM_VF_WAITING, &vcc->flags); | 440 | set_bit(ATM_VF_WAITING, &vcc->flags); |
435 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 441 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
436 | sigd_enq2(vcc,as_modify,NULL,NULL,&vcc->local,qos,0); | 442 | sigd_enq2(vcc, as_modify, NULL, NULL, &vcc->local, qos, 0); |
437 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && | 443 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && |
438 | !test_bit(ATM_VF_RELEASED, &vcc->flags) && sigd) { | 444 | !test_bit(ATM_VF_RELEASED, &vcc->flags) && sigd) { |
439 | schedule(); | 445 | schedule(); |
440 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 446 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
441 | } | 447 | } |
442 | finish_wait(sk->sk_sleep, &wait); | 448 | finish_wait(sk->sk_sleep, &wait); |
443 | if (!sigd) return -EUNATCH; | 449 | if (!sigd) |
450 | return -EUNATCH; | ||
444 | return -sk->sk_err; | 451 | return -sk->sk_err; |
445 | } | 452 | } |
446 | 453 | ||
447 | |||
448 | static int svc_setsockopt(struct socket *sock, int level, int optname, | 454 | static int svc_setsockopt(struct socket *sock, int level, int optname, |
449 | char __user *optval, unsigned int optlen) | 455 | char __user *optval, unsigned int optlen) |
450 | { | 456 | { |
@@ -454,37 +460,35 @@ static int svc_setsockopt(struct socket *sock, int level, int optname, | |||
454 | 460 | ||
455 | lock_sock(sk); | 461 | lock_sock(sk); |
456 | switch (optname) { | 462 | switch (optname) { |
457 | case SO_ATMSAP: | 463 | case SO_ATMSAP: |
458 | if (level != SOL_ATM || optlen != sizeof(struct atm_sap)) { | 464 | if (level != SOL_ATM || optlen != sizeof(struct atm_sap)) { |
459 | error = -EINVAL; | 465 | error = -EINVAL; |
460 | goto out; | 466 | goto out; |
461 | } | 467 | } |
462 | if (copy_from_user(&vcc->sap, optval, optlen)) { | 468 | if (copy_from_user(&vcc->sap, optval, optlen)) { |
463 | error = -EFAULT; | 469 | error = -EFAULT; |
464 | goto out; | 470 | goto out; |
465 | } | 471 | } |
466 | set_bit(ATM_VF_HASSAP, &vcc->flags); | 472 | set_bit(ATM_VF_HASSAP, &vcc->flags); |
467 | break; | 473 | break; |
468 | case SO_MULTIPOINT: | 474 | case SO_MULTIPOINT: |
469 | if (level != SOL_ATM || optlen != sizeof(int)) { | 475 | if (level != SOL_ATM || optlen != sizeof(int)) { |
470 | error = -EINVAL; | 476 | error = -EINVAL; |
471 | goto out; | 477 | goto out; |
472 | } | 478 | } |
473 | if (get_user(value, (int __user *) optval)) { | 479 | if (get_user(value, (int __user *)optval)) { |
474 | error = -EFAULT; | 480 | error = -EFAULT; |
475 | goto out; | 481 | goto out; |
476 | } | 482 | } |
477 | if (value == 1) { | 483 | if (value == 1) |
478 | set_bit(ATM_VF_SESSION, &vcc->flags); | 484 | set_bit(ATM_VF_SESSION, &vcc->flags); |
479 | } else if (value == 0) { | 485 | else if (value == 0) |
480 | clear_bit(ATM_VF_SESSION, &vcc->flags); | 486 | clear_bit(ATM_VF_SESSION, &vcc->flags); |
481 | } else { | 487 | else |
482 | error = -EINVAL; | 488 | error = -EINVAL; |
483 | } | 489 | break; |
484 | break; | 490 | default: |
485 | default: | 491 | error = vcc_setsockopt(sock, level, optname, optval, optlen); |
486 | error = vcc_setsockopt(sock, level, optname, | ||
487 | optval, optlen); | ||
488 | } | 492 | } |
489 | 493 | ||
490 | out: | 494 | out: |
@@ -492,9 +496,8 @@ out: | |||
492 | return error; | 496 | return error; |
493 | } | 497 | } |
494 | 498 | ||
495 | 499 | static int svc_getsockopt(struct socket *sock, int level, int optname, | |
496 | static int svc_getsockopt(struct socket *sock,int level,int optname, | 500 | char __user *optval, int __user *optlen) |
497 | char __user *optval,int __user *optlen) | ||
498 | { | 501 | { |
499 | struct sock *sk = sock->sk; | 502 | struct sock *sk = sock->sk; |
500 | int error = 0, len; | 503 | int error = 0, len; |
@@ -521,7 +524,6 @@ out: | |||
521 | return error; | 524 | return error; |
522 | } | 525 | } |
523 | 526 | ||
524 | |||
525 | static int svc_addparty(struct socket *sock, struct sockaddr *sockaddr, | 527 | static int svc_addparty(struct socket *sock, struct sockaddr *sockaddr, |
526 | int sockaddr_len, int flags) | 528 | int sockaddr_len, int flags) |
527 | { | 529 | { |
@@ -540,7 +542,7 @@ static int svc_addparty(struct socket *sock, struct sockaddr *sockaddr, | |||
540 | error = -EINPROGRESS; | 542 | error = -EINPROGRESS; |
541 | goto out; | 543 | goto out; |
542 | } | 544 | } |
543 | pr_debug("svc_addparty added wait queue\n"); | 545 | pr_debug("added wait queue\n"); |
544 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { | 546 | while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) { |
545 | schedule(); | 547 | schedule(); |
546 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 548 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
@@ -552,7 +554,6 @@ out: | |||
552 | return error; | 554 | return error; |
553 | } | 555 | } |
554 | 556 | ||
555 | |||
556 | static int svc_dropparty(struct socket *sock, int ep_ref) | 557 | static int svc_dropparty(struct socket *sock, int ep_ref) |
557 | { | 558 | { |
558 | DEFINE_WAIT(wait); | 559 | DEFINE_WAIT(wait); |
@@ -579,7 +580,6 @@ out: | |||
579 | return error; | 580 | return error; |
580 | } | 581 | } |
581 | 582 | ||
582 | |||
583 | static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 583 | static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
584 | { | 584 | { |
585 | int error, ep_ref; | 585 | int error, ep_ref; |
@@ -587,29 +587,31 @@ static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
587 | struct atm_vcc *vcc = ATM_SD(sock); | 587 | struct atm_vcc *vcc = ATM_SD(sock); |
588 | 588 | ||
589 | switch (cmd) { | 589 | switch (cmd) { |
590 | case ATM_ADDPARTY: | 590 | case ATM_ADDPARTY: |
591 | if (!test_bit(ATM_VF_SESSION, &vcc->flags)) | 591 | if (!test_bit(ATM_VF_SESSION, &vcc->flags)) |
592 | return -EINVAL; | 592 | return -EINVAL; |
593 | if (copy_from_user(&sa, (void __user *) arg, sizeof(sa))) | 593 | if (copy_from_user(&sa, (void __user *) arg, sizeof(sa))) |
594 | return -EFAULT; | 594 | return -EFAULT; |
595 | error = svc_addparty(sock, (struct sockaddr *) &sa, sizeof(sa), 0); | 595 | error = svc_addparty(sock, (struct sockaddr *)&sa, sizeof(sa), |
596 | break; | 596 | 0); |
597 | case ATM_DROPPARTY: | 597 | break; |
598 | if (!test_bit(ATM_VF_SESSION, &vcc->flags)) | 598 | case ATM_DROPPARTY: |
599 | return -EINVAL; | 599 | if (!test_bit(ATM_VF_SESSION, &vcc->flags)) |
600 | if (copy_from_user(&ep_ref, (void __user *) arg, sizeof(int))) | 600 | return -EINVAL; |
601 | return -EFAULT; | 601 | if (copy_from_user(&ep_ref, (void __user *) arg, sizeof(int))) |
602 | error = svc_dropparty(sock, ep_ref); | 602 | return -EFAULT; |
603 | break; | 603 | error = svc_dropparty(sock, ep_ref); |
604 | default: | 604 | break; |
605 | error = vcc_ioctl(sock, cmd, arg); | 605 | default: |
606 | error = vcc_ioctl(sock, cmd, arg); | ||
606 | } | 607 | } |
607 | 608 | ||
608 | return error; | 609 | return error; |
609 | } | 610 | } |
610 | 611 | ||
611 | #ifdef CONFIG_COMPAT | 612 | #ifdef CONFIG_COMPAT |
612 | static int svc_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 613 | static int svc_compat_ioctl(struct socket *sock, unsigned int cmd, |
614 | unsigned long arg) | ||
613 | { | 615 | { |
614 | /* The definition of ATM_ADDPARTY uses the size of struct atm_iobuf. | 616 | /* The definition of ATM_ADDPARTY uses the size of struct atm_iobuf. |
615 | But actually it takes a struct sockaddr_atmsvc, which doesn't need | 617 | But actually it takes a struct sockaddr_atmsvc, which doesn't need |
@@ -660,13 +662,13 @@ static int svc_create(struct net *net, struct socket *sock, int protocol, | |||
660 | 662 | ||
661 | sock->ops = &svc_proto_ops; | 663 | sock->ops = &svc_proto_ops; |
662 | error = vcc_create(net, sock, protocol, AF_ATMSVC); | 664 | error = vcc_create(net, sock, protocol, AF_ATMSVC); |
663 | if (error) return error; | 665 | if (error) |
666 | return error; | ||
664 | ATM_SD(sock)->local.sas_family = AF_ATMSVC; | 667 | ATM_SD(sock)->local.sas_family = AF_ATMSVC; |
665 | ATM_SD(sock)->remote.sas_family = AF_ATMSVC; | 668 | ATM_SD(sock)->remote.sas_family = AF_ATMSVC; |
666 | return 0; | 669 | return 0; |
667 | } | 670 | } |
668 | 671 | ||
669 | |||
670 | static const struct net_proto_family svc_family_ops = { | 672 | static const struct net_proto_family svc_family_ops = { |
671 | .family = PF_ATMSVC, | 673 | .family = PF_ATMSVC, |
672 | .create = svc_create, | 674 | .create = svc_create, |
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c index 97f8d68d574d..3487cfe74aec 100644 --- a/net/bluetooth/cmtp/capi.c +++ b/net/bluetooth/cmtp/capi.c | |||
@@ -21,7 +21,8 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | 24 | #include <linux/proc_fs.h> | |
25 | #include <linux/seq_file.h> | ||
25 | #include <linux/types.h> | 26 | #include <linux/types.h> |
26 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
27 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -516,33 +517,37 @@ static char *cmtp_procinfo(struct capi_ctr *ctrl) | |||
516 | return "CAPI Message Transport Protocol"; | 517 | return "CAPI Message Transport Protocol"; |
517 | } | 518 | } |
518 | 519 | ||
519 | static int cmtp_ctr_read_proc(char *page, char **start, off_t off, int count, int *eof, struct capi_ctr *ctrl) | 520 | static int cmtp_proc_show(struct seq_file *m, void *v) |
520 | { | 521 | { |
522 | struct capi_ctr *ctrl = m->private; | ||
521 | struct cmtp_session *session = ctrl->driverdata; | 523 | struct cmtp_session *session = ctrl->driverdata; |
522 | struct cmtp_application *app; | 524 | struct cmtp_application *app; |
523 | struct list_head *p, *n; | 525 | struct list_head *p, *n; |
524 | int len = 0; | ||
525 | 526 | ||
526 | len += sprintf(page + len, "%s\n\n", cmtp_procinfo(ctrl)); | 527 | seq_printf(m, "%s\n\n", cmtp_procinfo(ctrl)); |
527 | len += sprintf(page + len, "addr %s\n", session->name); | 528 | seq_printf(m, "addr %s\n", session->name); |
528 | len += sprintf(page + len, "ctrl %d\n", session->num); | 529 | seq_printf(m, "ctrl %d\n", session->num); |
529 | 530 | ||
530 | list_for_each_safe(p, n, &session->applications) { | 531 | list_for_each_safe(p, n, &session->applications) { |
531 | app = list_entry(p, struct cmtp_application, list); | 532 | app = list_entry(p, struct cmtp_application, list); |
532 | len += sprintf(page + len, "appl %d -> %d\n", app->appl, app->mapping); | 533 | seq_printf(m, "appl %d -> %d\n", app->appl, app->mapping); |
533 | } | 534 | } |
534 | 535 | ||
535 | if (off + count >= len) | 536 | return 0; |
536 | *eof = 1; | 537 | } |
537 | |||
538 | if (len < off) | ||
539 | return 0; | ||
540 | |||
541 | *start = page + off; | ||
542 | 538 | ||
543 | return ((count < len - off) ? count : len - off); | 539 | static int cmtp_proc_open(struct inode *inode, struct file *file) |
540 | { | ||
541 | return single_open(file, cmtp_proc_show, PDE(inode)->data); | ||
544 | } | 542 | } |
545 | 543 | ||
544 | static const struct file_operations cmtp_proc_fops = { | ||
545 | .owner = THIS_MODULE, | ||
546 | .open = cmtp_proc_open, | ||
547 | .read = seq_read, | ||
548 | .llseek = seq_lseek, | ||
549 | .release = single_release, | ||
550 | }; | ||
546 | 551 | ||
547 | int cmtp_attach_device(struct cmtp_session *session) | 552 | int cmtp_attach_device(struct cmtp_session *session) |
548 | { | 553 | { |
@@ -582,7 +587,7 @@ int cmtp_attach_device(struct cmtp_session *session) | |||
582 | session->ctrl.send_message = cmtp_send_message; | 587 | session->ctrl.send_message = cmtp_send_message; |
583 | 588 | ||
584 | session->ctrl.procinfo = cmtp_procinfo; | 589 | session->ctrl.procinfo = cmtp_procinfo; |
585 | session->ctrl.ctr_read_proc = cmtp_ctr_read_proc; | 590 | session->ctrl.proc_fops = &cmtp_proc_fops; |
586 | 591 | ||
587 | if (attach_capi_ctr(&session->ctrl) < 0) { | 592 | if (attach_capi_ctr(&session->ctrl) < 0) { |
588 | BT_ERR("Can't attach new controller"); | 593 | BT_ERR("Can't attach new controller"); |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index a2cbe61f6e65..7bc0604069c7 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -467,7 +467,7 @@ int br_del_if(struct net_bridge *br, struct net_device *dev) | |||
467 | return 0; | 467 | return 0; |
468 | } | 468 | } |
469 | 469 | ||
470 | void br_net_exit(struct net *net) | 470 | void __net_exit br_net_exit(struct net *net) |
471 | { | 471 | { |
472 | struct net_device *dev; | 472 | struct net_device *dev; |
473 | LIST_HEAD(list); | 473 | LIST_HEAD(list); |
diff --git a/net/can/af_can.c b/net/can/af_can.c index 51adc4c2b860..bc18b084ffdb 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c | |||
@@ -77,8 +77,8 @@ static int stats_timer __read_mostly = 1; | |||
77 | module_param(stats_timer, int, S_IRUGO); | 77 | module_param(stats_timer, int, S_IRUGO); |
78 | MODULE_PARM_DESC(stats_timer, "enable timer for statistics (default:on)"); | 78 | MODULE_PARM_DESC(stats_timer, "enable timer for statistics (default:on)"); |
79 | 79 | ||
80 | HLIST_HEAD(can_rx_dev_list); | 80 | /* receive filters subscribed for 'all' CAN devices */ |
81 | static struct dev_rcv_lists can_rx_alldev_list; | 81 | struct dev_rcv_lists can_rx_alldev_list; |
82 | static DEFINE_SPINLOCK(can_rcvlists_lock); | 82 | static DEFINE_SPINLOCK(can_rcvlists_lock); |
83 | 83 | ||
84 | static struct kmem_cache *rcv_cache __read_mostly; | 84 | static struct kmem_cache *rcv_cache __read_mostly; |
@@ -292,28 +292,10 @@ EXPORT_SYMBOL(can_send); | |||
292 | 292 | ||
293 | static struct dev_rcv_lists *find_dev_rcv_lists(struct net_device *dev) | 293 | static struct dev_rcv_lists *find_dev_rcv_lists(struct net_device *dev) |
294 | { | 294 | { |
295 | struct dev_rcv_lists *d = NULL; | 295 | if (!dev) |
296 | struct hlist_node *n; | 296 | return &can_rx_alldev_list; |
297 | 297 | else | |
298 | /* | 298 | return (struct dev_rcv_lists *)dev->ml_priv; |
299 | * find receive list for this device | ||
300 | * | ||
301 | * The hlist_for_each_entry*() macros curse through the list | ||
302 | * using the pointer variable n and set d to the containing | ||
303 | * struct in each list iteration. Therefore, after list | ||
304 | * iteration, d is unmodified when the list is empty, and it | ||
305 | * points to last list element, when the list is non-empty | ||
306 | * but no match in the loop body is found. I.e. d is *not* | ||
307 | * NULL when no match is found. We can, however, use the | ||
308 | * cursor variable n to decide if a match was found. | ||
309 | */ | ||
310 | |||
311 | hlist_for_each_entry_rcu(d, n, &can_rx_dev_list, list) { | ||
312 | if (d->dev == dev) | ||
313 | break; | ||
314 | } | ||
315 | |||
316 | return n ? d : NULL; | ||
317 | } | 299 | } |
318 | 300 | ||
319 | /** | 301 | /** |
@@ -468,16 +450,6 @@ int can_rx_register(struct net_device *dev, canid_t can_id, canid_t mask, | |||
468 | EXPORT_SYMBOL(can_rx_register); | 450 | EXPORT_SYMBOL(can_rx_register); |
469 | 451 | ||
470 | /* | 452 | /* |
471 | * can_rx_delete_device - rcu callback for dev_rcv_lists structure removal | ||
472 | */ | ||
473 | static void can_rx_delete_device(struct rcu_head *rp) | ||
474 | { | ||
475 | struct dev_rcv_lists *d = container_of(rp, struct dev_rcv_lists, rcu); | ||
476 | |||
477 | kfree(d); | ||
478 | } | ||
479 | |||
480 | /* | ||
481 | * can_rx_delete_receiver - rcu callback for single receiver entry removal | 453 | * can_rx_delete_receiver - rcu callback for single receiver entry removal |
482 | */ | 454 | */ |
483 | static void can_rx_delete_receiver(struct rcu_head *rp) | 455 | static void can_rx_delete_receiver(struct rcu_head *rp) |
@@ -541,7 +513,6 @@ void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask, | |||
541 | "dev %s, id %03X, mask %03X\n", | 513 | "dev %s, id %03X, mask %03X\n", |
542 | DNAME(dev), can_id, mask); | 514 | DNAME(dev), can_id, mask); |
543 | r = NULL; | 515 | r = NULL; |
544 | d = NULL; | ||
545 | goto out; | 516 | goto out; |
546 | } | 517 | } |
547 | 518 | ||
@@ -552,10 +523,10 @@ void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask, | |||
552 | can_pstats.rcv_entries--; | 523 | can_pstats.rcv_entries--; |
553 | 524 | ||
554 | /* remove device structure requested by NETDEV_UNREGISTER */ | 525 | /* remove device structure requested by NETDEV_UNREGISTER */ |
555 | if (d->remove_on_zero_entries && !d->entries) | 526 | if (d->remove_on_zero_entries && !d->entries) { |
556 | hlist_del_rcu(&d->list); | 527 | kfree(d); |
557 | else | 528 | dev->ml_priv = NULL; |
558 | d = NULL; | 529 | } |
559 | 530 | ||
560 | out: | 531 | out: |
561 | spin_unlock(&can_rcvlists_lock); | 532 | spin_unlock(&can_rcvlists_lock); |
@@ -563,10 +534,6 @@ void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask, | |||
563 | /* schedule the receiver item for deletion */ | 534 | /* schedule the receiver item for deletion */ |
564 | if (r) | 535 | if (r) |
565 | call_rcu(&r->rcu, can_rx_delete_receiver); | 536 | call_rcu(&r->rcu, can_rx_delete_receiver); |
566 | |||
567 | /* schedule the device structure for deletion */ | ||
568 | if (d) | ||
569 | call_rcu(&d->rcu, can_rx_delete_device); | ||
570 | } | 537 | } |
571 | EXPORT_SYMBOL(can_rx_unregister); | 538 | EXPORT_SYMBOL(can_rx_unregister); |
572 | 539 | ||
@@ -780,48 +747,35 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg, | |||
780 | 747 | ||
781 | case NETDEV_REGISTER: | 748 | case NETDEV_REGISTER: |
782 | 749 | ||
783 | /* | 750 | /* create new dev_rcv_lists for this device */ |
784 | * create new dev_rcv_lists for this device | ||
785 | * | ||
786 | * N.B. zeroing the struct is the correct initialization | ||
787 | * for the embedded hlist_head structs. | ||
788 | * Another list type, e.g. list_head, would require | ||
789 | * explicit initialization. | ||
790 | */ | ||
791 | |||
792 | d = kzalloc(sizeof(*d), GFP_KERNEL); | 751 | d = kzalloc(sizeof(*d), GFP_KERNEL); |
793 | if (!d) { | 752 | if (!d) { |
794 | printk(KERN_ERR | 753 | printk(KERN_ERR |
795 | "can: allocation of receive list failed\n"); | 754 | "can: allocation of receive list failed\n"); |
796 | return NOTIFY_DONE; | 755 | return NOTIFY_DONE; |
797 | } | 756 | } |
798 | d->dev = dev; | 757 | BUG_ON(dev->ml_priv); |
799 | 758 | dev->ml_priv = d; | |
800 | spin_lock(&can_rcvlists_lock); | ||
801 | hlist_add_head_rcu(&d->list, &can_rx_dev_list); | ||
802 | spin_unlock(&can_rcvlists_lock); | ||
803 | 759 | ||
804 | break; | 760 | break; |
805 | 761 | ||
806 | case NETDEV_UNREGISTER: | 762 | case NETDEV_UNREGISTER: |
807 | spin_lock(&can_rcvlists_lock); | 763 | spin_lock(&can_rcvlists_lock); |
808 | 764 | ||
809 | d = find_dev_rcv_lists(dev); | 765 | d = dev->ml_priv; |
810 | if (d) { | 766 | if (d) { |
811 | if (d->entries) { | 767 | if (d->entries) |
812 | d->remove_on_zero_entries = 1; | 768 | d->remove_on_zero_entries = 1; |
813 | d = NULL; | 769 | else { |
814 | } else | 770 | kfree(d); |
815 | hlist_del_rcu(&d->list); | 771 | dev->ml_priv = NULL; |
772 | } | ||
816 | } else | 773 | } else |
817 | printk(KERN_ERR "can: notifier: receive list not " | 774 | printk(KERN_ERR "can: notifier: receive list not " |
818 | "found for dev %s\n", dev->name); | 775 | "found for dev %s\n", dev->name); |
819 | 776 | ||
820 | spin_unlock(&can_rcvlists_lock); | 777 | spin_unlock(&can_rcvlists_lock); |
821 | 778 | ||
822 | if (d) | ||
823 | call_rcu(&d->rcu, can_rx_delete_device); | ||
824 | |||
825 | break; | 779 | break; |
826 | } | 780 | } |
827 | 781 | ||
@@ -853,21 +807,13 @@ static __init int can_init(void) | |||
853 | { | 807 | { |
854 | printk(banner); | 808 | printk(banner); |
855 | 809 | ||
810 | memset(&can_rx_alldev_list, 0, sizeof(can_rx_alldev_list)); | ||
811 | |||
856 | rcv_cache = kmem_cache_create("can_receiver", sizeof(struct receiver), | 812 | rcv_cache = kmem_cache_create("can_receiver", sizeof(struct receiver), |
857 | 0, 0, NULL); | 813 | 0, 0, NULL); |
858 | if (!rcv_cache) | 814 | if (!rcv_cache) |
859 | return -ENOMEM; | 815 | return -ENOMEM; |
860 | 816 | ||
861 | /* | ||
862 | * Insert can_rx_alldev_list for reception on all devices. | ||
863 | * This struct is zero initialized which is correct for the | ||
864 | * embedded hlist heads, the dev pointer, and the entries counter. | ||
865 | */ | ||
866 | |||
867 | spin_lock(&can_rcvlists_lock); | ||
868 | hlist_add_head_rcu(&can_rx_alldev_list.list, &can_rx_dev_list); | ||
869 | spin_unlock(&can_rcvlists_lock); | ||
870 | |||
871 | if (stats_timer) { | 817 | if (stats_timer) { |
872 | /* the statistics are updated every second (timer triggered) */ | 818 | /* the statistics are updated every second (timer triggered) */ |
873 | setup_timer(&can_stattimer, can_stat_update, 0); | 819 | setup_timer(&can_stattimer, can_stat_update, 0); |
@@ -887,8 +833,7 @@ static __init int can_init(void) | |||
887 | 833 | ||
888 | static __exit void can_exit(void) | 834 | static __exit void can_exit(void) |
889 | { | 835 | { |
890 | struct dev_rcv_lists *d; | 836 | struct net_device *dev; |
891 | struct hlist_node *n, *next; | ||
892 | 837 | ||
893 | if (stats_timer) | 838 | if (stats_timer) |
894 | del_timer(&can_stattimer); | 839 | del_timer(&can_stattimer); |
@@ -900,14 +845,19 @@ static __exit void can_exit(void) | |||
900 | unregister_netdevice_notifier(&can_netdev_notifier); | 845 | unregister_netdevice_notifier(&can_netdev_notifier); |
901 | sock_unregister(PF_CAN); | 846 | sock_unregister(PF_CAN); |
902 | 847 | ||
903 | /* remove can_rx_dev_list */ | 848 | /* remove created dev_rcv_lists from still registered CAN devices */ |
904 | spin_lock(&can_rcvlists_lock); | 849 | rcu_read_lock(); |
905 | hlist_del(&can_rx_alldev_list.list); | 850 | for_each_netdev_rcu(&init_net, dev) { |
906 | hlist_for_each_entry_safe(d, n, next, &can_rx_dev_list, list) { | 851 | if (dev->type == ARPHRD_CAN && dev->ml_priv){ |
907 | hlist_del(&d->list); | 852 | |
908 | kfree(d); | 853 | struct dev_rcv_lists *d = dev->ml_priv; |
854 | |||
855 | BUG_ON(d->entries); | ||
856 | kfree(d); | ||
857 | dev->ml_priv = NULL; | ||
858 | } | ||
909 | } | 859 | } |
910 | spin_unlock(&can_rcvlists_lock); | 860 | rcu_read_unlock(); |
911 | 861 | ||
912 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | 862 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
913 | 863 | ||
diff --git a/net/can/af_can.h b/net/can/af_can.h index 18f91e37cc30..34253b84e30f 100644 --- a/net/can/af_can.h +++ b/net/can/af_can.h | |||
@@ -63,10 +63,8 @@ struct receiver { | |||
63 | 63 | ||
64 | enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_EFF, RX_MAX }; | 64 | enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_EFF, RX_MAX }; |
65 | 65 | ||
66 | /* per device receive filters linked at dev->ml_priv */ | ||
66 | struct dev_rcv_lists { | 67 | struct dev_rcv_lists { |
67 | struct hlist_node list; | ||
68 | struct rcu_head rcu; | ||
69 | struct net_device *dev; | ||
70 | struct hlist_head rx[RX_MAX]; | 68 | struct hlist_head rx[RX_MAX]; |
71 | struct hlist_head rx_sff[0x800]; | 69 | struct hlist_head rx_sff[0x800]; |
72 | int remove_on_zero_entries; | 70 | int remove_on_zero_entries; |
diff --git a/net/can/proc.c b/net/can/proc.c index 9b9ad29be567..f4265cc9c3fb 100644 --- a/net/can/proc.c +++ b/net/can/proc.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/proc_fs.h> | 45 | #include <linux/proc_fs.h> |
46 | #include <linux/list.h> | 46 | #include <linux/list.h> |
47 | #include <linux/rcupdate.h> | 47 | #include <linux/rcupdate.h> |
48 | #include <linux/if_arp.h> | ||
48 | #include <linux/can/core.h> | 49 | #include <linux/can/core.h> |
49 | 50 | ||
50 | #include "af_can.h" | 51 | #include "af_can.h" |
@@ -84,6 +85,9 @@ static const char rx_list_name[][8] = { | |||
84 | [RX_EFF] = "rx_eff", | 85 | [RX_EFF] = "rx_eff", |
85 | }; | 86 | }; |
86 | 87 | ||
88 | /* receive filters subscribed for 'all' CAN devices */ | ||
89 | extern struct dev_rcv_lists can_rx_alldev_list; | ||
90 | |||
87 | /* | 91 | /* |
88 | * af_can statistics stuff | 92 | * af_can statistics stuff |
89 | */ | 93 | */ |
@@ -190,10 +194,6 @@ void can_stat_update(unsigned long data) | |||
190 | 194 | ||
191 | /* | 195 | /* |
192 | * proc read functions | 196 | * proc read functions |
193 | * | ||
194 | * From known use-cases we expect about 10 entries in a receive list to be | ||
195 | * printed in the proc_fs. So PAGE_SIZE is definitely enough space here. | ||
196 | * | ||
197 | */ | 197 | */ |
198 | 198 | ||
199 | static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list, | 199 | static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list, |
@@ -202,7 +202,6 @@ static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list, | |||
202 | struct receiver *r; | 202 | struct receiver *r; |
203 | struct hlist_node *n; | 203 | struct hlist_node *n; |
204 | 204 | ||
205 | rcu_read_lock(); | ||
206 | hlist_for_each_entry_rcu(r, n, rx_list, list) { | 205 | hlist_for_each_entry_rcu(r, n, rx_list, list) { |
207 | char *fmt = (r->can_id & CAN_EFF_FLAG)? | 206 | char *fmt = (r->can_id & CAN_EFF_FLAG)? |
208 | " %-5s %08X %08x %08x %08x %8ld %s\n" : | 207 | " %-5s %08X %08x %08x %08x %8ld %s\n" : |
@@ -212,7 +211,6 @@ static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list, | |||
212 | (unsigned long)r->func, (unsigned long)r->data, | 211 | (unsigned long)r->func, (unsigned long)r->data, |
213 | r->matches, r->ident); | 212 | r->matches, r->ident); |
214 | } | 213 | } |
215 | rcu_read_unlock(); | ||
216 | } | 214 | } |
217 | 215 | ||
218 | static void can_print_recv_banner(struct seq_file *m) | 216 | static void can_print_recv_banner(struct seq_file *m) |
@@ -346,24 +344,39 @@ static const struct file_operations can_version_proc_fops = { | |||
346 | .release = single_release, | 344 | .release = single_release, |
347 | }; | 345 | }; |
348 | 346 | ||
347 | static inline void can_rcvlist_proc_show_one(struct seq_file *m, int idx, | ||
348 | struct net_device *dev, | ||
349 | struct dev_rcv_lists *d) | ||
350 | { | ||
351 | if (!hlist_empty(&d->rx[idx])) { | ||
352 | can_print_recv_banner(m); | ||
353 | can_print_rcvlist(m, &d->rx[idx], dev); | ||
354 | } else | ||
355 | seq_printf(m, " (%s: no entry)\n", DNAME(dev)); | ||
356 | |||
357 | } | ||
358 | |||
349 | static int can_rcvlist_proc_show(struct seq_file *m, void *v) | 359 | static int can_rcvlist_proc_show(struct seq_file *m, void *v) |
350 | { | 360 | { |
351 | /* double cast to prevent GCC warning */ | 361 | /* double cast to prevent GCC warning */ |
352 | int idx = (int)(long)m->private; | 362 | int idx = (int)(long)m->private; |
363 | struct net_device *dev; | ||
353 | struct dev_rcv_lists *d; | 364 | struct dev_rcv_lists *d; |
354 | struct hlist_node *n; | ||
355 | 365 | ||
356 | seq_printf(m, "\nreceive list '%s':\n", rx_list_name[idx]); | 366 | seq_printf(m, "\nreceive list '%s':\n", rx_list_name[idx]); |
357 | 367 | ||
358 | rcu_read_lock(); | 368 | rcu_read_lock(); |
359 | hlist_for_each_entry_rcu(d, n, &can_rx_dev_list, list) { | ||
360 | 369 | ||
361 | if (!hlist_empty(&d->rx[idx])) { | 370 | /* receive list for 'all' CAN devices (dev == NULL) */ |
362 | can_print_recv_banner(m); | 371 | d = &can_rx_alldev_list; |
363 | can_print_rcvlist(m, &d->rx[idx], d->dev); | 372 | can_rcvlist_proc_show_one(m, idx, NULL, d); |
364 | } else | 373 | |
365 | seq_printf(m, " (%s: no entry)\n", DNAME(d->dev)); | 374 | /* receive list for registered CAN devices */ |
375 | for_each_netdev_rcu(&init_net, dev) { | ||
376 | if (dev->type == ARPHRD_CAN && dev->ml_priv) | ||
377 | can_rcvlist_proc_show_one(m, idx, dev, dev->ml_priv); | ||
366 | } | 378 | } |
379 | |||
367 | rcu_read_unlock(); | 380 | rcu_read_unlock(); |
368 | 381 | ||
369 | seq_putc(m, '\n'); | 382 | seq_putc(m, '\n'); |
@@ -383,34 +396,50 @@ static const struct file_operations can_rcvlist_proc_fops = { | |||
383 | .release = single_release, | 396 | .release = single_release, |
384 | }; | 397 | }; |
385 | 398 | ||
399 | static inline void can_rcvlist_sff_proc_show_one(struct seq_file *m, | ||
400 | struct net_device *dev, | ||
401 | struct dev_rcv_lists *d) | ||
402 | { | ||
403 | int i; | ||
404 | int all_empty = 1; | ||
405 | |||
406 | /* check wether at least one list is non-empty */ | ||
407 | for (i = 0; i < 0x800; i++) | ||
408 | if (!hlist_empty(&d->rx_sff[i])) { | ||
409 | all_empty = 0; | ||
410 | break; | ||
411 | } | ||
412 | |||
413 | if (!all_empty) { | ||
414 | can_print_recv_banner(m); | ||
415 | for (i = 0; i < 0x800; i++) { | ||
416 | if (!hlist_empty(&d->rx_sff[i])) | ||
417 | can_print_rcvlist(m, &d->rx_sff[i], dev); | ||
418 | } | ||
419 | } else | ||
420 | seq_printf(m, " (%s: no entry)\n", DNAME(dev)); | ||
421 | } | ||
422 | |||
386 | static int can_rcvlist_sff_proc_show(struct seq_file *m, void *v) | 423 | static int can_rcvlist_sff_proc_show(struct seq_file *m, void *v) |
387 | { | 424 | { |
425 | struct net_device *dev; | ||
388 | struct dev_rcv_lists *d; | 426 | struct dev_rcv_lists *d; |
389 | struct hlist_node *n; | ||
390 | 427 | ||
391 | /* RX_SFF */ | 428 | /* RX_SFF */ |
392 | seq_puts(m, "\nreceive list 'rx_sff':\n"); | 429 | seq_puts(m, "\nreceive list 'rx_sff':\n"); |
393 | 430 | ||
394 | rcu_read_lock(); | 431 | rcu_read_lock(); |
395 | hlist_for_each_entry_rcu(d, n, &can_rx_dev_list, list) { | 432 | |
396 | int i, all_empty = 1; | 433 | /* sff receive list for 'all' CAN devices (dev == NULL) */ |
397 | /* check wether at least one list is non-empty */ | 434 | d = &can_rx_alldev_list; |
398 | for (i = 0; i < 0x800; i++) | 435 | can_rcvlist_sff_proc_show_one(m, NULL, d); |
399 | if (!hlist_empty(&d->rx_sff[i])) { | 436 | |
400 | all_empty = 0; | 437 | /* sff receive list for registered CAN devices */ |
401 | break; | 438 | for_each_netdev_rcu(&init_net, dev) { |
402 | } | 439 | if (dev->type == ARPHRD_CAN && dev->ml_priv) |
403 | 440 | can_rcvlist_sff_proc_show_one(m, dev, dev->ml_priv); | |
404 | if (!all_empty) { | ||
405 | can_print_recv_banner(m); | ||
406 | for (i = 0; i < 0x800; i++) { | ||
407 | if (!hlist_empty(&d->rx_sff[i])) | ||
408 | can_print_rcvlist(m, &d->rx_sff[i], | ||
409 | d->dev); | ||
410 | } | ||
411 | } else | ||
412 | seq_printf(m, " (%s: no entry)\n", DNAME(d->dev)); | ||
413 | } | 441 | } |
442 | |||
414 | rcu_read_unlock(); | 443 | rcu_read_unlock(); |
415 | 444 | ||
416 | seq_putc(m, '\n'); | 445 | seq_putc(m, '\n'); |
diff --git a/net/core/dev.c b/net/core/dev.c index be9924f60ec3..2cba5c521e56 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1853,6 +1853,14 @@ gso: | |||
1853 | 1853 | ||
1854 | skb->next = nskb->next; | 1854 | skb->next = nskb->next; |
1855 | nskb->next = NULL; | 1855 | nskb->next = NULL; |
1856 | |||
1857 | /* | ||
1858 | * If device doesnt need nskb->dst, release it right now while | ||
1859 | * its hot in this cpu cache | ||
1860 | */ | ||
1861 | if (dev->priv_flags & IFF_XMIT_DST_RELEASE) | ||
1862 | skb_dst_drop(nskb); | ||
1863 | |||
1856 | rc = ops->ndo_start_xmit(nskb, dev); | 1864 | rc = ops->ndo_start_xmit(nskb, dev); |
1857 | if (unlikely(rc != NETDEV_TX_OK)) { | 1865 | if (unlikely(rc != NETDEV_TX_OK)) { |
1858 | if (rc & ~NETDEV_TX_MASK) | 1866 | if (rc & ~NETDEV_TX_MASK) |
@@ -1974,6 +1982,21 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, | |||
1974 | return rc; | 1982 | return rc; |
1975 | } | 1983 | } |
1976 | 1984 | ||
1985 | /* | ||
1986 | * Returns true if either: | ||
1987 | * 1. skb has frag_list and the device doesn't support FRAGLIST, or | ||
1988 | * 2. skb is fragmented and the device does not support SG, or if | ||
1989 | * at least one of fragments is in highmem and device does not | ||
1990 | * support DMA from it. | ||
1991 | */ | ||
1992 | static inline int skb_needs_linearize(struct sk_buff *skb, | ||
1993 | struct net_device *dev) | ||
1994 | { | ||
1995 | return (skb_has_frags(skb) && !(dev->features & NETIF_F_FRAGLIST)) || | ||
1996 | (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) || | ||
1997 | illegal_highdma(dev, skb))); | ||
1998 | } | ||
1999 | |||
1977 | /** | 2000 | /** |
1978 | * dev_queue_xmit - transmit a buffer | 2001 | * dev_queue_xmit - transmit a buffer |
1979 | * @skb: buffer to transmit | 2002 | * @skb: buffer to transmit |
@@ -2010,18 +2033,8 @@ int dev_queue_xmit(struct sk_buff *skb) | |||
2010 | if (netif_needs_gso(dev, skb)) | 2033 | if (netif_needs_gso(dev, skb)) |
2011 | goto gso; | 2034 | goto gso; |
2012 | 2035 | ||
2013 | if (skb_has_frags(skb) && | 2036 | /* Convert a paged skb to linear, if required */ |
2014 | !(dev->features & NETIF_F_FRAGLIST) && | 2037 | if (skb_needs_linearize(skb, dev) && __skb_linearize(skb)) |
2015 | __skb_linearize(skb)) | ||
2016 | goto out_kfree_skb; | ||
2017 | |||
2018 | /* Fragmented skb is linearized if device does not support SG, | ||
2019 | * or if at least one of fragments is in highmem and device | ||
2020 | * does not support DMA from it. | ||
2021 | */ | ||
2022 | if (skb_shinfo(skb)->nr_frags && | ||
2023 | (!(dev->features & NETIF_F_SG) || illegal_highdma(dev, skb)) && | ||
2024 | __skb_linearize(skb)) | ||
2025 | goto out_kfree_skb; | 2038 | goto out_kfree_skb; |
2026 | 2039 | ||
2027 | /* If packet is not checksummed and device does not support | 2040 | /* If packet is not checksummed and device does not support |
@@ -2422,6 +2435,7 @@ int netif_receive_skb(struct sk_buff *skb) | |||
2422 | struct packet_type *ptype, *pt_prev; | 2435 | struct packet_type *ptype, *pt_prev; |
2423 | struct net_device *orig_dev; | 2436 | struct net_device *orig_dev; |
2424 | struct net_device *null_or_orig; | 2437 | struct net_device *null_or_orig; |
2438 | struct net_device *null_or_bond; | ||
2425 | int ret = NET_RX_DROP; | 2439 | int ret = NET_RX_DROP; |
2426 | __be16 type; | 2440 | __be16 type; |
2427 | 2441 | ||
@@ -2487,12 +2501,24 @@ ncls: | |||
2487 | if (!skb) | 2501 | if (!skb) |
2488 | goto out; | 2502 | goto out; |
2489 | 2503 | ||
2504 | /* | ||
2505 | * Make sure frames received on VLAN interfaces stacked on | ||
2506 | * bonding interfaces still make their way to any base bonding | ||
2507 | * device that may have registered for a specific ptype. The | ||
2508 | * handler may have to adjust skb->dev and orig_dev. | ||
2509 | */ | ||
2510 | null_or_bond = NULL; | ||
2511 | if ((skb->dev->priv_flags & IFF_802_1Q_VLAN) && | ||
2512 | (vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING)) { | ||
2513 | null_or_bond = vlan_dev_real_dev(skb->dev); | ||
2514 | } | ||
2515 | |||
2490 | type = skb->protocol; | 2516 | type = skb->protocol; |
2491 | list_for_each_entry_rcu(ptype, | 2517 | list_for_each_entry_rcu(ptype, |
2492 | &ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) { | 2518 | &ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) { |
2493 | if (ptype->type == type && | 2519 | if (ptype->type == type && (ptype->dev == null_or_orig || |
2494 | (ptype->dev == null_or_orig || ptype->dev == skb->dev || | 2520 | ptype->dev == skb->dev || ptype->dev == orig_dev || |
2495 | ptype->dev == orig_dev)) { | 2521 | ptype->dev == null_or_bond)) { |
2496 | if (pt_prev) | 2522 | if (pt_prev) |
2497 | ret = deliver_skb(skb, pt_prev, orig_dev); | 2523 | ret = deliver_skb(skb, pt_prev, orig_dev); |
2498 | pt_prev = ptype; | 2524 | pt_prev = ptype; |
@@ -2561,7 +2587,7 @@ out: | |||
2561 | return netif_receive_skb(skb); | 2587 | return netif_receive_skb(skb); |
2562 | } | 2588 | } |
2563 | 2589 | ||
2564 | void napi_gro_flush(struct napi_struct *napi) | 2590 | static void napi_gro_flush(struct napi_struct *napi) |
2565 | { | 2591 | { |
2566 | struct sk_buff *skb, *next; | 2592 | struct sk_buff *skb, *next; |
2567 | 2593 | ||
@@ -2574,7 +2600,6 @@ void napi_gro_flush(struct napi_struct *napi) | |||
2574 | napi->gro_count = 0; | 2600 | napi->gro_count = 0; |
2575 | napi->gro_list = NULL; | 2601 | napi->gro_list = NULL; |
2576 | } | 2602 | } |
2577 | EXPORT_SYMBOL(napi_gro_flush); | ||
2578 | 2603 | ||
2579 | enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) | 2604 | enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) |
2580 | { | 2605 | { |
@@ -3185,7 +3210,7 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev) | |||
3185 | { | 3210 | { |
3186 | const struct net_device_stats *stats = dev_get_stats(dev); | 3211 | const struct net_device_stats *stats = dev_get_stats(dev); |
3187 | 3212 | ||
3188 | seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu " | 3213 | seq_printf(seq, "%6s: %7lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu " |
3189 | "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", | 3214 | "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", |
3190 | dev->name, stats->rx_bytes, stats->rx_packets, | 3215 | dev->name, stats->rx_bytes, stats->rx_packets, |
3191 | stats->rx_errors, | 3216 | stats->rx_errors, |
@@ -3640,10 +3665,10 @@ void __dev_set_rx_mode(struct net_device *dev) | |||
3640 | /* Unicast addresses changes may only happen under the rtnl, | 3665 | /* Unicast addresses changes may only happen under the rtnl, |
3641 | * therefore calling __dev_set_promiscuity here is safe. | 3666 | * therefore calling __dev_set_promiscuity here is safe. |
3642 | */ | 3667 | */ |
3643 | if (dev->uc.count > 0 && !dev->uc_promisc) { | 3668 | if (!netdev_uc_empty(dev) && !dev->uc_promisc) { |
3644 | __dev_set_promiscuity(dev, 1); | 3669 | __dev_set_promiscuity(dev, 1); |
3645 | dev->uc_promisc = 1; | 3670 | dev->uc_promisc = 1; |
3646 | } else if (dev->uc.count == 0 && dev->uc_promisc) { | 3671 | } else if (netdev_uc_empty(dev) && dev->uc_promisc) { |
3647 | __dev_set_promiscuity(dev, -1); | 3672 | __dev_set_promiscuity(dev, -1); |
3648 | dev->uc_promisc = 0; | 3673 | dev->uc_promisc = 0; |
3649 | } | 3674 | } |
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 02a3b2c69c1e..9a24377146bf 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -708,7 +708,7 @@ static struct notifier_block fib_rules_notifier = { | |||
708 | .notifier_call = fib_rules_event, | 708 | .notifier_call = fib_rules_event, |
709 | }; | 709 | }; |
710 | 710 | ||
711 | static int fib_rules_net_init(struct net *net) | 711 | static int __net_init fib_rules_net_init(struct net *net) |
712 | { | 712 | { |
713 | INIT_LIST_HEAD(&net->rules_ops); | 713 | INIT_LIST_HEAD(&net->rules_ops); |
714 | spin_lock_init(&net->rules_mod_lock); | 714 | spin_lock_init(&net->rules_mod_lock); |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index f35377b643e4..f2efd72da799 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -2417,8 +2417,7 @@ EXPORT_SYMBOL(neigh_seq_stop); | |||
2417 | 2417 | ||
2418 | static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos) | 2418 | static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos) |
2419 | { | 2419 | { |
2420 | struct proc_dir_entry *pde = seq->private; | 2420 | struct neigh_table *tbl = seq->private; |
2421 | struct neigh_table *tbl = pde->data; | ||
2422 | int cpu; | 2421 | int cpu; |
2423 | 2422 | ||
2424 | if (*pos == 0) | 2423 | if (*pos == 0) |
@@ -2435,8 +2434,7 @@ static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos) | |||
2435 | 2434 | ||
2436 | static void *neigh_stat_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2435 | static void *neigh_stat_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
2437 | { | 2436 | { |
2438 | struct proc_dir_entry *pde = seq->private; | 2437 | struct neigh_table *tbl = seq->private; |
2439 | struct neigh_table *tbl = pde->data; | ||
2440 | int cpu; | 2438 | int cpu; |
2441 | 2439 | ||
2442 | for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) { | 2440 | for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) { |
@@ -2455,8 +2453,7 @@ static void neigh_stat_seq_stop(struct seq_file *seq, void *v) | |||
2455 | 2453 | ||
2456 | static int neigh_stat_seq_show(struct seq_file *seq, void *v) | 2454 | static int neigh_stat_seq_show(struct seq_file *seq, void *v) |
2457 | { | 2455 | { |
2458 | struct proc_dir_entry *pde = seq->private; | 2456 | struct neigh_table *tbl = seq->private; |
2459 | struct neigh_table *tbl = pde->data; | ||
2460 | struct neigh_statistics *st = v; | 2457 | struct neigh_statistics *st = v; |
2461 | 2458 | ||
2462 | if (v == SEQ_START_TOKEN) { | 2459 | if (v == SEQ_START_TOKEN) { |
@@ -2501,7 +2498,7 @@ static int neigh_stat_seq_open(struct inode *inode, struct file *file) | |||
2501 | 2498 | ||
2502 | if (!ret) { | 2499 | if (!ret) { |
2503 | struct seq_file *sf = file->private_data; | 2500 | struct seq_file *sf = file->private_data; |
2504 | sf->private = PDE(inode); | 2501 | sf->private = PDE(inode)->data; |
2505 | } | 2502 | } |
2506 | return ret; | 2503 | return ret; |
2507 | }; | 2504 | }; |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 0b4d0d35ef40..7aa697253765 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -407,11 +407,24 @@ static void arp_reply(struct sk_buff *skb) | |||
407 | __be32 sip, tip; | 407 | __be32 sip, tip; |
408 | unsigned char *sha; | 408 | unsigned char *sha; |
409 | struct sk_buff *send_skb; | 409 | struct sk_buff *send_skb; |
410 | struct netpoll *np = NULL; | 410 | struct netpoll *np, *tmp; |
411 | unsigned long flags; | ||
412 | int hits = 0; | ||
413 | |||
414 | if (list_empty(&npinfo->rx_np)) | ||
415 | return; | ||
416 | |||
417 | /* Before checking the packet, we do some early | ||
418 | inspection whether this is interesting at all */ | ||
419 | spin_lock_irqsave(&npinfo->rx_lock, flags); | ||
420 | list_for_each_entry_safe(np, tmp, &npinfo->rx_np, rx) { | ||
421 | if (np->dev == skb->dev) | ||
422 | hits++; | ||
423 | } | ||
424 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); | ||
411 | 425 | ||
412 | if (npinfo->rx_np && npinfo->rx_np->dev == skb->dev) | 426 | /* No netpoll struct is using this dev */ |
413 | np = npinfo->rx_np; | 427 | if (!hits) |
414 | if (!np) | ||
415 | return; | 428 | return; |
416 | 429 | ||
417 | /* No arp on this interface */ | 430 | /* No arp on this interface */ |
@@ -437,77 +450,91 @@ static void arp_reply(struct sk_buff *skb) | |||
437 | arp_ptr += skb->dev->addr_len; | 450 | arp_ptr += skb->dev->addr_len; |
438 | memcpy(&sip, arp_ptr, 4); | 451 | memcpy(&sip, arp_ptr, 4); |
439 | arp_ptr += 4; | 452 | arp_ptr += 4; |
440 | /* if we actually cared about dst hw addr, it would get copied here */ | 453 | /* If we actually cared about dst hw addr, |
454 | it would get copied here */ | ||
441 | arp_ptr += skb->dev->addr_len; | 455 | arp_ptr += skb->dev->addr_len; |
442 | memcpy(&tip, arp_ptr, 4); | 456 | memcpy(&tip, arp_ptr, 4); |
443 | 457 | ||
444 | /* Should we ignore arp? */ | 458 | /* Should we ignore arp? */ |
445 | if (tip != np->local_ip || | 459 | if (ipv4_is_loopback(tip) || ipv4_is_multicast(tip)) |
446 | ipv4_is_loopback(tip) || ipv4_is_multicast(tip)) | ||
447 | return; | 460 | return; |
448 | 461 | ||
449 | size = arp_hdr_len(skb->dev); | 462 | size = arp_hdr_len(skb->dev); |
450 | send_skb = find_skb(np, size + LL_ALLOCATED_SPACE(np->dev), | ||
451 | LL_RESERVED_SPACE(np->dev)); | ||
452 | 463 | ||
453 | if (!send_skb) | 464 | spin_lock_irqsave(&npinfo->rx_lock, flags); |
454 | return; | 465 | list_for_each_entry_safe(np, tmp, &npinfo->rx_np, rx) { |
455 | 466 | if (tip != np->local_ip) | |
456 | skb_reset_network_header(send_skb); | 467 | continue; |
457 | arp = (struct arphdr *) skb_put(send_skb, size); | ||
458 | send_skb->dev = skb->dev; | ||
459 | send_skb->protocol = htons(ETH_P_ARP); | ||
460 | 468 | ||
461 | /* Fill the device header for the ARP frame */ | 469 | send_skb = find_skb(np, size + LL_ALLOCATED_SPACE(np->dev), |
462 | if (dev_hard_header(send_skb, skb->dev, ptype, | 470 | LL_RESERVED_SPACE(np->dev)); |
463 | sha, np->dev->dev_addr, | 471 | if (!send_skb) |
464 | send_skb->len) < 0) { | 472 | continue; |
465 | kfree_skb(send_skb); | ||
466 | return; | ||
467 | } | ||
468 | 473 | ||
469 | /* | 474 | skb_reset_network_header(send_skb); |
470 | * Fill out the arp protocol part. | 475 | arp = (struct arphdr *) skb_put(send_skb, size); |
471 | * | 476 | send_skb->dev = skb->dev; |
472 | * we only support ethernet device type, | 477 | send_skb->protocol = htons(ETH_P_ARP); |
473 | * which (according to RFC 1390) should always equal 1 (Ethernet). | ||
474 | */ | ||
475 | 478 | ||
476 | arp->ar_hrd = htons(np->dev->type); | 479 | /* Fill the device header for the ARP frame */ |
477 | arp->ar_pro = htons(ETH_P_IP); | 480 | if (dev_hard_header(send_skb, skb->dev, ptype, |
478 | arp->ar_hln = np->dev->addr_len; | 481 | sha, np->dev->dev_addr, |
479 | arp->ar_pln = 4; | 482 | send_skb->len) < 0) { |
480 | arp->ar_op = htons(type); | 483 | kfree_skb(send_skb); |
484 | continue; | ||
485 | } | ||
481 | 486 | ||
482 | arp_ptr=(unsigned char *)(arp + 1); | 487 | /* |
483 | memcpy(arp_ptr, np->dev->dev_addr, np->dev->addr_len); | 488 | * Fill out the arp protocol part. |
484 | arp_ptr += np->dev->addr_len; | 489 | * |
485 | memcpy(arp_ptr, &tip, 4); | 490 | * we only support ethernet device type, |
486 | arp_ptr += 4; | 491 | * which (according to RFC 1390) should |
487 | memcpy(arp_ptr, sha, np->dev->addr_len); | 492 | * always equal 1 (Ethernet). |
488 | arp_ptr += np->dev->addr_len; | 493 | */ |
489 | memcpy(arp_ptr, &sip, 4); | ||
490 | 494 | ||
491 | netpoll_send_skb(np, send_skb); | 495 | arp->ar_hrd = htons(np->dev->type); |
496 | arp->ar_pro = htons(ETH_P_IP); | ||
497 | arp->ar_hln = np->dev->addr_len; | ||
498 | arp->ar_pln = 4; | ||
499 | arp->ar_op = htons(type); | ||
500 | |||
501 | arp_ptr = (unsigned char *)(arp + 1); | ||
502 | memcpy(arp_ptr, np->dev->dev_addr, np->dev->addr_len); | ||
503 | arp_ptr += np->dev->addr_len; | ||
504 | memcpy(arp_ptr, &tip, 4); | ||
505 | arp_ptr += 4; | ||
506 | memcpy(arp_ptr, sha, np->dev->addr_len); | ||
507 | arp_ptr += np->dev->addr_len; | ||
508 | memcpy(arp_ptr, &sip, 4); | ||
509 | |||
510 | netpoll_send_skb(np, send_skb); | ||
511 | |||
512 | /* If there are several rx_hooks for the same address, | ||
513 | we're fine by sending a single reply */ | ||
514 | break; | ||
515 | } | ||
516 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); | ||
492 | } | 517 | } |
493 | 518 | ||
494 | int __netpoll_rx(struct sk_buff *skb) | 519 | int __netpoll_rx(struct sk_buff *skb) |
495 | { | 520 | { |
496 | int proto, len, ulen; | 521 | int proto, len, ulen; |
522 | int hits = 0; | ||
497 | struct iphdr *iph; | 523 | struct iphdr *iph; |
498 | struct udphdr *uh; | 524 | struct udphdr *uh; |
499 | struct netpoll_info *npi = skb->dev->npinfo; | 525 | struct netpoll_info *npinfo = skb->dev->npinfo; |
500 | struct netpoll *np = npi->rx_np; | 526 | struct netpoll *np, *tmp; |
501 | 527 | ||
502 | if (!np) | 528 | if (list_empty(&npinfo->rx_np)) |
503 | goto out; | 529 | goto out; |
530 | |||
504 | if (skb->dev->type != ARPHRD_ETHER) | 531 | if (skb->dev->type != ARPHRD_ETHER) |
505 | goto out; | 532 | goto out; |
506 | 533 | ||
507 | /* check if netpoll clients need ARP */ | 534 | /* check if netpoll clients need ARP */ |
508 | if (skb->protocol == htons(ETH_P_ARP) && | 535 | if (skb->protocol == htons(ETH_P_ARP) && |
509 | atomic_read(&trapped)) { | 536 | atomic_read(&trapped)) { |
510 | skb_queue_tail(&npi->arp_tx, skb); | 537 | skb_queue_tail(&npinfo->arp_tx, skb); |
511 | return 1; | 538 | return 1; |
512 | } | 539 | } |
513 | 540 | ||
@@ -551,16 +578,23 @@ int __netpoll_rx(struct sk_buff *skb) | |||
551 | goto out; | 578 | goto out; |
552 | if (checksum_udp(skb, uh, ulen, iph->saddr, iph->daddr)) | 579 | if (checksum_udp(skb, uh, ulen, iph->saddr, iph->daddr)) |
553 | goto out; | 580 | goto out; |
554 | if (np->local_ip && np->local_ip != iph->daddr) | ||
555 | goto out; | ||
556 | if (np->remote_ip && np->remote_ip != iph->saddr) | ||
557 | goto out; | ||
558 | if (np->local_port && np->local_port != ntohs(uh->dest)) | ||
559 | goto out; | ||
560 | 581 | ||
561 | np->rx_hook(np, ntohs(uh->source), | 582 | list_for_each_entry_safe(np, tmp, &npinfo->rx_np, rx) { |
562 | (char *)(uh+1), | 583 | if (np->local_ip && np->local_ip != iph->daddr) |
563 | ulen - sizeof(struct udphdr)); | 584 | continue; |
585 | if (np->remote_ip && np->remote_ip != iph->saddr) | ||
586 | continue; | ||
587 | if (np->local_port && np->local_port != ntohs(uh->dest)) | ||
588 | continue; | ||
589 | |||
590 | np->rx_hook(np, ntohs(uh->source), | ||
591 | (char *)(uh+1), | ||
592 | ulen - sizeof(struct udphdr)); | ||
593 | hits++; | ||
594 | } | ||
595 | |||
596 | if (!hits) | ||
597 | goto out; | ||
564 | 598 | ||
565 | kfree_skb(skb); | 599 | kfree_skb(skb); |
566 | return 1; | 600 | return 1; |
@@ -684,6 +718,7 @@ int netpoll_setup(struct netpoll *np) | |||
684 | struct net_device *ndev = NULL; | 718 | struct net_device *ndev = NULL; |
685 | struct in_device *in_dev; | 719 | struct in_device *in_dev; |
686 | struct netpoll_info *npinfo; | 720 | struct netpoll_info *npinfo; |
721 | struct netpoll *npe, *tmp; | ||
687 | unsigned long flags; | 722 | unsigned long flags; |
688 | int err; | 723 | int err; |
689 | 724 | ||
@@ -704,7 +739,7 @@ int netpoll_setup(struct netpoll *np) | |||
704 | } | 739 | } |
705 | 740 | ||
706 | npinfo->rx_flags = 0; | 741 | npinfo->rx_flags = 0; |
707 | npinfo->rx_np = NULL; | 742 | INIT_LIST_HEAD(&npinfo->rx_np); |
708 | 743 | ||
709 | spin_lock_init(&npinfo->rx_lock); | 744 | spin_lock_init(&npinfo->rx_lock); |
710 | skb_queue_head_init(&npinfo->arp_tx); | 745 | skb_queue_head_init(&npinfo->arp_tx); |
@@ -785,7 +820,7 @@ int netpoll_setup(struct netpoll *np) | |||
785 | if (np->rx_hook) { | 820 | if (np->rx_hook) { |
786 | spin_lock_irqsave(&npinfo->rx_lock, flags); | 821 | spin_lock_irqsave(&npinfo->rx_lock, flags); |
787 | npinfo->rx_flags |= NETPOLL_RX_ENABLED; | 822 | npinfo->rx_flags |= NETPOLL_RX_ENABLED; |
788 | npinfo->rx_np = np; | 823 | list_add_tail(&np->rx, &npinfo->rx_np); |
789 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); | 824 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); |
790 | } | 825 | } |
791 | 826 | ||
@@ -801,9 +836,16 @@ int netpoll_setup(struct netpoll *np) | |||
801 | return 0; | 836 | return 0; |
802 | 837 | ||
803 | release: | 838 | release: |
804 | if (!ndev->npinfo) | 839 | if (!ndev->npinfo) { |
840 | spin_lock_irqsave(&npinfo->rx_lock, flags); | ||
841 | list_for_each_entry_safe(npe, tmp, &npinfo->rx_np, rx) { | ||
842 | npe->dev = NULL; | ||
843 | } | ||
844 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); | ||
845 | |||
805 | kfree(npinfo); | 846 | kfree(npinfo); |
806 | np->dev = NULL; | 847 | } |
848 | |||
807 | dev_put(ndev); | 849 | dev_put(ndev); |
808 | return err; | 850 | return err; |
809 | } | 851 | } |
@@ -823,10 +865,11 @@ void netpoll_cleanup(struct netpoll *np) | |||
823 | if (np->dev) { | 865 | if (np->dev) { |
824 | npinfo = np->dev->npinfo; | 866 | npinfo = np->dev->npinfo; |
825 | if (npinfo) { | 867 | if (npinfo) { |
826 | if (npinfo->rx_np == np) { | 868 | if (!list_empty(&npinfo->rx_np)) { |
827 | spin_lock_irqsave(&npinfo->rx_lock, flags); | 869 | spin_lock_irqsave(&npinfo->rx_lock, flags); |
828 | npinfo->rx_np = NULL; | 870 | list_del(&np->rx); |
829 | npinfo->rx_flags &= ~NETPOLL_RX_ENABLED; | 871 | if (list_empty(&npinfo->rx_np)) |
872 | npinfo->rx_flags &= ~NETPOLL_RX_ENABLED; | ||
830 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); | 873 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); |
831 | } | 874 | } |
832 | 875 | ||
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 794bcb897ff0..62f3878a6010 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -1386,7 +1386,7 @@ static struct notifier_block rtnetlink_dev_notifier = { | |||
1386 | }; | 1386 | }; |
1387 | 1387 | ||
1388 | 1388 | ||
1389 | static int rtnetlink_net_init(struct net *net) | 1389 | static int __net_init rtnetlink_net_init(struct net *net) |
1390 | { | 1390 | { |
1391 | struct sock *sk; | 1391 | struct sock *sk; |
1392 | sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX, | 1392 | sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX, |
@@ -1397,7 +1397,7 @@ static int rtnetlink_net_init(struct net *net) | |||
1397 | return 0; | 1397 | return 0; |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | static void rtnetlink_net_exit(struct net *net) | 1400 | static void __net_exit rtnetlink_net_exit(struct net *net) |
1401 | { | 1401 | { |
1402 | netlink_kernel_release(net->rtnl); | 1402 | netlink_kernel_release(net->rtnl); |
1403 | net->rtnl = NULL; | 1403 | net->rtnl = NULL; |
diff --git a/net/core/sock.c b/net/core/sock.c index e1f6f225f012..ceef50bd131b 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -741,7 +741,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, | |||
741 | struct timeval tm; | 741 | struct timeval tm; |
742 | } v; | 742 | } v; |
743 | 743 | ||
744 | unsigned int lv = sizeof(int); | 744 | int lv = sizeof(int); |
745 | int len; | 745 | int len; |
746 | 746 | ||
747 | if (get_user(len, optlen)) | 747 | if (get_user(len, optlen)) |
@@ -2140,13 +2140,13 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot) | |||
2140 | } | 2140 | } |
2141 | EXPORT_SYMBOL_GPL(sock_prot_inuse_get); | 2141 | EXPORT_SYMBOL_GPL(sock_prot_inuse_get); |
2142 | 2142 | ||
2143 | static int sock_inuse_init_net(struct net *net) | 2143 | static int __net_init sock_inuse_init_net(struct net *net) |
2144 | { | 2144 | { |
2145 | net->core.inuse = alloc_percpu(struct prot_inuse); | 2145 | net->core.inuse = alloc_percpu(struct prot_inuse); |
2146 | return net->core.inuse ? 0 : -ENOMEM; | 2146 | return net->core.inuse ? 0 : -ENOMEM; |
2147 | } | 2147 | } |
2148 | 2148 | ||
2149 | static void sock_inuse_exit_net(struct net *net) | 2149 | static void __net_exit sock_inuse_exit_net(struct net *net) |
2150 | { | 2150 | { |
2151 | free_percpu(net->core.inuse); | 2151 | free_percpu(net->core.inuse); |
2152 | } | 2152 | } |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index dad7bc4878e0..b195c4feaa0a 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -996,7 +996,7 @@ static struct inet_protosw dccp_v4_protosw = { | |||
996 | .flags = INET_PROTOSW_ICSK, | 996 | .flags = INET_PROTOSW_ICSK, |
997 | }; | 997 | }; |
998 | 998 | ||
999 | static int dccp_v4_init_net(struct net *net) | 999 | static int __net_init dccp_v4_init_net(struct net *net) |
1000 | { | 1000 | { |
1001 | int err; | 1001 | int err; |
1002 | 1002 | ||
@@ -1005,7 +1005,7 @@ static int dccp_v4_init_net(struct net *net) | |||
1005 | return err; | 1005 | return err; |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | static void dccp_v4_exit_net(struct net *net) | 1008 | static void __net_exit dccp_v4_exit_net(struct net *net) |
1009 | { | 1009 | { |
1010 | inet_ctl_sock_destroy(net->dccp.v4_ctl_sk); | 1010 | inet_ctl_sock_destroy(net->dccp.v4_ctl_sk); |
1011 | } | 1011 | } |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index baf05cf43c28..1aec6349e858 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -1189,7 +1189,7 @@ static struct inet_protosw dccp_v6_protosw = { | |||
1189 | .flags = INET_PROTOSW_ICSK, | 1189 | .flags = INET_PROTOSW_ICSK, |
1190 | }; | 1190 | }; |
1191 | 1191 | ||
1192 | static int dccp_v6_init_net(struct net *net) | 1192 | static int __net_init dccp_v6_init_net(struct net *net) |
1193 | { | 1193 | { |
1194 | int err; | 1194 | int err; |
1195 | 1195 | ||
@@ -1198,7 +1198,7 @@ static int dccp_v6_init_net(struct net *net) | |||
1198 | return err; | 1198 | return err; |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | static void dccp_v6_exit_net(struct net *net) | 1201 | static void __net_exit dccp_v6_exit_net(struct net *net) |
1202 | { | 1202 | { |
1203 | inet_ctl_sock_destroy(net->dccp.v6_ctl_sk); | 1203 | inet_ctl_sock_destroy(net->dccp.v6_ctl_sk); |
1204 | } | 1204 | } |
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index dd3db88f8f0a..205a1c12f3c0 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c | |||
@@ -73,8 +73,8 @@ __setup("ether=", netdev_boot_setup); | |||
73 | * @len: packet length (<= skb->len) | 73 | * @len: packet length (<= skb->len) |
74 | * | 74 | * |
75 | * | 75 | * |
76 | * Set the protocol type. For a packet of type ETH_P_802_3 we put the length | 76 | * Set the protocol type. For a packet of type ETH_P_802_3/2 we put the length |
77 | * in here instead. It is up to the 802.2 layer to carry protocol information. | 77 | * in here instead. |
78 | */ | 78 | */ |
79 | int eth_header(struct sk_buff *skb, struct net_device *dev, | 79 | int eth_header(struct sk_buff *skb, struct net_device *dev, |
80 | unsigned short type, | 80 | unsigned short type, |
@@ -82,7 +82,7 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, | |||
82 | { | 82 | { |
83 | struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); | 83 | struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); |
84 | 84 | ||
85 | if (type != ETH_P_802_3) | 85 | if (type != ETH_P_802_3 && type != ETH_P_802_2) |
86 | eth->h_proto = htons(type); | 86 | eth->h_proto = htons(type); |
87 | else | 87 | else |
88 | eth->h_proto = htons(len); | 88 | eth->h_proto = htons(len); |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index c95cd93acf29..1940b4df7699 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -70,6 +70,7 @@ | |||
70 | * bonding can change the skb before | 70 | * bonding can change the skb before |
71 | * sending (e.g. insert 8021q tag). | 71 | * sending (e.g. insert 8021q tag). |
72 | * Harald Welte : convert to make use of jenkins hash | 72 | * Harald Welte : convert to make use of jenkins hash |
73 | * Jesper D. Brouer: Proxy ARP PVLAN RFC 3069 support. | ||
73 | */ | 74 | */ |
74 | 75 | ||
75 | #include <linux/module.h> | 76 | #include <linux/module.h> |
@@ -524,12 +525,15 @@ int arp_bind_neighbour(struct dst_entry *dst) | |||
524 | /* | 525 | /* |
525 | * Check if we can use proxy ARP for this path | 526 | * Check if we can use proxy ARP for this path |
526 | */ | 527 | */ |
527 | 528 | static inline int arp_fwd_proxy(struct in_device *in_dev, | |
528 | static inline int arp_fwd_proxy(struct in_device *in_dev, struct rtable *rt) | 529 | struct net_device *dev, struct rtable *rt) |
529 | { | 530 | { |
530 | struct in_device *out_dev; | 531 | struct in_device *out_dev; |
531 | int imi, omi = -1; | 532 | int imi, omi = -1; |
532 | 533 | ||
534 | if (rt->u.dst.dev == dev) | ||
535 | return 0; | ||
536 | |||
533 | if (!IN_DEV_PROXY_ARP(in_dev)) | 537 | if (!IN_DEV_PROXY_ARP(in_dev)) |
534 | return 0; | 538 | return 0; |
535 | 539 | ||
@@ -548,6 +552,43 @@ static inline int arp_fwd_proxy(struct in_device *in_dev, struct rtable *rt) | |||
548 | } | 552 | } |
549 | 553 | ||
550 | /* | 554 | /* |
555 | * Check for RFC3069 proxy arp private VLAN (allow to send back to same dev) | ||
556 | * | ||
557 | * RFC3069 supports proxy arp replies back to the same interface. This | ||
558 | * is done to support (ethernet) switch features, like RFC 3069, where | ||
559 | * the individual ports are not allowed to communicate with each | ||
560 | * other, BUT they are allowed to talk to the upstream router. As | ||
561 | * described in RFC 3069, it is possible to allow these hosts to | ||
562 | * communicate through the upstream router, by proxy_arp'ing. | ||
563 | * | ||
564 | * RFC 3069: "VLAN Aggregation for Efficient IP Address Allocation" | ||
565 | * | ||
566 | * This technology is known by different names: | ||
567 | * In RFC 3069 it is called VLAN Aggregation. | ||
568 | * Cisco and Allied Telesyn call it Private VLAN. | ||
569 | * Hewlett-Packard call it Source-Port filtering or port-isolation. | ||
570 | * Ericsson call it MAC-Forced Forwarding (RFC Draft). | ||
571 | * | ||
572 | */ | ||
573 | static inline int arp_fwd_pvlan(struct in_device *in_dev, | ||
574 | struct net_device *dev, struct rtable *rt, | ||
575 | __be32 sip, __be32 tip) | ||
576 | { | ||
577 | /* Private VLAN is only concerned about the same ethernet segment */ | ||
578 | if (rt->u.dst.dev != dev) | ||
579 | return 0; | ||
580 | |||
581 | /* Don't reply on self probes (often done by windowz boxes)*/ | ||
582 | if (sip == tip) | ||
583 | return 0; | ||
584 | |||
585 | if (IN_DEV_PROXY_ARP_PVLAN(in_dev)) | ||
586 | return 1; | ||
587 | else | ||
588 | return 0; | ||
589 | } | ||
590 | |||
591 | /* | ||
551 | * Interface to link layer: send routine and receive handler. | 592 | * Interface to link layer: send routine and receive handler. |
552 | */ | 593 | */ |
553 | 594 | ||
@@ -833,8 +874,11 @@ static int arp_process(struct sk_buff *skb) | |||
833 | } | 874 | } |
834 | goto out; | 875 | goto out; |
835 | } else if (IN_DEV_FORWARD(in_dev)) { | 876 | } else if (IN_DEV_FORWARD(in_dev)) { |
836 | if (addr_type == RTN_UNICAST && rt->u.dst.dev != dev && | 877 | if (addr_type == RTN_UNICAST && |
837 | (arp_fwd_proxy(in_dev, rt) || pneigh_lookup(&arp_tbl, net, &tip, dev, 0))) { | 878 | (arp_fwd_proxy(in_dev, dev, rt) || |
879 | arp_fwd_pvlan(in_dev, dev, rt, sip, tip) || | ||
880 | pneigh_lookup(&arp_tbl, net, &tip, dev, 0))) | ||
881 | { | ||
838 | n = neigh_event_ns(&arp_tbl, sha, &sip, dev); | 882 | n = neigh_event_ns(&arp_tbl, sha, &sip, dev); |
839 | if (n) | 883 | if (n) |
840 | neigh_release(n); | 884 | neigh_release(n); |
@@ -863,7 +907,8 @@ static int arp_process(struct sk_buff *skb) | |||
863 | devices (strip is candidate) | 907 | devices (strip is candidate) |
864 | */ | 908 | */ |
865 | if (n == NULL && | 909 | if (n == NULL && |
866 | arp->ar_op == htons(ARPOP_REPLY) && | 910 | (arp->ar_op == htons(ARPOP_REPLY) || |
911 | (arp->ar_op == htons(ARPOP_REQUEST) && tip == sip)) && | ||
867 | inet_addr_type(net, sip) == RTN_UNICAST) | 912 | inet_addr_type(net, sip) == RTN_UNICAST) |
868 | n = __neigh_lookup(&arp_tbl, &sip, dev, 1); | 913 | n = __neigh_lookup(&arp_tbl, &sip, dev, 1); |
869 | } | 914 | } |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 040c4f05b653..cd71a3908391 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -1408,6 +1408,7 @@ static struct devinet_sysctl_table { | |||
1408 | DEVINET_SYSCTL_RW_ENTRY(ARP_IGNORE, "arp_ignore"), | 1408 | DEVINET_SYSCTL_RW_ENTRY(ARP_IGNORE, "arp_ignore"), |
1409 | DEVINET_SYSCTL_RW_ENTRY(ARP_ACCEPT, "arp_accept"), | 1409 | DEVINET_SYSCTL_RW_ENTRY(ARP_ACCEPT, "arp_accept"), |
1410 | DEVINET_SYSCTL_RW_ENTRY(ARP_NOTIFY, "arp_notify"), | 1410 | DEVINET_SYSCTL_RW_ENTRY(ARP_NOTIFY, "arp_notify"), |
1411 | DEVINET_SYSCTL_RW_ENTRY(PROXY_ARP_PVLAN, "proxy_arp_pvlan"), | ||
1411 | 1412 | ||
1412 | DEVINET_SYSCTL_FLUSHING_ENTRY(NOXFRM, "disable_xfrm"), | 1413 | DEVINET_SYSCTL_FLUSHING_ENTRY(NOXFRM, "disable_xfrm"), |
1413 | DEVINET_SYSCTL_FLUSHING_ENTRY(NOPOLICY, "disable_policy"), | 1414 | DEVINET_SYSCTL_FLUSHING_ENTRY(NOPOLICY, "disable_policy"), |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 82dbf711d6d0..9b3e28ed5240 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -883,7 +883,7 @@ static void nl_fib_input(struct sk_buff *skb) | |||
883 | netlink_unicast(net->ipv4.fibnl, skb, pid, MSG_DONTWAIT); | 883 | netlink_unicast(net->ipv4.fibnl, skb, pid, MSG_DONTWAIT); |
884 | } | 884 | } |
885 | 885 | ||
886 | static int nl_fib_lookup_init(struct net *net) | 886 | static int __net_init nl_fib_lookup_init(struct net *net) |
887 | { | 887 | { |
888 | struct sock *sk; | 888 | struct sock *sk; |
889 | sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, 0, | 889 | sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, 0, |
@@ -1004,7 +1004,7 @@ fail: | |||
1004 | return err; | 1004 | return err; |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | static void __net_exit ip_fib_net_exit(struct net *net) | 1007 | static void ip_fib_net_exit(struct net *net) |
1008 | { | 1008 | { |
1009 | unsigned int i; | 1009 | unsigned int i; |
1010 | 1010 | ||
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index ed19aa6919c2..96b21011a3e4 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -62,8 +62,8 @@ static DEFINE_SPINLOCK(fib_multipath_lock); | |||
62 | #define for_nexthops(fi) { int nhsel; const struct fib_nh * nh; \ | 62 | #define for_nexthops(fi) { int nhsel; const struct fib_nh * nh; \ |
63 | for (nhsel=0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++) | 63 | for (nhsel=0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++) |
64 | 64 | ||
65 | #define change_nexthops(fi) { int nhsel; struct fib_nh * nh; \ | 65 | #define change_nexthops(fi) { int nhsel; struct fib_nh *nexthop_nh; \ |
66 | for (nhsel=0, nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, nhsel++) | 66 | for (nhsel=0, nexthop_nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nexthop_nh++, nhsel++) |
67 | 67 | ||
68 | #else /* CONFIG_IP_ROUTE_MULTIPATH */ | 68 | #else /* CONFIG_IP_ROUTE_MULTIPATH */ |
69 | 69 | ||
@@ -72,7 +72,7 @@ for (nhsel=0, nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, | |||
72 | #define for_nexthops(fi) { int nhsel = 0; const struct fib_nh * nh = (fi)->fib_nh; \ | 72 | #define for_nexthops(fi) { int nhsel = 0; const struct fib_nh * nh = (fi)->fib_nh; \ |
73 | for (nhsel=0; nhsel < 1; nhsel++) | 73 | for (nhsel=0; nhsel < 1; nhsel++) |
74 | 74 | ||
75 | #define change_nexthops(fi) { int nhsel = 0; struct fib_nh * nh = (struct fib_nh *)((fi)->fib_nh); \ | 75 | #define change_nexthops(fi) { int nhsel = 0; struct fib_nh *nexthop_nh = (struct fib_nh *)((fi)->fib_nh); \ |
76 | for (nhsel=0; nhsel < 1; nhsel++) | 76 | for (nhsel=0; nhsel < 1; nhsel++) |
77 | 77 | ||
78 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ | 78 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ |
@@ -145,9 +145,9 @@ void free_fib_info(struct fib_info *fi) | |||
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | change_nexthops(fi) { | 147 | change_nexthops(fi) { |
148 | if (nh->nh_dev) | 148 | if (nexthop_nh->nh_dev) |
149 | dev_put(nh->nh_dev); | 149 | dev_put(nexthop_nh->nh_dev); |
150 | nh->nh_dev = NULL; | 150 | nexthop_nh->nh_dev = NULL; |
151 | } endfor_nexthops(fi); | 151 | } endfor_nexthops(fi); |
152 | fib_info_cnt--; | 152 | fib_info_cnt--; |
153 | release_net(fi->fib_net); | 153 | release_net(fi->fib_net); |
@@ -162,9 +162,9 @@ void fib_release_info(struct fib_info *fi) | |||
162 | if (fi->fib_prefsrc) | 162 | if (fi->fib_prefsrc) |
163 | hlist_del(&fi->fib_lhash); | 163 | hlist_del(&fi->fib_lhash); |
164 | change_nexthops(fi) { | 164 | change_nexthops(fi) { |
165 | if (!nh->nh_dev) | 165 | if (!nexthop_nh->nh_dev) |
166 | continue; | 166 | continue; |
167 | hlist_del(&nh->nh_hash); | 167 | hlist_del(&nexthop_nh->nh_hash); |
168 | } endfor_nexthops(fi) | 168 | } endfor_nexthops(fi) |
169 | fi->fib_dead = 1; | 169 | fi->fib_dead = 1; |
170 | fib_info_put(fi); | 170 | fib_info_put(fi); |
@@ -395,19 +395,20 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, | |||
395 | if (!rtnh_ok(rtnh, remaining)) | 395 | if (!rtnh_ok(rtnh, remaining)) |
396 | return -EINVAL; | 396 | return -EINVAL; |
397 | 397 | ||
398 | nh->nh_flags = (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags; | 398 | nexthop_nh->nh_flags = |
399 | nh->nh_oif = rtnh->rtnh_ifindex; | 399 | (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags; |
400 | nh->nh_weight = rtnh->rtnh_hops + 1; | 400 | nexthop_nh->nh_oif = rtnh->rtnh_ifindex; |
401 | nexthop_nh->nh_weight = rtnh->rtnh_hops + 1; | ||
401 | 402 | ||
402 | attrlen = rtnh_attrlen(rtnh); | 403 | attrlen = rtnh_attrlen(rtnh); |
403 | if (attrlen > 0) { | 404 | if (attrlen > 0) { |
404 | struct nlattr *nla, *attrs = rtnh_attrs(rtnh); | 405 | struct nlattr *nla, *attrs = rtnh_attrs(rtnh); |
405 | 406 | ||
406 | nla = nla_find(attrs, attrlen, RTA_GATEWAY); | 407 | nla = nla_find(attrs, attrlen, RTA_GATEWAY); |
407 | nh->nh_gw = nla ? nla_get_be32(nla) : 0; | 408 | nexthop_nh->nh_gw = nla ? nla_get_be32(nla) : 0; |
408 | #ifdef CONFIG_NET_CLS_ROUTE | 409 | #ifdef CONFIG_NET_CLS_ROUTE |
409 | nla = nla_find(attrs, attrlen, RTA_FLOW); | 410 | nla = nla_find(attrs, attrlen, RTA_FLOW); |
410 | nh->nh_tclassid = nla ? nla_get_u32(nla) : 0; | 411 | nexthop_nh->nh_tclassid = nla ? nla_get_u32(nla) : 0; |
411 | #endif | 412 | #endif |
412 | } | 413 | } |
413 | 414 | ||
@@ -738,7 +739,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
738 | 739 | ||
739 | fi->fib_nhs = nhs; | 740 | fi->fib_nhs = nhs; |
740 | change_nexthops(fi) { | 741 | change_nexthops(fi) { |
741 | nh->nh_parent = fi; | 742 | nexthop_nh->nh_parent = fi; |
742 | } endfor_nexthops(fi) | 743 | } endfor_nexthops(fi) |
743 | 744 | ||
744 | if (cfg->fc_mx) { | 745 | if (cfg->fc_mx) { |
@@ -808,7 +809,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
808 | goto failure; | 809 | goto failure; |
809 | } else { | 810 | } else { |
810 | change_nexthops(fi) { | 811 | change_nexthops(fi) { |
811 | if ((err = fib_check_nh(cfg, fi, nh)) != 0) | 812 | if ((err = fib_check_nh(cfg, fi, nexthop_nh)) != 0) |
812 | goto failure; | 813 | goto failure; |
813 | } endfor_nexthops(fi) | 814 | } endfor_nexthops(fi) |
814 | } | 815 | } |
@@ -843,11 +844,11 @@ link_it: | |||
843 | struct hlist_head *head; | 844 | struct hlist_head *head; |
844 | unsigned int hash; | 845 | unsigned int hash; |
845 | 846 | ||
846 | if (!nh->nh_dev) | 847 | if (!nexthop_nh->nh_dev) |
847 | continue; | 848 | continue; |
848 | hash = fib_devindex_hashfn(nh->nh_dev->ifindex); | 849 | hash = fib_devindex_hashfn(nexthop_nh->nh_dev->ifindex); |
849 | head = &fib_info_devhash[hash]; | 850 | head = &fib_info_devhash[hash]; |
850 | hlist_add_head(&nh->nh_hash, head); | 851 | hlist_add_head(&nexthop_nh->nh_hash, head); |
851 | } endfor_nexthops(fi) | 852 | } endfor_nexthops(fi) |
852 | spin_unlock_bh(&fib_info_lock); | 853 | spin_unlock_bh(&fib_info_lock); |
853 | return fi; | 854 | return fi; |
@@ -1080,21 +1081,21 @@ int fib_sync_down_dev(struct net_device *dev, int force) | |||
1080 | prev_fi = fi; | 1081 | prev_fi = fi; |
1081 | dead = 0; | 1082 | dead = 0; |
1082 | change_nexthops(fi) { | 1083 | change_nexthops(fi) { |
1083 | if (nh->nh_flags&RTNH_F_DEAD) | 1084 | if (nexthop_nh->nh_flags&RTNH_F_DEAD) |
1084 | dead++; | 1085 | dead++; |
1085 | else if (nh->nh_dev == dev && | 1086 | else if (nexthop_nh->nh_dev == dev && |
1086 | nh->nh_scope != scope) { | 1087 | nexthop_nh->nh_scope != scope) { |
1087 | nh->nh_flags |= RTNH_F_DEAD; | 1088 | nexthop_nh->nh_flags |= RTNH_F_DEAD; |
1088 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 1089 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
1089 | spin_lock_bh(&fib_multipath_lock); | 1090 | spin_lock_bh(&fib_multipath_lock); |
1090 | fi->fib_power -= nh->nh_power; | 1091 | fi->fib_power -= nexthop_nh->nh_power; |
1091 | nh->nh_power = 0; | 1092 | nexthop_nh->nh_power = 0; |
1092 | spin_unlock_bh(&fib_multipath_lock); | 1093 | spin_unlock_bh(&fib_multipath_lock); |
1093 | #endif | 1094 | #endif |
1094 | dead++; | 1095 | dead++; |
1095 | } | 1096 | } |
1096 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 1097 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
1097 | if (force > 1 && nh->nh_dev == dev) { | 1098 | if (force > 1 && nexthop_nh->nh_dev == dev) { |
1098 | dead = fi->fib_nhs; | 1099 | dead = fi->fib_nhs; |
1099 | break; | 1100 | break; |
1100 | } | 1101 | } |
@@ -1144,18 +1145,20 @@ int fib_sync_up(struct net_device *dev) | |||
1144 | prev_fi = fi; | 1145 | prev_fi = fi; |
1145 | alive = 0; | 1146 | alive = 0; |
1146 | change_nexthops(fi) { | 1147 | change_nexthops(fi) { |
1147 | if (!(nh->nh_flags&RTNH_F_DEAD)) { | 1148 | if (!(nexthop_nh->nh_flags&RTNH_F_DEAD)) { |
1148 | alive++; | 1149 | alive++; |
1149 | continue; | 1150 | continue; |
1150 | } | 1151 | } |
1151 | if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP)) | 1152 | if (nexthop_nh->nh_dev == NULL || |
1153 | !(nexthop_nh->nh_dev->flags&IFF_UP)) | ||
1152 | continue; | 1154 | continue; |
1153 | if (nh->nh_dev != dev || !__in_dev_get_rtnl(dev)) | 1155 | if (nexthop_nh->nh_dev != dev || |
1156 | !__in_dev_get_rtnl(dev)) | ||
1154 | continue; | 1157 | continue; |
1155 | alive++; | 1158 | alive++; |
1156 | spin_lock_bh(&fib_multipath_lock); | 1159 | spin_lock_bh(&fib_multipath_lock); |
1157 | nh->nh_power = 0; | 1160 | nexthop_nh->nh_power = 0; |
1158 | nh->nh_flags &= ~RTNH_F_DEAD; | 1161 | nexthop_nh->nh_flags &= ~RTNH_F_DEAD; |
1159 | spin_unlock_bh(&fib_multipath_lock); | 1162 | spin_unlock_bh(&fib_multipath_lock); |
1160 | } endfor_nexthops(fi) | 1163 | } endfor_nexthops(fi) |
1161 | 1164 | ||
@@ -1182,9 +1185,9 @@ void fib_select_multipath(const struct flowi *flp, struct fib_result *res) | |||
1182 | if (fi->fib_power <= 0) { | 1185 | if (fi->fib_power <= 0) { |
1183 | int power = 0; | 1186 | int power = 0; |
1184 | change_nexthops(fi) { | 1187 | change_nexthops(fi) { |
1185 | if (!(nh->nh_flags&RTNH_F_DEAD)) { | 1188 | if (!(nexthop_nh->nh_flags&RTNH_F_DEAD)) { |
1186 | power += nh->nh_weight; | 1189 | power += nexthop_nh->nh_weight; |
1187 | nh->nh_power = nh->nh_weight; | 1190 | nexthop_nh->nh_power = nexthop_nh->nh_weight; |
1188 | } | 1191 | } |
1189 | } endfor_nexthops(fi); | 1192 | } endfor_nexthops(fi); |
1190 | fi->fib_power = power; | 1193 | fi->fib_power = power; |
@@ -1204,9 +1207,10 @@ void fib_select_multipath(const struct flowi *flp, struct fib_result *res) | |||
1204 | w = jiffies % fi->fib_power; | 1207 | w = jiffies % fi->fib_power; |
1205 | 1208 | ||
1206 | change_nexthops(fi) { | 1209 | change_nexthops(fi) { |
1207 | if (!(nh->nh_flags&RTNH_F_DEAD) && nh->nh_power) { | 1210 | if (!(nexthop_nh->nh_flags&RTNH_F_DEAD) && |
1208 | if ((w -= nh->nh_power) <= 0) { | 1211 | nexthop_nh->nh_power) { |
1209 | nh->nh_power--; | 1212 | if ((w -= nexthop_nh->nh_power) <= 0) { |
1213 | nexthop_nh->nh_power--; | ||
1210 | fi->fib_power--; | 1214 | fi->fib_power--; |
1211 | res->nh_sel = nhsel; | 1215 | res->nh_sel = nhsel; |
1212 | spin_unlock_bh(&fib_multipath_lock); | 1216 | spin_unlock_bh(&fib_multipath_lock); |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index fe11f60ce41b..4b4c2bcd15db 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -114,7 +114,7 @@ struct icmp_bxm { | |||
114 | /* An array of errno for error messages from dest unreach. */ | 114 | /* An array of errno for error messages from dest unreach. */ |
115 | /* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */ | 115 | /* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */ |
116 | 116 | ||
117 | struct icmp_err icmp_err_convert[] = { | 117 | const struct icmp_err icmp_err_convert[] = { |
118 | { | 118 | { |
119 | .errno = ENETUNREACH, /* ICMP_NET_UNREACH */ | 119 | .errno = ENETUNREACH, /* ICMP_NET_UNREACH */ |
120 | .fatal = 0, | 120 | .fatal = 0, |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 76c08402c933..8f5468393f01 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -2603,7 +2603,7 @@ static const struct file_operations igmp_mcf_seq_fops = { | |||
2603 | .release = seq_release_net, | 2603 | .release = seq_release_net, |
2604 | }; | 2604 | }; |
2605 | 2605 | ||
2606 | static int igmp_net_init(struct net *net) | 2606 | static int __net_init igmp_net_init(struct net *net) |
2607 | { | 2607 | { |
2608 | struct proc_dir_entry *pde; | 2608 | struct proc_dir_entry *pde; |
2609 | 2609 | ||
@@ -2621,7 +2621,7 @@ out_igmp: | |||
2621 | return -ENOMEM; | 2621 | return -ENOMEM; |
2622 | } | 2622 | } |
2623 | 2623 | ||
2624 | static void igmp_net_exit(struct net *net) | 2624 | static void __net_exit igmp_net_exit(struct net *net) |
2625 | { | 2625 | { |
2626 | proc_net_remove(net, "mcfilter"); | 2626 | proc_net_remove(net, "mcfilter"); |
2627 | proc_net_remove(net, "igmp"); | 2627 | proc_net_remove(net, "igmp"); |
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index ee16475f8fc3..8da6429269dd 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -529,6 +529,8 @@ void inet_csk_reqsk_queue_prune(struct sock *parent, | |||
529 | syn_ack_recalc(req, thresh, max_retries, | 529 | syn_ack_recalc(req, thresh, max_retries, |
530 | queue->rskq_defer_accept, | 530 | queue->rskq_defer_accept, |
531 | &expire, &resend); | 531 | &expire, &resend); |
532 | if (req->rsk_ops->syn_ack_timeout) | ||
533 | req->rsk_ops->syn_ack_timeout(parent, req); | ||
532 | if (!expire && | 534 | if (!expire && |
533 | (!resend || | 535 | (!resend || |
534 | !req->rsk_ops->rtx_syn_ack(parent, req, NULL) || | 536 | !req->rsk_ops->rtx_syn_ack(parent, req, NULL) || |
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 86964b353c31..9f41bd311754 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/netdevice.h> | 32 | #include <linux/netdevice.h> |
33 | #include <linux/jhash.h> | 33 | #include <linux/jhash.h> |
34 | #include <linux/random.h> | 34 | #include <linux/random.h> |
35 | #include <net/route.h> | ||
36 | #include <net/dst.h> | ||
35 | #include <net/sock.h> | 37 | #include <net/sock.h> |
36 | #include <net/ip.h> | 38 | #include <net/ip.h> |
37 | #include <net/icmp.h> | 39 | #include <net/icmp.h> |
@@ -205,13 +207,37 @@ static void ip_expire(unsigned long arg) | |||
205 | if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) { | 207 | if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) { |
206 | struct sk_buff *head = qp->q.fragments; | 208 | struct sk_buff *head = qp->q.fragments; |
207 | 209 | ||
208 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ | ||
209 | rcu_read_lock(); | 210 | rcu_read_lock(); |
210 | head->dev = dev_get_by_index_rcu(net, qp->iif); | 211 | head->dev = dev_get_by_index_rcu(net, qp->iif); |
211 | if (head->dev) | 212 | if (!head->dev) |
212 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); | 213 | goto out_rcu_unlock; |
213 | rcu_read_unlock(); | 214 | |
215 | /* | ||
216 | * Only search router table for the head fragment, | ||
217 | * when defraging timeout at PRE_ROUTING HOOK. | ||
218 | */ | ||
219 | if (qp->user == IP_DEFRAG_CONNTRACK_IN && !skb_dst(head)) { | ||
220 | const struct iphdr *iph = ip_hdr(head); | ||
221 | int err = ip_route_input(head, iph->daddr, iph->saddr, | ||
222 | iph->tos, head->dev); | ||
223 | if (unlikely(err)) | ||
224 | goto out_rcu_unlock; | ||
225 | |||
226 | /* | ||
227 | * Only an end host needs to send an ICMP | ||
228 | * "Fragment Reassembly Timeout" message, per RFC792. | ||
229 | */ | ||
230 | if (skb_rtable(head)->rt_type != RTN_LOCAL) | ||
231 | goto out_rcu_unlock; | ||
232 | |||
233 | } | ||
234 | |||
235 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ | ||
236 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); | ||
214 | } | 237 | } |
238 | |||
239 | out_rcu_unlock: | ||
240 | rcu_read_unlock(); | ||
215 | out: | 241 | out: |
216 | spin_unlock(&qp->q.lock); | 242 | spin_unlock(&qp->q.lock); |
217 | ipq_put(qp); | 243 | ipq_put(qp); |
@@ -646,7 +672,7 @@ static struct ctl_table ip4_frags_ctl_table[] = { | |||
646 | { } | 672 | { } |
647 | }; | 673 | }; |
648 | 674 | ||
649 | static int ip4_frags_ns_ctl_register(struct net *net) | 675 | static int __net_init ip4_frags_ns_ctl_register(struct net *net) |
650 | { | 676 | { |
651 | struct ctl_table *table; | 677 | struct ctl_table *table; |
652 | struct ctl_table_header *hdr; | 678 | struct ctl_table_header *hdr; |
@@ -676,7 +702,7 @@ err_alloc: | |||
676 | return -ENOMEM; | 702 | return -ENOMEM; |
677 | } | 703 | } |
678 | 704 | ||
679 | static void ip4_frags_ns_ctl_unregister(struct net *net) | 705 | static void __net_exit ip4_frags_ns_ctl_unregister(struct net *net) |
680 | { | 706 | { |
681 | struct ctl_table *table; | 707 | struct ctl_table *table; |
682 | 708 | ||
@@ -704,7 +730,7 @@ static inline void ip4_frags_ctl_register(void) | |||
704 | } | 730 | } |
705 | #endif | 731 | #endif |
706 | 732 | ||
707 | static int ipv4_frags_init_net(struct net *net) | 733 | static int __net_init ipv4_frags_init_net(struct net *net) |
708 | { | 734 | { |
709 | /* | 735 | /* |
710 | * Fragment cache limits. We will commit 256K at one time. Should we | 736 | * Fragment cache limits. We will commit 256K at one time. Should we |
@@ -726,7 +752,7 @@ static int ipv4_frags_init_net(struct net *net) | |||
726 | return ip4_frags_ns_ctl_register(net); | 752 | return ip4_frags_ns_ctl_register(net); |
727 | } | 753 | } |
728 | 754 | ||
729 | static void ipv4_frags_exit_net(struct net *net) | 755 | static void __net_exit ipv4_frags_exit_net(struct net *net) |
730 | { | 756 | { |
731 | ip4_frags_ns_ctl_unregister(net); | 757 | ip4_frags_ns_ctl_unregister(net); |
732 | inet_frags_exit_net(&net->ipv4.frags, &ip4_frags); | 758 | inet_frags_exit_net(&net->ipv4.frags, &ip4_frags); |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index f36ce156cac6..7631b20490f5 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -1307,7 +1307,7 @@ static void ipgre_destroy_tunnels(struct ipgre_net *ign, struct list_head *head) | |||
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | static int ipgre_init_net(struct net *net) | 1310 | static int __net_init ipgre_init_net(struct net *net) |
1311 | { | 1311 | { |
1312 | struct ipgre_net *ign = net_generic(net, ipgre_net_id); | 1312 | struct ipgre_net *ign = net_generic(net, ipgre_net_id); |
1313 | int err; | 1313 | int err; |
@@ -1334,7 +1334,7 @@ err_alloc_dev: | |||
1334 | return err; | 1334 | return err; |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | static void ipgre_exit_net(struct net *net) | 1337 | static void __net_exit ipgre_exit_net(struct net *net) |
1338 | { | 1338 | { |
1339 | struct ipgre_net *ign; | 1339 | struct ipgre_net *ign; |
1340 | LIST_HEAD(list); | 1340 | LIST_HEAD(list); |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index cafad9baff03..644dc43a55de 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -451,7 +451,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
451 | (1<<IP_TTL) | (1<<IP_HDRINCL) | | 451 | (1<<IP_TTL) | (1<<IP_HDRINCL) | |
452 | (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | | 452 | (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | |
453 | (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | | 453 | (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | |
454 | (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT))) || | 454 | (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) | |
455 | (1<<IP_MINTTL))) || | ||
455 | optname == IP_MULTICAST_TTL || | 456 | optname == IP_MULTICAST_TTL || |
456 | optname == IP_MULTICAST_ALL || | 457 | optname == IP_MULTICAST_ALL || |
457 | optname == IP_MULTICAST_LOOP || | 458 | optname == IP_MULTICAST_LOOP || |
@@ -936,6 +937,14 @@ mc_msf_out: | |||
936 | inet->transparent = !!val; | 937 | inet->transparent = !!val; |
937 | break; | 938 | break; |
938 | 939 | ||
940 | case IP_MINTTL: | ||
941 | if (optlen < 1) | ||
942 | goto e_inval; | ||
943 | if (val < 0 || val > 255) | ||
944 | goto e_inval; | ||
945 | inet->min_ttl = val; | ||
946 | break; | ||
947 | |||
939 | default: | 948 | default: |
940 | err = -ENOPROTOOPT; | 949 | err = -ENOPROTOOPT; |
941 | break; | 950 | break; |
@@ -1198,6 +1207,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, | |||
1198 | case IP_TRANSPARENT: | 1207 | case IP_TRANSPARENT: |
1199 | val = inet->transparent; | 1208 | val = inet->transparent; |
1200 | break; | 1209 | break; |
1210 | case IP_MINTTL: | ||
1211 | val = inet->min_ttl; | ||
1212 | break; | ||
1201 | default: | 1213 | default: |
1202 | release_sock(sk); | 1214 | release_sock(sk); |
1203 | return -ENOPROTOOPT; | 1215 | return -ENOPROTOOPT; |
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index eda04fed3379..95db732e542b 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
@@ -130,7 +130,6 @@ struct ipip_net { | |||
130 | struct net_device *fb_tunnel_dev; | 130 | struct net_device *fb_tunnel_dev; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | static void ipip_fb_tunnel_init(struct net_device *dev); | ||
134 | static void ipip_tunnel_init(struct net_device *dev); | 133 | static void ipip_tunnel_init(struct net_device *dev); |
135 | static void ipip_tunnel_setup(struct net_device *dev); | 134 | static void ipip_tunnel_setup(struct net_device *dev); |
136 | 135 | ||
@@ -730,7 +729,7 @@ static void ipip_tunnel_init(struct net_device *dev) | |||
730 | ipip_tunnel_bind_dev(dev); | 729 | ipip_tunnel_bind_dev(dev); |
731 | } | 730 | } |
732 | 731 | ||
733 | static void ipip_fb_tunnel_init(struct net_device *dev) | 732 | static void __net_init ipip_fb_tunnel_init(struct net_device *dev) |
734 | { | 733 | { |
735 | struct ip_tunnel *tunnel = netdev_priv(dev); | 734 | struct ip_tunnel *tunnel = netdev_priv(dev); |
736 | struct iphdr *iph = &tunnel->parms.iph; | 735 | struct iphdr *iph = &tunnel->parms.iph; |
@@ -773,7 +772,7 @@ static void ipip_destroy_tunnels(struct ipip_net *ipn, struct list_head *head) | |||
773 | } | 772 | } |
774 | } | 773 | } |
775 | 774 | ||
776 | static int ipip_init_net(struct net *net) | 775 | static int __net_init ipip_init_net(struct net *net) |
777 | { | 776 | { |
778 | struct ipip_net *ipn = net_generic(net, ipip_net_id); | 777 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
779 | int err; | 778 | int err; |
@@ -806,7 +805,7 @@ err_alloc_dev: | |||
806 | return err; | 805 | return err; |
807 | } | 806 | } |
808 | 807 | ||
809 | static void ipip_exit_net(struct net *net) | 808 | static void __net_exit ipip_exit_net(struct net *net) |
810 | { | 809 | { |
811 | struct ipip_net *ipn = net_generic(net, ipip_net_id); | 810 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
812 | LIST_HEAD(list); | 811 | LIST_HEAD(list); |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index f25542c48b7d..1b09a6dde7c0 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -127,8 +127,8 @@ static const struct snmp_mib snmp4_ipextstats_list[] = { | |||
127 | SNMP_MIB_SENTINEL | 127 | SNMP_MIB_SENTINEL |
128 | }; | 128 | }; |
129 | 129 | ||
130 | static struct { | 130 | static const struct { |
131 | char *name; | 131 | const char *name; |
132 | int index; | 132 | int index; |
133 | } icmpmibmap[] = { | 133 | } icmpmibmap[] = { |
134 | { "DestUnreachs", ICMP_DEST_UNREACH }, | 134 | { "DestUnreachs", ICMP_DEST_UNREACH }, |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index d62b05d33384..b16dfadbe6d6 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1990,8 +1990,13 @@ static int __mkroute_input(struct sk_buff *skb, | |||
1990 | if (skb->protocol != htons(ETH_P_IP)) { | 1990 | if (skb->protocol != htons(ETH_P_IP)) { |
1991 | /* Not IP (i.e. ARP). Do not create route, if it is | 1991 | /* Not IP (i.e. ARP). Do not create route, if it is |
1992 | * invalid for proxy arp. DNAT routes are always valid. | 1992 | * invalid for proxy arp. DNAT routes are always valid. |
1993 | * | ||
1994 | * Proxy arp feature have been extended to allow, ARP | ||
1995 | * replies back to the same interface, to support | ||
1996 | * Private VLAN switch technologies. See arp.c. | ||
1993 | */ | 1997 | */ |
1994 | if (out_dev == in_dev) { | 1998 | if (out_dev == in_dev && |
1999 | IN_DEV_PROXY_ARP_PVLAN(in_dev) == 0) { | ||
1995 | err = -EINVAL; | 2000 | err = -EINVAL; |
1996 | goto cleanup; | 2001 | goto cleanup; |
1997 | } | 2002 | } |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 66fd80ef2473..5c24db4a3c91 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -358,7 +358,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
358 | 358 | ||
359 | tcp_select_initial_window(tcp_full_space(sk), req->mss, | 359 | tcp_select_initial_window(tcp_full_space(sk), req->mss, |
360 | &req->rcv_wnd, &req->window_clamp, | 360 | &req->rcv_wnd, &req->window_clamp, |
361 | ireq->wscale_ok, &rcv_wscale); | 361 | ireq->wscale_ok, &rcv_wscale, |
362 | dst_metric(&rt->u.dst, RTAX_INITRWND)); | ||
362 | 363 | ||
363 | ireq->rcv_wscale = rcv_wscale; | 364 | ireq->rcv_wscale = rcv_wscale; |
364 | 365 | ||
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index b0a26bb25e2e..d5d69ea8f249 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -536,8 +536,7 @@ static inline void skb_entail(struct sock *sk, struct sk_buff *skb) | |||
536 | tp->nonagle &= ~TCP_NAGLE_PUSH; | 536 | tp->nonagle &= ~TCP_NAGLE_PUSH; |
537 | } | 537 | } |
538 | 538 | ||
539 | static inline void tcp_mark_urg(struct tcp_sock *tp, int flags, | 539 | static inline void tcp_mark_urg(struct tcp_sock *tp, int flags) |
540 | struct sk_buff *skb) | ||
541 | { | 540 | { |
542 | if (flags & MSG_OOB) | 541 | if (flags & MSG_OOB) |
543 | tp->snd_up = tp->write_seq; | 542 | tp->snd_up = tp->write_seq; |
@@ -546,13 +545,13 @@ static inline void tcp_mark_urg(struct tcp_sock *tp, int flags, | |||
546 | static inline void tcp_push(struct sock *sk, int flags, int mss_now, | 545 | static inline void tcp_push(struct sock *sk, int flags, int mss_now, |
547 | int nonagle) | 546 | int nonagle) |
548 | { | 547 | { |
549 | struct tcp_sock *tp = tcp_sk(sk); | ||
550 | |||
551 | if (tcp_send_head(sk)) { | 548 | if (tcp_send_head(sk)) { |
552 | struct sk_buff *skb = tcp_write_queue_tail(sk); | 549 | struct tcp_sock *tp = tcp_sk(sk); |
550 | |||
553 | if (!(flags & MSG_MORE) || forced_push(tp)) | 551 | if (!(flags & MSG_MORE) || forced_push(tp)) |
554 | tcp_mark_push(tp, skb); | 552 | tcp_mark_push(tp, tcp_write_queue_tail(sk)); |
555 | tcp_mark_urg(tp, flags, skb); | 553 | |
554 | tcp_mark_urg(tp, flags); | ||
556 | __tcp_push_pending_frames(sk, mss_now, | 555 | __tcp_push_pending_frames(sk, mss_now, |
557 | (flags & MSG_MORE) ? TCP_NAGLE_CORK : nonagle); | 556 | (flags & MSG_MORE) ? TCP_NAGLE_CORK : nonagle); |
558 | } | 557 | } |
@@ -877,12 +876,12 @@ ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset, | |||
877 | #define TCP_PAGE(sk) (sk->sk_sndmsg_page) | 876 | #define TCP_PAGE(sk) (sk->sk_sndmsg_page) |
878 | #define TCP_OFF(sk) (sk->sk_sndmsg_off) | 877 | #define TCP_OFF(sk) (sk->sk_sndmsg_off) |
879 | 878 | ||
880 | static inline int select_size(struct sock *sk) | 879 | static inline int select_size(struct sock *sk, int sg) |
881 | { | 880 | { |
882 | struct tcp_sock *tp = tcp_sk(sk); | 881 | struct tcp_sock *tp = tcp_sk(sk); |
883 | int tmp = tp->mss_cache; | 882 | int tmp = tp->mss_cache; |
884 | 883 | ||
885 | if (sk->sk_route_caps & NETIF_F_SG) { | 884 | if (sg) { |
886 | if (sk_can_gso(sk)) | 885 | if (sk_can_gso(sk)) |
887 | tmp = 0; | 886 | tmp = 0; |
888 | else { | 887 | else { |
@@ -906,7 +905,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
906 | struct sk_buff *skb; | 905 | struct sk_buff *skb; |
907 | int iovlen, flags; | 906 | int iovlen, flags; |
908 | int mss_now, size_goal; | 907 | int mss_now, size_goal; |
909 | int err, copied; | 908 | int sg, err, copied; |
910 | long timeo; | 909 | long timeo; |
911 | 910 | ||
912 | lock_sock(sk); | 911 | lock_sock(sk); |
@@ -934,6 +933,8 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
934 | if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) | 933 | if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) |
935 | goto out_err; | 934 | goto out_err; |
936 | 935 | ||
936 | sg = sk->sk_route_caps & NETIF_F_SG; | ||
937 | |||
937 | while (--iovlen >= 0) { | 938 | while (--iovlen >= 0) { |
938 | int seglen = iov->iov_len; | 939 | int seglen = iov->iov_len; |
939 | unsigned char __user *from = iov->iov_base; | 940 | unsigned char __user *from = iov->iov_base; |
@@ -959,8 +960,9 @@ new_segment: | |||
959 | if (!sk_stream_memory_free(sk)) | 960 | if (!sk_stream_memory_free(sk)) |
960 | goto wait_for_sndbuf; | 961 | goto wait_for_sndbuf; |
961 | 962 | ||
962 | skb = sk_stream_alloc_skb(sk, select_size(sk), | 963 | skb = sk_stream_alloc_skb(sk, |
963 | sk->sk_allocation); | 964 | select_size(sk, sg), |
965 | sk->sk_allocation); | ||
964 | if (!skb) | 966 | if (!skb) |
965 | goto wait_for_memory; | 967 | goto wait_for_memory; |
966 | 968 | ||
@@ -997,9 +999,7 @@ new_segment: | |||
997 | /* We can extend the last page | 999 | /* We can extend the last page |
998 | * fragment. */ | 1000 | * fragment. */ |
999 | merge = 1; | 1001 | merge = 1; |
1000 | } else if (i == MAX_SKB_FRAGS || | 1002 | } else if (i == MAX_SKB_FRAGS || !sg) { |
1001 | (!i && | ||
1002 | !(sk->sk_route_caps & NETIF_F_SG))) { | ||
1003 | /* Need to add new fragment and cannot | 1003 | /* Need to add new fragment and cannot |
1004 | * do this because interface is non-SG, | 1004 | * do this because interface is non-SG, |
1005 | * or because all the page slots are | 1005 | * or because all the page slots are |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 65b8ebfd078a..c3588b4fd979 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -742,9 +742,9 @@ static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, | |||
742 | * This still operates on a request_sock only, not on a big | 742 | * This still operates on a request_sock only, not on a big |
743 | * socket. | 743 | * socket. |
744 | */ | 744 | */ |
745 | static int __tcp_v4_send_synack(struct sock *sk, struct dst_entry *dst, | 745 | static int tcp_v4_send_synack(struct sock *sk, struct dst_entry *dst, |
746 | struct request_sock *req, | 746 | struct request_sock *req, |
747 | struct request_values *rvp) | 747 | struct request_values *rvp) |
748 | { | 748 | { |
749 | const struct inet_request_sock *ireq = inet_rsk(req); | 749 | const struct inet_request_sock *ireq = inet_rsk(req); |
750 | int err = -1; | 750 | int err = -1; |
@@ -775,10 +775,11 @@ static int __tcp_v4_send_synack(struct sock *sk, struct dst_entry *dst, | |||
775 | return err; | 775 | return err; |
776 | } | 776 | } |
777 | 777 | ||
778 | static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req, | 778 | static int tcp_v4_rtx_synack(struct sock *sk, struct request_sock *req, |
779 | struct request_values *rvp) | 779 | struct request_values *rvp) |
780 | { | 780 | { |
781 | return __tcp_v4_send_synack(sk, NULL, req, rvp); | 781 | TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS); |
782 | return tcp_v4_send_synack(sk, NULL, req, rvp); | ||
782 | } | 783 | } |
783 | 784 | ||
784 | /* | 785 | /* |
@@ -1192,10 +1193,11 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb) | |||
1192 | struct request_sock_ops tcp_request_sock_ops __read_mostly = { | 1193 | struct request_sock_ops tcp_request_sock_ops __read_mostly = { |
1193 | .family = PF_INET, | 1194 | .family = PF_INET, |
1194 | .obj_size = sizeof(struct tcp_request_sock), | 1195 | .obj_size = sizeof(struct tcp_request_sock), |
1195 | .rtx_syn_ack = tcp_v4_send_synack, | 1196 | .rtx_syn_ack = tcp_v4_rtx_synack, |
1196 | .send_ack = tcp_v4_reqsk_send_ack, | 1197 | .send_ack = tcp_v4_reqsk_send_ack, |
1197 | .destructor = tcp_v4_reqsk_destructor, | 1198 | .destructor = tcp_v4_reqsk_destructor, |
1198 | .send_reset = tcp_v4_send_reset, | 1199 | .send_reset = tcp_v4_send_reset, |
1200 | .syn_ack_timeout = tcp_syn_ack_timeout, | ||
1199 | }; | 1201 | }; |
1200 | 1202 | ||
1201 | #ifdef CONFIG_TCP_MD5SIG | 1203 | #ifdef CONFIG_TCP_MD5SIG |
@@ -1373,8 +1375,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1373 | } | 1375 | } |
1374 | tcp_rsk(req)->snt_isn = isn; | 1376 | tcp_rsk(req)->snt_isn = isn; |
1375 | 1377 | ||
1376 | if (__tcp_v4_send_synack(sk, dst, req, | 1378 | if (tcp_v4_send_synack(sk, dst, req, |
1377 | (struct request_values *)&tmp_ext) || | 1379 | (struct request_values *)&tmp_ext) || |
1378 | want_cookie) | 1380 | want_cookie) |
1379 | goto drop_and_free; | 1381 | goto drop_and_free; |
1380 | 1382 | ||
@@ -1649,6 +1651,9 @@ int tcp_v4_rcv(struct sk_buff *skb) | |||
1649 | if (!sk) | 1651 | if (!sk) |
1650 | goto no_tcp_socket; | 1652 | goto no_tcp_socket; |
1651 | 1653 | ||
1654 | if (iph->ttl < inet_sk(sk)->min_ttl) | ||
1655 | goto discard_and_relse; | ||
1656 | |||
1652 | process: | 1657 | process: |
1653 | if (sk->sk_state == TCP_TIME_WAIT) | 1658 | if (sk->sk_state == TCP_TIME_WAIT) |
1654 | goto do_time_wait; | 1659 | goto do_time_wait; |
@@ -2425,12 +2430,12 @@ static struct tcp_seq_afinfo tcp4_seq_afinfo = { | |||
2425 | }, | 2430 | }, |
2426 | }; | 2431 | }; |
2427 | 2432 | ||
2428 | static int tcp4_proc_init_net(struct net *net) | 2433 | static int __net_init tcp4_proc_init_net(struct net *net) |
2429 | { | 2434 | { |
2430 | return tcp_proc_register(net, &tcp4_seq_afinfo); | 2435 | return tcp_proc_register(net, &tcp4_seq_afinfo); |
2431 | } | 2436 | } |
2432 | 2437 | ||
2433 | static void tcp4_proc_exit_net(struct net *net) | 2438 | static void __net_exit tcp4_proc_exit_net(struct net *net) |
2434 | { | 2439 | { |
2435 | tcp_proc_unregister(net, &tcp4_seq_afinfo); | 2440 | tcp_proc_unregister(net, &tcp4_seq_afinfo); |
2436 | } | 2441 | } |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 383ce237640f..4a1605d3f909 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -183,7 +183,8 @@ static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts) | |||
183 | */ | 183 | */ |
184 | void tcp_select_initial_window(int __space, __u32 mss, | 184 | void tcp_select_initial_window(int __space, __u32 mss, |
185 | __u32 *rcv_wnd, __u32 *window_clamp, | 185 | __u32 *rcv_wnd, __u32 *window_clamp, |
186 | int wscale_ok, __u8 *rcv_wscale) | 186 | int wscale_ok, __u8 *rcv_wscale, |
187 | __u32 init_rcv_wnd) | ||
187 | { | 188 | { |
188 | unsigned int space = (__space < 0 ? 0 : __space); | 189 | unsigned int space = (__space < 0 ? 0 : __space); |
189 | 190 | ||
@@ -232,7 +233,13 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
232 | init_cwnd = 2; | 233 | init_cwnd = 2; |
233 | else if (mss > 1460) | 234 | else if (mss > 1460) |
234 | init_cwnd = 3; | 235 | init_cwnd = 3; |
235 | if (*rcv_wnd > init_cwnd * mss) | 236 | /* when initializing use the value from init_rcv_wnd |
237 | * rather than the default from above | ||
238 | */ | ||
239 | if (init_rcv_wnd && | ||
240 | (*rcv_wnd > init_rcv_wnd * mss)) | ||
241 | *rcv_wnd = init_rcv_wnd * mss; | ||
242 | else if (*rcv_wnd > init_cwnd * mss) | ||
236 | *rcv_wnd = init_cwnd * mss; | 243 | *rcv_wnd = init_cwnd * mss; |
237 | } | 244 | } |
238 | 245 | ||
@@ -1794,11 +1801,6 @@ static int tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, | |||
1794 | void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, | 1801 | void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, |
1795 | int nonagle) | 1802 | int nonagle) |
1796 | { | 1803 | { |
1797 | struct sk_buff *skb = tcp_send_head(sk); | ||
1798 | |||
1799 | if (!skb) | ||
1800 | return; | ||
1801 | |||
1802 | /* If we are closed, the bytes will have to remain here. | 1804 | /* If we are closed, the bytes will have to remain here. |
1803 | * In time closedown will finish, we empty the write queue and | 1805 | * In time closedown will finish, we empty the write queue and |
1804 | * all will be happy. | 1806 | * all will be happy. |
@@ -2422,7 +2424,8 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, | |||
2422 | &req->rcv_wnd, | 2424 | &req->rcv_wnd, |
2423 | &req->window_clamp, | 2425 | &req->window_clamp, |
2424 | ireq->wscale_ok, | 2426 | ireq->wscale_ok, |
2425 | &rcv_wscale); | 2427 | &rcv_wscale, |
2428 | dst_metric(dst, RTAX_INITRWND)); | ||
2426 | ireq->rcv_wscale = rcv_wscale; | 2429 | ireq->rcv_wscale = rcv_wscale; |
2427 | } | 2430 | } |
2428 | 2431 | ||
@@ -2549,7 +2552,8 @@ static void tcp_connect_init(struct sock *sk) | |||
2549 | &tp->rcv_wnd, | 2552 | &tp->rcv_wnd, |
2550 | &tp->window_clamp, | 2553 | &tp->window_clamp, |
2551 | sysctl_tcp_window_scaling, | 2554 | sysctl_tcp_window_scaling, |
2552 | &rcv_wscale); | 2555 | &rcv_wscale, |
2556 | dst_metric(dst, RTAX_INITRWND)); | ||
2553 | 2557 | ||
2554 | tp->rx_opt.rcv_wscale = rcv_wscale; | 2558 | tp->rx_opt.rcv_wscale = rcv_wscale; |
2555 | tp->rcv_ssthresh = tp->rcv_wnd; | 2559 | tp->rcv_ssthresh = tp->rcv_wnd; |
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 8816a20c2597..de7d1bf9114f 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -474,6 +474,12 @@ static void tcp_synack_timer(struct sock *sk) | |||
474 | TCP_TIMEOUT_INIT, TCP_RTO_MAX); | 474 | TCP_TIMEOUT_INIT, TCP_RTO_MAX); |
475 | } | 475 | } |
476 | 476 | ||
477 | void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req) | ||
478 | { | ||
479 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPTIMEOUTS); | ||
480 | } | ||
481 | EXPORT_SYMBOL(tcp_syn_ack_timeout); | ||
482 | |||
477 | void tcp_set_keepalive(struct sock *sk, int val) | 483 | void tcp_set_keepalive(struct sock *sk, int val) |
478 | { | 484 | { |
479 | if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) | 485 | if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index f0126fdd7e04..4f7d2122d818 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -2027,12 +2027,12 @@ static struct udp_seq_afinfo udp4_seq_afinfo = { | |||
2027 | }, | 2027 | }, |
2028 | }; | 2028 | }; |
2029 | 2029 | ||
2030 | static int udp4_proc_init_net(struct net *net) | 2030 | static int __net_init udp4_proc_init_net(struct net *net) |
2031 | { | 2031 | { |
2032 | return udp_proc_register(net, &udp4_seq_afinfo); | 2032 | return udp_proc_register(net, &udp4_seq_afinfo); |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | static void udp4_proc_exit_net(struct net *net) | 2035 | static void __net_exit udp4_proc_exit_net(struct net *net) |
2036 | { | 2036 | { |
2037 | udp_proc_unregister(net, &udp4_seq_afinfo); | 2037 | udp_proc_unregister(net, &udp4_seq_afinfo); |
2038 | } | 2038 | } |
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 66f79513f4a5..6610bf76369f 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c | |||
@@ -81,12 +81,12 @@ static struct udp_seq_afinfo udplite4_seq_afinfo = { | |||
81 | }, | 81 | }, |
82 | }; | 82 | }; |
83 | 83 | ||
84 | static int udplite4_proc_init_net(struct net *net) | 84 | static int __net_init udplite4_proc_init_net(struct net *net) |
85 | { | 85 | { |
86 | return udp_proc_register(net, &udplite4_seq_afinfo); | 86 | return udp_proc_register(net, &udplite4_seq_afinfo); |
87 | } | 87 | } |
88 | 88 | ||
89 | static void udplite4_proc_exit_net(struct net *net) | 89 | static void __net_exit udplite4_proc_exit_net(struct net *net) |
90 | { | 90 | { |
91 | udp_proc_unregister(net, &udplite4_seq_afinfo); | 91 | udp_proc_unregister(net, &udplite4_seq_afinfo); |
92 | } | 92 | } |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index de7a194a64ab..1593289155ff 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -3027,14 +3027,14 @@ static const struct file_operations if6_fops = { | |||
3027 | .release = seq_release_net, | 3027 | .release = seq_release_net, |
3028 | }; | 3028 | }; |
3029 | 3029 | ||
3030 | static int if6_proc_net_init(struct net *net) | 3030 | static int __net_init if6_proc_net_init(struct net *net) |
3031 | { | 3031 | { |
3032 | if (!proc_net_fops_create(net, "if_inet6", S_IRUGO, &if6_fops)) | 3032 | if (!proc_net_fops_create(net, "if_inet6", S_IRUGO, &if6_fops)) |
3033 | return -ENOMEM; | 3033 | return -ENOMEM; |
3034 | return 0; | 3034 | return 0; |
3035 | } | 3035 | } |
3036 | 3036 | ||
3037 | static void if6_proc_net_exit(struct net *net) | 3037 | static void __net_exit if6_proc_net_exit(struct net *net) |
3038 | { | 3038 | { |
3039 | proc_net_remove(net, "if_inet6"); | 3039 | proc_net_remove(net, "if_inet6"); |
3040 | } | 3040 | } |
@@ -4418,7 +4418,7 @@ static void addrconf_sysctl_unregister(struct inet6_dev *idev) | |||
4418 | 4418 | ||
4419 | #endif | 4419 | #endif |
4420 | 4420 | ||
4421 | static int addrconf_init_net(struct net *net) | 4421 | static int __net_init addrconf_init_net(struct net *net) |
4422 | { | 4422 | { |
4423 | int err; | 4423 | int err; |
4424 | struct ipv6_devconf *all, *dflt; | 4424 | struct ipv6_devconf *all, *dflt; |
@@ -4467,7 +4467,7 @@ err_alloc_all: | |||
4467 | return err; | 4467 | return err; |
4468 | } | 4468 | } |
4469 | 4469 | ||
4470 | static void addrconf_exit_net(struct net *net) | 4470 | static void __net_exit addrconf_exit_net(struct net *net) |
4471 | { | 4471 | { |
4472 | #ifdef CONFIG_SYSCTL | 4472 | #ifdef CONFIG_SYSCTL |
4473 | __addrconf_sysctl_unregister(net->ipv6.devconf_dflt); | 4473 | __addrconf_sysctl_unregister(net->ipv6.devconf_dflt); |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 12e69d364dd5..e29160ff4a0f 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -999,7 +999,7 @@ err_udplite_mib: | |||
999 | return -ENOMEM; | 999 | return -ENOMEM; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | static void __net_exit ipv6_cleanup_mibs(struct net *net) | 1002 | static void ipv6_cleanup_mibs(struct net *net) |
1003 | { | 1003 | { |
1004 | snmp_mib_free((void **)net->mib.udp_stats_in6); | 1004 | snmp_mib_free((void **)net->mib.udp_stats_in6); |
1005 | snmp_mib_free((void **)net->mib.udplite_stats_in6); | 1005 | snmp_mib_free((void **)net->mib.udplite_stats_in6); |
@@ -1042,7 +1042,7 @@ out: | |||
1042 | #endif | 1042 | #endif |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | static void inet6_net_exit(struct net *net) | 1045 | static void __net_exit inet6_net_exit(struct net *net) |
1046 | { | 1046 | { |
1047 | #ifdef CONFIG_PROC_FS | 1047 | #ifdef CONFIG_PROC_FS |
1048 | udp6_proc_exit(net); | 1048 | udp6_proc_exit(net); |
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c index f1c74c8ef9de..c4f6ca32fa74 100644 --- a/net/ipv6/anycast.c +++ b/net/ipv6/anycast.c | |||
@@ -538,7 +538,7 @@ static const struct file_operations ac6_seq_fops = { | |||
538 | .release = seq_release_net, | 538 | .release = seq_release_net, |
539 | }; | 539 | }; |
540 | 540 | ||
541 | int ac6_proc_init(struct net *net) | 541 | int __net_init ac6_proc_init(struct net *net) |
542 | { | 542 | { |
543 | if (!proc_net_fops_create(net, "anycast6", S_IRUGO, &ac6_seq_fops)) | 543 | if (!proc_net_fops_create(net, "anycast6", S_IRUGO, &ac6_seq_fops)) |
544 | return -ENOMEM; | 544 | return -ENOMEM; |
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index b7aa7c64cc4a..551882b9dfd6 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
@@ -262,7 +262,7 @@ static struct fib_rules_ops fib6_rules_ops_template = { | |||
262 | .fro_net = &init_net, | 262 | .fro_net = &init_net, |
263 | }; | 263 | }; |
264 | 264 | ||
265 | static int fib6_rules_net_init(struct net *net) | 265 | static int __net_init fib6_rules_net_init(struct net *net) |
266 | { | 266 | { |
267 | struct fib_rules_ops *ops; | 267 | struct fib_rules_ops *ops; |
268 | int err = -ENOMEM; | 268 | int err = -ENOMEM; |
@@ -291,7 +291,7 @@ out_fib6_rules_ops: | |||
291 | goto out; | 291 | goto out; |
292 | } | 292 | } |
293 | 293 | ||
294 | static void fib6_rules_net_exit(struct net *net) | 294 | static void __net_exit fib6_rules_net_exit(struct net *net) |
295 | { | 295 | { |
296 | fib_rules_unregister(net->ipv6.fib6_rules_ops); | 296 | fib_rules_unregister(net->ipv6.fib6_rules_ops); |
297 | } | 297 | } |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 4ae661bc3677..217dbc2e28d4 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -951,7 +951,7 @@ ctl_table ipv6_icmp_table_template[] = { | |||
951 | { }, | 951 | { }, |
952 | }; | 952 | }; |
953 | 953 | ||
954 | struct ctl_table *ipv6_icmp_sysctl_init(struct net *net) | 954 | struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net) |
955 | { | 955 | { |
956 | struct ctl_table *table; | 956 | struct ctl_table *table; |
957 | 957 | ||
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 0e93ca56eb69..f626ea2b304f 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -239,7 +239,7 @@ struct fib6_table *fib6_get_table(struct net *net, u32 id) | |||
239 | return NULL; | 239 | return NULL; |
240 | } | 240 | } |
241 | 241 | ||
242 | static void fib6_tables_init(struct net *net) | 242 | static void __net_init fib6_tables_init(struct net *net) |
243 | { | 243 | { |
244 | fib6_link_table(net, net->ipv6.fib6_main_tbl); | 244 | fib6_link_table(net, net->ipv6.fib6_main_tbl); |
245 | fib6_link_table(net, net->ipv6.fib6_local_tbl); | 245 | fib6_link_table(net, net->ipv6.fib6_local_tbl); |
@@ -262,7 +262,7 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl, | |||
262 | return (struct dst_entry *) lookup(net, net->ipv6.fib6_main_tbl, fl, flags); | 262 | return (struct dst_entry *) lookup(net, net->ipv6.fib6_main_tbl, fl, flags); |
263 | } | 263 | } |
264 | 264 | ||
265 | static void fib6_tables_init(struct net *net) | 265 | static void __net_init fib6_tables_init(struct net *net) |
266 | { | 266 | { |
267 | fib6_link_table(net, net->ipv6.fib6_main_tbl); | 267 | fib6_link_table(net, net->ipv6.fib6_main_tbl); |
268 | } | 268 | } |
@@ -1469,7 +1469,7 @@ static void fib6_gc_timer_cb(unsigned long arg) | |||
1469 | fib6_run_gc(0, (struct net *)arg); | 1469 | fib6_run_gc(0, (struct net *)arg); |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | static int fib6_net_init(struct net *net) | 1472 | static int __net_init fib6_net_init(struct net *net) |
1473 | { | 1473 | { |
1474 | setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); | 1474 | setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); |
1475 | 1475 | ||
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 6e7bffa2205e..e41eba8aacf1 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c | |||
@@ -154,7 +154,7 @@ static void ip6_fl_gc(unsigned long dummy) | |||
154 | write_unlock(&ip6_fl_lock); | 154 | write_unlock(&ip6_fl_lock); |
155 | } | 155 | } |
156 | 156 | ||
157 | static void ip6_fl_purge(struct net *net) | 157 | static void __net_exit ip6_fl_purge(struct net *net) |
158 | { | 158 | { |
159 | int i; | 159 | int i; |
160 | 160 | ||
@@ -735,7 +735,7 @@ static const struct file_operations ip6fl_seq_fops = { | |||
735 | .release = seq_release_net, | 735 | .release = seq_release_net, |
736 | }; | 736 | }; |
737 | 737 | ||
738 | static int ip6_flowlabel_proc_init(struct net *net) | 738 | static int __net_init ip6_flowlabel_proc_init(struct net *net) |
739 | { | 739 | { |
740 | if (!proc_net_fops_create(net, "ip6_flowlabel", | 740 | if (!proc_net_fops_create(net, "ip6_flowlabel", |
741 | S_IRUGO, &ip6fl_seq_fops)) | 741 | S_IRUGO, &ip6fl_seq_fops)) |
@@ -743,7 +743,7 @@ static int ip6_flowlabel_proc_init(struct net *net) | |||
743 | return 0; | 743 | return 0; |
744 | } | 744 | } |
745 | 745 | ||
746 | static void ip6_flowlabel_proc_fini(struct net *net) | 746 | static void __net_exit ip6_flowlabel_proc_fini(struct net *net) |
747 | { | 747 | { |
748 | proc_net_remove(net, "ip6_flowlabel"); | 748 | proc_net_remove(net, "ip6_flowlabel"); |
749 | } | 749 | } |
@@ -754,11 +754,10 @@ static inline int ip6_flowlabel_proc_init(struct net *net) | |||
754 | } | 754 | } |
755 | static inline void ip6_flowlabel_proc_fini(struct net *net) | 755 | static inline void ip6_flowlabel_proc_fini(struct net *net) |
756 | { | 756 | { |
757 | return ; | ||
758 | } | 757 | } |
759 | #endif | 758 | #endif |
760 | 759 | ||
761 | static inline void ip6_flowlabel_net_exit(struct net *net) | 760 | static void __net_exit ip6_flowlabel_net_exit(struct net *net) |
762 | { | 761 | { |
763 | ip6_fl_purge(net); | 762 | ip6_fl_purge(net); |
764 | ip6_flowlabel_proc_fini(net); | 763 | ip6_flowlabel_proc_fini(net); |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index d453d07b0dfe..fbd786981aa9 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -74,7 +74,6 @@ MODULE_LICENSE("GPL"); | |||
74 | (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \ | 74 | (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \ |
75 | (HASH_SIZE - 1)) | 75 | (HASH_SIZE - 1)) |
76 | 76 | ||
77 | static void ip6_fb_tnl_dev_init(struct net_device *dev); | ||
78 | static void ip6_tnl_dev_init(struct net_device *dev); | 77 | static void ip6_tnl_dev_init(struct net_device *dev); |
79 | static void ip6_tnl_dev_setup(struct net_device *dev); | 78 | static void ip6_tnl_dev_setup(struct net_device *dev); |
80 | 79 | ||
@@ -1364,7 +1363,7 @@ static void ip6_tnl_dev_init(struct net_device *dev) | |||
1364 | * Return: 0 | 1363 | * Return: 0 |
1365 | **/ | 1364 | **/ |
1366 | 1365 | ||
1367 | static void ip6_fb_tnl_dev_init(struct net_device *dev) | 1366 | static void __net_init ip6_fb_tnl_dev_init(struct net_device *dev) |
1368 | { | 1367 | { |
1369 | struct ip6_tnl *t = netdev_priv(dev); | 1368 | struct ip6_tnl *t = netdev_priv(dev); |
1370 | struct net *net = dev_net(dev); | 1369 | struct net *net = dev_net(dev); |
@@ -1388,7 +1387,7 @@ static struct xfrm6_tunnel ip6ip6_handler = { | |||
1388 | .priority = 1, | 1387 | .priority = 1, |
1389 | }; | 1388 | }; |
1390 | 1389 | ||
1391 | static void ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n) | 1390 | static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n) |
1392 | { | 1391 | { |
1393 | int h; | 1392 | int h; |
1394 | struct ip6_tnl *t; | 1393 | struct ip6_tnl *t; |
@@ -1407,7 +1406,7 @@ static void ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n) | |||
1407 | unregister_netdevice_many(&list); | 1406 | unregister_netdevice_many(&list); |
1408 | } | 1407 | } |
1409 | 1408 | ||
1410 | static int ip6_tnl_init_net(struct net *net) | 1409 | static int __net_init ip6_tnl_init_net(struct net *net) |
1411 | { | 1410 | { |
1412 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); | 1411 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); |
1413 | int err; | 1412 | int err; |
@@ -1436,7 +1435,7 @@ err_alloc_dev: | |||
1436 | return err; | 1435 | return err; |
1437 | } | 1436 | } |
1438 | 1437 | ||
1439 | static void ip6_tnl_exit_net(struct net *net) | 1438 | static void __net_exit ip6_tnl_exit_net(struct net *net) |
1440 | { | 1439 | { |
1441 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); | 1440 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); |
1442 | 1441 | ||
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 1f9c44442e65..25f6cca79e6b 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -2646,7 +2646,7 @@ static const struct file_operations igmp6_mcf_seq_fops = { | |||
2646 | .release = seq_release_net, | 2646 | .release = seq_release_net, |
2647 | }; | 2647 | }; |
2648 | 2648 | ||
2649 | static int igmp6_proc_init(struct net *net) | 2649 | static int __net_init igmp6_proc_init(struct net *net) |
2650 | { | 2650 | { |
2651 | int err; | 2651 | int err; |
2652 | 2652 | ||
@@ -2666,23 +2666,22 @@ out_proc_net_igmp6: | |||
2666 | goto out; | 2666 | goto out; |
2667 | } | 2667 | } |
2668 | 2668 | ||
2669 | static void igmp6_proc_exit(struct net *net) | 2669 | static void __net_exit igmp6_proc_exit(struct net *net) |
2670 | { | 2670 | { |
2671 | proc_net_remove(net, "mcfilter6"); | 2671 | proc_net_remove(net, "mcfilter6"); |
2672 | proc_net_remove(net, "igmp6"); | 2672 | proc_net_remove(net, "igmp6"); |
2673 | } | 2673 | } |
2674 | #else | 2674 | #else |
2675 | static int igmp6_proc_init(struct net *net) | 2675 | static inline int igmp6_proc_init(struct net *net) |
2676 | { | 2676 | { |
2677 | return 0; | 2677 | return 0; |
2678 | } | 2678 | } |
2679 | static void igmp6_proc_exit(struct net *net) | 2679 | static inline void igmp6_proc_exit(struct net *net) |
2680 | { | 2680 | { |
2681 | ; | ||
2682 | } | 2681 | } |
2683 | #endif | 2682 | #endif |
2684 | 2683 | ||
2685 | static int igmp6_net_init(struct net *net) | 2684 | static int __net_init igmp6_net_init(struct net *net) |
2686 | { | 2685 | { |
2687 | int err; | 2686 | int err; |
2688 | 2687 | ||
@@ -2708,7 +2707,7 @@ out_sock_create: | |||
2708 | goto out; | 2707 | goto out; |
2709 | } | 2708 | } |
2710 | 2709 | ||
2711 | static void igmp6_net_exit(struct net *net) | 2710 | static void __net_exit igmp6_net_exit(struct net *net) |
2712 | { | 2711 | { |
2713 | inet_ctl_sock_destroy(net->ipv6.igmp_sk); | 2712 | inet_ctl_sock_destroy(net->ipv6.igmp_sk); |
2714 | igmp6_proc_exit(net); | 2713 | igmp6_proc_exit(net); |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index c45852798092..2dfec6bb8ada 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -1772,7 +1772,7 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu | |||
1772 | 1772 | ||
1773 | #endif | 1773 | #endif |
1774 | 1774 | ||
1775 | static int ndisc_net_init(struct net *net) | 1775 | static int __net_init ndisc_net_init(struct net *net) |
1776 | { | 1776 | { |
1777 | struct ipv6_pinfo *np; | 1777 | struct ipv6_pinfo *np; |
1778 | struct sock *sk; | 1778 | struct sock *sk; |
@@ -1797,7 +1797,7 @@ static int ndisc_net_init(struct net *net) | |||
1797 | return 0; | 1797 | return 0; |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | static void ndisc_net_exit(struct net *net) | 1800 | static void __net_exit ndisc_net_exit(struct net *net) |
1801 | { | 1801 | { |
1802 | inet_ctl_sock_destroy(net->ipv6.ndisc_sk); | 1802 | inet_ctl_sock_destroy(net->ipv6.ndisc_sk); |
1803 | } | 1803 | } |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index c9605c3ad91f..bfe2598dd563 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -59,7 +59,7 @@ static const struct file_operations sockstat6_seq_fops = { | |||
59 | .release = single_release_net, | 59 | .release = single_release_net, |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static struct snmp_mib snmp6_ipstats_list[] = { | 62 | static const struct snmp_mib snmp6_ipstats_list[] = { |
63 | /* ipv6 mib according to RFC 2465 */ | 63 | /* ipv6 mib according to RFC 2465 */ |
64 | SNMP_MIB_ITEM("Ip6InReceives", IPSTATS_MIB_INPKTS), | 64 | SNMP_MIB_ITEM("Ip6InReceives", IPSTATS_MIB_INPKTS), |
65 | SNMP_MIB_ITEM("Ip6InHdrErrors", IPSTATS_MIB_INHDRERRORS), | 65 | SNMP_MIB_ITEM("Ip6InHdrErrors", IPSTATS_MIB_INHDRERRORS), |
@@ -92,7 +92,7 @@ static struct snmp_mib snmp6_ipstats_list[] = { | |||
92 | SNMP_MIB_SENTINEL | 92 | SNMP_MIB_SENTINEL |
93 | }; | 93 | }; |
94 | 94 | ||
95 | static struct snmp_mib snmp6_icmp6_list[] = { | 95 | static const struct snmp_mib snmp6_icmp6_list[] = { |
96 | /* icmpv6 mib according to RFC 2466 */ | 96 | /* icmpv6 mib according to RFC 2466 */ |
97 | SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS), | 97 | SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS), |
98 | SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS), | 98 | SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS), |
@@ -120,7 +120,7 @@ static const char *const icmp6type2name[256] = { | |||
120 | }; | 120 | }; |
121 | 121 | ||
122 | 122 | ||
123 | static struct snmp_mib snmp6_udp6_list[] = { | 123 | static const struct snmp_mib snmp6_udp6_list[] = { |
124 | SNMP_MIB_ITEM("Udp6InDatagrams", UDP_MIB_INDATAGRAMS), | 124 | SNMP_MIB_ITEM("Udp6InDatagrams", UDP_MIB_INDATAGRAMS), |
125 | SNMP_MIB_ITEM("Udp6NoPorts", UDP_MIB_NOPORTS), | 125 | SNMP_MIB_ITEM("Udp6NoPorts", UDP_MIB_NOPORTS), |
126 | SNMP_MIB_ITEM("Udp6InErrors", UDP_MIB_INERRORS), | 126 | SNMP_MIB_ITEM("Udp6InErrors", UDP_MIB_INERRORS), |
@@ -128,7 +128,7 @@ static struct snmp_mib snmp6_udp6_list[] = { | |||
128 | SNMP_MIB_SENTINEL | 128 | SNMP_MIB_SENTINEL |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static struct snmp_mib snmp6_udplite6_list[] = { | 131 | static const struct snmp_mib snmp6_udplite6_list[] = { |
132 | SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS), | 132 | SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS), |
133 | SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS), | 133 | SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS), |
134 | SNMP_MIB_ITEM("UdpLite6InErrors", UDP_MIB_INERRORS), | 134 | SNMP_MIB_ITEM("UdpLite6InErrors", UDP_MIB_INERRORS), |
@@ -170,8 +170,8 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) | |||
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | 172 | ||
173 | static inline void | 173 | static void snmp6_seq_show_item(struct seq_file *seq, void **mib, |
174 | snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp_mib *itemlist) | 174 | const struct snmp_mib *itemlist) |
175 | { | 175 | { |
176 | int i; | 176 | int i; |
177 | for (i=0; itemlist[i].name; i++) | 177 | for (i=0; itemlist[i].name; i++) |
@@ -259,7 +259,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev) | |||
259 | struct net *net = dev_net(idev->dev); | 259 | struct net *net = dev_net(idev->dev); |
260 | if (!net->mib.proc_net_devsnmp6) | 260 | if (!net->mib.proc_net_devsnmp6) |
261 | return -ENOENT; | 261 | return -ENOENT; |
262 | if (!idev || !idev->stats.proc_dir_entry) | 262 | if (!idev->stats.proc_dir_entry) |
263 | return -EINVAL; | 263 | return -EINVAL; |
264 | remove_proc_entry(idev->stats.proc_dir_entry->name, | 264 | remove_proc_entry(idev->stats.proc_dir_entry->name, |
265 | net->mib.proc_net_devsnmp6); | 265 | net->mib.proc_net_devsnmp6); |
@@ -267,7 +267,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev) | |||
267 | return 0; | 267 | return 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | static int ipv6_proc_init_net(struct net *net) | 270 | static int __net_init ipv6_proc_init_net(struct net *net) |
271 | { | 271 | { |
272 | if (!proc_net_fops_create(net, "sockstat6", S_IRUGO, | 272 | if (!proc_net_fops_create(net, "sockstat6", S_IRUGO, |
273 | &sockstat6_seq_fops)) | 273 | &sockstat6_seq_fops)) |
@@ -288,7 +288,7 @@ proc_dev_snmp6_fail: | |||
288 | return -ENOMEM; | 288 | return -ENOMEM; |
289 | } | 289 | } |
290 | 290 | ||
291 | static void ipv6_proc_exit_net(struct net *net) | 291 | static void __net_exit ipv6_proc_exit_net(struct net *net) |
292 | { | 292 | { |
293 | proc_net_remove(net, "sockstat6"); | 293 | proc_net_remove(net, "sockstat6"); |
294 | proc_net_remove(net, "dev_snmp6"); | 294 | proc_net_remove(net, "dev_snmp6"); |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 926ce8eeffaf..ed31c37c6e39 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -1275,7 +1275,7 @@ static const struct file_operations raw6_seq_fops = { | |||
1275 | .release = seq_release_net, | 1275 | .release = seq_release_net, |
1276 | }; | 1276 | }; |
1277 | 1277 | ||
1278 | static int raw6_init_net(struct net *net) | 1278 | static int __net_init raw6_init_net(struct net *net) |
1279 | { | 1279 | { |
1280 | if (!proc_net_fops_create(net, "raw6", S_IRUGO, &raw6_seq_fops)) | 1280 | if (!proc_net_fops_create(net, "raw6", S_IRUGO, &raw6_seq_fops)) |
1281 | return -ENOMEM; | 1281 | return -ENOMEM; |
@@ -1283,7 +1283,7 @@ static int raw6_init_net(struct net *net) | |||
1283 | return 0; | 1283 | return 0; |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | static void raw6_exit_net(struct net *net) | 1286 | static void __net_exit raw6_exit_net(struct net *net) |
1287 | { | 1287 | { |
1288 | proc_net_remove(net, "raw6"); | 1288 | proc_net_remove(net, "raw6"); |
1289 | } | 1289 | } |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 2cddea3bd6be..fa38fc7cc6e9 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -672,7 +672,7 @@ static struct ctl_table ip6_frags_ctl_table[] = { | |||
672 | { } | 672 | { } |
673 | }; | 673 | }; |
674 | 674 | ||
675 | static int ip6_frags_ns_sysctl_register(struct net *net) | 675 | static int __net_init ip6_frags_ns_sysctl_register(struct net *net) |
676 | { | 676 | { |
677 | struct ctl_table *table; | 677 | struct ctl_table *table; |
678 | struct ctl_table_header *hdr; | 678 | struct ctl_table_header *hdr; |
@@ -702,7 +702,7 @@ err_alloc: | |||
702 | return -ENOMEM; | 702 | return -ENOMEM; |
703 | } | 703 | } |
704 | 704 | ||
705 | static void ip6_frags_ns_sysctl_unregister(struct net *net) | 705 | static void __net_exit ip6_frags_ns_sysctl_unregister(struct net *net) |
706 | { | 706 | { |
707 | struct ctl_table *table; | 707 | struct ctl_table *table; |
708 | 708 | ||
@@ -745,7 +745,7 @@ static inline void ip6_frags_sysctl_unregister(void) | |||
745 | } | 745 | } |
746 | #endif | 746 | #endif |
747 | 747 | ||
748 | static int ipv6_frags_init_net(struct net *net) | 748 | static int __net_init ipv6_frags_init_net(struct net *net) |
749 | { | 749 | { |
750 | net->ipv6.frags.high_thresh = 256 * 1024; | 750 | net->ipv6.frags.high_thresh = 256 * 1024; |
751 | net->ipv6.frags.low_thresh = 192 * 1024; | 751 | net->ipv6.frags.low_thresh = 192 * 1024; |
@@ -756,7 +756,7 @@ static int ipv6_frags_init_net(struct net *net) | |||
756 | return ip6_frags_ns_sysctl_register(net); | 756 | return ip6_frags_ns_sysctl_register(net); |
757 | } | 757 | } |
758 | 758 | ||
759 | static void ipv6_frags_exit_net(struct net *net) | 759 | static void __net_exit ipv6_frags_exit_net(struct net *net) |
760 | { | 760 | { |
761 | ip6_frags_ns_sysctl_unregister(net); | 761 | ip6_frags_ns_sysctl_unregister(net); |
762 | inet_frags_exit_net(&net->ipv6.frags, &ip6_frags); | 762 | inet_frags_exit_net(&net->ipv6.frags, &ip6_frags); |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index c2bd74c5f8d9..8500156f2637 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2612,7 +2612,7 @@ ctl_table ipv6_route_table_template[] = { | |||
2612 | { } | 2612 | { } |
2613 | }; | 2613 | }; |
2614 | 2614 | ||
2615 | struct ctl_table *ipv6_route_sysctl_init(struct net *net) | 2615 | struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) |
2616 | { | 2616 | { |
2617 | struct ctl_table *table; | 2617 | struct ctl_table *table; |
2618 | 2618 | ||
@@ -2637,7 +2637,7 @@ struct ctl_table *ipv6_route_sysctl_init(struct net *net) | |||
2637 | } | 2637 | } |
2638 | #endif | 2638 | #endif |
2639 | 2639 | ||
2640 | static int ip6_route_net_init(struct net *net) | 2640 | static int __net_init ip6_route_net_init(struct net *net) |
2641 | { | 2641 | { |
2642 | int ret = -ENOMEM; | 2642 | int ret = -ENOMEM; |
2643 | 2643 | ||
@@ -2702,7 +2702,7 @@ out_ip6_dst_ops: | |||
2702 | goto out; | 2702 | goto out; |
2703 | } | 2703 | } |
2704 | 2704 | ||
2705 | static void ip6_route_net_exit(struct net *net) | 2705 | static void __net_exit ip6_route_net_exit(struct net *net) |
2706 | { | 2706 | { |
2707 | #ifdef CONFIG_PROC_FS | 2707 | #ifdef CONFIG_PROC_FS |
2708 | proc_net_remove(net, "ipv6_route"); | 2708 | proc_net_remove(net, "ipv6_route"); |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 976e68244b99..10207cc8cc0e 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -62,7 +62,6 @@ | |||
62 | #define HASH_SIZE 16 | 62 | #define HASH_SIZE 16 |
63 | #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF) | 63 | #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF) |
64 | 64 | ||
65 | static void ipip6_fb_tunnel_init(struct net_device *dev); | ||
66 | static void ipip6_tunnel_init(struct net_device *dev); | 65 | static void ipip6_tunnel_init(struct net_device *dev); |
67 | static void ipip6_tunnel_setup(struct net_device *dev); | 66 | static void ipip6_tunnel_setup(struct net_device *dev); |
68 | 67 | ||
@@ -1120,7 +1119,7 @@ static void ipip6_tunnel_init(struct net_device *dev) | |||
1120 | ipip6_tunnel_bind_dev(dev); | 1119 | ipip6_tunnel_bind_dev(dev); |
1121 | } | 1120 | } |
1122 | 1121 | ||
1123 | static void ipip6_fb_tunnel_init(struct net_device *dev) | 1122 | static void __net_init ipip6_fb_tunnel_init(struct net_device *dev) |
1124 | { | 1123 | { |
1125 | struct ip_tunnel *tunnel = netdev_priv(dev); | 1124 | struct ip_tunnel *tunnel = netdev_priv(dev); |
1126 | struct iphdr *iph = &tunnel->parms.iph; | 1125 | struct iphdr *iph = &tunnel->parms.iph; |
@@ -1145,7 +1144,7 @@ static struct xfrm_tunnel sit_handler = { | |||
1145 | .priority = 1, | 1144 | .priority = 1, |
1146 | }; | 1145 | }; |
1147 | 1146 | ||
1148 | static void sit_destroy_tunnels(struct sit_net *sitn, struct list_head *head) | 1147 | static void __net_exit sit_destroy_tunnels(struct sit_net *sitn, struct list_head *head) |
1149 | { | 1148 | { |
1150 | int prio; | 1149 | int prio; |
1151 | 1150 | ||
@@ -1162,7 +1161,7 @@ static void sit_destroy_tunnels(struct sit_net *sitn, struct list_head *head) | |||
1162 | } | 1161 | } |
1163 | } | 1162 | } |
1164 | 1163 | ||
1165 | static int sit_init_net(struct net *net) | 1164 | static int __net_init sit_init_net(struct net *net) |
1166 | { | 1165 | { |
1167 | struct sit_net *sitn = net_generic(net, sit_net_id); | 1166 | struct sit_net *sitn = net_generic(net, sit_net_id); |
1168 | int err; | 1167 | int err; |
@@ -1195,7 +1194,7 @@ err_alloc_dev: | |||
1195 | return err; | 1194 | return err; |
1196 | } | 1195 | } |
1197 | 1196 | ||
1198 | static void sit_exit_net(struct net *net) | 1197 | static void __net_exit sit_exit_net(struct net *net) |
1199 | { | 1198 | { |
1200 | struct sit_net *sitn = net_generic(net, sit_net_id); | 1199 | struct sit_net *sitn = net_generic(net, sit_net_id); |
1201 | LIST_HEAD(list); | 1200 | LIST_HEAD(list); |
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 7208a06576c6..34d1f0690d7e 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c | |||
@@ -269,7 +269,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
269 | req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); | 269 | req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); |
270 | tcp_select_initial_window(tcp_full_space(sk), req->mss, | 270 | tcp_select_initial_window(tcp_full_space(sk), req->mss, |
271 | &req->rcv_wnd, &req->window_clamp, | 271 | &req->rcv_wnd, &req->window_clamp, |
272 | ireq->wscale_ok, &rcv_wscale); | 272 | ireq->wscale_ok, &rcv_wscale, |
273 | dst_metric(dst, RTAX_INITRWND)); | ||
273 | 274 | ||
274 | ireq->rcv_wscale = rcv_wscale; | 275 | ireq->rcv_wscale = rcv_wscale; |
275 | 276 | ||
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index c690736885b4..f841d93bf987 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c | |||
@@ -55,7 +55,7 @@ struct ctl_path net_ipv6_ctl_path[] = { | |||
55 | }; | 55 | }; |
56 | EXPORT_SYMBOL_GPL(net_ipv6_ctl_path); | 56 | EXPORT_SYMBOL_GPL(net_ipv6_ctl_path); |
57 | 57 | ||
58 | static int ipv6_sysctl_net_init(struct net *net) | 58 | static int __net_init ipv6_sysctl_net_init(struct net *net) |
59 | { | 59 | { |
60 | struct ctl_table *ipv6_table; | 60 | struct ctl_table *ipv6_table; |
61 | struct ctl_table *ipv6_route_table; | 61 | struct ctl_table *ipv6_route_table; |
@@ -98,7 +98,7 @@ out_ipv6_table: | |||
98 | goto out; | 98 | goto out; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void ipv6_sysctl_net_exit(struct net *net) | 101 | static void __net_exit ipv6_sysctl_net_exit(struct net *net) |
102 | { | 102 | { |
103 | struct ctl_table *ipv6_table; | 103 | struct ctl_table *ipv6_table; |
104 | struct ctl_table *ipv6_route_table; | 104 | struct ctl_table *ipv6_route_table; |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index febfd595a40d..6963a6b6763e 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -520,6 +520,13 @@ done: | |||
520 | return err; | 520 | return err; |
521 | } | 521 | } |
522 | 522 | ||
523 | static int tcp_v6_rtx_synack(struct sock *sk, struct request_sock *req, | ||
524 | struct request_values *rvp) | ||
525 | { | ||
526 | TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS); | ||
527 | return tcp_v6_send_synack(sk, req, rvp); | ||
528 | } | ||
529 | |||
523 | static inline void syn_flood_warning(struct sk_buff *skb) | 530 | static inline void syn_flood_warning(struct sk_buff *skb) |
524 | { | 531 | { |
525 | #ifdef CONFIG_SYN_COOKIES | 532 | #ifdef CONFIG_SYN_COOKIES |
@@ -876,7 +883,7 @@ static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | |||
876 | 883 | ||
877 | if (genhash || memcmp(hash_location, newhash, 16) != 0) { | 884 | if (genhash || memcmp(hash_location, newhash, 16) != 0) { |
878 | if (net_ratelimit()) { | 885 | if (net_ratelimit()) { |
879 | printk(KERN_INFO "MD5 Hash %s for (%pI6, %u)->(%pI6, %u)\n", | 886 | printk(KERN_INFO "MD5 Hash %s for [%pI6c]:%u->[%pI6c]:%u\n", |
880 | genhash ? "failed" : "mismatch", | 887 | genhash ? "failed" : "mismatch", |
881 | &ip6h->saddr, ntohs(th->source), | 888 | &ip6h->saddr, ntohs(th->source), |
882 | &ip6h->daddr, ntohs(th->dest)); | 889 | &ip6h->daddr, ntohs(th->dest)); |
@@ -890,10 +897,11 @@ static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | |||
890 | struct request_sock_ops tcp6_request_sock_ops __read_mostly = { | 897 | struct request_sock_ops tcp6_request_sock_ops __read_mostly = { |
891 | .family = AF_INET6, | 898 | .family = AF_INET6, |
892 | .obj_size = sizeof(struct tcp6_request_sock), | 899 | .obj_size = sizeof(struct tcp6_request_sock), |
893 | .rtx_syn_ack = tcp_v6_send_synack, | 900 | .rtx_syn_ack = tcp_v6_rtx_synack, |
894 | .send_ack = tcp_v6_reqsk_send_ack, | 901 | .send_ack = tcp_v6_reqsk_send_ack, |
895 | .destructor = tcp_v6_reqsk_destructor, | 902 | .destructor = tcp_v6_reqsk_destructor, |
896 | .send_reset = tcp_v6_send_reset | 903 | .send_reset = tcp_v6_send_reset, |
904 | .syn_ack_timeout = tcp_syn_ack_timeout, | ||
897 | }; | 905 | }; |
898 | 906 | ||
899 | #ifdef CONFIG_TCP_MD5SIG | 907 | #ifdef CONFIG_TCP_MD5SIG |
@@ -2105,7 +2113,7 @@ static struct tcp_seq_afinfo tcp6_seq_afinfo = { | |||
2105 | }, | 2113 | }, |
2106 | }; | 2114 | }; |
2107 | 2115 | ||
2108 | int tcp6_proc_init(struct net *net) | 2116 | int __net_init tcp6_proc_init(struct net *net) |
2109 | { | 2117 | { |
2110 | return tcp_proc_register(net, &tcp6_seq_afinfo); | 2118 | return tcp_proc_register(net, &tcp6_seq_afinfo); |
2111 | } | 2119 | } |
@@ -2174,18 +2182,18 @@ static struct inet_protosw tcpv6_protosw = { | |||
2174 | INET_PROTOSW_ICSK, | 2182 | INET_PROTOSW_ICSK, |
2175 | }; | 2183 | }; |
2176 | 2184 | ||
2177 | static int tcpv6_net_init(struct net *net) | 2185 | static int __net_init tcpv6_net_init(struct net *net) |
2178 | { | 2186 | { |
2179 | return inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6, | 2187 | return inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6, |
2180 | SOCK_RAW, IPPROTO_TCP, net); | 2188 | SOCK_RAW, IPPROTO_TCP, net); |
2181 | } | 2189 | } |
2182 | 2190 | ||
2183 | static void tcpv6_net_exit(struct net *net) | 2191 | static void __net_exit tcpv6_net_exit(struct net *net) |
2184 | { | 2192 | { |
2185 | inet_ctl_sock_destroy(net->ipv6.tcp_sk); | 2193 | inet_ctl_sock_destroy(net->ipv6.tcp_sk); |
2186 | } | 2194 | } |
2187 | 2195 | ||
2188 | static void tcpv6_net_exit_batch(struct list_head *net_exit_list) | 2196 | static void __net_exit tcpv6_net_exit_batch(struct list_head *net_exit_list) |
2189 | { | 2197 | { |
2190 | inet_twsk_purge(&tcp_hashinfo, &tcp_death_row, AF_INET6); | 2198 | inet_twsk_purge(&tcp_hashinfo, &tcp_death_row, AF_INET6); |
2191 | } | 2199 | } |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 69ebdbe78c47..34efb3589ffa 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -1396,7 +1396,7 @@ static struct udp_seq_afinfo udp6_seq_afinfo = { | |||
1396 | }, | 1396 | }, |
1397 | }; | 1397 | }; |
1398 | 1398 | ||
1399 | int udp6_proc_init(struct net *net) | 1399 | int __net_init udp6_proc_init(struct net *net) |
1400 | { | 1400 | { |
1401 | return udp_proc_register(net, &udp6_seq_afinfo); | 1401 | return udp_proc_register(net, &udp6_seq_afinfo); |
1402 | } | 1402 | } |
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 6ea6938919e6..5f48fadc27f7 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c | |||
@@ -104,12 +104,12 @@ static struct udp_seq_afinfo udplite6_seq_afinfo = { | |||
104 | }, | 104 | }, |
105 | }; | 105 | }; |
106 | 106 | ||
107 | static int udplite6_proc_init_net(struct net *net) | 107 | static int __net_init udplite6_proc_init_net(struct net *net) |
108 | { | 108 | { |
109 | return udp_proc_register(net, &udplite6_seq_afinfo); | 109 | return udp_proc_register(net, &udplite6_seq_afinfo); |
110 | } | 110 | } |
111 | 111 | ||
112 | static void udplite6_proc_exit_net(struct net *net) | 112 | static void __net_exit udplite6_proc_exit_net(struct net *net) |
113 | { | 113 | { |
114 | udp_proc_unregister(net, &udplite6_seq_afinfo); | 114 | udp_proc_unregister(net, &udplite6_seq_afinfo); |
115 | } | 115 | } |
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 811984d9324b..8b85d774e47f 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -496,9 +496,6 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp) | |||
496 | 496 | ||
497 | IRDA_DEBUG(0, "%s()\n", __func__ ); | 497 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
498 | 498 | ||
499 | if (!tty) | ||
500 | return; | ||
501 | |||
502 | IRDA_ASSERT(self != NULL, return;); | 499 | IRDA_ASSERT(self != NULL, return;); |
503 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); | 500 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); |
504 | 501 | ||
@@ -1007,9 +1004,6 @@ static void ircomm_tty_hangup(struct tty_struct *tty) | |||
1007 | IRDA_ASSERT(self != NULL, return;); | 1004 | IRDA_ASSERT(self != NULL, return;); |
1008 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); | 1005 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); |
1009 | 1006 | ||
1010 | if (!tty) | ||
1011 | return; | ||
1012 | |||
1013 | /* ircomm_tty_flush_buffer(tty); */ | 1007 | /* ircomm_tty_flush_buffer(tty); */ |
1014 | ircomm_tty_shutdown(self); | 1008 | ircomm_tty_shutdown(self); |
1015 | 1009 | ||
diff --git a/net/key/af_key.c b/net/key/af_key.c index 76fa6fef6473..4744b1f6372f 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -3738,17 +3738,17 @@ static int __net_init pfkey_init_proc(struct net *net) | |||
3738 | return 0; | 3738 | return 0; |
3739 | } | 3739 | } |
3740 | 3740 | ||
3741 | static void pfkey_exit_proc(struct net *net) | 3741 | static void __net_exit pfkey_exit_proc(struct net *net) |
3742 | { | 3742 | { |
3743 | proc_net_remove(net, "pfkey"); | 3743 | proc_net_remove(net, "pfkey"); |
3744 | } | 3744 | } |
3745 | #else | 3745 | #else |
3746 | static int __net_init pfkey_init_proc(struct net *net) | 3746 | static inline int pfkey_init_proc(struct net *net) |
3747 | { | 3747 | { |
3748 | return 0; | 3748 | return 0; |
3749 | } | 3749 | } |
3750 | 3750 | ||
3751 | static void pfkey_exit_proc(struct net *net) | 3751 | static inline void pfkey_exit_proc(struct net *net) |
3752 | { | 3752 | { |
3753 | } | 3753 | } |
3754 | #endif | 3754 | #endif |
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 3a66546cad06..e35d907fba2c 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c | |||
@@ -47,6 +47,10 @@ static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout); | |||
47 | #define dprintk(args...) | 47 | #define dprintk(args...) |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | /* Maybe we'll add some more in the future. */ | ||
51 | #define LLC_CMSG_PKTINFO 1 | ||
52 | |||
53 | |||
50 | /** | 54 | /** |
51 | * llc_ui_next_link_no - return the next unused link number for a sap | 55 | * llc_ui_next_link_no - return the next unused link number for a sap |
52 | * @sap: Address of sap to get link number from. | 56 | * @sap: Address of sap to get link number from. |
@@ -136,6 +140,7 @@ static struct proto llc_proto = { | |||
136 | .name = "LLC", | 140 | .name = "LLC", |
137 | .owner = THIS_MODULE, | 141 | .owner = THIS_MODULE, |
138 | .obj_size = sizeof(struct llc_sock), | 142 | .obj_size = sizeof(struct llc_sock), |
143 | .slab_flags = SLAB_DESTROY_BY_RCU, | ||
139 | }; | 144 | }; |
140 | 145 | ||
141 | /** | 146 | /** |
@@ -192,10 +197,8 @@ static int llc_ui_release(struct socket *sock) | |||
192 | llc->laddr.lsap, llc->daddr.lsap); | 197 | llc->laddr.lsap, llc->daddr.lsap); |
193 | if (!llc_send_disc(sk)) | 198 | if (!llc_send_disc(sk)) |
194 | llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo); | 199 | llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo); |
195 | if (!sock_flag(sk, SOCK_ZAPPED)) { | 200 | if (!sock_flag(sk, SOCK_ZAPPED)) |
196 | llc_sap_put(llc->sap); | ||
197 | llc_sap_remove_socket(llc->sap, sk); | 201 | llc_sap_remove_socket(llc->sap, sk); |
198 | } | ||
199 | release_sock(sk); | 202 | release_sock(sk); |
200 | if (llc->dev) | 203 | if (llc->dev) |
201 | dev_put(llc->dev); | 204 | dev_put(llc->dev); |
@@ -255,7 +258,14 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) | |||
255 | if (!sock_flag(sk, SOCK_ZAPPED)) | 258 | if (!sock_flag(sk, SOCK_ZAPPED)) |
256 | goto out; | 259 | goto out; |
257 | rc = -ENODEV; | 260 | rc = -ENODEV; |
258 | llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd); | 261 | if (sk->sk_bound_dev_if) { |
262 | llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); | ||
263 | if (llc->dev && addr->sllc_arphrd != llc->dev->type) { | ||
264 | dev_put(llc->dev); | ||
265 | llc->dev = NULL; | ||
266 | } | ||
267 | } else | ||
268 | llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd); | ||
259 | if (!llc->dev) | 269 | if (!llc->dev) |
260 | goto out; | 270 | goto out; |
261 | rc = -EUSERS; | 271 | rc = -EUSERS; |
@@ -306,7 +316,25 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
306 | goto out; | 316 | goto out; |
307 | rc = -ENODEV; | 317 | rc = -ENODEV; |
308 | rtnl_lock(); | 318 | rtnl_lock(); |
309 | llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd, addr->sllc_mac); | 319 | if (sk->sk_bound_dev_if) { |
320 | llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); | ||
321 | if (llc->dev) { | ||
322 | if (!addr->sllc_arphrd) | ||
323 | addr->sllc_arphrd = llc->dev->type; | ||
324 | if (llc_mac_null(addr->sllc_mac)) | ||
325 | memcpy(addr->sllc_mac, llc->dev->dev_addr, | ||
326 | IFHWADDRLEN); | ||
327 | if (addr->sllc_arphrd != llc->dev->type || | ||
328 | !llc_mac_match(addr->sllc_mac, | ||
329 | llc->dev->dev_addr)) { | ||
330 | rc = -EINVAL; | ||
331 | dev_put(llc->dev); | ||
332 | llc->dev = NULL; | ||
333 | } | ||
334 | } | ||
335 | } else | ||
336 | llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd, | ||
337 | addr->sllc_mac); | ||
310 | rtnl_unlock(); | 338 | rtnl_unlock(); |
311 | if (!llc->dev) | 339 | if (!llc->dev) |
312 | goto out; | 340 | goto out; |
@@ -322,7 +350,6 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
322 | rc = -EBUSY; /* some other network layer is using the sap */ | 350 | rc = -EBUSY; /* some other network layer is using the sap */ |
323 | if (!sap) | 351 | if (!sap) |
324 | goto out; | 352 | goto out; |
325 | llc_sap_hold(sap); | ||
326 | } else { | 353 | } else { |
327 | struct llc_addr laddr, daddr; | 354 | struct llc_addr laddr, daddr; |
328 | struct sock *ask; | 355 | struct sock *ask; |
@@ -591,6 +618,20 @@ static int llc_wait_data(struct sock *sk, long timeo) | |||
591 | return rc; | 618 | return rc; |
592 | } | 619 | } |
593 | 620 | ||
621 | static void llc_cmsg_rcv(struct msghdr *msg, struct sk_buff *skb) | ||
622 | { | ||
623 | struct llc_sock *llc = llc_sk(skb->sk); | ||
624 | |||
625 | if (llc->cmsg_flags & LLC_CMSG_PKTINFO) { | ||
626 | struct llc_pktinfo info; | ||
627 | |||
628 | info.lpi_ifindex = llc_sk(skb->sk)->dev->ifindex; | ||
629 | llc_pdu_decode_dsap(skb, &info.lpi_sap); | ||
630 | llc_pdu_decode_da(skb, info.lpi_mac); | ||
631 | put_cmsg(msg, SOL_LLC, LLC_OPT_PKTINFO, sizeof(info), &info); | ||
632 | } | ||
633 | } | ||
634 | |||
594 | /** | 635 | /** |
595 | * llc_ui_accept - accept a new incoming connection. | 636 | * llc_ui_accept - accept a new incoming connection. |
596 | * @sock: Socket which connections arrive on. | 637 | * @sock: Socket which connections arrive on. |
@@ -812,6 +853,8 @@ copy_uaddr: | |||
812 | memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); | 853 | memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); |
813 | msg->msg_namelen = sizeof(*uaddr); | 854 | msg->msg_namelen = sizeof(*uaddr); |
814 | } | 855 | } |
856 | if (llc_sk(sk)->cmsg_flags) | ||
857 | llc_cmsg_rcv(msg, skb); | ||
815 | goto out; | 858 | goto out; |
816 | } | 859 | } |
817 | 860 | ||
@@ -1030,6 +1073,12 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, | |||
1030 | goto out; | 1073 | goto out; |
1031 | llc->rw = opt; | 1074 | llc->rw = opt; |
1032 | break; | 1075 | break; |
1076 | case LLC_OPT_PKTINFO: | ||
1077 | if (opt) | ||
1078 | llc->cmsg_flags |= LLC_CMSG_PKTINFO; | ||
1079 | else | ||
1080 | llc->cmsg_flags &= ~LLC_CMSG_PKTINFO; | ||
1081 | break; | ||
1033 | default: | 1082 | default: |
1034 | rc = -ENOPROTOOPT; | 1083 | rc = -ENOPROTOOPT; |
1035 | goto out; | 1084 | goto out; |
@@ -1083,6 +1132,9 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname, | |||
1083 | val = llc->k; break; | 1132 | val = llc->k; break; |
1084 | case LLC_OPT_RX_WIN: | 1133 | case LLC_OPT_RX_WIN: |
1085 | val = llc->rw; break; | 1134 | val = llc->rw; break; |
1135 | case LLC_OPT_PKTINFO: | ||
1136 | val = (llc->cmsg_flags & LLC_CMSG_PKTINFO) != 0; | ||
1137 | break; | ||
1086 | default: | 1138 | default: |
1087 | rc = -ENOPROTOOPT; | 1139 | rc = -ENOPROTOOPT; |
1088 | goto out; | 1140 | goto out; |
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c index c6bab39b018e..a8dde9b010da 100644 --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c | |||
@@ -468,6 +468,19 @@ static int llc_exec_conn_trans_actions(struct sock *sk, | |||
468 | return rc; | 468 | return rc; |
469 | } | 469 | } |
470 | 470 | ||
471 | static inline bool llc_estab_match(const struct llc_sap *sap, | ||
472 | const struct llc_addr *daddr, | ||
473 | const struct llc_addr *laddr, | ||
474 | const struct sock *sk) | ||
475 | { | ||
476 | struct llc_sock *llc = llc_sk(sk); | ||
477 | |||
478 | return llc->laddr.lsap == laddr->lsap && | ||
479 | llc->daddr.lsap == daddr->lsap && | ||
480 | llc_mac_match(llc->laddr.mac, laddr->mac) && | ||
481 | llc_mac_match(llc->daddr.mac, daddr->mac); | ||
482 | } | ||
483 | |||
471 | /** | 484 | /** |
472 | * __llc_lookup_established - Finds connection for the remote/local sap/mac | 485 | * __llc_lookup_established - Finds connection for the remote/local sap/mac |
473 | * @sap: SAP | 486 | * @sap: SAP |
@@ -484,23 +497,35 @@ static struct sock *__llc_lookup_established(struct llc_sap *sap, | |||
484 | struct llc_addr *laddr) | 497 | struct llc_addr *laddr) |
485 | { | 498 | { |
486 | struct sock *rc; | 499 | struct sock *rc; |
487 | struct hlist_node *node; | 500 | struct hlist_nulls_node *node; |
488 | 501 | int slot = llc_sk_laddr_hashfn(sap, laddr); | |
489 | read_lock(&sap->sk_list.lock); | 502 | struct hlist_nulls_head *laddr_hb = &sap->sk_laddr_hash[slot]; |
490 | sk_for_each(rc, node, &sap->sk_list.list) { | 503 | |
491 | struct llc_sock *llc = llc_sk(rc); | 504 | rcu_read_lock(); |
492 | 505 | again: | |
493 | if (llc->laddr.lsap == laddr->lsap && | 506 | sk_nulls_for_each_rcu(rc, node, laddr_hb) { |
494 | llc->daddr.lsap == daddr->lsap && | 507 | if (llc_estab_match(sap, daddr, laddr, rc)) { |
495 | llc_mac_match(llc->laddr.mac, laddr->mac) && | 508 | /* Extra checks required by SLAB_DESTROY_BY_RCU */ |
496 | llc_mac_match(llc->daddr.mac, daddr->mac)) { | 509 | if (unlikely(!atomic_inc_not_zero(&rc->sk_refcnt))) |
497 | sock_hold(rc); | 510 | goto again; |
511 | if (unlikely(llc_sk(rc)->sap != sap || | ||
512 | !llc_estab_match(sap, daddr, laddr, rc))) { | ||
513 | sock_put(rc); | ||
514 | continue; | ||
515 | } | ||
498 | goto found; | 516 | goto found; |
499 | } | 517 | } |
500 | } | 518 | } |
501 | rc = NULL; | 519 | rc = NULL; |
520 | /* | ||
521 | * if the nulls value we got at the end of this lookup is | ||
522 | * not the expected one, we must restart lookup. | ||
523 | * We probably met an item that was moved to another chain. | ||
524 | */ | ||
525 | if (unlikely(get_nulls_value(node) != slot)) | ||
526 | goto again; | ||
502 | found: | 527 | found: |
503 | read_unlock(&sap->sk_list.lock); | 528 | rcu_read_unlock(); |
504 | return rc; | 529 | return rc; |
505 | } | 530 | } |
506 | 531 | ||
@@ -516,6 +541,53 @@ struct sock *llc_lookup_established(struct llc_sap *sap, | |||
516 | return sk; | 541 | return sk; |
517 | } | 542 | } |
518 | 543 | ||
544 | static inline bool llc_listener_match(const struct llc_sap *sap, | ||
545 | const struct llc_addr *laddr, | ||
546 | const struct sock *sk) | ||
547 | { | ||
548 | struct llc_sock *llc = llc_sk(sk); | ||
549 | |||
550 | return sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN && | ||
551 | llc->laddr.lsap == laddr->lsap && | ||
552 | llc_mac_match(llc->laddr.mac, laddr->mac); | ||
553 | } | ||
554 | |||
555 | static struct sock *__llc_lookup_listener(struct llc_sap *sap, | ||
556 | struct llc_addr *laddr) | ||
557 | { | ||
558 | struct sock *rc; | ||
559 | struct hlist_nulls_node *node; | ||
560 | int slot = llc_sk_laddr_hashfn(sap, laddr); | ||
561 | struct hlist_nulls_head *laddr_hb = &sap->sk_laddr_hash[slot]; | ||
562 | |||
563 | rcu_read_lock(); | ||
564 | again: | ||
565 | sk_nulls_for_each_rcu(rc, node, laddr_hb) { | ||
566 | if (llc_listener_match(sap, laddr, rc)) { | ||
567 | /* Extra checks required by SLAB_DESTROY_BY_RCU */ | ||
568 | if (unlikely(!atomic_inc_not_zero(&rc->sk_refcnt))) | ||
569 | goto again; | ||
570 | if (unlikely(llc_sk(rc)->sap != sap || | ||
571 | !llc_listener_match(sap, laddr, rc))) { | ||
572 | sock_put(rc); | ||
573 | continue; | ||
574 | } | ||
575 | goto found; | ||
576 | } | ||
577 | } | ||
578 | rc = NULL; | ||
579 | /* | ||
580 | * if the nulls value we got at the end of this lookup is | ||
581 | * not the expected one, we must restart lookup. | ||
582 | * We probably met an item that was moved to another chain. | ||
583 | */ | ||
584 | if (unlikely(get_nulls_value(node) != slot)) | ||
585 | goto again; | ||
586 | found: | ||
587 | rcu_read_unlock(); | ||
588 | return rc; | ||
589 | } | ||
590 | |||
519 | /** | 591 | /** |
520 | * llc_lookup_listener - Finds listener for local MAC + SAP | 592 | * llc_lookup_listener - Finds listener for local MAC + SAP |
521 | * @sap: SAP | 593 | * @sap: SAP |
@@ -529,24 +601,12 @@ struct sock *llc_lookup_established(struct llc_sap *sap, | |||
529 | static struct sock *llc_lookup_listener(struct llc_sap *sap, | 601 | static struct sock *llc_lookup_listener(struct llc_sap *sap, |
530 | struct llc_addr *laddr) | 602 | struct llc_addr *laddr) |
531 | { | 603 | { |
532 | struct sock *rc; | 604 | static struct llc_addr null_addr; |
533 | struct hlist_node *node; | 605 | struct sock *rc = __llc_lookup_listener(sap, laddr); |
534 | 606 | ||
535 | read_lock(&sap->sk_list.lock); | 607 | if (!rc) |
536 | sk_for_each(rc, node, &sap->sk_list.list) { | 608 | rc = __llc_lookup_listener(sap, &null_addr); |
537 | struct llc_sock *llc = llc_sk(rc); | ||
538 | 609 | ||
539 | if (rc->sk_type == SOCK_STREAM && rc->sk_state == TCP_LISTEN && | ||
540 | llc->laddr.lsap == laddr->lsap && | ||
541 | (llc_mac_match(llc->laddr.mac, laddr->mac) || | ||
542 | llc_mac_null(llc->laddr.mac))) { | ||
543 | sock_hold(rc); | ||
544 | goto found; | ||
545 | } | ||
546 | } | ||
547 | rc = NULL; | ||
548 | found: | ||
549 | read_unlock(&sap->sk_list.lock); | ||
550 | return rc; | 610 | return rc; |
551 | } | 611 | } |
552 | 612 | ||
@@ -647,15 +707,22 @@ static int llc_find_offset(int state, int ev_type) | |||
647 | * @sap: SAP | 707 | * @sap: SAP |
648 | * @sk: socket | 708 | * @sk: socket |
649 | * | 709 | * |
650 | * This function adds a socket to sk_list of a SAP. | 710 | * This function adds a socket to the hash tables of a SAP. |
651 | */ | 711 | */ |
652 | void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) | 712 | void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) |
653 | { | 713 | { |
714 | struct llc_sock *llc = llc_sk(sk); | ||
715 | struct hlist_head *dev_hb = llc_sk_dev_hash(sap, llc->dev->ifindex); | ||
716 | struct hlist_nulls_head *laddr_hb = llc_sk_laddr_hash(sap, &llc->laddr); | ||
717 | |||
654 | llc_sap_hold(sap); | 718 | llc_sap_hold(sap); |
655 | write_lock_bh(&sap->sk_list.lock); | ||
656 | llc_sk(sk)->sap = sap; | 719 | llc_sk(sk)->sap = sap; |
657 | sk_add_node(sk, &sap->sk_list.list); | 720 | |
658 | write_unlock_bh(&sap->sk_list.lock); | 721 | spin_lock_bh(&sap->sk_lock); |
722 | sap->sk_count++; | ||
723 | sk_nulls_add_node_rcu(sk, laddr_hb); | ||
724 | hlist_add_head(&llc->dev_hash_node, dev_hb); | ||
725 | spin_unlock_bh(&sap->sk_lock); | ||
659 | } | 726 | } |
660 | 727 | ||
661 | /** | 728 | /** |
@@ -663,14 +730,18 @@ void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) | |||
663 | * @sap: SAP | 730 | * @sap: SAP |
664 | * @sk: socket | 731 | * @sk: socket |
665 | * | 732 | * |
666 | * This function removes a connection from sk_list.list of a SAP if | 733 | * This function removes a connection from the hash tables of a SAP if |
667 | * the connection was in this list. | 734 | * the connection was in this list. |
668 | */ | 735 | */ |
669 | void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) | 736 | void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) |
670 | { | 737 | { |
671 | write_lock_bh(&sap->sk_list.lock); | 738 | struct llc_sock *llc = llc_sk(sk); |
672 | sk_del_node_init(sk); | 739 | |
673 | write_unlock_bh(&sap->sk_list.lock); | 740 | spin_lock_bh(&sap->sk_lock); |
741 | sk_nulls_del_node_init_rcu(sk); | ||
742 | hlist_del(&llc->dev_hash_node); | ||
743 | sap->sk_count--; | ||
744 | spin_unlock_bh(&sap->sk_lock); | ||
674 | llc_sap_put(sap); | 745 | llc_sap_put(sap); |
675 | } | 746 | } |
676 | 747 | ||
diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c index ff4c0ab96a69..78167e81dfeb 100644 --- a/net/llc/llc_core.c +++ b/net/llc/llc_core.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <net/llc.h> | 23 | #include <net/llc.h> |
24 | 24 | ||
25 | LIST_HEAD(llc_sap_list); | 25 | LIST_HEAD(llc_sap_list); |
26 | DEFINE_RWLOCK(llc_sap_list_lock); | 26 | DEFINE_SPINLOCK(llc_sap_list_lock); |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * llc_sap_alloc - allocates and initializes sap. | 29 | * llc_sap_alloc - allocates and initializes sap. |
@@ -33,40 +33,19 @@ DEFINE_RWLOCK(llc_sap_list_lock); | |||
33 | static struct llc_sap *llc_sap_alloc(void) | 33 | static struct llc_sap *llc_sap_alloc(void) |
34 | { | 34 | { |
35 | struct llc_sap *sap = kzalloc(sizeof(*sap), GFP_ATOMIC); | 35 | struct llc_sap *sap = kzalloc(sizeof(*sap), GFP_ATOMIC); |
36 | int i; | ||
36 | 37 | ||
37 | if (sap) { | 38 | if (sap) { |
38 | /* sap->laddr.mac - leave as a null, it's filled by bind */ | 39 | /* sap->laddr.mac - leave as a null, it's filled by bind */ |
39 | sap->state = LLC_SAP_STATE_ACTIVE; | 40 | sap->state = LLC_SAP_STATE_ACTIVE; |
40 | rwlock_init(&sap->sk_list.lock); | 41 | spin_lock_init(&sap->sk_lock); |
42 | for (i = 0; i < LLC_SK_LADDR_HASH_ENTRIES; i++) | ||
43 | INIT_HLIST_NULLS_HEAD(&sap->sk_laddr_hash[i], i); | ||
41 | atomic_set(&sap->refcnt, 1); | 44 | atomic_set(&sap->refcnt, 1); |
42 | } | 45 | } |
43 | return sap; | 46 | return sap; |
44 | } | 47 | } |
45 | 48 | ||
46 | /** | ||
47 | * llc_add_sap - add sap to station list | ||
48 | * @sap: Address of the sap | ||
49 | * | ||
50 | * Adds a sap to the LLC's station sap list. | ||
51 | */ | ||
52 | static void llc_add_sap(struct llc_sap *sap) | ||
53 | { | ||
54 | list_add_tail(&sap->node, &llc_sap_list); | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * llc_del_sap - del sap from station list | ||
59 | * @sap: Address of the sap | ||
60 | * | ||
61 | * Removes a sap to the LLC's station sap list. | ||
62 | */ | ||
63 | static void llc_del_sap(struct llc_sap *sap) | ||
64 | { | ||
65 | write_lock_bh(&llc_sap_list_lock); | ||
66 | list_del(&sap->node); | ||
67 | write_unlock_bh(&llc_sap_list_lock); | ||
68 | } | ||
69 | |||
70 | static struct llc_sap *__llc_sap_find(unsigned char sap_value) | 49 | static struct llc_sap *__llc_sap_find(unsigned char sap_value) |
71 | { | 50 | { |
72 | struct llc_sap* sap; | 51 | struct llc_sap* sap; |
@@ -90,13 +69,13 @@ out: | |||
90 | */ | 69 | */ |
91 | struct llc_sap *llc_sap_find(unsigned char sap_value) | 70 | struct llc_sap *llc_sap_find(unsigned char sap_value) |
92 | { | 71 | { |
93 | struct llc_sap* sap; | 72 | struct llc_sap *sap; |
94 | 73 | ||
95 | read_lock_bh(&llc_sap_list_lock); | 74 | rcu_read_lock_bh(); |
96 | sap = __llc_sap_find(sap_value); | 75 | sap = __llc_sap_find(sap_value); |
97 | if (sap) | 76 | if (sap) |
98 | llc_sap_hold(sap); | 77 | llc_sap_hold(sap); |
99 | read_unlock_bh(&llc_sap_list_lock); | 78 | rcu_read_unlock_bh(); |
100 | return sap; | 79 | return sap; |
101 | } | 80 | } |
102 | 81 | ||
@@ -117,7 +96,7 @@ struct llc_sap *llc_sap_open(unsigned char lsap, | |||
117 | { | 96 | { |
118 | struct llc_sap *sap = NULL; | 97 | struct llc_sap *sap = NULL; |
119 | 98 | ||
120 | write_lock_bh(&llc_sap_list_lock); | 99 | spin_lock_bh(&llc_sap_list_lock); |
121 | if (__llc_sap_find(lsap)) /* SAP already exists */ | 100 | if (__llc_sap_find(lsap)) /* SAP already exists */ |
122 | goto out; | 101 | goto out; |
123 | sap = llc_sap_alloc(); | 102 | sap = llc_sap_alloc(); |
@@ -125,9 +104,9 @@ struct llc_sap *llc_sap_open(unsigned char lsap, | |||
125 | goto out; | 104 | goto out; |
126 | sap->laddr.lsap = lsap; | 105 | sap->laddr.lsap = lsap; |
127 | sap->rcv_func = func; | 106 | sap->rcv_func = func; |
128 | llc_add_sap(sap); | 107 | list_add_tail_rcu(&sap->node, &llc_sap_list); |
129 | out: | 108 | out: |
130 | write_unlock_bh(&llc_sap_list_lock); | 109 | spin_unlock_bh(&llc_sap_list_lock); |
131 | return sap; | 110 | return sap; |
132 | } | 111 | } |
133 | 112 | ||
@@ -142,8 +121,14 @@ out: | |||
142 | */ | 121 | */ |
143 | void llc_sap_close(struct llc_sap *sap) | 122 | void llc_sap_close(struct llc_sap *sap) |
144 | { | 123 | { |
145 | WARN_ON(!hlist_empty(&sap->sk_list.list)); | 124 | WARN_ON(sap->sk_count); |
146 | llc_del_sap(sap); | 125 | |
126 | spin_lock_bh(&llc_sap_list_lock); | ||
127 | list_del_rcu(&sap->node); | ||
128 | spin_unlock_bh(&llc_sap_list_lock); | ||
129 | |||
130 | synchronize_rcu(); | ||
131 | |||
147 | kfree(sap); | 132 | kfree(sap); |
148 | } | 133 | } |
149 | 134 | ||
diff --git a/net/llc/llc_output.c b/net/llc/llc_output.c index 754f4fedc852..b38a1079a98e 100644 --- a/net/llc/llc_output.c +++ b/net/llc/llc_output.c | |||
@@ -33,48 +33,19 @@ | |||
33 | int llc_mac_hdr_init(struct sk_buff *skb, | 33 | int llc_mac_hdr_init(struct sk_buff *skb, |
34 | const unsigned char *sa, const unsigned char *da) | 34 | const unsigned char *sa, const unsigned char *da) |
35 | { | 35 | { |
36 | int rc = 0; | 36 | int rc = -EINVAL; |
37 | 37 | ||
38 | switch (skb->dev->type) { | 38 | switch (skb->dev->type) { |
39 | #ifdef CONFIG_TR | 39 | case ARPHRD_IEEE802_TR: |
40 | case ARPHRD_IEEE802_TR: { | ||
41 | struct net_device *dev = skb->dev; | ||
42 | struct trh_hdr *trh; | ||
43 | |||
44 | skb_push(skb, sizeof(*trh)); | ||
45 | skb_reset_mac_header(skb); | ||
46 | trh = tr_hdr(skb); | ||
47 | trh->ac = AC; | ||
48 | trh->fc = LLC_FRAME; | ||
49 | if (sa) | ||
50 | memcpy(trh->saddr, sa, dev->addr_len); | ||
51 | else | ||
52 | memset(trh->saddr, 0, dev->addr_len); | ||
53 | if (da) { | ||
54 | memcpy(trh->daddr, da, dev->addr_len); | ||
55 | tr_source_route(skb, trh, dev); | ||
56 | skb_reset_mac_header(skb); | ||
57 | } | ||
58 | break; | ||
59 | } | ||
60 | #endif | ||
61 | case ARPHRD_ETHER: | 40 | case ARPHRD_ETHER: |
62 | case ARPHRD_LOOPBACK: { | 41 | case ARPHRD_LOOPBACK: |
63 | unsigned short len = skb->len; | 42 | rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa, |
64 | struct ethhdr *eth; | 43 | skb->len); |
65 | 44 | if (rc > 0) | |
66 | skb_push(skb, sizeof(*eth)); | 45 | rc = 0; |
67 | skb_reset_mac_header(skb); | ||
68 | eth = eth_hdr(skb); | ||
69 | eth->h_proto = htons(len); | ||
70 | memcpy(eth->h_dest, da, ETH_ALEN); | ||
71 | memcpy(eth->h_source, sa, ETH_ALEN); | ||
72 | break; | 46 | break; |
73 | } | ||
74 | default: | 47 | default: |
75 | printk(KERN_WARNING "device type not supported: %d\n", | 48 | WARN(1, "device type not supported: %d\n", skb->dev->type); |
76 | skb->dev->type); | ||
77 | rc = -EINVAL; | ||
78 | } | 49 | } |
79 | return rc; | 50 | return rc; |
80 | } | 51 | } |
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c index be47ac427f6b..7af1ff2d1f19 100644 --- a/net/llc/llc_proc.c +++ b/net/llc/llc_proc.c | |||
@@ -32,21 +32,23 @@ static void llc_ui_format_mac(struct seq_file *seq, u8 *addr) | |||
32 | 32 | ||
33 | static struct sock *llc_get_sk_idx(loff_t pos) | 33 | static struct sock *llc_get_sk_idx(loff_t pos) |
34 | { | 34 | { |
35 | struct list_head *sap_entry; | ||
36 | struct llc_sap *sap; | 35 | struct llc_sap *sap; |
37 | struct hlist_node *node; | ||
38 | struct sock *sk = NULL; | 36 | struct sock *sk = NULL; |
39 | 37 | int i; | |
40 | list_for_each(sap_entry, &llc_sap_list) { | 38 | |
41 | sap = list_entry(sap_entry, struct llc_sap, node); | 39 | list_for_each_entry_rcu(sap, &llc_sap_list, node) { |
42 | 40 | spin_lock_bh(&sap->sk_lock); | |
43 | read_lock_bh(&sap->sk_list.lock); | 41 | for (i = 0; i < LLC_SK_LADDR_HASH_ENTRIES; i++) { |
44 | sk_for_each(sk, node, &sap->sk_list.list) { | 42 | struct hlist_nulls_head *head = &sap->sk_laddr_hash[i]; |
45 | if (!pos) | 43 | struct hlist_nulls_node *node; |
46 | goto found; | 44 | |
47 | --pos; | 45 | sk_nulls_for_each(sk, node, head) { |
46 | if (!pos) | ||
47 | goto found; /* keep the lock */ | ||
48 | --pos; | ||
49 | } | ||
48 | } | 50 | } |
49 | read_unlock_bh(&sap->sk_list.lock); | 51 | spin_unlock_bh(&sap->sk_lock); |
50 | } | 52 | } |
51 | sk = NULL; | 53 | sk = NULL; |
52 | found: | 54 | found: |
@@ -57,10 +59,23 @@ static void *llc_seq_start(struct seq_file *seq, loff_t *pos) | |||
57 | { | 59 | { |
58 | loff_t l = *pos; | 60 | loff_t l = *pos; |
59 | 61 | ||
60 | read_lock_bh(&llc_sap_list_lock); | 62 | rcu_read_lock_bh(); |
61 | return l ? llc_get_sk_idx(--l) : SEQ_START_TOKEN; | 63 | return l ? llc_get_sk_idx(--l) : SEQ_START_TOKEN; |
62 | } | 64 | } |
63 | 65 | ||
66 | static struct sock *laddr_hash_next(struct llc_sap *sap, int bucket) | ||
67 | { | ||
68 | struct hlist_nulls_node *node; | ||
69 | struct sock *sk = NULL; | ||
70 | |||
71 | while (++bucket < LLC_SK_LADDR_HASH_ENTRIES) | ||
72 | sk_nulls_for_each(sk, node, &sap->sk_laddr_hash[bucket]) | ||
73 | goto out; | ||
74 | |||
75 | out: | ||
76 | return sk; | ||
77 | } | ||
78 | |||
64 | static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 79 | static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
65 | { | 80 | { |
66 | struct sock* sk, *next; | 81 | struct sock* sk, *next; |
@@ -73,25 +88,23 @@ static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
73 | goto out; | 88 | goto out; |
74 | } | 89 | } |
75 | sk = v; | 90 | sk = v; |
76 | next = sk_next(sk); | 91 | next = sk_nulls_next(sk); |
77 | if (next) { | 92 | if (next) { |
78 | sk = next; | 93 | sk = next; |
79 | goto out; | 94 | goto out; |
80 | } | 95 | } |
81 | llc = llc_sk(sk); | 96 | llc = llc_sk(sk); |
82 | sap = llc->sap; | 97 | sap = llc->sap; |
83 | read_unlock_bh(&sap->sk_list.lock); | 98 | sk = laddr_hash_next(sap, llc_sk_laddr_hashfn(sap, &llc->laddr)); |
84 | sk = NULL; | 99 | if (sk) |
85 | for (;;) { | 100 | goto out; |
86 | if (sap->node.next == &llc_sap_list) | 101 | spin_unlock_bh(&sap->sk_lock); |
87 | break; | 102 | list_for_each_entry_continue_rcu(sap, &llc_sap_list, node) { |
88 | sap = list_entry(sap->node.next, struct llc_sap, node); | 103 | spin_lock_bh(&sap->sk_lock); |
89 | read_lock_bh(&sap->sk_list.lock); | 104 | sk = laddr_hash_next(sap, -1); |
90 | if (!hlist_empty(&sap->sk_list.list)) { | 105 | if (sk) |
91 | sk = sk_head(&sap->sk_list.list); | 106 | break; /* keep the lock */ |
92 | break; | 107 | spin_unlock_bh(&sap->sk_lock); |
93 | } | ||
94 | read_unlock_bh(&sap->sk_list.lock); | ||
95 | } | 108 | } |
96 | out: | 109 | out: |
97 | return sk; | 110 | return sk; |
@@ -104,9 +117,9 @@ static void llc_seq_stop(struct seq_file *seq, void *v) | |||
104 | struct llc_sock *llc = llc_sk(sk); | 117 | struct llc_sock *llc = llc_sk(sk); |
105 | struct llc_sap *sap = llc->sap; | 118 | struct llc_sap *sap = llc->sap; |
106 | 119 | ||
107 | read_unlock_bh(&sap->sk_list.lock); | 120 | spin_unlock_bh(&sap->sk_lock); |
108 | } | 121 | } |
109 | read_unlock_bh(&llc_sap_list_lock); | 122 | rcu_read_unlock_bh(); |
110 | } | 123 | } |
111 | 124 | ||
112 | static int llc_seq_socket_show(struct seq_file *seq, void *v) | 125 | static int llc_seq_socket_show(struct seq_file *seq, void *v) |
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c index 008de1fc42ca..ad6e6e1cf22f 100644 --- a/net/llc/llc_sap.c +++ b/net/llc/llc_sap.c | |||
@@ -297,6 +297,17 @@ static void llc_sap_rcv(struct llc_sap *sap, struct sk_buff *skb, | |||
297 | llc_sap_state_process(sap, skb); | 297 | llc_sap_state_process(sap, skb); |
298 | } | 298 | } |
299 | 299 | ||
300 | static inline bool llc_dgram_match(const struct llc_sap *sap, | ||
301 | const struct llc_addr *laddr, | ||
302 | const struct sock *sk) | ||
303 | { | ||
304 | struct llc_sock *llc = llc_sk(sk); | ||
305 | |||
306 | return sk->sk_type == SOCK_DGRAM && | ||
307 | llc->laddr.lsap == laddr->lsap && | ||
308 | llc_mac_match(llc->laddr.mac, laddr->mac); | ||
309 | } | ||
310 | |||
300 | /** | 311 | /** |
301 | * llc_lookup_dgram - Finds dgram socket for the local sap/mac | 312 | * llc_lookup_dgram - Finds dgram socket for the local sap/mac |
302 | * @sap: SAP | 313 | * @sap: SAP |
@@ -309,25 +320,68 @@ static struct sock *llc_lookup_dgram(struct llc_sap *sap, | |||
309 | const struct llc_addr *laddr) | 320 | const struct llc_addr *laddr) |
310 | { | 321 | { |
311 | struct sock *rc; | 322 | struct sock *rc; |
312 | struct hlist_node *node; | 323 | struct hlist_nulls_node *node; |
313 | 324 | int slot = llc_sk_laddr_hashfn(sap, laddr); | |
314 | read_lock_bh(&sap->sk_list.lock); | 325 | struct hlist_nulls_head *laddr_hb = &sap->sk_laddr_hash[slot]; |
315 | sk_for_each(rc, node, &sap->sk_list.list) { | 326 | |
316 | struct llc_sock *llc = llc_sk(rc); | 327 | rcu_read_lock_bh(); |
317 | 328 | again: | |
318 | if (rc->sk_type == SOCK_DGRAM && | 329 | sk_nulls_for_each_rcu(rc, node, laddr_hb) { |
319 | llc->laddr.lsap == laddr->lsap && | 330 | if (llc_dgram_match(sap, laddr, rc)) { |
320 | llc_mac_match(llc->laddr.mac, laddr->mac)) { | 331 | /* Extra checks required by SLAB_DESTROY_BY_RCU */ |
321 | sock_hold(rc); | 332 | if (unlikely(!atomic_inc_not_zero(&rc->sk_refcnt))) |
333 | goto again; | ||
334 | if (unlikely(llc_sk(rc)->sap != sap || | ||
335 | !llc_dgram_match(sap, laddr, rc))) { | ||
336 | sock_put(rc); | ||
337 | continue; | ||
338 | } | ||
322 | goto found; | 339 | goto found; |
323 | } | 340 | } |
324 | } | 341 | } |
325 | rc = NULL; | 342 | rc = NULL; |
343 | /* | ||
344 | * if the nulls value we got at the end of this lookup is | ||
345 | * not the expected one, we must restart lookup. | ||
346 | * We probably met an item that was moved to another chain. | ||
347 | */ | ||
348 | if (unlikely(get_nulls_value(node) != slot)) | ||
349 | goto again; | ||
326 | found: | 350 | found: |
327 | read_unlock_bh(&sap->sk_list.lock); | 351 | rcu_read_unlock_bh(); |
328 | return rc; | 352 | return rc; |
329 | } | 353 | } |
330 | 354 | ||
355 | static inline bool llc_mcast_match(const struct llc_sap *sap, | ||
356 | const struct llc_addr *laddr, | ||
357 | const struct sk_buff *skb, | ||
358 | const struct sock *sk) | ||
359 | { | ||
360 | struct llc_sock *llc = llc_sk(sk); | ||
361 | |||
362 | return sk->sk_type == SOCK_DGRAM && | ||
363 | llc->laddr.lsap == laddr->lsap && | ||
364 | llc->dev == skb->dev; | ||
365 | } | ||
366 | |||
367 | static void llc_do_mcast(struct llc_sap *sap, struct sk_buff *skb, | ||
368 | struct sock **stack, int count) | ||
369 | { | ||
370 | struct sk_buff *skb1; | ||
371 | int i; | ||
372 | |||
373 | for (i = 0; i < count; i++) { | ||
374 | skb1 = skb_clone(skb, GFP_ATOMIC); | ||
375 | if (!skb1) { | ||
376 | sock_put(stack[i]); | ||
377 | continue; | ||
378 | } | ||
379 | |||
380 | llc_sap_rcv(sap, skb1, stack[i]); | ||
381 | sock_put(stack[i]); | ||
382 | } | ||
383 | } | ||
384 | |||
331 | /** | 385 | /** |
332 | * llc_sap_mcast - Deliver multicast PDU's to all matching datagram sockets. | 386 | * llc_sap_mcast - Deliver multicast PDU's to all matching datagram sockets. |
333 | * @sap: SAP | 387 | * @sap: SAP |
@@ -340,32 +394,31 @@ static void llc_sap_mcast(struct llc_sap *sap, | |||
340 | const struct llc_addr *laddr, | 394 | const struct llc_addr *laddr, |
341 | struct sk_buff *skb) | 395 | struct sk_buff *skb) |
342 | { | 396 | { |
343 | struct sock *sk; | 397 | int i = 0, count = 256 / sizeof(struct sock *); |
398 | struct sock *sk, *stack[count]; | ||
344 | struct hlist_node *node; | 399 | struct hlist_node *node; |
400 | struct llc_sock *llc; | ||
401 | struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->dev->ifindex); | ||
345 | 402 | ||
346 | read_lock_bh(&sap->sk_list.lock); | 403 | spin_lock_bh(&sap->sk_lock); |
347 | sk_for_each(sk, node, &sap->sk_list.list) { | 404 | hlist_for_each_entry(llc, node, dev_hb, dev_hash_node) { |
348 | struct llc_sock *llc = llc_sk(sk); | ||
349 | struct sk_buff *skb1; | ||
350 | 405 | ||
351 | if (sk->sk_type != SOCK_DGRAM) | 406 | sk = &llc->sk; |
352 | continue; | ||
353 | 407 | ||
354 | if (llc->laddr.lsap != laddr->lsap) | 408 | if (!llc_mcast_match(sap, laddr, skb, sk)) |
355 | continue; | 409 | continue; |
356 | 410 | ||
357 | if (llc->dev != skb->dev) | ||
358 | continue; | ||
359 | |||
360 | skb1 = skb_clone(skb, GFP_ATOMIC); | ||
361 | if (!skb1) | ||
362 | break; | ||
363 | |||
364 | sock_hold(sk); | 411 | sock_hold(sk); |
365 | llc_sap_rcv(sap, skb1, sk); | 412 | if (i < count) |
366 | sock_put(sk); | 413 | stack[i++] = sk; |
414 | else { | ||
415 | llc_do_mcast(sap, skb, stack, i); | ||
416 | i = 0; | ||
417 | } | ||
367 | } | 418 | } |
368 | read_unlock_bh(&sap->sk_list.lock); | 419 | spin_unlock_bh(&sap->sk_lock); |
420 | |||
421 | llc_do_mcast(sap, skb, stack, i); | ||
369 | } | 422 | } |
370 | 423 | ||
371 | 424 | ||
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig index a10d508b07e1..a952b7f8c648 100644 --- a/net/mac80211/Kconfig +++ b/net/mac80211/Kconfig | |||
@@ -96,18 +96,6 @@ menuconfig MAC80211_DEBUG_MENU | |||
96 | ---help--- | 96 | ---help--- |
97 | This option collects various mac80211 debug settings. | 97 | This option collects various mac80211 debug settings. |
98 | 98 | ||
99 | config MAC80211_DEBUG_PACKET_ALIGNMENT | ||
100 | bool "Enable packet alignment debugging" | ||
101 | depends on MAC80211_DEBUG_MENU | ||
102 | ---help--- | ||
103 | This option is recommended for driver authors and strongly | ||
104 | discouraged for everybody else, it will trigger a warning | ||
105 | when a driver hands mac80211 a buffer that is aligned in | ||
106 | a way that will cause problems with the IP stack on some | ||
107 | architectures. | ||
108 | |||
109 | Say N unless you're writing a mac80211 based driver. | ||
110 | |||
111 | config MAC80211_NOINLINE | 99 | config MAC80211_NOINLINE |
112 | bool "Do not inline TX/RX handlers" | 100 | bool "Do not inline TX/RX handlers" |
113 | depends on MAC80211_DEBUG_MENU | 101 | depends on MAC80211_DEBUG_MENU |
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index 298cfcc1bf8d..04420291e7ad 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile | |||
@@ -6,10 +6,10 @@ mac80211-y := \ | |||
6 | sta_info.o \ | 6 | sta_info.o \ |
7 | wep.o \ | 7 | wep.o \ |
8 | wpa.o \ | 8 | wpa.o \ |
9 | scan.o \ | 9 | scan.o offchannel.o \ |
10 | ht.o agg-tx.o agg-rx.o \ | 10 | ht.o agg-tx.o agg-rx.o \ |
11 | ibss.o \ | 11 | ibss.o \ |
12 | mlme.o \ | 12 | mlme.o work.o \ |
13 | iface.o \ | 13 | iface.o \ |
14 | rate.o \ | 14 | rate.o \ |
15 | michael.o \ | 15 | michael.o \ |
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c index 51c7dc3c4c3b..a978e666ed6f 100644 --- a/net/mac80211/agg-rx.c +++ b/net/mac80211/agg-rx.c | |||
@@ -41,8 +41,7 @@ void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid, | |||
41 | sta->sta.addr, tid); | 41 | sta->sta.addr, tid); |
42 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 42 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
43 | 43 | ||
44 | if (drv_ampdu_action(local, &sta->sdata->vif, | 44 | if (drv_ampdu_action(local, sta->sdata, IEEE80211_AMPDU_RX_STOP, |
45 | IEEE80211_AMPDU_RX_STOP, | ||
46 | &sta->sta, tid, NULL)) | 45 | &sta->sta, tid, NULL)) |
47 | printk(KERN_DEBUG "HW problem - can not stop rx " | 46 | printk(KERN_DEBUG "HW problem - can not stop rx " |
48 | "aggregation for tid %d\n", tid); | 47 | "aggregation for tid %d\n", tid); |
@@ -83,12 +82,11 @@ void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid, | |||
83 | void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, | 82 | void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, |
84 | u16 initiator, u16 reason) | 83 | u16 initiator, u16 reason) |
85 | { | 84 | { |
86 | struct ieee80211_local *local = sdata->local; | ||
87 | struct sta_info *sta; | 85 | struct sta_info *sta; |
88 | 86 | ||
89 | rcu_read_lock(); | 87 | rcu_read_lock(); |
90 | 88 | ||
91 | sta = sta_info_get(local, ra); | 89 | sta = sta_info_get(sdata, ra); |
92 | if (!sta) { | 90 | if (!sta) { |
93 | rcu_read_unlock(); | 91 | rcu_read_unlock(); |
94 | return; | 92 | return; |
@@ -136,7 +134,7 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d | |||
136 | 134 | ||
137 | if (!skb) { | 135 | if (!skb) { |
138 | printk(KERN_DEBUG "%s: failed to allocate buffer " | 136 | printk(KERN_DEBUG "%s: failed to allocate buffer " |
139 | "for addba resp frame\n", sdata->dev->name); | 137 | "for addba resp frame\n", sdata->name); |
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | 140 | ||
@@ -144,10 +142,10 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d | |||
144 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | 142 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
145 | memset(mgmt, 0, 24); | 143 | memset(mgmt, 0, 24); |
146 | memcpy(mgmt->da, da, ETH_ALEN); | 144 | memcpy(mgmt->da, da, ETH_ALEN); |
147 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 145 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
148 | if (sdata->vif.type == NL80211_IFTYPE_AP || | 146 | if (sdata->vif.type == NL80211_IFTYPE_AP || |
149 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 147 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
150 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | 148 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
151 | else if (sdata->vif.type == NL80211_IFTYPE_STATION) | 149 | else if (sdata->vif.type == NL80211_IFTYPE_STATION) |
152 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); | 150 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
153 | 151 | ||
@@ -281,8 +279,7 @@ void ieee80211_process_addba_request(struct ieee80211_local *local, | |||
281 | goto end; | 279 | goto end; |
282 | } | 280 | } |
283 | 281 | ||
284 | ret = drv_ampdu_action(local, &sta->sdata->vif, | 282 | ret = drv_ampdu_action(local, sta->sdata, IEEE80211_AMPDU_RX_START, |
285 | IEEE80211_AMPDU_RX_START, | ||
286 | &sta->sta, tid, &start_seq_num); | 283 | &sta->sta, tid, &start_seq_num); |
287 | #ifdef CONFIG_MAC80211_HT_DEBUG | 284 | #ifdef CONFIG_MAC80211_HT_DEBUG |
288 | printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret); | 285 | printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret); |
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c index 5e3a7eccef5a..718fbcff84d2 100644 --- a/net/mac80211/agg-tx.c +++ b/net/mac80211/agg-tx.c | |||
@@ -58,17 +58,17 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, | |||
58 | 58 | ||
59 | if (!skb) { | 59 | if (!skb) { |
60 | printk(KERN_ERR "%s: failed to allocate buffer " | 60 | printk(KERN_ERR "%s: failed to allocate buffer " |
61 | "for addba request frame\n", sdata->dev->name); | 61 | "for addba request frame\n", sdata->name); |
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | skb_reserve(skb, local->hw.extra_tx_headroom); | 64 | skb_reserve(skb, local->hw.extra_tx_headroom); |
65 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | 65 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
66 | memset(mgmt, 0, 24); | 66 | memset(mgmt, 0, 24); |
67 | memcpy(mgmt->da, da, ETH_ALEN); | 67 | memcpy(mgmt->da, da, ETH_ALEN); |
68 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 68 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
69 | if (sdata->vif.type == NL80211_IFTYPE_AP || | 69 | if (sdata->vif.type == NL80211_IFTYPE_AP || |
70 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 70 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
71 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | 71 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
72 | else if (sdata->vif.type == NL80211_IFTYPE_STATION) | 72 | else if (sdata->vif.type == NL80211_IFTYPE_STATION) |
73 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); | 73 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
74 | 74 | ||
@@ -104,7 +104,7 @@ void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u1 | |||
104 | skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom); | 104 | skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom); |
105 | if (!skb) { | 105 | if (!skb) { |
106 | printk(KERN_ERR "%s: failed to allocate buffer for " | 106 | printk(KERN_ERR "%s: failed to allocate buffer for " |
107 | "bar frame\n", sdata->dev->name); | 107 | "bar frame\n", sdata->name); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | skb_reserve(skb, local->hw.extra_tx_headroom); | 110 | skb_reserve(skb, local->hw.extra_tx_headroom); |
@@ -113,7 +113,7 @@ void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u1 | |||
113 | bar->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | | 113 | bar->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | |
114 | IEEE80211_STYPE_BACK_REQ); | 114 | IEEE80211_STYPE_BACK_REQ); |
115 | memcpy(bar->ra, ra, ETH_ALEN); | 115 | memcpy(bar->ra, ra, ETH_ALEN); |
116 | memcpy(bar->ta, sdata->dev->dev_addr, ETH_ALEN); | 116 | memcpy(bar->ta, sdata->vif.addr, ETH_ALEN); |
117 | bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL; | 117 | bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL; |
118 | bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA; | 118 | bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA; |
119 | bar_control |= (u16)(tid << 12); | 119 | bar_control |= (u16)(tid << 12); |
@@ -144,7 +144,7 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, | |||
144 | *state = HT_AGG_STATE_REQ_STOP_BA_MSK | | 144 | *state = HT_AGG_STATE_REQ_STOP_BA_MSK | |
145 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); | 145 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); |
146 | 146 | ||
147 | ret = drv_ampdu_action(local, &sta->sdata->vif, | 147 | ret = drv_ampdu_action(local, sta->sdata, |
148 | IEEE80211_AMPDU_TX_STOP, | 148 | IEEE80211_AMPDU_TX_STOP, |
149 | &sta->sta, tid, NULL); | 149 | &sta->sta, tid, NULL); |
150 | 150 | ||
@@ -179,7 +179,8 @@ static void sta_addba_resp_timer_expired(unsigned long data) | |||
179 | 179 | ||
180 | /* check if the TID waits for addBA response */ | 180 | /* check if the TID waits for addBA response */ |
181 | spin_lock_bh(&sta->lock); | 181 | spin_lock_bh(&sta->lock); |
182 | if ((*state & (HT_ADDBA_REQUESTED_MSK | HT_ADDBA_RECEIVED_MSK)) != | 182 | if ((*state & (HT_ADDBA_REQUESTED_MSK | HT_ADDBA_RECEIVED_MSK | |
183 | HT_AGG_STATE_REQ_STOP_BA_MSK)) != | ||
183 | HT_ADDBA_REQUESTED_MSK) { | 184 | HT_ADDBA_REQUESTED_MSK) { |
184 | spin_unlock_bh(&sta->lock); | 185 | spin_unlock_bh(&sta->lock); |
185 | *state = HT_AGG_STATE_IDLE; | 186 | *state = HT_AGG_STATE_IDLE; |
@@ -301,10 +302,9 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid) | |||
301 | * call back right away, it must see that the flow has begun */ | 302 | * call back right away, it must see that the flow has begun */ |
302 | *state |= HT_ADDBA_REQUESTED_MSK; | 303 | *state |= HT_ADDBA_REQUESTED_MSK; |
303 | 304 | ||
304 | start_seq_num = sta->tid_seq[tid]; | 305 | start_seq_num = sta->tid_seq[tid] >> 4; |
305 | 306 | ||
306 | ret = drv_ampdu_action(local, &sdata->vif, | 307 | ret = drv_ampdu_action(local, sdata, IEEE80211_AMPDU_TX_START, |
307 | IEEE80211_AMPDU_TX_START, | ||
308 | pubsta, tid, &start_seq_num); | 308 | pubsta, tid, &start_seq_num); |
309 | 309 | ||
310 | if (ret) { | 310 | if (ret) { |
@@ -420,7 +420,7 @@ static void ieee80211_agg_tx_operational(struct ieee80211_local *local, | |||
420 | ieee80211_agg_splice_finish(local, sta, tid); | 420 | ieee80211_agg_splice_finish(local, sta, tid); |
421 | spin_unlock(&local->ampdu_lock); | 421 | spin_unlock(&local->ampdu_lock); |
422 | 422 | ||
423 | drv_ampdu_action(local, &sta->sdata->vif, | 423 | drv_ampdu_action(local, sta->sdata, |
424 | IEEE80211_AMPDU_TX_OPERATIONAL, | 424 | IEEE80211_AMPDU_TX_OPERATIONAL, |
425 | &sta->sta, tid, NULL); | 425 | &sta->sta, tid, NULL); |
426 | } | 426 | } |
@@ -441,7 +441,7 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid) | |||
441 | } | 441 | } |
442 | 442 | ||
443 | rcu_read_lock(); | 443 | rcu_read_lock(); |
444 | sta = sta_info_get(local, ra); | 444 | sta = sta_info_get(sdata, ra); |
445 | if (!sta) { | 445 | if (!sta) { |
446 | rcu_read_unlock(); | 446 | rcu_read_unlock(); |
447 | #ifdef CONFIG_MAC80211_HT_DEBUG | 447 | #ifdef CONFIG_MAC80211_HT_DEBUG |
@@ -489,7 +489,7 @@ void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, | |||
489 | #ifdef CONFIG_MAC80211_HT_DEBUG | 489 | #ifdef CONFIG_MAC80211_HT_DEBUG |
490 | if (net_ratelimit()) | 490 | if (net_ratelimit()) |
491 | printk(KERN_WARNING "%s: Not enough memory, " | 491 | printk(KERN_WARNING "%s: Not enough memory, " |
492 | "dropping start BA session", skb->dev->name); | 492 | "dropping start BA session", sdata->name); |
493 | #endif | 493 | #endif |
494 | return; | 494 | return; |
495 | } | 495 | } |
@@ -564,7 +564,7 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid) | |||
564 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 564 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
565 | 565 | ||
566 | rcu_read_lock(); | 566 | rcu_read_lock(); |
567 | sta = sta_info_get(local, ra); | 567 | sta = sta_info_get(sdata, ra); |
568 | if (!sta) { | 568 | if (!sta) { |
569 | #ifdef CONFIG_MAC80211_HT_DEBUG | 569 | #ifdef CONFIG_MAC80211_HT_DEBUG |
570 | printk(KERN_DEBUG "Could not find station: %pM\n", ra); | 570 | printk(KERN_DEBUG "Could not find station: %pM\n", ra); |
@@ -621,7 +621,7 @@ void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, | |||
621 | #ifdef CONFIG_MAC80211_HT_DEBUG | 621 | #ifdef CONFIG_MAC80211_HT_DEBUG |
622 | if (net_ratelimit()) | 622 | if (net_ratelimit()) |
623 | printk(KERN_WARNING "%s: Not enough memory, " | 623 | printk(KERN_WARNING "%s: Not enough memory, " |
624 | "dropping stop BA session", skb->dev->name); | 624 | "dropping stop BA session", sdata->name); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 9ae1a4760b58..facf233843e0 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -78,17 +78,15 @@ static int ieee80211_change_iface(struct wiphy *wiphy, | |||
78 | enum nl80211_iftype type, u32 *flags, | 78 | enum nl80211_iftype type, u32 *flags, |
79 | struct vif_params *params) | 79 | struct vif_params *params) |
80 | { | 80 | { |
81 | struct ieee80211_sub_if_data *sdata; | 81 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
82 | int ret; | 82 | int ret; |
83 | 83 | ||
84 | if (netif_running(dev)) | 84 | if (ieee80211_sdata_running(sdata)) |
85 | return -EBUSY; | 85 | return -EBUSY; |
86 | 86 | ||
87 | if (!nl80211_params_check(type, params)) | 87 | if (!nl80211_params_check(type, params)) |
88 | return -EINVAL; | 88 | return -EINVAL; |
89 | 89 | ||
90 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
91 | |||
92 | ret = ieee80211_if_change_type(sdata, type); | 90 | ret = ieee80211_if_change_type(sdata, type); |
93 | if (ret) | 91 | if (ret) |
94 | return ret; | 92 | return ret; |
@@ -150,7 +148,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
150 | rcu_read_lock(); | 148 | rcu_read_lock(); |
151 | 149 | ||
152 | if (mac_addr) { | 150 | if (mac_addr) { |
153 | sta = sta_info_get(sdata->local, mac_addr); | 151 | sta = sta_info_get_bss(sdata, mac_addr); |
154 | if (!sta) { | 152 | if (!sta) { |
155 | ieee80211_key_free(key); | 153 | ieee80211_key_free(key); |
156 | err = -ENOENT; | 154 | err = -ENOENT; |
@@ -181,7 +179,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |||
181 | if (mac_addr) { | 179 | if (mac_addr) { |
182 | ret = -ENOENT; | 180 | ret = -ENOENT; |
183 | 181 | ||
184 | sta = sta_info_get(sdata->local, mac_addr); | 182 | sta = sta_info_get_bss(sdata, mac_addr); |
185 | if (!sta) | 183 | if (!sta) |
186 | goto out_unlock; | 184 | goto out_unlock; |
187 | 185 | ||
@@ -228,7 +226,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, | |||
228 | rcu_read_lock(); | 226 | rcu_read_lock(); |
229 | 227 | ||
230 | if (mac_addr) { | 228 | if (mac_addr) { |
231 | sta = sta_info_get(sdata->local, mac_addr); | 229 | sta = sta_info_get_bss(sdata, mac_addr); |
232 | if (!sta) | 230 | if (!sta) |
233 | goto out; | 231 | goto out; |
234 | 232 | ||
@@ -415,15 +413,13 @@ static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, | |||
415 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, | 413 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
416 | u8 *mac, struct station_info *sinfo) | 414 | u8 *mac, struct station_info *sinfo) |
417 | { | 415 | { |
418 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 416 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
419 | struct sta_info *sta; | 417 | struct sta_info *sta; |
420 | int ret = -ENOENT; | 418 | int ret = -ENOENT; |
421 | 419 | ||
422 | rcu_read_lock(); | 420 | rcu_read_lock(); |
423 | 421 | ||
424 | /* XXX: verify sta->dev == dev */ | 422 | sta = sta_info_get_bss(sdata, mac); |
425 | |||
426 | sta = sta_info_get(local, mac); | ||
427 | if (sta) { | 423 | if (sta) { |
428 | ret = 0; | 424 | ret = 0; |
429 | sta_set_sinfo(sta, sinfo); | 425 | sta_set_sinfo(sta, sinfo); |
@@ -732,7 +728,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |||
732 | } else | 728 | } else |
733 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 729 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
734 | 730 | ||
735 | if (compare_ether_addr(mac, dev->dev_addr) == 0) | 731 | if (compare_ether_addr(mac, sdata->vif.addr) == 0) |
736 | return -EINVAL; | 732 | return -EINVAL; |
737 | 733 | ||
738 | if (is_multicast_ether_addr(mac)) | 734 | if (is_multicast_ether_addr(mac)) |
@@ -779,8 +775,7 @@ static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, | |||
779 | if (mac) { | 775 | if (mac) { |
780 | rcu_read_lock(); | 776 | rcu_read_lock(); |
781 | 777 | ||
782 | /* XXX: get sta belonging to dev */ | 778 | sta = sta_info_get_bss(sdata, mac); |
783 | sta = sta_info_get(local, mac); | ||
784 | if (!sta) { | 779 | if (!sta) { |
785 | rcu_read_unlock(); | 780 | rcu_read_unlock(); |
786 | return -ENOENT; | 781 | return -ENOENT; |
@@ -801,14 +796,14 @@ static int ieee80211_change_station(struct wiphy *wiphy, | |||
801 | u8 *mac, | 796 | u8 *mac, |
802 | struct station_parameters *params) | 797 | struct station_parameters *params) |
803 | { | 798 | { |
799 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
804 | struct ieee80211_local *local = wiphy_priv(wiphy); | 800 | struct ieee80211_local *local = wiphy_priv(wiphy); |
805 | struct sta_info *sta; | 801 | struct sta_info *sta; |
806 | struct ieee80211_sub_if_data *vlansdata; | 802 | struct ieee80211_sub_if_data *vlansdata; |
807 | 803 | ||
808 | rcu_read_lock(); | 804 | rcu_read_lock(); |
809 | 805 | ||
810 | /* XXX: get sta belonging to dev */ | 806 | sta = sta_info_get_bss(sdata, mac); |
811 | sta = sta_info_get(local, mac); | ||
812 | if (!sta) { | 807 | if (!sta) { |
813 | rcu_read_unlock(); | 808 | rcu_read_unlock(); |
814 | return -ENOENT; | 809 | return -ENOENT; |
@@ -847,7 +842,6 @@ static int ieee80211_change_station(struct wiphy *wiphy, | |||
847 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | 842 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
848 | u8 *dst, u8 *next_hop) | 843 | u8 *dst, u8 *next_hop) |
849 | { | 844 | { |
850 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
851 | struct ieee80211_sub_if_data *sdata; | 845 | struct ieee80211_sub_if_data *sdata; |
852 | struct mesh_path *mpath; | 846 | struct mesh_path *mpath; |
853 | struct sta_info *sta; | 847 | struct sta_info *sta; |
@@ -856,7 +850,7 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
856 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 850 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
857 | 851 | ||
858 | rcu_read_lock(); | 852 | rcu_read_lock(); |
859 | sta = sta_info_get(local, next_hop); | 853 | sta = sta_info_get(sdata, next_hop); |
860 | if (!sta) { | 854 | if (!sta) { |
861 | rcu_read_unlock(); | 855 | rcu_read_unlock(); |
862 | return -ENOENT; | 856 | return -ENOENT; |
@@ -895,7 +889,6 @@ static int ieee80211_change_mpath(struct wiphy *wiphy, | |||
895 | struct net_device *dev, | 889 | struct net_device *dev, |
896 | u8 *dst, u8 *next_hop) | 890 | u8 *dst, u8 *next_hop) |
897 | { | 891 | { |
898 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
899 | struct ieee80211_sub_if_data *sdata; | 892 | struct ieee80211_sub_if_data *sdata; |
900 | struct mesh_path *mpath; | 893 | struct mesh_path *mpath; |
901 | struct sta_info *sta; | 894 | struct sta_info *sta; |
@@ -904,7 +897,7 @@ static int ieee80211_change_mpath(struct wiphy *wiphy, | |||
904 | 897 | ||
905 | rcu_read_lock(); | 898 | rcu_read_lock(); |
906 | 899 | ||
907 | sta = sta_info_get(local, next_hop); | 900 | sta = sta_info_get(sdata, next_hop); |
908 | if (!sta) { | 901 | if (!sta) { |
909 | rcu_read_unlock(); | 902 | rcu_read_unlock(); |
910 | return -ENOENT; | 903 | return -ENOENT; |
@@ -1092,6 +1085,13 @@ static int ieee80211_change_bss(struct wiphy *wiphy, | |||
1092 | params->use_short_preamble; | 1085 | params->use_short_preamble; |
1093 | changed |= BSS_CHANGED_ERP_PREAMBLE; | 1086 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
1094 | } | 1087 | } |
1088 | |||
1089 | if (!sdata->vif.bss_conf.use_short_slot && | ||
1090 | sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) { | ||
1091 | sdata->vif.bss_conf.use_short_slot = true; | ||
1092 | changed |= BSS_CHANGED_ERP_SLOT; | ||
1093 | } | ||
1094 | |||
1095 | if (params->use_short_slot_time >= 0) { | 1095 | if (params->use_short_slot_time >= 0) { |
1096 | sdata->vif.bss_conf.use_short_slot = | 1096 | sdata->vif.bss_conf.use_short_slot = |
1097 | params->use_short_slot_time; | 1097 | params->use_short_slot_time; |
@@ -1135,6 +1135,13 @@ static int ieee80211_set_txq_params(struct wiphy *wiphy, | |||
1135 | p.cw_max = params->cwmax; | 1135 | p.cw_max = params->cwmax; |
1136 | p.cw_min = params->cwmin; | 1136 | p.cw_min = params->cwmin; |
1137 | p.txop = params->txop; | 1137 | p.txop = params->txop; |
1138 | |||
1139 | /* | ||
1140 | * Setting tx queue params disables u-apsd because it's only | ||
1141 | * called in master mode. | ||
1142 | */ | ||
1143 | p.uapsd = false; | ||
1144 | |||
1138 | if (drv_conf_tx(local, params->queue, &p)) { | 1145 | if (drv_conf_tx(local, params->queue, &p)) { |
1139 | printk(KERN_DEBUG "%s: failed to set TX queue " | 1146 | printk(KERN_DEBUG "%s: failed to set TX queue " |
1140 | "parameters for queue %d\n", | 1147 | "parameters for queue %d\n", |
@@ -1237,6 +1244,13 @@ static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) | |||
1237 | struct ieee80211_local *local = wiphy_priv(wiphy); | 1244 | struct ieee80211_local *local = wiphy_priv(wiphy); |
1238 | int err; | 1245 | int err; |
1239 | 1246 | ||
1247 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) { | ||
1248 | err = drv_set_coverage_class(local, wiphy->coverage_class); | ||
1249 | |||
1250 | if (err) | ||
1251 | return err; | ||
1252 | } | ||
1253 | |||
1240 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { | 1254 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
1241 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); | 1255 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
1242 | 1256 | ||
@@ -1324,6 +1338,50 @@ static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len) | |||
1324 | } | 1338 | } |
1325 | #endif | 1339 | #endif |
1326 | 1340 | ||
1341 | int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, | ||
1342 | enum ieee80211_smps_mode smps_mode) | ||
1343 | { | ||
1344 | const u8 *ap; | ||
1345 | enum ieee80211_smps_mode old_req; | ||
1346 | int err; | ||
1347 | |||
1348 | old_req = sdata->u.mgd.req_smps; | ||
1349 | sdata->u.mgd.req_smps = smps_mode; | ||
1350 | |||
1351 | if (old_req == smps_mode && | ||
1352 | smps_mode != IEEE80211_SMPS_AUTOMATIC) | ||
1353 | return 0; | ||
1354 | |||
1355 | /* | ||
1356 | * If not associated, or current association is not an HT | ||
1357 | * association, there's no need to send an action frame. | ||
1358 | */ | ||
1359 | if (!sdata->u.mgd.associated || | ||
1360 | sdata->local->oper_channel_type == NL80211_CHAN_NO_HT) { | ||
1361 | mutex_lock(&sdata->local->iflist_mtx); | ||
1362 | ieee80211_recalc_smps(sdata->local, sdata); | ||
1363 | mutex_unlock(&sdata->local->iflist_mtx); | ||
1364 | return 0; | ||
1365 | } | ||
1366 | |||
1367 | ap = sdata->u.mgd.associated->bssid; | ||
1368 | |||
1369 | if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { | ||
1370 | if (sdata->u.mgd.powersave) | ||
1371 | smps_mode = IEEE80211_SMPS_DYNAMIC; | ||
1372 | else | ||
1373 | smps_mode = IEEE80211_SMPS_OFF; | ||
1374 | } | ||
1375 | |||
1376 | /* send SM PS frame to AP */ | ||
1377 | err = ieee80211_send_smps_action(sdata, smps_mode, | ||
1378 | ap, ap); | ||
1379 | if (err) | ||
1380 | sdata->u.mgd.req_smps = old_req; | ||
1381 | |||
1382 | return err; | ||
1383 | } | ||
1384 | |||
1327 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, | 1385 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
1328 | bool enabled, int timeout) | 1386 | bool enabled, int timeout) |
1329 | { | 1387 | { |
@@ -1344,6 +1402,11 @@ static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, | |||
1344 | sdata->u.mgd.powersave = enabled; | 1402 | sdata->u.mgd.powersave = enabled; |
1345 | conf->dynamic_ps_timeout = timeout; | 1403 | conf->dynamic_ps_timeout = timeout; |
1346 | 1404 | ||
1405 | /* no change, but if automatic follow powersave */ | ||
1406 | mutex_lock(&sdata->u.mgd.mtx); | ||
1407 | __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps); | ||
1408 | mutex_unlock(&sdata->u.mgd.mtx); | ||
1409 | |||
1347 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) | 1410 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) |
1348 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | 1411 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
1349 | 1412 | ||
@@ -1359,39 +1422,43 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, | |||
1359 | { | 1422 | { |
1360 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1423 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1361 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1424 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1362 | int i, err = -EINVAL; | 1425 | int i; |
1363 | u32 target_rate; | ||
1364 | struct ieee80211_supported_band *sband; | ||
1365 | 1426 | ||
1366 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 1427 | /* |
1428 | * This _could_ be supported by providing a hook for | ||
1429 | * drivers for this function, but at this point it | ||
1430 | * doesn't seem worth bothering. | ||
1431 | */ | ||
1432 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) | ||
1433 | return -EOPNOTSUPP; | ||
1367 | 1434 | ||
1368 | /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates | ||
1369 | * target_rate = X, rate->fixed = 1 means only rate X | ||
1370 | * target_rate = X, rate->fixed = 0 means all rates <= X */ | ||
1371 | sdata->max_ratectrl_rateidx = -1; | ||
1372 | sdata->force_unicast_rateidx = -1; | ||
1373 | 1435 | ||
1374 | if (mask->fixed) | 1436 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
1375 | target_rate = mask->fixed / 100; | 1437 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
1376 | else if (mask->maxrate) | ||
1377 | target_rate = mask->maxrate / 100; | ||
1378 | else | ||
1379 | return 0; | ||
1380 | 1438 | ||
1381 | for (i=0; i< sband->n_bitrates; i++) { | 1439 | return 0; |
1382 | struct ieee80211_rate *brate = &sband->bitrates[i]; | 1440 | } |
1383 | int this_rate = brate->bitrate; | ||
1384 | 1441 | ||
1385 | if (target_rate == this_rate) { | 1442 | static int ieee80211_remain_on_channel(struct wiphy *wiphy, |
1386 | sdata->max_ratectrl_rateidx = i; | 1443 | struct net_device *dev, |
1387 | if (mask->fixed) | 1444 | struct ieee80211_channel *chan, |
1388 | sdata->force_unicast_rateidx = i; | 1445 | enum nl80211_channel_type channel_type, |
1389 | err = 0; | 1446 | unsigned int duration, |
1390 | break; | 1447 | u64 *cookie) |
1391 | } | 1448 | { |
1392 | } | 1449 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1393 | 1450 | ||
1394 | return err; | 1451 | return ieee80211_wk_remain_on_channel(sdata, chan, channel_type, |
1452 | duration, cookie); | ||
1453 | } | ||
1454 | |||
1455 | static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, | ||
1456 | struct net_device *dev, | ||
1457 | u64 cookie) | ||
1458 | { | ||
1459 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1460 | |||
1461 | return ieee80211_wk_cancel_remain_on_channel(sdata, cookie); | ||
1395 | } | 1462 | } |
1396 | 1463 | ||
1397 | struct cfg80211_ops mac80211_config_ops = { | 1464 | struct cfg80211_ops mac80211_config_ops = { |
@@ -1440,4 +1507,6 @@ struct cfg80211_ops mac80211_config_ops = { | |||
1440 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) | 1507 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) |
1441 | .set_power_mgmt = ieee80211_set_power_mgmt, | 1508 | .set_power_mgmt = ieee80211_set_power_mgmt, |
1442 | .set_bitrate_mask = ieee80211_set_bitrate_mask, | 1509 | .set_bitrate_mask = ieee80211_set_bitrate_mask, |
1510 | .remain_on_channel = ieee80211_remain_on_channel, | ||
1511 | .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, | ||
1443 | }; | 1512 | }; |
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index e4b54093d41b..b3bc32b62a5a 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c | |||
@@ -158,6 +158,98 @@ static const struct file_operations noack_ops = { | |||
158 | .open = mac80211_open_file_generic | 158 | .open = mac80211_open_file_generic |
159 | }; | 159 | }; |
160 | 160 | ||
161 | static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf, | ||
162 | size_t count, loff_t *ppos) | ||
163 | { | ||
164 | struct ieee80211_local *local = file->private_data; | ||
165 | int res; | ||
166 | char buf[10]; | ||
167 | |||
168 | res = scnprintf(buf, sizeof(buf), "0x%x\n", local->uapsd_queues); | ||
169 | |||
170 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); | ||
171 | } | ||
172 | |||
173 | static ssize_t uapsd_queues_write(struct file *file, | ||
174 | const char __user *user_buf, | ||
175 | size_t count, loff_t *ppos) | ||
176 | { | ||
177 | struct ieee80211_local *local = file->private_data; | ||
178 | unsigned long val; | ||
179 | char buf[10]; | ||
180 | size_t len; | ||
181 | int ret; | ||
182 | |||
183 | len = min(count, sizeof(buf) - 1); | ||
184 | if (copy_from_user(buf, user_buf, len)) | ||
185 | return -EFAULT; | ||
186 | buf[len] = '\0'; | ||
187 | |||
188 | ret = strict_strtoul(buf, 0, &val); | ||
189 | |||
190 | if (ret) | ||
191 | return -EINVAL; | ||
192 | |||
193 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) | ||
194 | return -ERANGE; | ||
195 | |||
196 | local->uapsd_queues = val; | ||
197 | |||
198 | return count; | ||
199 | } | ||
200 | |||
201 | static const struct file_operations uapsd_queues_ops = { | ||
202 | .read = uapsd_queues_read, | ||
203 | .write = uapsd_queues_write, | ||
204 | .open = mac80211_open_file_generic | ||
205 | }; | ||
206 | |||
207 | static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf, | ||
208 | size_t count, loff_t *ppos) | ||
209 | { | ||
210 | struct ieee80211_local *local = file->private_data; | ||
211 | int res; | ||
212 | char buf[10]; | ||
213 | |||
214 | res = scnprintf(buf, sizeof(buf), "0x%x\n", local->uapsd_max_sp_len); | ||
215 | |||
216 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); | ||
217 | } | ||
218 | |||
219 | static ssize_t uapsd_max_sp_len_write(struct file *file, | ||
220 | const char __user *user_buf, | ||
221 | size_t count, loff_t *ppos) | ||
222 | { | ||
223 | struct ieee80211_local *local = file->private_data; | ||
224 | unsigned long val; | ||
225 | char buf[10]; | ||
226 | size_t len; | ||
227 | int ret; | ||
228 | |||
229 | len = min(count, sizeof(buf) - 1); | ||
230 | if (copy_from_user(buf, user_buf, len)) | ||
231 | return -EFAULT; | ||
232 | buf[len] = '\0'; | ||
233 | |||
234 | ret = strict_strtoul(buf, 0, &val); | ||
235 | |||
236 | if (ret) | ||
237 | return -EINVAL; | ||
238 | |||
239 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) | ||
240 | return -ERANGE; | ||
241 | |||
242 | local->uapsd_max_sp_len = val; | ||
243 | |||
244 | return count; | ||
245 | } | ||
246 | |||
247 | static const struct file_operations uapsd_max_sp_len_ops = { | ||
248 | .read = uapsd_max_sp_len_read, | ||
249 | .write = uapsd_max_sp_len_write, | ||
250 | .open = mac80211_open_file_generic | ||
251 | }; | ||
252 | |||
161 | static ssize_t queues_read(struct file *file, char __user *user_buf, | 253 | static ssize_t queues_read(struct file *file, char __user *user_buf, |
162 | size_t count, loff_t *ppos) | 254 | size_t count, loff_t *ppos) |
163 | { | 255 | { |
@@ -314,6 +406,8 @@ void debugfs_hw_add(struct ieee80211_local *local) | |||
314 | DEBUGFS_ADD(queues); | 406 | DEBUGFS_ADD(queues); |
315 | DEBUGFS_ADD_MODE(reset, 0200); | 407 | DEBUGFS_ADD_MODE(reset, 0200); |
316 | DEBUGFS_ADD(noack); | 408 | DEBUGFS_ADD(noack); |
409 | DEBUGFS_ADD(uapsd_queues); | ||
410 | DEBUGFS_ADD(uapsd_max_sp_len); | ||
317 | 411 | ||
318 | statsd = debugfs_create_dir("statistics", phyd); | 412 | statsd = debugfs_create_dir("statistics", phyd); |
319 | 413 | ||
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c index e0f5224630da..d12e743cb4e1 100644 --- a/net/mac80211/debugfs_key.c +++ b/net/mac80211/debugfs_key.c | |||
@@ -56,7 +56,7 @@ KEY_CONF_FILE(keyidx, D); | |||
56 | KEY_CONF_FILE(hw_key_idx, D); | 56 | KEY_CONF_FILE(hw_key_idx, D); |
57 | KEY_FILE(flags, X); | 57 | KEY_FILE(flags, X); |
58 | KEY_FILE(tx_rx_count, D); | 58 | KEY_FILE(tx_rx_count, D); |
59 | KEY_READ(ifindex, sdata->dev->ifindex, 20, "%d\n"); | 59 | KEY_READ(ifindex, sdata->name, IFNAMSIZ + 2, "%s\n"); |
60 | KEY_OPS(ifindex); | 60 | KEY_OPS(ifindex); |
61 | 61 | ||
62 | static ssize_t key_algorithm_read(struct file *file, | 62 | static ssize_t key_algorithm_read(struct file *file, |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 472b2039906c..9affe2cd185f 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -41,6 +41,30 @@ static ssize_t ieee80211_if_read( | |||
41 | return ret; | 41 | return ret; |
42 | } | 42 | } |
43 | 43 | ||
44 | static ssize_t ieee80211_if_write( | ||
45 | struct ieee80211_sub_if_data *sdata, | ||
46 | const char __user *userbuf, | ||
47 | size_t count, loff_t *ppos, | ||
48 | ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int)) | ||
49 | { | ||
50 | u8 *buf; | ||
51 | ssize_t ret = -ENODEV; | ||
52 | |||
53 | buf = kzalloc(count, GFP_KERNEL); | ||
54 | if (!buf) | ||
55 | return -ENOMEM; | ||
56 | |||
57 | if (copy_from_user(buf, userbuf, count)) | ||
58 | return -EFAULT; | ||
59 | |||
60 | rtnl_lock(); | ||
61 | if (sdata->dev->reg_state == NETREG_REGISTERED) | ||
62 | ret = (*write)(sdata, buf, count); | ||
63 | rtnl_unlock(); | ||
64 | |||
65 | return ret; | ||
66 | } | ||
67 | |||
44 | #define IEEE80211_IF_FMT(name, field, format_string) \ | 68 | #define IEEE80211_IF_FMT(name, field, format_string) \ |
45 | static ssize_t ieee80211_if_fmt_##name( \ | 69 | static ssize_t ieee80211_if_fmt_##name( \ |
46 | const struct ieee80211_sub_if_data *sdata, char *buf, \ | 70 | const struct ieee80211_sub_if_data *sdata, char *buf, \ |
@@ -71,7 +95,7 @@ static ssize_t ieee80211_if_fmt_##name( \ | |||
71 | return scnprintf(buf, buflen, "%pM\n", sdata->field); \ | 95 | return scnprintf(buf, buflen, "%pM\n", sdata->field); \ |
72 | } | 96 | } |
73 | 97 | ||
74 | #define __IEEE80211_IF_FILE(name) \ | 98 | #define __IEEE80211_IF_FILE(name, _write) \ |
75 | static ssize_t ieee80211_if_read_##name(struct file *file, \ | 99 | static ssize_t ieee80211_if_read_##name(struct file *file, \ |
76 | char __user *userbuf, \ | 100 | char __user *userbuf, \ |
77 | size_t count, loff_t *ppos) \ | 101 | size_t count, loff_t *ppos) \ |
@@ -82,22 +106,99 @@ static ssize_t ieee80211_if_read_##name(struct file *file, \ | |||
82 | } \ | 106 | } \ |
83 | static const struct file_operations name##_ops = { \ | 107 | static const struct file_operations name##_ops = { \ |
84 | .read = ieee80211_if_read_##name, \ | 108 | .read = ieee80211_if_read_##name, \ |
109 | .write = (_write), \ | ||
85 | .open = mac80211_open_file_generic, \ | 110 | .open = mac80211_open_file_generic, \ |
86 | } | 111 | } |
87 | 112 | ||
113 | #define __IEEE80211_IF_FILE_W(name) \ | ||
114 | static ssize_t ieee80211_if_write_##name(struct file *file, \ | ||
115 | const char __user *userbuf, \ | ||
116 | size_t count, loff_t *ppos) \ | ||
117 | { \ | ||
118 | return ieee80211_if_write(file->private_data, userbuf, count, \ | ||
119 | ppos, ieee80211_if_parse_##name); \ | ||
120 | } \ | ||
121 | __IEEE80211_IF_FILE(name, ieee80211_if_write_##name) | ||
122 | |||
123 | |||
88 | #define IEEE80211_IF_FILE(name, field, format) \ | 124 | #define IEEE80211_IF_FILE(name, field, format) \ |
89 | IEEE80211_IF_FMT_##format(name, field) \ | 125 | IEEE80211_IF_FMT_##format(name, field) \ |
90 | __IEEE80211_IF_FILE(name) | 126 | __IEEE80211_IF_FILE(name, NULL) |
91 | 127 | ||
92 | /* common attributes */ | 128 | /* common attributes */ |
93 | IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); | 129 | IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); |
94 | IEEE80211_IF_FILE(force_unicast_rateidx, force_unicast_rateidx, DEC); | 130 | IEEE80211_IF_FILE(rc_rateidx_mask_2ghz, rc_rateidx_mask[IEEE80211_BAND_2GHZ], |
95 | IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC); | 131 | HEX); |
132 | IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[IEEE80211_BAND_5GHZ], | ||
133 | HEX); | ||
96 | 134 | ||
97 | /* STA attributes */ | 135 | /* STA attributes */ |
98 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); | 136 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); |
99 | IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); | 137 | IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); |
100 | IEEE80211_IF_FILE(capab, u.mgd.capab, HEX); | 138 | |
139 | static int ieee80211_set_smps(struct ieee80211_sub_if_data *sdata, | ||
140 | enum ieee80211_smps_mode smps_mode) | ||
141 | { | ||
142 | struct ieee80211_local *local = sdata->local; | ||
143 | int err; | ||
144 | |||
145 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) && | ||
146 | smps_mode == IEEE80211_SMPS_STATIC) | ||
147 | return -EINVAL; | ||
148 | |||
149 | /* auto should be dynamic if in PS mode */ | ||
150 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) && | ||
151 | (smps_mode == IEEE80211_SMPS_DYNAMIC || | ||
152 | smps_mode == IEEE80211_SMPS_AUTOMATIC)) | ||
153 | return -EINVAL; | ||
154 | |||
155 | /* supported only on managed interfaces for now */ | ||
156 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
157 | return -EOPNOTSUPP; | ||
158 | |||
159 | mutex_lock(&local->iflist_mtx); | ||
160 | err = __ieee80211_request_smps(sdata, smps_mode); | ||
161 | mutex_unlock(&local->iflist_mtx); | ||
162 | |||
163 | return err; | ||
164 | } | ||
165 | |||
166 | static const char *smps_modes[IEEE80211_SMPS_NUM_MODES] = { | ||
167 | [IEEE80211_SMPS_AUTOMATIC] = "auto", | ||
168 | [IEEE80211_SMPS_OFF] = "off", | ||
169 | [IEEE80211_SMPS_STATIC] = "static", | ||
170 | [IEEE80211_SMPS_DYNAMIC] = "dynamic", | ||
171 | }; | ||
172 | |||
173 | static ssize_t ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data *sdata, | ||
174 | char *buf, int buflen) | ||
175 | { | ||
176 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
177 | return -EOPNOTSUPP; | ||
178 | |||
179 | return snprintf(buf, buflen, "request: %s\nused: %s\n", | ||
180 | smps_modes[sdata->u.mgd.req_smps], | ||
181 | smps_modes[sdata->u.mgd.ap_smps]); | ||
182 | } | ||
183 | |||
184 | static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata, | ||
185 | const char *buf, int buflen) | ||
186 | { | ||
187 | enum ieee80211_smps_mode mode; | ||
188 | |||
189 | for (mode = 0; mode < IEEE80211_SMPS_NUM_MODES; mode++) { | ||
190 | if (strncmp(buf, smps_modes[mode], buflen) == 0) { | ||
191 | int err = ieee80211_set_smps(sdata, mode); | ||
192 | if (!err) | ||
193 | return buflen; | ||
194 | return err; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | return -EINVAL; | ||
199 | } | ||
200 | |||
201 | __IEEE80211_IF_FILE_W(smps); | ||
101 | 202 | ||
102 | /* AP attributes */ | 203 | /* AP attributes */ |
103 | IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); | 204 | IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); |
@@ -109,7 +210,7 @@ static ssize_t ieee80211_if_fmt_num_buffered_multicast( | |||
109 | return scnprintf(buf, buflen, "%u\n", | 210 | return scnprintf(buf, buflen, "%u\n", |
110 | skb_queue_len(&sdata->u.ap.ps_bc_buf)); | 211 | skb_queue_len(&sdata->u.ap.ps_bc_buf)); |
111 | } | 212 | } |
112 | __IEEE80211_IF_FILE(num_buffered_multicast); | 213 | __IEEE80211_IF_FILE(num_buffered_multicast, NULL); |
113 | 214 | ||
114 | /* WDS attributes */ | 215 | /* WDS attributes */ |
115 | IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC); | 216 | IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC); |
@@ -154,46 +255,50 @@ IEEE80211_IF_FILE(dot11MeshHWMPRootMode, | |||
154 | #endif | 255 | #endif |
155 | 256 | ||
156 | 257 | ||
157 | #define DEBUGFS_ADD(name, type) \ | 258 | #define DEBUGFS_ADD(name) \ |
158 | debugfs_create_file(#name, 0400, sdata->debugfs.dir, \ | 259 | debugfs_create_file(#name, 0400, sdata->debugfs.dir, \ |
159 | sdata, &name##_ops); | 260 | sdata, &name##_ops); |
160 | 261 | ||
262 | #define DEBUGFS_ADD_MODE(name, mode) \ | ||
263 | debugfs_create_file(#name, mode, sdata->debugfs.dir, \ | ||
264 | sdata, &name##_ops); | ||
265 | |||
161 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) | 266 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) |
162 | { | 267 | { |
163 | DEBUGFS_ADD(drop_unencrypted, sta); | 268 | DEBUGFS_ADD(drop_unencrypted); |
164 | DEBUGFS_ADD(force_unicast_rateidx, sta); | 269 | DEBUGFS_ADD(rc_rateidx_mask_2ghz); |
165 | DEBUGFS_ADD(max_ratectrl_rateidx, sta); | 270 | DEBUGFS_ADD(rc_rateidx_mask_5ghz); |
166 | 271 | ||
167 | DEBUGFS_ADD(bssid, sta); | 272 | DEBUGFS_ADD(bssid); |
168 | DEBUGFS_ADD(aid, sta); | 273 | DEBUGFS_ADD(aid); |
169 | DEBUGFS_ADD(capab, sta); | 274 | DEBUGFS_ADD_MODE(smps, 0600); |
170 | } | 275 | } |
171 | 276 | ||
172 | static void add_ap_files(struct ieee80211_sub_if_data *sdata) | 277 | static void add_ap_files(struct ieee80211_sub_if_data *sdata) |
173 | { | 278 | { |
174 | DEBUGFS_ADD(drop_unencrypted, ap); | 279 | DEBUGFS_ADD(drop_unencrypted); |
175 | DEBUGFS_ADD(force_unicast_rateidx, ap); | 280 | DEBUGFS_ADD(rc_rateidx_mask_2ghz); |
176 | DEBUGFS_ADD(max_ratectrl_rateidx, ap); | 281 | DEBUGFS_ADD(rc_rateidx_mask_5ghz); |
177 | 282 | ||
178 | DEBUGFS_ADD(num_sta_ps, ap); | 283 | DEBUGFS_ADD(num_sta_ps); |
179 | DEBUGFS_ADD(dtim_count, ap); | 284 | DEBUGFS_ADD(dtim_count); |
180 | DEBUGFS_ADD(num_buffered_multicast, ap); | 285 | DEBUGFS_ADD(num_buffered_multicast); |
181 | } | 286 | } |
182 | 287 | ||
183 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) | 288 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) |
184 | { | 289 | { |
185 | DEBUGFS_ADD(drop_unencrypted, wds); | 290 | DEBUGFS_ADD(drop_unencrypted); |
186 | DEBUGFS_ADD(force_unicast_rateidx, wds); | 291 | DEBUGFS_ADD(rc_rateidx_mask_2ghz); |
187 | DEBUGFS_ADD(max_ratectrl_rateidx, wds); | 292 | DEBUGFS_ADD(rc_rateidx_mask_5ghz); |
188 | 293 | ||
189 | DEBUGFS_ADD(peer, wds); | 294 | DEBUGFS_ADD(peer); |
190 | } | 295 | } |
191 | 296 | ||
192 | static void add_vlan_files(struct ieee80211_sub_if_data *sdata) | 297 | static void add_vlan_files(struct ieee80211_sub_if_data *sdata) |
193 | { | 298 | { |
194 | DEBUGFS_ADD(drop_unencrypted, vlan); | 299 | DEBUGFS_ADD(drop_unencrypted); |
195 | DEBUGFS_ADD(force_unicast_rateidx, vlan); | 300 | DEBUGFS_ADD(rc_rateidx_mask_2ghz); |
196 | DEBUGFS_ADD(max_ratectrl_rateidx, vlan); | 301 | DEBUGFS_ADD(rc_rateidx_mask_5ghz); |
197 | } | 302 | } |
198 | 303 | ||
199 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) | 304 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) |
@@ -280,16 +385,11 @@ static void add_files(struct ieee80211_sub_if_data *sdata) | |||
280 | } | 385 | } |
281 | } | 386 | } |
282 | 387 | ||
283 | static int notif_registered; | ||
284 | |||
285 | void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata) | 388 | void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata) |
286 | { | 389 | { |
287 | char buf[10+IFNAMSIZ]; | 390 | char buf[10+IFNAMSIZ]; |
288 | 391 | ||
289 | if (!notif_registered) | 392 | sprintf(buf, "netdev:%s", sdata->name); |
290 | return; | ||
291 | |||
292 | sprintf(buf, "netdev:%s", sdata->dev->name); | ||
293 | sdata->debugfs.dir = debugfs_create_dir(buf, | 393 | sdata->debugfs.dir = debugfs_create_dir(buf, |
294 | sdata->local->hw.wiphy->debugfsdir); | 394 | sdata->local->hw.wiphy->debugfsdir); |
295 | add_files(sdata); | 395 | add_files(sdata); |
@@ -304,58 +404,18 @@ void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata) | |||
304 | sdata->debugfs.dir = NULL; | 404 | sdata->debugfs.dir = NULL; |
305 | } | 405 | } |
306 | 406 | ||
307 | static int netdev_notify(struct notifier_block *nb, | 407 | void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata) |
308 | unsigned long state, | ||
309 | void *ndev) | ||
310 | { | 408 | { |
311 | struct net_device *dev = ndev; | ||
312 | struct dentry *dir; | 409 | struct dentry *dir; |
313 | struct ieee80211_sub_if_data *sdata; | 410 | char buf[10 + IFNAMSIZ]; |
314 | char buf[10+IFNAMSIZ]; | ||
315 | |||
316 | if (state != NETDEV_CHANGENAME) | ||
317 | return 0; | ||
318 | |||
319 | if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) | ||
320 | return 0; | ||
321 | |||
322 | if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid) | ||
323 | return 0; | ||
324 | |||
325 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
326 | 411 | ||
327 | dir = sdata->debugfs.dir; | 412 | dir = sdata->debugfs.dir; |
328 | 413 | ||
329 | if (!dir) | 414 | if (!dir) |
330 | return 0; | 415 | return; |
331 | 416 | ||
332 | sprintf(buf, "netdev:%s", dev->name); | 417 | sprintf(buf, "netdev:%s", sdata->name); |
333 | if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf)) | 418 | if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf)) |
334 | printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs " | 419 | printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs " |
335 | "dir to %s\n", buf); | 420 | "dir to %s\n", buf); |
336 | |||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | static struct notifier_block mac80211_debugfs_netdev_notifier = { | ||
341 | .notifier_call = netdev_notify, | ||
342 | }; | ||
343 | |||
344 | void ieee80211_debugfs_netdev_init(void) | ||
345 | { | ||
346 | int err; | ||
347 | |||
348 | err = register_netdevice_notifier(&mac80211_debugfs_netdev_notifier); | ||
349 | if (err) { | ||
350 | printk(KERN_ERR | ||
351 | "mac80211: failed to install netdev notifier," | ||
352 | " disabling per-netdev debugfs!\n"); | ||
353 | } else | ||
354 | notif_registered = 1; | ||
355 | } | ||
356 | |||
357 | void ieee80211_debugfs_netdev_exit(void) | ||
358 | { | ||
359 | unregister_netdevice_notifier(&mac80211_debugfs_netdev_notifier); | ||
360 | notif_registered = 0; | ||
361 | } | 421 | } |
diff --git a/net/mac80211/debugfs_netdev.h b/net/mac80211/debugfs_netdev.h index 7af731f0b731..79025e79f4d6 100644 --- a/net/mac80211/debugfs_netdev.h +++ b/net/mac80211/debugfs_netdev.h | |||
@@ -6,8 +6,7 @@ | |||
6 | #ifdef CONFIG_MAC80211_DEBUGFS | 6 | #ifdef CONFIG_MAC80211_DEBUGFS |
7 | void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata); | 7 | void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata); |
8 | void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata); | 8 | void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata); |
9 | void ieee80211_debugfs_netdev_init(void); | 9 | void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata); |
10 | void ieee80211_debugfs_netdev_exit(void); | ||
11 | #else | 10 | #else |
12 | static inline void ieee80211_debugfs_add_netdev( | 11 | static inline void ieee80211_debugfs_add_netdev( |
13 | struct ieee80211_sub_if_data *sdata) | 12 | struct ieee80211_sub_if_data *sdata) |
@@ -15,10 +14,8 @@ static inline void ieee80211_debugfs_add_netdev( | |||
15 | static inline void ieee80211_debugfs_remove_netdev( | 14 | static inline void ieee80211_debugfs_remove_netdev( |
16 | struct ieee80211_sub_if_data *sdata) | 15 | struct ieee80211_sub_if_data *sdata) |
17 | {} | 16 | {} |
18 | static inline void ieee80211_debugfs_netdev_init(void) | 17 | static inline void ieee80211_debugfs_rename_netdev( |
19 | {} | 18 | struct ieee80211_sub_if_data *sdata) |
20 | |||
21 | static inline void ieee80211_debugfs_netdev_exit(void) | ||
22 | {} | 19 | {} |
23 | #endif | 20 | #endif |
24 | 21 | ||
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c index 3f41608c8081..0d4a759ba72c 100644 --- a/net/mac80211/debugfs_sta.c +++ b/net/mac80211/debugfs_sta.c | |||
@@ -44,7 +44,7 @@ static const struct file_operations sta_ ##name## _ops = { \ | |||
44 | STA_OPS(name) | 44 | STA_OPS(name) |
45 | 45 | ||
46 | STA_FILE(aid, sta.aid, D); | 46 | STA_FILE(aid, sta.aid, D); |
47 | STA_FILE(dev, sdata->dev->name, S); | 47 | STA_FILE(dev, sdata->name, S); |
48 | STA_FILE(rx_packets, rx_packets, LU); | 48 | STA_FILE(rx_packets, rx_packets, LU); |
49 | STA_FILE(tx_packets, tx_packets, LU); | 49 | STA_FILE(tx_packets, tx_packets, LU); |
50 | STA_FILE(rx_bytes, rx_bytes, LU); | 50 | STA_FILE(rx_bytes, rx_bytes, LU); |
@@ -160,7 +160,12 @@ STA_OPS(agg_status); | |||
160 | static ssize_t sta_ht_capa_read(struct file *file, char __user *userbuf, | 160 | static ssize_t sta_ht_capa_read(struct file *file, char __user *userbuf, |
161 | size_t count, loff_t *ppos) | 161 | size_t count, loff_t *ppos) |
162 | { | 162 | { |
163 | char buf[200], *p = buf; | 163 | #define PRINT_HT_CAP(_cond, _str) \ |
164 | do { \ | ||
165 | if (_cond) \ | ||
166 | p += scnprintf(p, sizeof(buf)+buf-p, "\t" _str "\n"); \ | ||
167 | } while (0) | ||
168 | char buf[1024], *p = buf; | ||
164 | int i; | 169 | int i; |
165 | struct sta_info *sta = file->private_data; | 170 | struct sta_info *sta = file->private_data; |
166 | struct ieee80211_sta_ht_cap *htc = &sta->sta.ht_cap; | 171 | struct ieee80211_sta_ht_cap *htc = &sta->sta.ht_cap; |
@@ -168,15 +173,64 @@ static ssize_t sta_ht_capa_read(struct file *file, char __user *userbuf, | |||
168 | p += scnprintf(p, sizeof(buf) + buf - p, "ht %ssupported\n", | 173 | p += scnprintf(p, sizeof(buf) + buf - p, "ht %ssupported\n", |
169 | htc->ht_supported ? "" : "not "); | 174 | htc->ht_supported ? "" : "not "); |
170 | if (htc->ht_supported) { | 175 | if (htc->ht_supported) { |
171 | p += scnprintf(p, sizeof(buf)+buf-p, "cap: %#.2x\n", htc->cap); | 176 | p += scnprintf(p, sizeof(buf)+buf-p, "cap: %#.4x\n", htc->cap); |
177 | |||
178 | PRINT_HT_CAP((htc->cap & BIT(0)), "RX LDCP"); | ||
179 | PRINT_HT_CAP((htc->cap & BIT(1)), "HT20/HT40"); | ||
180 | PRINT_HT_CAP(!(htc->cap & BIT(1)), "HT20"); | ||
181 | |||
182 | PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 0, "Static SM Power Save"); | ||
183 | PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 1, "Dynamic SM Power Save"); | ||
184 | PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 3, "SM Power Save disabled"); | ||
185 | |||
186 | PRINT_HT_CAP((htc->cap & BIT(4)), "RX Greenfield"); | ||
187 | PRINT_HT_CAP((htc->cap & BIT(5)), "RX HT20 SGI"); | ||
188 | PRINT_HT_CAP((htc->cap & BIT(6)), "RX HT40 SGI"); | ||
189 | PRINT_HT_CAP((htc->cap & BIT(7)), "TX STBC"); | ||
190 | |||
191 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 0, "No RX STBC"); | ||
192 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 1, "RX STBC 1-stream"); | ||
193 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 2, "RX STBC 2-streams"); | ||
194 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 3, "RX STBC 3-streams"); | ||
195 | |||
196 | PRINT_HT_CAP((htc->cap & BIT(10)), "HT Delayed Block Ack"); | ||
197 | |||
198 | PRINT_HT_CAP((htc->cap & BIT(11)), "Max AMSDU length: " | ||
199 | "3839 bytes"); | ||
200 | PRINT_HT_CAP(!(htc->cap & BIT(11)), "Max AMSDU length: " | ||
201 | "7935 bytes"); | ||
202 | |||
203 | /* | ||
204 | * For beacons and probe response this would mean the BSS | ||
205 | * does or does not allow the usage of DSSS/CCK HT40. | ||
206 | * Otherwise it means the STA does or does not use | ||
207 | * DSSS/CCK HT40. | ||
208 | */ | ||
209 | PRINT_HT_CAP((htc->cap & BIT(12)), "DSSS/CCK HT40"); | ||
210 | PRINT_HT_CAP(!(htc->cap & BIT(12)), "No DSSS/CCK HT40"); | ||
211 | |||
212 | /* BIT(13) is reserved */ | ||
213 | |||
214 | PRINT_HT_CAP((htc->cap & BIT(14)), "40 MHz Intolerant"); | ||
215 | |||
216 | PRINT_HT_CAP((htc->cap & BIT(15)), "L-SIG TXOP protection"); | ||
217 | |||
172 | p += scnprintf(p, sizeof(buf)+buf-p, "ampdu factor/density: %d/%d\n", | 218 | p += scnprintf(p, sizeof(buf)+buf-p, "ampdu factor/density: %d/%d\n", |
173 | htc->ampdu_factor, htc->ampdu_density); | 219 | htc->ampdu_factor, htc->ampdu_density); |
174 | p += scnprintf(p, sizeof(buf)+buf-p, "MCS mask:"); | 220 | p += scnprintf(p, sizeof(buf)+buf-p, "MCS mask:"); |
221 | |||
175 | for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) | 222 | for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) |
176 | p += scnprintf(p, sizeof(buf)+buf-p, " %.2x", | 223 | p += scnprintf(p, sizeof(buf)+buf-p, " %.2x", |
177 | htc->mcs.rx_mask[i]); | 224 | htc->mcs.rx_mask[i]); |
178 | p += scnprintf(p, sizeof(buf)+buf-p, "\nMCS rx highest: %d\n", | 225 | p += scnprintf(p, sizeof(buf)+buf-p, "\n"); |
179 | le16_to_cpu(htc->mcs.rx_highest)); | 226 | |
227 | /* If not set this is meaningless */ | ||
228 | if (le16_to_cpu(htc->mcs.rx_highest)) { | ||
229 | p += scnprintf(p, sizeof(buf)+buf-p, | ||
230 | "MCS rx highest: %d Mbps\n", | ||
231 | le16_to_cpu(htc->mcs.rx_highest)); | ||
232 | } | ||
233 | |||
180 | p += scnprintf(p, sizeof(buf)+buf-p, "MCS tx params: %x\n", | 234 | p += scnprintf(p, sizeof(buf)+buf-p, "MCS tx params: %x\n", |
181 | htc->mcs.tx_params); | 235 | htc->mcs.tx_params); |
182 | } | 236 | } |
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 921dd9c9ff62..de91d39e0276 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h | |||
@@ -14,6 +14,8 @@ static inline int drv_start(struct ieee80211_local *local) | |||
14 | { | 14 | { |
15 | int ret; | 15 | int ret; |
16 | 16 | ||
17 | might_sleep(); | ||
18 | |||
17 | local->started = true; | 19 | local->started = true; |
18 | smp_mb(); | 20 | smp_mb(); |
19 | ret = local->ops->start(&local->hw); | 21 | ret = local->ops->start(&local->hw); |
@@ -23,6 +25,8 @@ static inline int drv_start(struct ieee80211_local *local) | |||
23 | 25 | ||
24 | static inline void drv_stop(struct ieee80211_local *local) | 26 | static inline void drv_stop(struct ieee80211_local *local) |
25 | { | 27 | { |
28 | might_sleep(); | ||
29 | |||
26 | local->ops->stop(&local->hw); | 30 | local->ops->stop(&local->hw); |
27 | trace_drv_stop(local); | 31 | trace_drv_stop(local); |
28 | 32 | ||
@@ -36,35 +40,47 @@ static inline void drv_stop(struct ieee80211_local *local) | |||
36 | } | 40 | } |
37 | 41 | ||
38 | static inline int drv_add_interface(struct ieee80211_local *local, | 42 | static inline int drv_add_interface(struct ieee80211_local *local, |
39 | struct ieee80211_if_init_conf *conf) | 43 | struct ieee80211_vif *vif) |
40 | { | 44 | { |
41 | int ret = local->ops->add_interface(&local->hw, conf); | 45 | int ret; |
42 | trace_drv_add_interface(local, conf->mac_addr, conf->vif, ret); | 46 | |
47 | might_sleep(); | ||
48 | |||
49 | ret = local->ops->add_interface(&local->hw, vif); | ||
50 | trace_drv_add_interface(local, vif_to_sdata(vif), ret); | ||
43 | return ret; | 51 | return ret; |
44 | } | 52 | } |
45 | 53 | ||
46 | static inline void drv_remove_interface(struct ieee80211_local *local, | 54 | static inline void drv_remove_interface(struct ieee80211_local *local, |
47 | struct ieee80211_if_init_conf *conf) | 55 | struct ieee80211_vif *vif) |
48 | { | 56 | { |
49 | local->ops->remove_interface(&local->hw, conf); | 57 | might_sleep(); |
50 | trace_drv_remove_interface(local, conf->mac_addr, conf->vif); | 58 | |
59 | local->ops->remove_interface(&local->hw, vif); | ||
60 | trace_drv_remove_interface(local, vif_to_sdata(vif)); | ||
51 | } | 61 | } |
52 | 62 | ||
53 | static inline int drv_config(struct ieee80211_local *local, u32 changed) | 63 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
54 | { | 64 | { |
55 | int ret = local->ops->config(&local->hw, changed); | 65 | int ret; |
66 | |||
67 | might_sleep(); | ||
68 | |||
69 | ret = local->ops->config(&local->hw, changed); | ||
56 | trace_drv_config(local, changed, ret); | 70 | trace_drv_config(local, changed, ret); |
57 | return ret; | 71 | return ret; |
58 | } | 72 | } |
59 | 73 | ||
60 | static inline void drv_bss_info_changed(struct ieee80211_local *local, | 74 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
61 | struct ieee80211_vif *vif, | 75 | struct ieee80211_sub_if_data *sdata, |
62 | struct ieee80211_bss_conf *info, | 76 | struct ieee80211_bss_conf *info, |
63 | u32 changed) | 77 | u32 changed) |
64 | { | 78 | { |
79 | might_sleep(); | ||
80 | |||
65 | if (local->ops->bss_info_changed) | 81 | if (local->ops->bss_info_changed) |
66 | local->ops->bss_info_changed(&local->hw, vif, info, changed); | 82 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
67 | trace_drv_bss_info_changed(local, vif, info, changed); | 83 | trace_drv_bss_info_changed(local, sdata, info, changed); |
68 | } | 84 | } |
69 | 85 | ||
70 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, | 86 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
@@ -106,12 +122,17 @@ static inline int drv_set_tim(struct ieee80211_local *local, | |||
106 | } | 122 | } |
107 | 123 | ||
108 | static inline int drv_set_key(struct ieee80211_local *local, | 124 | static inline int drv_set_key(struct ieee80211_local *local, |
109 | enum set_key_cmd cmd, struct ieee80211_vif *vif, | 125 | enum set_key_cmd cmd, |
126 | struct ieee80211_sub_if_data *sdata, | ||
110 | struct ieee80211_sta *sta, | 127 | struct ieee80211_sta *sta, |
111 | struct ieee80211_key_conf *key) | 128 | struct ieee80211_key_conf *key) |
112 | { | 129 | { |
113 | int ret = local->ops->set_key(&local->hw, cmd, vif, sta, key); | 130 | int ret; |
114 | trace_drv_set_key(local, cmd, vif, sta, key, ret); | 131 | |
132 | might_sleep(); | ||
133 | |||
134 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); | ||
135 | trace_drv_set_key(local, cmd, sdata, sta, key, ret); | ||
115 | return ret; | 136 | return ret; |
116 | } | 137 | } |
117 | 138 | ||
@@ -120,6 +141,8 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local, | |||
120 | const u8 *address, u32 iv32, | 141 | const u8 *address, u32 iv32, |
121 | u16 *phase1key) | 142 | u16 *phase1key) |
122 | { | 143 | { |
144 | might_sleep(); | ||
145 | |||
123 | if (local->ops->update_tkip_key) | 146 | if (local->ops->update_tkip_key) |
124 | local->ops->update_tkip_key(&local->hw, conf, address, | 147 | local->ops->update_tkip_key(&local->hw, conf, address, |
125 | iv32, phase1key); | 148 | iv32, phase1key); |
@@ -129,13 +152,19 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local, | |||
129 | static inline int drv_hw_scan(struct ieee80211_local *local, | 152 | static inline int drv_hw_scan(struct ieee80211_local *local, |
130 | struct cfg80211_scan_request *req) | 153 | struct cfg80211_scan_request *req) |
131 | { | 154 | { |
132 | int ret = local->ops->hw_scan(&local->hw, req); | 155 | int ret; |
156 | |||
157 | might_sleep(); | ||
158 | |||
159 | ret = local->ops->hw_scan(&local->hw, req); | ||
133 | trace_drv_hw_scan(local, req, ret); | 160 | trace_drv_hw_scan(local, req, ret); |
134 | return ret; | 161 | return ret; |
135 | } | 162 | } |
136 | 163 | ||
137 | static inline void drv_sw_scan_start(struct ieee80211_local *local) | 164 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
138 | { | 165 | { |
166 | might_sleep(); | ||
167 | |||
139 | if (local->ops->sw_scan_start) | 168 | if (local->ops->sw_scan_start) |
140 | local->ops->sw_scan_start(&local->hw); | 169 | local->ops->sw_scan_start(&local->hw); |
141 | trace_drv_sw_scan_start(local); | 170 | trace_drv_sw_scan_start(local); |
@@ -143,6 +172,8 @@ static inline void drv_sw_scan_start(struct ieee80211_local *local) | |||
143 | 172 | ||
144 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) | 173 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) |
145 | { | 174 | { |
175 | might_sleep(); | ||
176 | |||
146 | if (local->ops->sw_scan_complete) | 177 | if (local->ops->sw_scan_complete) |
147 | local->ops->sw_scan_complete(&local->hw); | 178 | local->ops->sw_scan_complete(&local->hw); |
148 | trace_drv_sw_scan_complete(local); | 179 | trace_drv_sw_scan_complete(local); |
@@ -153,6 +184,8 @@ static inline int drv_get_stats(struct ieee80211_local *local, | |||
153 | { | 184 | { |
154 | int ret = -EOPNOTSUPP; | 185 | int ret = -EOPNOTSUPP; |
155 | 186 | ||
187 | might_sleep(); | ||
188 | |||
156 | if (local->ops->get_stats) | 189 | if (local->ops->get_stats) |
157 | ret = local->ops->get_stats(&local->hw, stats); | 190 | ret = local->ops->get_stats(&local->hw, stats); |
158 | trace_drv_get_stats(local, stats, ret); | 191 | trace_drv_get_stats(local, stats, ret); |
@@ -172,26 +205,47 @@ static inline int drv_set_rts_threshold(struct ieee80211_local *local, | |||
172 | u32 value) | 205 | u32 value) |
173 | { | 206 | { |
174 | int ret = 0; | 207 | int ret = 0; |
208 | |||
209 | might_sleep(); | ||
210 | |||
175 | if (local->ops->set_rts_threshold) | 211 | if (local->ops->set_rts_threshold) |
176 | ret = local->ops->set_rts_threshold(&local->hw, value); | 212 | ret = local->ops->set_rts_threshold(&local->hw, value); |
177 | trace_drv_set_rts_threshold(local, value, ret); | 213 | trace_drv_set_rts_threshold(local, value, ret); |
178 | return ret; | 214 | return ret; |
179 | } | 215 | } |
180 | 216 | ||
217 | static inline int drv_set_coverage_class(struct ieee80211_local *local, | ||
218 | u8 value) | ||
219 | { | ||
220 | int ret = 0; | ||
221 | might_sleep(); | ||
222 | |||
223 | if (local->ops->set_coverage_class) | ||
224 | local->ops->set_coverage_class(&local->hw, value); | ||
225 | else | ||
226 | ret = -EOPNOTSUPP; | ||
227 | |||
228 | trace_drv_set_coverage_class(local, value, ret); | ||
229 | return ret; | ||
230 | } | ||
231 | |||
181 | static inline void drv_sta_notify(struct ieee80211_local *local, | 232 | static inline void drv_sta_notify(struct ieee80211_local *local, |
182 | struct ieee80211_vif *vif, | 233 | struct ieee80211_sub_if_data *sdata, |
183 | enum sta_notify_cmd cmd, | 234 | enum sta_notify_cmd cmd, |
184 | struct ieee80211_sta *sta) | 235 | struct ieee80211_sta *sta) |
185 | { | 236 | { |
186 | if (local->ops->sta_notify) | 237 | if (local->ops->sta_notify) |
187 | local->ops->sta_notify(&local->hw, vif, cmd, sta); | 238 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
188 | trace_drv_sta_notify(local, vif, cmd, sta); | 239 | trace_drv_sta_notify(local, sdata, cmd, sta); |
189 | } | 240 | } |
190 | 241 | ||
191 | static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, | 242 | static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, |
192 | const struct ieee80211_tx_queue_params *params) | 243 | const struct ieee80211_tx_queue_params *params) |
193 | { | 244 | { |
194 | int ret = -EOPNOTSUPP; | 245 | int ret = -EOPNOTSUPP; |
246 | |||
247 | might_sleep(); | ||
248 | |||
195 | if (local->ops->conf_tx) | 249 | if (local->ops->conf_tx) |
196 | ret = local->ops->conf_tx(&local->hw, queue, params); | 250 | ret = local->ops->conf_tx(&local->hw, queue, params); |
197 | trace_drv_conf_tx(local, queue, params, ret); | 251 | trace_drv_conf_tx(local, queue, params, ret); |
@@ -209,6 +263,9 @@ static inline int drv_get_tx_stats(struct ieee80211_local *local, | |||
209 | static inline u64 drv_get_tsf(struct ieee80211_local *local) | 263 | static inline u64 drv_get_tsf(struct ieee80211_local *local) |
210 | { | 264 | { |
211 | u64 ret = -1ULL; | 265 | u64 ret = -1ULL; |
266 | |||
267 | might_sleep(); | ||
268 | |||
212 | if (local->ops->get_tsf) | 269 | if (local->ops->get_tsf) |
213 | ret = local->ops->get_tsf(&local->hw); | 270 | ret = local->ops->get_tsf(&local->hw); |
214 | trace_drv_get_tsf(local, ret); | 271 | trace_drv_get_tsf(local, ret); |
@@ -217,6 +274,8 @@ static inline u64 drv_get_tsf(struct ieee80211_local *local) | |||
217 | 274 | ||
218 | static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) | 275 | static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) |
219 | { | 276 | { |
277 | might_sleep(); | ||
278 | |||
220 | if (local->ops->set_tsf) | 279 | if (local->ops->set_tsf) |
221 | local->ops->set_tsf(&local->hw, tsf); | 280 | local->ops->set_tsf(&local->hw, tsf); |
222 | trace_drv_set_tsf(local, tsf); | 281 | trace_drv_set_tsf(local, tsf); |
@@ -224,6 +283,8 @@ static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) | |||
224 | 283 | ||
225 | static inline void drv_reset_tsf(struct ieee80211_local *local) | 284 | static inline void drv_reset_tsf(struct ieee80211_local *local) |
226 | { | 285 | { |
286 | might_sleep(); | ||
287 | |||
227 | if (local->ops->reset_tsf) | 288 | if (local->ops->reset_tsf) |
228 | local->ops->reset_tsf(&local->hw); | 289 | local->ops->reset_tsf(&local->hw); |
229 | trace_drv_reset_tsf(local); | 290 | trace_drv_reset_tsf(local); |
@@ -232,6 +293,9 @@ static inline void drv_reset_tsf(struct ieee80211_local *local) | |||
232 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) | 293 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
233 | { | 294 | { |
234 | int ret = 1; | 295 | int ret = 1; |
296 | |||
297 | might_sleep(); | ||
298 | |||
235 | if (local->ops->tx_last_beacon) | 299 | if (local->ops->tx_last_beacon) |
236 | ret = local->ops->tx_last_beacon(&local->hw); | 300 | ret = local->ops->tx_last_beacon(&local->hw); |
237 | trace_drv_tx_last_beacon(local, ret); | 301 | trace_drv_tx_last_beacon(local, ret); |
@@ -239,23 +303,34 @@ static inline int drv_tx_last_beacon(struct ieee80211_local *local) | |||
239 | } | 303 | } |
240 | 304 | ||
241 | static inline int drv_ampdu_action(struct ieee80211_local *local, | 305 | static inline int drv_ampdu_action(struct ieee80211_local *local, |
242 | struct ieee80211_vif *vif, | 306 | struct ieee80211_sub_if_data *sdata, |
243 | enum ieee80211_ampdu_mlme_action action, | 307 | enum ieee80211_ampdu_mlme_action action, |
244 | struct ieee80211_sta *sta, u16 tid, | 308 | struct ieee80211_sta *sta, u16 tid, |
245 | u16 *ssn) | 309 | u16 *ssn) |
246 | { | 310 | { |
247 | int ret = -EOPNOTSUPP; | 311 | int ret = -EOPNOTSUPP; |
248 | if (local->ops->ampdu_action) | 312 | if (local->ops->ampdu_action) |
249 | ret = local->ops->ampdu_action(&local->hw, vif, action, | 313 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
250 | sta, tid, ssn); | 314 | sta, tid, ssn); |
251 | trace_drv_ampdu_action(local, vif, action, sta, tid, ssn, ret); | 315 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, ret); |
252 | return ret; | 316 | return ret; |
253 | } | 317 | } |
254 | 318 | ||
255 | 319 | ||
256 | static inline void drv_rfkill_poll(struct ieee80211_local *local) | 320 | static inline void drv_rfkill_poll(struct ieee80211_local *local) |
257 | { | 321 | { |
322 | might_sleep(); | ||
323 | |||
258 | if (local->ops->rfkill_poll) | 324 | if (local->ops->rfkill_poll) |
259 | local->ops->rfkill_poll(&local->hw); | 325 | local->ops->rfkill_poll(&local->hw); |
260 | } | 326 | } |
327 | |||
328 | static inline void drv_flush(struct ieee80211_local *local, bool drop) | ||
329 | { | ||
330 | might_sleep(); | ||
331 | |||
332 | trace_drv_flush(local, drop); | ||
333 | if (local->ops->flush) | ||
334 | local->ops->flush(&local->hw, drop); | ||
335 | } | ||
261 | #endif /* __MAC80211_DRIVER_OPS */ | 336 | #endif /* __MAC80211_DRIVER_OPS */ |
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h index da8497ef7063..d6bd9f517401 100644 --- a/net/mac80211/driver-trace.h +++ b/net/mac80211/driver-trace.h | |||
@@ -25,10 +25,12 @@ static inline void trace_ ## name(proto) {} | |||
25 | #define STA_PR_FMT " sta:%pM" | 25 | #define STA_PR_FMT " sta:%pM" |
26 | #define STA_PR_ARG __entry->sta_addr | 26 | #define STA_PR_ARG __entry->sta_addr |
27 | 27 | ||
28 | #define VIF_ENTRY __field(enum nl80211_iftype, vif_type) __field(void *, vif) | 28 | #define VIF_ENTRY __field(enum nl80211_iftype, vif_type) __field(void *, sdata) \ |
29 | #define VIF_ASSIGN __entry->vif_type = vif ? vif->type : 0; __entry->vif = vif | 29 | __string(vif_name, sdata->dev ? sdata->dev->name : "<nodev>") |
30 | #define VIF_PR_FMT " vif:%p(%d)" | 30 | #define VIF_ASSIGN __entry->vif_type = sdata->vif.type; __entry->sdata = sdata; \ |
31 | #define VIF_PR_ARG __entry->vif, __entry->vif_type | 31 | __assign_str(vif_name, sdata->dev ? sdata->dev->name : "<nodev>") |
32 | #define VIF_PR_FMT " vif:%s(%d)" | ||
33 | #define VIF_PR_ARG __get_str(vif_name), __entry->vif_type | ||
32 | 34 | ||
33 | TRACE_EVENT(drv_start, | 35 | TRACE_EVENT(drv_start, |
34 | TP_PROTO(struct ieee80211_local *local, int ret), | 36 | TP_PROTO(struct ieee80211_local *local, int ret), |
@@ -70,11 +72,10 @@ TRACE_EVENT(drv_stop, | |||
70 | 72 | ||
71 | TRACE_EVENT(drv_add_interface, | 73 | TRACE_EVENT(drv_add_interface, |
72 | TP_PROTO(struct ieee80211_local *local, | 74 | TP_PROTO(struct ieee80211_local *local, |
73 | const u8 *addr, | 75 | struct ieee80211_sub_if_data *sdata, |
74 | struct ieee80211_vif *vif, | ||
75 | int ret), | 76 | int ret), |
76 | 77 | ||
77 | TP_ARGS(local, addr, vif, ret), | 78 | TP_ARGS(local, sdata, ret), |
78 | 79 | ||
79 | TP_STRUCT__entry( | 80 | TP_STRUCT__entry( |
80 | LOCAL_ENTRY | 81 | LOCAL_ENTRY |
@@ -86,7 +87,7 @@ TRACE_EVENT(drv_add_interface, | |||
86 | TP_fast_assign( | 87 | TP_fast_assign( |
87 | LOCAL_ASSIGN; | 88 | LOCAL_ASSIGN; |
88 | VIF_ASSIGN; | 89 | VIF_ASSIGN; |
89 | memcpy(__entry->addr, addr, 6); | 90 | memcpy(__entry->addr, sdata->vif.addr, 6); |
90 | __entry->ret = ret; | 91 | __entry->ret = ret; |
91 | ), | 92 | ), |
92 | 93 | ||
@@ -97,10 +98,9 @@ TRACE_EVENT(drv_add_interface, | |||
97 | ); | 98 | ); |
98 | 99 | ||
99 | TRACE_EVENT(drv_remove_interface, | 100 | TRACE_EVENT(drv_remove_interface, |
100 | TP_PROTO(struct ieee80211_local *local, | 101 | TP_PROTO(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata), |
101 | const u8 *addr, struct ieee80211_vif *vif), | ||
102 | 102 | ||
103 | TP_ARGS(local, addr, vif), | 103 | TP_ARGS(local, sdata), |
104 | 104 | ||
105 | TP_STRUCT__entry( | 105 | TP_STRUCT__entry( |
106 | LOCAL_ENTRY | 106 | LOCAL_ENTRY |
@@ -111,7 +111,7 @@ TRACE_EVENT(drv_remove_interface, | |||
111 | TP_fast_assign( | 111 | TP_fast_assign( |
112 | LOCAL_ASSIGN; | 112 | LOCAL_ASSIGN; |
113 | VIF_ASSIGN; | 113 | VIF_ASSIGN; |
114 | memcpy(__entry->addr, addr, 6); | 114 | memcpy(__entry->addr, sdata->vif.addr, 6); |
115 | ), | 115 | ), |
116 | 116 | ||
117 | TP_printk( | 117 | TP_printk( |
@@ -140,6 +140,7 @@ TRACE_EVENT(drv_config, | |||
140 | __field(u8, short_frame_max_tx_count) | 140 | __field(u8, short_frame_max_tx_count) |
141 | __field(int, center_freq) | 141 | __field(int, center_freq) |
142 | __field(int, channel_type) | 142 | __field(int, channel_type) |
143 | __field(int, smps) | ||
143 | ), | 144 | ), |
144 | 145 | ||
145 | TP_fast_assign( | 146 | TP_fast_assign( |
@@ -155,6 +156,7 @@ TRACE_EVENT(drv_config, | |||
155 | __entry->short_frame_max_tx_count = local->hw.conf.short_frame_max_tx_count; | 156 | __entry->short_frame_max_tx_count = local->hw.conf.short_frame_max_tx_count; |
156 | __entry->center_freq = local->hw.conf.channel->center_freq; | 157 | __entry->center_freq = local->hw.conf.channel->center_freq; |
157 | __entry->channel_type = local->hw.conf.channel_type; | 158 | __entry->channel_type = local->hw.conf.channel_type; |
159 | __entry->smps = local->hw.conf.smps_mode; | ||
158 | ), | 160 | ), |
159 | 161 | ||
160 | TP_printk( | 162 | TP_printk( |
@@ -165,11 +167,11 @@ TRACE_EVENT(drv_config, | |||
165 | 167 | ||
166 | TRACE_EVENT(drv_bss_info_changed, | 168 | TRACE_EVENT(drv_bss_info_changed, |
167 | TP_PROTO(struct ieee80211_local *local, | 169 | TP_PROTO(struct ieee80211_local *local, |
168 | struct ieee80211_vif *vif, | 170 | struct ieee80211_sub_if_data *sdata, |
169 | struct ieee80211_bss_conf *info, | 171 | struct ieee80211_bss_conf *info, |
170 | u32 changed), | 172 | u32 changed), |
171 | 173 | ||
172 | TP_ARGS(local, vif, info, changed), | 174 | TP_ARGS(local, sdata, info, changed), |
173 | 175 | ||
174 | TP_STRUCT__entry( | 176 | TP_STRUCT__entry( |
175 | LOCAL_ENTRY | 177 | LOCAL_ENTRY |
@@ -293,11 +295,11 @@ TRACE_EVENT(drv_set_tim, | |||
293 | 295 | ||
294 | TRACE_EVENT(drv_set_key, | 296 | TRACE_EVENT(drv_set_key, |
295 | TP_PROTO(struct ieee80211_local *local, | 297 | TP_PROTO(struct ieee80211_local *local, |
296 | enum set_key_cmd cmd, struct ieee80211_vif *vif, | 298 | enum set_key_cmd cmd, struct ieee80211_sub_if_data *sdata, |
297 | struct ieee80211_sta *sta, | 299 | struct ieee80211_sta *sta, |
298 | struct ieee80211_key_conf *key, int ret), | 300 | struct ieee80211_key_conf *key, int ret), |
299 | 301 | ||
300 | TP_ARGS(local, cmd, vif, sta, key, ret), | 302 | TP_ARGS(local, cmd, sdata, sta, key, ret), |
301 | 303 | ||
302 | TP_STRUCT__entry( | 304 | TP_STRUCT__entry( |
303 | LOCAL_ENTRY | 305 | LOCAL_ENTRY |
@@ -489,13 +491,36 @@ TRACE_EVENT(drv_set_rts_threshold, | |||
489 | ) | 491 | ) |
490 | ); | 492 | ); |
491 | 493 | ||
494 | TRACE_EVENT(drv_set_coverage_class, | ||
495 | TP_PROTO(struct ieee80211_local *local, u8 value, int ret), | ||
496 | |||
497 | TP_ARGS(local, value, ret), | ||
498 | |||
499 | TP_STRUCT__entry( | ||
500 | LOCAL_ENTRY | ||
501 | __field(u8, value) | ||
502 | __field(int, ret) | ||
503 | ), | ||
504 | |||
505 | TP_fast_assign( | ||
506 | LOCAL_ASSIGN; | ||
507 | __entry->ret = ret; | ||
508 | __entry->value = value; | ||
509 | ), | ||
510 | |||
511 | TP_printk( | ||
512 | LOCAL_PR_FMT " value:%d ret:%d", | ||
513 | LOCAL_PR_ARG, __entry->value, __entry->ret | ||
514 | ) | ||
515 | ); | ||
516 | |||
492 | TRACE_EVENT(drv_sta_notify, | 517 | TRACE_EVENT(drv_sta_notify, |
493 | TP_PROTO(struct ieee80211_local *local, | 518 | TP_PROTO(struct ieee80211_local *local, |
494 | struct ieee80211_vif *vif, | 519 | struct ieee80211_sub_if_data *sdata, |
495 | enum sta_notify_cmd cmd, | 520 | enum sta_notify_cmd cmd, |
496 | struct ieee80211_sta *sta), | 521 | struct ieee80211_sta *sta), |
497 | 522 | ||
498 | TP_ARGS(local, vif, cmd, sta), | 523 | TP_ARGS(local, sdata, cmd, sta), |
499 | 524 | ||
500 | TP_STRUCT__entry( | 525 | TP_STRUCT__entry( |
501 | LOCAL_ENTRY | 526 | LOCAL_ENTRY |
@@ -656,12 +681,12 @@ TRACE_EVENT(drv_tx_last_beacon, | |||
656 | 681 | ||
657 | TRACE_EVENT(drv_ampdu_action, | 682 | TRACE_EVENT(drv_ampdu_action, |
658 | TP_PROTO(struct ieee80211_local *local, | 683 | TP_PROTO(struct ieee80211_local *local, |
659 | struct ieee80211_vif *vif, | 684 | struct ieee80211_sub_if_data *sdata, |
660 | enum ieee80211_ampdu_mlme_action action, | 685 | enum ieee80211_ampdu_mlme_action action, |
661 | struct ieee80211_sta *sta, u16 tid, | 686 | struct ieee80211_sta *sta, u16 tid, |
662 | u16 *ssn, int ret), | 687 | u16 *ssn, int ret), |
663 | 688 | ||
664 | TP_ARGS(local, vif, action, sta, tid, ssn, ret), | 689 | TP_ARGS(local, sdata, action, sta, tid, ssn, ret), |
665 | 690 | ||
666 | TP_STRUCT__entry( | 691 | TP_STRUCT__entry( |
667 | LOCAL_ENTRY | 692 | LOCAL_ENTRY |
@@ -688,6 +713,27 @@ TRACE_EVENT(drv_ampdu_action, | |||
688 | LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->action, __entry->tid, __entry->ret | 713 | LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->action, __entry->tid, __entry->ret |
689 | ) | 714 | ) |
690 | ); | 715 | ); |
716 | |||
717 | TRACE_EVENT(drv_flush, | ||
718 | TP_PROTO(struct ieee80211_local *local, bool drop), | ||
719 | |||
720 | TP_ARGS(local, drop), | ||
721 | |||
722 | TP_STRUCT__entry( | ||
723 | LOCAL_ENTRY | ||
724 | __field(bool, drop) | ||
725 | ), | ||
726 | |||
727 | TP_fast_assign( | ||
728 | LOCAL_ASSIGN; | ||
729 | __entry->drop = drop; | ||
730 | ), | ||
731 | |||
732 | TP_printk( | ||
733 | LOCAL_PR_FMT " drop:%d", | ||
734 | LOCAL_PR_ARG, __entry->drop | ||
735 | ) | ||
736 | ); | ||
691 | #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ | 737 | #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ |
692 | 738 | ||
693 | #undef TRACE_INCLUDE_PATH | 739 | #undef TRACE_INCLUDE_PATH |
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c index d7dcee680728..bb677a73b7c9 100644 --- a/net/mac80211/ht.c +++ b/net/mac80211/ht.c | |||
@@ -125,7 +125,7 @@ void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, | |||
125 | 125 | ||
126 | if (!skb) { | 126 | if (!skb) { |
127 | printk(KERN_ERR "%s: failed to allocate buffer " | 127 | printk(KERN_ERR "%s: failed to allocate buffer " |
128 | "for delba frame\n", sdata->dev->name); | 128 | "for delba frame\n", sdata->name); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
@@ -133,10 +133,10 @@ void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, | |||
133 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | 133 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
134 | memset(mgmt, 0, 24); | 134 | memset(mgmt, 0, 24); |
135 | memcpy(mgmt->da, da, ETH_ALEN); | 135 | memcpy(mgmt->da, da, ETH_ALEN); |
136 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 136 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
137 | if (sdata->vif.type == NL80211_IFTYPE_AP || | 137 | if (sdata->vif.type == NL80211_IFTYPE_AP || |
138 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 138 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
139 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | 139 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
140 | else if (sdata->vif.type == NL80211_IFTYPE_STATION) | 140 | else if (sdata->vif.type == NL80211_IFTYPE_STATION) |
141 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); | 141 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
142 | 142 | ||
@@ -185,3 +185,50 @@ void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, | |||
185 | spin_unlock_bh(&sta->lock); | 185 | spin_unlock_bh(&sta->lock); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | |||
189 | int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata, | ||
190 | enum ieee80211_smps_mode smps, const u8 *da, | ||
191 | const u8 *bssid) | ||
192 | { | ||
193 | struct ieee80211_local *local = sdata->local; | ||
194 | struct sk_buff *skb; | ||
195 | struct ieee80211_mgmt *action_frame; | ||
196 | |||
197 | /* 27 = header + category + action + smps mode */ | ||
198 | skb = dev_alloc_skb(27 + local->hw.extra_tx_headroom); | ||
199 | if (!skb) | ||
200 | return -ENOMEM; | ||
201 | |||
202 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
203 | action_frame = (void *)skb_put(skb, 27); | ||
204 | memcpy(action_frame->da, da, ETH_ALEN); | ||
205 | memcpy(action_frame->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
206 | memcpy(action_frame->bssid, bssid, ETH_ALEN); | ||
207 | action_frame->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
208 | IEEE80211_STYPE_ACTION); | ||
209 | action_frame->u.action.category = WLAN_CATEGORY_HT; | ||
210 | action_frame->u.action.u.ht_smps.action = WLAN_HT_ACTION_SMPS; | ||
211 | switch (smps) { | ||
212 | case IEEE80211_SMPS_AUTOMATIC: | ||
213 | case IEEE80211_SMPS_NUM_MODES: | ||
214 | WARN_ON(1); | ||
215 | case IEEE80211_SMPS_OFF: | ||
216 | action_frame->u.action.u.ht_smps.smps_control = | ||
217 | WLAN_HT_SMPS_CONTROL_DISABLED; | ||
218 | break; | ||
219 | case IEEE80211_SMPS_STATIC: | ||
220 | action_frame->u.action.u.ht_smps.smps_control = | ||
221 | WLAN_HT_SMPS_CONTROL_STATIC; | ||
222 | break; | ||
223 | case IEEE80211_SMPS_DYNAMIC: | ||
224 | action_frame->u.action.u.ht_smps.smps_control = | ||
225 | WLAN_HT_SMPS_CONTROL_DYNAMIC; | ||
226 | break; | ||
227 | } | ||
228 | |||
229 | /* we'll do more on status of this frame */ | ||
230 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; | ||
231 | ieee80211_tx_skb(sdata, skb); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 1f2db647bb5c..5bcde4c3fba1 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
@@ -117,7 +117,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
117 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 117 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
118 | IEEE80211_STYPE_PROBE_RESP); | 118 | IEEE80211_STYPE_PROBE_RESP); |
119 | memset(mgmt->da, 0xff, ETH_ALEN); | 119 | memset(mgmt->da, 0xff, ETH_ALEN); |
120 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 120 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
121 | memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); | 121 | memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); |
122 | mgmt->u.beacon.beacon_int = cpu_to_le16(beacon_int); | 122 | mgmt->u.beacon.beacon_int = cpu_to_le16(beacon_int); |
123 | mgmt->u.beacon.timestamp = cpu_to_le64(tsf); | 123 | mgmt->u.beacon.timestamp = cpu_to_le64(tsf); |
@@ -187,15 +187,17 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
187 | static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | 187 | static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, |
188 | struct ieee80211_bss *bss) | 188 | struct ieee80211_bss *bss) |
189 | { | 189 | { |
190 | struct cfg80211_bss *cbss = | ||
191 | container_of((void *)bss, struct cfg80211_bss, priv); | ||
190 | struct ieee80211_supported_band *sband; | 192 | struct ieee80211_supported_band *sband; |
191 | u32 basic_rates; | 193 | u32 basic_rates; |
192 | int i, j; | 194 | int i, j; |
193 | u16 beacon_int = bss->cbss.beacon_interval; | 195 | u16 beacon_int = cbss->beacon_interval; |
194 | 196 | ||
195 | if (beacon_int < 10) | 197 | if (beacon_int < 10) |
196 | beacon_int = 10; | 198 | beacon_int = 10; |
197 | 199 | ||
198 | sband = sdata->local->hw.wiphy->bands[bss->cbss.channel->band]; | 200 | sband = sdata->local->hw.wiphy->bands[cbss->channel->band]; |
199 | 201 | ||
200 | basic_rates = 0; | 202 | basic_rates = 0; |
201 | 203 | ||
@@ -212,12 +214,12 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
212 | } | 214 | } |
213 | } | 215 | } |
214 | 216 | ||
215 | __ieee80211_sta_join_ibss(sdata, bss->cbss.bssid, | 217 | __ieee80211_sta_join_ibss(sdata, cbss->bssid, |
216 | beacon_int, | 218 | beacon_int, |
217 | bss->cbss.channel, | 219 | cbss->channel, |
218 | basic_rates, | 220 | basic_rates, |
219 | bss->cbss.capability, | 221 | cbss->capability, |
220 | bss->cbss.tsf); | 222 | cbss->tsf); |
221 | } | 223 | } |
222 | 224 | ||
223 | static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | 225 | static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, |
@@ -229,6 +231,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
229 | { | 231 | { |
230 | struct ieee80211_local *local = sdata->local; | 232 | struct ieee80211_local *local = sdata->local; |
231 | int freq; | 233 | int freq; |
234 | struct cfg80211_bss *cbss; | ||
232 | struct ieee80211_bss *bss; | 235 | struct ieee80211_bss *bss; |
233 | struct sta_info *sta; | 236 | struct sta_info *sta; |
234 | struct ieee80211_channel *channel; | 237 | struct ieee80211_channel *channel; |
@@ -252,7 +255,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
252 | 255 | ||
253 | rcu_read_lock(); | 256 | rcu_read_lock(); |
254 | 257 | ||
255 | sta = sta_info_get(local, mgmt->sa); | 258 | sta = sta_info_get(sdata, mgmt->sa); |
256 | if (sta) { | 259 | if (sta) { |
257 | u32 prev_rates; | 260 | u32 prev_rates; |
258 | 261 | ||
@@ -266,7 +269,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
266 | printk(KERN_DEBUG "%s: updated supp_rates set " | 269 | printk(KERN_DEBUG "%s: updated supp_rates set " |
267 | "for %pM based on beacon info (0x%llx | " | 270 | "for %pM based on beacon info (0x%llx | " |
268 | "0x%llx -> 0x%llx)\n", | 271 | "0x%llx -> 0x%llx)\n", |
269 | sdata->dev->name, | 272 | sdata->name, |
270 | sta->sta.addr, | 273 | sta->sta.addr, |
271 | (unsigned long long) prev_rates, | 274 | (unsigned long long) prev_rates, |
272 | (unsigned long long) supp_rates, | 275 | (unsigned long long) supp_rates, |
@@ -283,8 +286,10 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
283 | if (!bss) | 286 | if (!bss) |
284 | return; | 287 | return; |
285 | 288 | ||
289 | cbss = container_of((void *)bss, struct cfg80211_bss, priv); | ||
290 | |||
286 | /* was just updated in ieee80211_bss_info_update */ | 291 | /* was just updated in ieee80211_bss_info_update */ |
287 | beacon_timestamp = bss->cbss.tsf; | 292 | beacon_timestamp = cbss->tsf; |
288 | 293 | ||
289 | /* check if we need to merge IBSS */ | 294 | /* check if we need to merge IBSS */ |
290 | 295 | ||
@@ -297,11 +302,11 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
297 | goto put_bss; | 302 | goto put_bss; |
298 | 303 | ||
299 | /* not an IBSS */ | 304 | /* not an IBSS */ |
300 | if (!(bss->cbss.capability & WLAN_CAPABILITY_IBSS)) | 305 | if (!(cbss->capability & WLAN_CAPABILITY_IBSS)) |
301 | goto put_bss; | 306 | goto put_bss; |
302 | 307 | ||
303 | /* different channel */ | 308 | /* different channel */ |
304 | if (bss->cbss.channel != local->oper_channel) | 309 | if (cbss->channel != local->oper_channel) |
305 | goto put_bss; | 310 | goto put_bss; |
306 | 311 | ||
307 | /* different SSID */ | 312 | /* different SSID */ |
@@ -311,7 +316,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
311 | goto put_bss; | 316 | goto put_bss; |
312 | 317 | ||
313 | /* same BSSID */ | 318 | /* same BSSID */ |
314 | if (memcmp(bss->cbss.bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) | 319 | if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) |
315 | goto put_bss; | 320 | goto put_bss; |
316 | 321 | ||
317 | if (rx_status->flag & RX_FLAG_TSFT) { | 322 | if (rx_status->flag & RX_FLAG_TSFT) { |
@@ -364,7 +369,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
364 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 369 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
365 | printk(KERN_DEBUG "%s: beacon TSF higher than " | 370 | printk(KERN_DEBUG "%s: beacon TSF higher than " |
366 | "local TSF - IBSS merge with BSSID %pM\n", | 371 | "local TSF - IBSS merge with BSSID %pM\n", |
367 | sdata->dev->name, mgmt->bssid); | 372 | sdata->name, mgmt->bssid); |
368 | #endif | 373 | #endif |
369 | ieee80211_sta_join_ibss(sdata, bss); | 374 | ieee80211_sta_join_ibss(sdata, bss); |
370 | ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); | 375 | ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); |
@@ -394,7 +399,7 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | |||
394 | if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) { | 399 | if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) { |
395 | if (net_ratelimit()) | 400 | if (net_ratelimit()) |
396 | printk(KERN_DEBUG "%s: No room for a new IBSS STA entry %pM\n", | 401 | printk(KERN_DEBUG "%s: No room for a new IBSS STA entry %pM\n", |
397 | sdata->dev->name, addr); | 402 | sdata->name, addr); |
398 | return NULL; | 403 | return NULL; |
399 | } | 404 | } |
400 | 405 | ||
@@ -406,7 +411,7 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | |||
406 | 411 | ||
407 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 412 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
408 | printk(KERN_DEBUG "%s: Adding new IBSS station %pM (dev=%s)\n", | 413 | printk(KERN_DEBUG "%s: Adding new IBSS station %pM (dev=%s)\n", |
409 | wiphy_name(local->hw.wiphy), addr, sdata->dev->name); | 414 | wiphy_name(local->hw.wiphy), addr, sdata->name); |
410 | #endif | 415 | #endif |
411 | 416 | ||
412 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); | 417 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); |
@@ -470,7 +475,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) | |||
470 | return; | 475 | return; |
471 | 476 | ||
472 | printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " | 477 | printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " |
473 | "IBSS networks with same SSID (merge)\n", sdata->dev->name); | 478 | "IBSS networks with same SSID (merge)\n", sdata->name); |
474 | 479 | ||
475 | ieee80211_request_internal_scan(sdata, ifibss->ssid, ifibss->ssid_len); | 480 | ieee80211_request_internal_scan(sdata, ifibss->ssid, ifibss->ssid_len); |
476 | } | 481 | } |
@@ -492,13 +497,13 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) | |||
492 | * random number generator get different BSSID. */ | 497 | * random number generator get different BSSID. */ |
493 | get_random_bytes(bssid, ETH_ALEN); | 498 | get_random_bytes(bssid, ETH_ALEN); |
494 | for (i = 0; i < ETH_ALEN; i++) | 499 | for (i = 0; i < ETH_ALEN; i++) |
495 | bssid[i] ^= sdata->dev->dev_addr[i]; | 500 | bssid[i] ^= sdata->vif.addr[i]; |
496 | bssid[0] &= ~0x01; | 501 | bssid[0] &= ~0x01; |
497 | bssid[0] |= 0x02; | 502 | bssid[0] |= 0x02; |
498 | } | 503 | } |
499 | 504 | ||
500 | printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", | 505 | printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", |
501 | sdata->dev->name, bssid); | 506 | sdata->name, bssid); |
502 | 507 | ||
503 | sband = local->hw.wiphy->bands[ifibss->channel->band]; | 508 | sband = local->hw.wiphy->bands[ifibss->channel->band]; |
504 | 509 | ||
@@ -518,7 +523,7 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) | |||
518 | { | 523 | { |
519 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | 524 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
520 | struct ieee80211_local *local = sdata->local; | 525 | struct ieee80211_local *local = sdata->local; |
521 | struct ieee80211_bss *bss; | 526 | struct cfg80211_bss *cbss; |
522 | struct ieee80211_channel *chan = NULL; | 527 | struct ieee80211_channel *chan = NULL; |
523 | const u8 *bssid = NULL; | 528 | const u8 *bssid = NULL; |
524 | int active_ibss; | 529 | int active_ibss; |
@@ -527,7 +532,7 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) | |||
527 | active_ibss = ieee80211_sta_active_ibss(sdata); | 532 | active_ibss = ieee80211_sta_active_ibss(sdata); |
528 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 533 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
529 | printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", | 534 | printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", |
530 | sdata->dev->name, active_ibss); | 535 | sdata->name, active_ibss); |
531 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 536 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
532 | 537 | ||
533 | if (active_ibss) | 538 | if (active_ibss) |
@@ -542,21 +547,23 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) | |||
542 | chan = ifibss->channel; | 547 | chan = ifibss->channel; |
543 | if (!is_zero_ether_addr(ifibss->bssid)) | 548 | if (!is_zero_ether_addr(ifibss->bssid)) |
544 | bssid = ifibss->bssid; | 549 | bssid = ifibss->bssid; |
545 | bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan, bssid, | 550 | cbss = cfg80211_get_bss(local->hw.wiphy, chan, bssid, |
546 | ifibss->ssid, ifibss->ssid_len, | 551 | ifibss->ssid, ifibss->ssid_len, |
547 | WLAN_CAPABILITY_IBSS | | 552 | WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_PRIVACY, |
548 | WLAN_CAPABILITY_PRIVACY, | 553 | capability); |
549 | capability); | 554 | |
555 | if (cbss) { | ||
556 | struct ieee80211_bss *bss; | ||
550 | 557 | ||
551 | if (bss) { | 558 | bss = (void *)cbss->priv; |
552 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 559 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
553 | printk(KERN_DEBUG " sta_find_ibss: selected %pM current " | 560 | printk(KERN_DEBUG " sta_find_ibss: selected %pM current " |
554 | "%pM\n", bss->cbss.bssid, ifibss->bssid); | 561 | "%pM\n", cbss->bssid, ifibss->bssid); |
555 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 562 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
556 | 563 | ||
557 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" | 564 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" |
558 | " based on configured SSID\n", | 565 | " based on configured SSID\n", |
559 | sdata->dev->name, bss->cbss.bssid); | 566 | sdata->name, cbss->bssid); |
560 | 567 | ||
561 | ieee80211_sta_join_ibss(sdata, bss); | 568 | ieee80211_sta_join_ibss(sdata, bss); |
562 | ieee80211_rx_bss_put(local, bss); | 569 | ieee80211_rx_bss_put(local, bss); |
@@ -575,7 +582,7 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) | |||
575 | } else if (time_after(jiffies, ifibss->last_scan_completed + | 582 | } else if (time_after(jiffies, ifibss->last_scan_completed + |
576 | IEEE80211_SCAN_INTERVAL)) { | 583 | IEEE80211_SCAN_INTERVAL)) { |
577 | printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " | 584 | printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " |
578 | "join\n", sdata->dev->name); | 585 | "join\n", sdata->name); |
579 | 586 | ||
580 | ieee80211_request_internal_scan(sdata, ifibss->ssid, | 587 | ieee80211_request_internal_scan(sdata, ifibss->ssid, |
581 | ifibss->ssid_len); | 588 | ifibss->ssid_len); |
@@ -589,7 +596,7 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) | |||
589 | return; | 596 | return; |
590 | } | 597 | } |
591 | printk(KERN_DEBUG "%s: IBSS not allowed on" | 598 | printk(KERN_DEBUG "%s: IBSS not allowed on" |
592 | " %d MHz\n", sdata->dev->name, | 599 | " %d MHz\n", sdata->name, |
593 | local->hw.conf.channel->center_freq); | 600 | local->hw.conf.channel->center_freq); |
594 | 601 | ||
595 | /* No IBSS found - decrease scan interval and continue | 602 | /* No IBSS found - decrease scan interval and continue |
@@ -623,7 +630,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
623 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 630 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
624 | printk(KERN_DEBUG "%s: RX ProbeReq SA=%pM DA=%pM BSSID=%pM" | 631 | printk(KERN_DEBUG "%s: RX ProbeReq SA=%pM DA=%pM BSSID=%pM" |
625 | " (tx_last_beacon=%d)\n", | 632 | " (tx_last_beacon=%d)\n", |
626 | sdata->dev->name, mgmt->sa, mgmt->da, | 633 | sdata->name, mgmt->sa, mgmt->da, |
627 | mgmt->bssid, tx_last_beacon); | 634 | mgmt->bssid, tx_last_beacon); |
628 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 635 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
629 | 636 | ||
@@ -641,7 +648,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
641 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 648 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
642 | printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " | 649 | printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " |
643 | "from %pM\n", | 650 | "from %pM\n", |
644 | sdata->dev->name, mgmt->sa); | 651 | sdata->name, mgmt->sa); |
645 | #endif | 652 | #endif |
646 | return; | 653 | return; |
647 | } | 654 | } |
@@ -661,7 +668,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
661 | memcpy(resp->da, mgmt->sa, ETH_ALEN); | 668 | memcpy(resp->da, mgmt->sa, ETH_ALEN); |
662 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 669 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
663 | printk(KERN_DEBUG "%s: Sending ProbeResp to %pM\n", | 670 | printk(KERN_DEBUG "%s: Sending ProbeResp to %pM\n", |
664 | sdata->dev->name, resp->da); | 671 | sdata->name, resp->da); |
665 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 672 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
666 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 673 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
667 | ieee80211_tx_skb(sdata, skb); | 674 | ieee80211_tx_skb(sdata, skb); |
@@ -675,7 +682,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | |||
675 | size_t baselen; | 682 | size_t baselen; |
676 | struct ieee802_11_elems elems; | 683 | struct ieee802_11_elems elems; |
677 | 684 | ||
678 | if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) | 685 | if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) |
679 | return; /* ignore ProbeResp to foreign address */ | 686 | return; /* ignore ProbeResp to foreign address */ |
680 | 687 | ||
681 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; | 688 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; |
@@ -748,7 +755,7 @@ static void ieee80211_ibss_work(struct work_struct *work) | |||
748 | if (WARN_ON(local->suspended)) | 755 | if (WARN_ON(local->suspended)) |
749 | return; | 756 | return; |
750 | 757 | ||
751 | if (!netif_running(sdata->dev)) | 758 | if (!ieee80211_sdata_running(sdata)) |
752 | return; | 759 | return; |
753 | 760 | ||
754 | if (local->scanning) | 761 | if (local->scanning) |
@@ -831,7 +838,7 @@ void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local) | |||
831 | 838 | ||
832 | mutex_lock(&local->iflist_mtx); | 839 | mutex_lock(&local->iflist_mtx); |
833 | list_for_each_entry(sdata, &local->interfaces, list) { | 840 | list_for_each_entry(sdata, &local->interfaces, list) { |
834 | if (!netif_running(sdata->dev)) | 841 | if (!ieee80211_sdata_running(sdata)) |
835 | continue; | 842 | continue; |
836 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC) | 843 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC) |
837 | continue; | 844 | continue; |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 91dc8636d644..c18f576f1848 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -58,6 +58,15 @@ struct ieee80211_local; | |||
58 | 58 | ||
59 | #define TU_TO_EXP_TIME(x) (jiffies + usecs_to_jiffies((x) * 1024)) | 59 | #define TU_TO_EXP_TIME(x) (jiffies + usecs_to_jiffies((x) * 1024)) |
60 | 60 | ||
61 | #define IEEE80211_DEFAULT_UAPSD_QUEUES \ | ||
62 | (IEEE80211_WMM_IE_STA_QOSINFO_AC_BK | \ | ||
63 | IEEE80211_WMM_IE_STA_QOSINFO_AC_BE | \ | ||
64 | IEEE80211_WMM_IE_STA_QOSINFO_AC_VI | \ | ||
65 | IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) | ||
66 | |||
67 | #define IEEE80211_DEFAULT_MAX_SP_LEN \ | ||
68 | IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL | ||
69 | |||
61 | struct ieee80211_fragment_entry { | 70 | struct ieee80211_fragment_entry { |
62 | unsigned long first_frag_time; | 71 | unsigned long first_frag_time; |
63 | unsigned int seq; | 72 | unsigned int seq; |
@@ -71,9 +80,6 @@ struct ieee80211_fragment_entry { | |||
71 | 80 | ||
72 | 81 | ||
73 | struct ieee80211_bss { | 82 | struct ieee80211_bss { |
74 | /* Yes, this is a hack */ | ||
75 | struct cfg80211_bss cbss; | ||
76 | |||
77 | /* don't want to look up all the time */ | 83 | /* don't want to look up all the time */ |
78 | size_t ssid_len; | 84 | size_t ssid_len; |
79 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 85 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
@@ -81,6 +87,7 @@ struct ieee80211_bss { | |||
81 | u8 dtim_period; | 87 | u8 dtim_period; |
82 | 88 | ||
83 | bool wmm_used; | 89 | bool wmm_used; |
90 | bool uapsd_supported; | ||
84 | 91 | ||
85 | unsigned long last_probe_resp; | 92 | unsigned long last_probe_resp; |
86 | 93 | ||
@@ -140,7 +147,6 @@ typedef unsigned __bitwise__ ieee80211_tx_result; | |||
140 | 147 | ||
141 | struct ieee80211_tx_data { | 148 | struct ieee80211_tx_data { |
142 | struct sk_buff *skb; | 149 | struct sk_buff *skb; |
143 | struct net_device *dev; | ||
144 | struct ieee80211_local *local; | 150 | struct ieee80211_local *local; |
145 | struct ieee80211_sub_if_data *sdata; | 151 | struct ieee80211_sub_if_data *sdata; |
146 | struct sta_info *sta; | 152 | struct sta_info *sta; |
@@ -228,31 +234,78 @@ struct mesh_preq_queue { | |||
228 | u8 flags; | 234 | u8 flags; |
229 | }; | 235 | }; |
230 | 236 | ||
231 | enum ieee80211_mgd_state { | 237 | enum ieee80211_work_type { |
232 | IEEE80211_MGD_STATE_IDLE, | 238 | IEEE80211_WORK_ABORT, |
233 | IEEE80211_MGD_STATE_PROBE, | 239 | IEEE80211_WORK_DIRECT_PROBE, |
234 | IEEE80211_MGD_STATE_AUTH, | 240 | IEEE80211_WORK_AUTH, |
235 | IEEE80211_MGD_STATE_ASSOC, | 241 | IEEE80211_WORK_ASSOC, |
242 | IEEE80211_WORK_REMAIN_ON_CHANNEL, | ||
243 | }; | ||
244 | |||
245 | /** | ||
246 | * enum work_done_result - indicates what to do after work was done | ||
247 | * | ||
248 | * @WORK_DONE_DESTROY: This work item is no longer needed, destroy. | ||
249 | * @WORK_DONE_REQUEUE: This work item was reset to be reused, and | ||
250 | * should be requeued. | ||
251 | */ | ||
252 | enum work_done_result { | ||
253 | WORK_DONE_DESTROY, | ||
254 | WORK_DONE_REQUEUE, | ||
236 | }; | 255 | }; |
237 | 256 | ||
238 | struct ieee80211_mgd_work { | 257 | struct ieee80211_work { |
239 | struct list_head list; | 258 | struct list_head list; |
240 | struct ieee80211_bss *bss; | 259 | |
241 | int ie_len; | 260 | struct rcu_head rcu_head; |
242 | u8 prev_bssid[ETH_ALEN]; | 261 | |
243 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 262 | struct ieee80211_sub_if_data *sdata; |
244 | u8 ssid_len; | 263 | |
264 | enum work_done_result (*done)(struct ieee80211_work *wk, | ||
265 | struct sk_buff *skb); | ||
266 | |||
267 | struct ieee80211_channel *chan; | ||
268 | enum nl80211_channel_type chan_type; | ||
269 | |||
245 | unsigned long timeout; | 270 | unsigned long timeout; |
246 | enum ieee80211_mgd_state state; | 271 | enum ieee80211_work_type type; |
247 | u16 auth_alg, auth_transaction; | ||
248 | 272 | ||
249 | int tries; | 273 | u8 filter_ta[ETH_ALEN]; |
250 | 274 | ||
251 | u8 key[WLAN_KEY_LEN_WEP104]; | 275 | bool started; |
252 | u8 key_len, key_idx; | 276 | |
277 | union { | ||
278 | struct { | ||
279 | int tries; | ||
280 | u16 algorithm, transaction; | ||
281 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | ||
282 | u8 ssid_len; | ||
283 | u8 key[WLAN_KEY_LEN_WEP104]; | ||
284 | u8 key_len, key_idx; | ||
285 | bool privacy; | ||
286 | } probe_auth; | ||
287 | struct { | ||
288 | struct cfg80211_bss *bss; | ||
289 | const u8 *supp_rates; | ||
290 | const u8 *ht_information_ie; | ||
291 | enum ieee80211_smps_mode smps; | ||
292 | int tries; | ||
293 | u16 capability; | ||
294 | u8 prev_bssid[ETH_ALEN]; | ||
295 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | ||
296 | u8 ssid_len; | ||
297 | u8 supp_rates_len; | ||
298 | bool wmm_used, use_11n, uapsd_used; | ||
299 | } assoc; | ||
300 | struct { | ||
301 | u32 duration; | ||
302 | bool started; | ||
303 | } remain; | ||
304 | }; | ||
253 | 305 | ||
306 | int ie_len; | ||
254 | /* must be last */ | 307 | /* must be last */ |
255 | u8 ie[0]; /* for auth or assoc frame, not probe */ | 308 | u8 ie[0]; |
256 | }; | 309 | }; |
257 | 310 | ||
258 | /* flags used in struct ieee80211_if_managed.flags */ | 311 | /* flags used in struct ieee80211_if_managed.flags */ |
@@ -260,15 +313,10 @@ enum ieee80211_sta_flags { | |||
260 | IEEE80211_STA_BEACON_POLL = BIT(0), | 313 | IEEE80211_STA_BEACON_POLL = BIT(0), |
261 | IEEE80211_STA_CONNECTION_POLL = BIT(1), | 314 | IEEE80211_STA_CONNECTION_POLL = BIT(1), |
262 | IEEE80211_STA_CONTROL_PORT = BIT(2), | 315 | IEEE80211_STA_CONTROL_PORT = BIT(2), |
263 | IEEE80211_STA_WMM_ENABLED = BIT(3), | ||
264 | IEEE80211_STA_DISABLE_11N = BIT(4), | 316 | IEEE80211_STA_DISABLE_11N = BIT(4), |
265 | IEEE80211_STA_CSA_RECEIVED = BIT(5), | 317 | IEEE80211_STA_CSA_RECEIVED = BIT(5), |
266 | IEEE80211_STA_MFP_ENABLED = BIT(6), | 318 | IEEE80211_STA_MFP_ENABLED = BIT(6), |
267 | }; | 319 | IEEE80211_STA_UAPSD_ENABLED = BIT(7), |
268 | |||
269 | /* flags for MLME request */ | ||
270 | enum ieee80211_sta_request { | ||
271 | IEEE80211_STA_REQ_SCAN, | ||
272 | }; | 320 | }; |
273 | 321 | ||
274 | struct ieee80211_if_managed { | 322 | struct ieee80211_if_managed { |
@@ -285,21 +333,18 @@ struct ieee80211_if_managed { | |||
285 | int probe_send_count; | 333 | int probe_send_count; |
286 | 334 | ||
287 | struct mutex mtx; | 335 | struct mutex mtx; |
288 | struct ieee80211_bss *associated; | 336 | struct cfg80211_bss *associated; |
289 | struct ieee80211_mgd_work *old_associate_work; | ||
290 | struct list_head work_list; | ||
291 | 337 | ||
292 | u8 bssid[ETH_ALEN]; | 338 | u8 bssid[ETH_ALEN]; |
293 | 339 | ||
294 | u16 aid; | 340 | u16 aid; |
295 | u16 capab; | ||
296 | 341 | ||
297 | struct sk_buff_head skb_queue; | 342 | struct sk_buff_head skb_queue; |
298 | 343 | ||
299 | unsigned long timers_running; /* used for quiesce/restart */ | 344 | unsigned long timers_running; /* used for quiesce/restart */ |
300 | bool powersave; /* powersave requested for this iface */ | 345 | bool powersave; /* powersave requested for this iface */ |
301 | 346 | enum ieee80211_smps_mode req_smps, /* requested smps mode */ | |
302 | unsigned long request; | 347 | ap_smps; /* smps mode AP thinks we're in */ |
303 | 348 | ||
304 | unsigned int flags; | 349 | unsigned int flags; |
305 | 350 | ||
@@ -433,6 +478,8 @@ struct ieee80211_sub_if_data { | |||
433 | 478 | ||
434 | int drop_unencrypted; | 479 | int drop_unencrypted; |
435 | 480 | ||
481 | char name[IFNAMSIZ]; | ||
482 | |||
436 | /* | 483 | /* |
437 | * keep track of whether the HT opmode (stored in | 484 | * keep track of whether the HT opmode (stored in |
438 | * vif.bss_info.ht_operation_mode) is valid. | 485 | * vif.bss_info.ht_operation_mode) is valid. |
@@ -458,8 +505,8 @@ struct ieee80211_sub_if_data { | |||
458 | */ | 505 | */ |
459 | struct ieee80211_if_ap *bss; | 506 | struct ieee80211_if_ap *bss; |
460 | 507 | ||
461 | int force_unicast_rateidx; /* forced TX rateidx for unicast frames */ | 508 | /* bitmap of allowed (non-MCS) rate indexes for rate control */ |
462 | int max_ratectrl_rateidx; /* max TX rateidx for rate control */ | 509 | u32 rc_rateidx_mask[IEEE80211_NUM_BANDS]; |
463 | 510 | ||
464 | union { | 511 | union { |
465 | struct ieee80211_if_ap ap; | 512 | struct ieee80211_if_ap ap; |
@@ -565,6 +612,15 @@ struct ieee80211_local { | |||
565 | const struct ieee80211_ops *ops; | 612 | const struct ieee80211_ops *ops; |
566 | 613 | ||
567 | /* | 614 | /* |
615 | * work stuff, potentially off-channel (in the future) | ||
616 | */ | ||
617 | struct mutex work_mtx; | ||
618 | struct list_head work_list; | ||
619 | struct timer_list work_timer; | ||
620 | struct work_struct work_work; | ||
621 | struct sk_buff_head work_skb_queue; | ||
622 | |||
623 | /* | ||
568 | * private workqueue to mac80211. mac80211 makes this accessible | 624 | * private workqueue to mac80211. mac80211 makes this accessible |
569 | * via ieee80211_queue_work() | 625 | * via ieee80211_queue_work() |
570 | */ | 626 | */ |
@@ -586,6 +642,9 @@ struct ieee80211_local { | |||
586 | /* used for uploading changed mc list */ | 642 | /* used for uploading changed mc list */ |
587 | struct work_struct reconfig_filter; | 643 | struct work_struct reconfig_filter; |
588 | 644 | ||
645 | /* used to reconfigure hardware SM PS */ | ||
646 | struct work_struct recalc_smps; | ||
647 | |||
589 | /* aggregated multicast list */ | 648 | /* aggregated multicast list */ |
590 | struct dev_addr_list *mc_list; | 649 | struct dev_addr_list *mc_list; |
591 | int mc_count; | 650 | int mc_count; |
@@ -689,6 +748,10 @@ struct ieee80211_local { | |||
689 | enum nl80211_channel_type oper_channel_type; | 748 | enum nl80211_channel_type oper_channel_type; |
690 | struct ieee80211_channel *oper_channel, *csa_channel; | 749 | struct ieee80211_channel *oper_channel, *csa_channel; |
691 | 750 | ||
751 | /* Temporary remain-on-channel for off-channel operations */ | ||
752 | struct ieee80211_channel *tmp_channel; | ||
753 | enum nl80211_channel_type tmp_channel_type; | ||
754 | |||
692 | /* SNMP counters */ | 755 | /* SNMP counters */ |
693 | /* dot11CountersTable */ | 756 | /* dot11CountersTable */ |
694 | u32 dot11TransmittedFragmentCount; | 757 | u32 dot11TransmittedFragmentCount; |
@@ -745,8 +808,22 @@ struct ieee80211_local { | |||
745 | int wifi_wme_noack_test; | 808 | int wifi_wme_noack_test; |
746 | unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ | 809 | unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ |
747 | 810 | ||
811 | /* | ||
812 | * Bitmask of enabled u-apsd queues, | ||
813 | * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association | ||
814 | * to take effect. | ||
815 | */ | ||
816 | unsigned int uapsd_queues; | ||
817 | |||
818 | /* | ||
819 | * Maximum number of buffered frames AP can deliver during a | ||
820 | * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar. | ||
821 | * Needs a new association to take effect. | ||
822 | */ | ||
823 | unsigned int uapsd_max_sp_len; | ||
824 | |||
748 | bool pspolling; | 825 | bool pspolling; |
749 | bool scan_ps_enabled; | 826 | bool offchannel_ps_enabled; |
750 | /* | 827 | /* |
751 | * PS can only be enabled when we have exactly one managed | 828 | * PS can only be enabled when we have exactly one managed |
752 | * interface (and monitors) in PS, this then points there. | 829 | * interface (and monitors) in PS, this then points there. |
@@ -760,6 +837,8 @@ struct ieee80211_local { | |||
760 | int user_power_level; /* in dBm */ | 837 | int user_power_level; /* in dBm */ |
761 | int power_constr_level; /* in dBm */ | 838 | int power_constr_level; /* in dBm */ |
762 | 839 | ||
840 | enum ieee80211_smps_mode smps_mode; | ||
841 | |||
763 | struct work_struct restart_work; | 842 | struct work_struct restart_work; |
764 | 843 | ||
765 | #ifdef CONFIG_MAC80211_DEBUGFS | 844 | #ifdef CONFIG_MAC80211_DEBUGFS |
@@ -874,6 +953,8 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | |||
874 | void ieee80211_configure_filter(struct ieee80211_local *local); | 953 | void ieee80211_configure_filter(struct ieee80211_local *local); |
875 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); | 954 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); |
876 | 955 | ||
956 | extern bool ieee80211_disable_40mhz_24ghz; | ||
957 | |||
877 | /* STA code */ | 958 | /* STA code */ |
878 | void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); | 959 | void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); |
879 | int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, | 960 | int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, |
@@ -937,7 +1018,15 @@ ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, | |||
937 | void ieee80211_rx_bss_put(struct ieee80211_local *local, | 1018 | void ieee80211_rx_bss_put(struct ieee80211_local *local, |
938 | struct ieee80211_bss *bss); | 1019 | struct ieee80211_bss *bss); |
939 | 1020 | ||
1021 | /* off-channel helpers */ | ||
1022 | void ieee80211_offchannel_stop_beaconing(struct ieee80211_local *local); | ||
1023 | void ieee80211_offchannel_stop_station(struct ieee80211_local *local); | ||
1024 | void ieee80211_offchannel_return(struct ieee80211_local *local, | ||
1025 | bool enable_beaconing); | ||
1026 | |||
940 | /* interface handling */ | 1027 | /* interface handling */ |
1028 | int ieee80211_iface_init(void); | ||
1029 | void ieee80211_iface_exit(void); | ||
941 | int ieee80211_if_add(struct ieee80211_local *local, const char *name, | 1030 | int ieee80211_if_add(struct ieee80211_local *local, const char *name, |
942 | struct net_device **new_dev, enum nl80211_iftype type, | 1031 | struct net_device **new_dev, enum nl80211_iftype type, |
943 | struct vif_params *params); | 1032 | struct vif_params *params); |
@@ -948,6 +1037,11 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local); | |||
948 | u32 __ieee80211_recalc_idle(struct ieee80211_local *local); | 1037 | u32 __ieee80211_recalc_idle(struct ieee80211_local *local); |
949 | void ieee80211_recalc_idle(struct ieee80211_local *local); | 1038 | void ieee80211_recalc_idle(struct ieee80211_local *local); |
950 | 1039 | ||
1040 | static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata) | ||
1041 | { | ||
1042 | return netif_running(sdata->dev); | ||
1043 | } | ||
1044 | |||
951 | /* tx handling */ | 1045 | /* tx handling */ |
952 | void ieee80211_clear_tx_pending(struct ieee80211_local *local); | 1046 | void ieee80211_clear_tx_pending(struct ieee80211_local *local); |
953 | void ieee80211_tx_pending(unsigned long data); | 1047 | void ieee80211_tx_pending(unsigned long data); |
@@ -976,6 +1070,9 @@ void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u1 | |||
976 | void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, | 1070 | void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, |
977 | const u8 *da, u16 tid, | 1071 | const u8 *da, u16 tid, |
978 | u16 initiator, u16 reason_code); | 1072 | u16 initiator, u16 reason_code); |
1073 | int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata, | ||
1074 | enum ieee80211_smps_mode smps, const u8 *da, | ||
1075 | const u8 *bssid); | ||
979 | 1076 | ||
980 | void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da, | 1077 | void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da, |
981 | u16 tid, u16 initiator, u16 reason); | 1078 | u16 tid, u16 initiator, u16 reason); |
@@ -1086,6 +1183,28 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, | |||
1086 | u32 ieee80211_sta_get_rates(struct ieee80211_local *local, | 1183 | u32 ieee80211_sta_get_rates(struct ieee80211_local *local, |
1087 | struct ieee802_11_elems *elems, | 1184 | struct ieee802_11_elems *elems, |
1088 | enum ieee80211_band band); | 1185 | enum ieee80211_band band); |
1186 | int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, | ||
1187 | enum ieee80211_smps_mode smps_mode); | ||
1188 | void ieee80211_recalc_smps(struct ieee80211_local *local, | ||
1189 | struct ieee80211_sub_if_data *forsdata); | ||
1190 | |||
1191 | size_t ieee80211_ie_split(const u8 *ies, size_t ielen, | ||
1192 | const u8 *ids, int n_ids, size_t offset); | ||
1193 | size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset); | ||
1194 | |||
1195 | /* internal work items */ | ||
1196 | void ieee80211_work_init(struct ieee80211_local *local); | ||
1197 | void ieee80211_add_work(struct ieee80211_work *wk); | ||
1198 | void free_work(struct ieee80211_work *wk); | ||
1199 | void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata); | ||
1200 | ieee80211_rx_result ieee80211_work_rx_mgmt(struct ieee80211_sub_if_data *sdata, | ||
1201 | struct sk_buff *skb); | ||
1202 | int ieee80211_wk_remain_on_channel(struct ieee80211_sub_if_data *sdata, | ||
1203 | struct ieee80211_channel *chan, | ||
1204 | enum nl80211_channel_type channel_type, | ||
1205 | unsigned int duration, u64 *cookie); | ||
1206 | int ieee80211_wk_cancel_remain_on_channel( | ||
1207 | struct ieee80211_sub_if_data *sdata, u64 cookie); | ||
1089 | 1208 | ||
1090 | #ifdef CONFIG_MAC80211_NOINLINE | 1209 | #ifdef CONFIG_MAC80211_NOINLINE |
1091 | #define debug_noinline noinline | 1210 | #define debug_noinline noinline |
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 32abae3ce32a..edf21cebeee8 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -62,6 +62,23 @@ static int ieee80211_change_mtu(struct net_device *dev, int new_mtu) | |||
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | static int ieee80211_change_mac(struct net_device *dev, void *addr) | ||
66 | { | ||
67 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
68 | struct sockaddr *sa = addr; | ||
69 | int ret; | ||
70 | |||
71 | if (ieee80211_sdata_running(sdata)) | ||
72 | return -EBUSY; | ||
73 | |||
74 | ret = eth_mac_addr(dev, sa); | ||
75 | |||
76 | if (ret == 0) | ||
77 | memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN); | ||
78 | |||
79 | return ret; | ||
80 | } | ||
81 | |||
65 | static inline int identical_mac_addr_allowed(int type1, int type2) | 82 | static inline int identical_mac_addr_allowed(int type1, int type2) |
66 | { | 83 | { |
67 | return type1 == NL80211_IFTYPE_MONITOR || | 84 | return type1 == NL80211_IFTYPE_MONITOR || |
@@ -82,7 +99,6 @@ static int ieee80211_open(struct net_device *dev) | |||
82 | struct ieee80211_sub_if_data *nsdata; | 99 | struct ieee80211_sub_if_data *nsdata; |
83 | struct ieee80211_local *local = sdata->local; | 100 | struct ieee80211_local *local = sdata->local; |
84 | struct sta_info *sta; | 101 | struct sta_info *sta; |
85 | struct ieee80211_if_init_conf conf; | ||
86 | u32 changed = 0; | 102 | u32 changed = 0; |
87 | int res; | 103 | int res; |
88 | u32 hw_reconf_flags = 0; | 104 | u32 hw_reconf_flags = 0; |
@@ -97,7 +113,7 @@ static int ieee80211_open(struct net_device *dev) | |||
97 | list_for_each_entry(nsdata, &local->interfaces, list) { | 113 | list_for_each_entry(nsdata, &local->interfaces, list) { |
98 | struct net_device *ndev = nsdata->dev; | 114 | struct net_device *ndev = nsdata->dev; |
99 | 115 | ||
100 | if (ndev != dev && netif_running(ndev)) { | 116 | if (ndev != dev && ieee80211_sdata_running(nsdata)) { |
101 | /* | 117 | /* |
102 | * Allow only a single IBSS interface to be up at any | 118 | * Allow only a single IBSS interface to be up at any |
103 | * time. This is restricted because beacon distribution | 119 | * time. This is restricted because beacon distribution |
@@ -183,7 +199,7 @@ static int ieee80211_open(struct net_device *dev) | |||
183 | struct net_device *ndev = nsdata->dev; | 199 | struct net_device *ndev = nsdata->dev; |
184 | 200 | ||
185 | /* | 201 | /* |
186 | * No need to check netif_running since we do not allow | 202 | * No need to check running since we do not allow |
187 | * it to start up with this invalid address. | 203 | * it to start up with this invalid address. |
188 | */ | 204 | */ |
189 | if (compare_ether_addr(null_addr, ndev->dev_addr) == 0) { | 205 | if (compare_ether_addr(null_addr, ndev->dev_addr) == 0) { |
@@ -234,10 +250,7 @@ static int ieee80211_open(struct net_device *dev) | |||
234 | ieee80211_configure_filter(local); | 250 | ieee80211_configure_filter(local); |
235 | break; | 251 | break; |
236 | default: | 252 | default: |
237 | conf.vif = &sdata->vif; | 253 | res = drv_add_interface(local, &sdata->vif); |
238 | conf.type = sdata->vif.type; | ||
239 | conf.mac_addr = dev->dev_addr; | ||
240 | res = drv_add_interface(local, &conf); | ||
241 | if (res) | 254 | if (res) |
242 | goto err_stop; | 255 | goto err_stop; |
243 | 256 | ||
@@ -320,7 +333,7 @@ static int ieee80211_open(struct net_device *dev) | |||
320 | 333 | ||
321 | return 0; | 334 | return 0; |
322 | err_del_interface: | 335 | err_del_interface: |
323 | drv_remove_interface(local, &conf); | 336 | drv_remove_interface(local, &sdata->vif); |
324 | err_stop: | 337 | err_stop: |
325 | if (!local->open_count) | 338 | if (!local->open_count) |
326 | drv_stop(local); | 339 | drv_stop(local); |
@@ -335,7 +348,6 @@ static int ieee80211_stop(struct net_device *dev) | |||
335 | { | 348 | { |
336 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 349 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
337 | struct ieee80211_local *local = sdata->local; | 350 | struct ieee80211_local *local = sdata->local; |
338 | struct ieee80211_if_init_conf conf; | ||
339 | struct sta_info *sta; | 351 | struct sta_info *sta; |
340 | unsigned long flags; | 352 | unsigned long flags; |
341 | struct sk_buff *skb, *tmp; | 353 | struct sk_buff *skb, *tmp; |
@@ -348,6 +360,11 @@ static int ieee80211_stop(struct net_device *dev) | |||
348 | netif_tx_stop_all_queues(dev); | 360 | netif_tx_stop_all_queues(dev); |
349 | 361 | ||
350 | /* | 362 | /* |
363 | * Purge work for this interface. | ||
364 | */ | ||
365 | ieee80211_work_purge(sdata); | ||
366 | |||
367 | /* | ||
351 | * Now delete all active aggregation sessions. | 368 | * Now delete all active aggregation sessions. |
352 | */ | 369 | */ |
353 | rcu_read_lock(); | 370 | rcu_read_lock(); |
@@ -514,12 +531,9 @@ static int ieee80211_stop(struct net_device *dev) | |||
514 | BSS_CHANGED_BEACON_ENABLED); | 531 | BSS_CHANGED_BEACON_ENABLED); |
515 | } | 532 | } |
516 | 533 | ||
517 | conf.vif = &sdata->vif; | ||
518 | conf.type = sdata->vif.type; | ||
519 | conf.mac_addr = dev->dev_addr; | ||
520 | /* disable all keys for as long as this netdev is down */ | 534 | /* disable all keys for as long as this netdev is down */ |
521 | ieee80211_disable_keys(sdata); | 535 | ieee80211_disable_keys(sdata); |
522 | drv_remove_interface(local, &conf); | 536 | drv_remove_interface(local, &sdata->vif); |
523 | } | 537 | } |
524 | 538 | ||
525 | sdata->bss = NULL; | 539 | sdata->bss = NULL; |
@@ -659,7 +673,7 @@ static const struct net_device_ops ieee80211_dataif_ops = { | |||
659 | .ndo_start_xmit = ieee80211_subif_start_xmit, | 673 | .ndo_start_xmit = ieee80211_subif_start_xmit, |
660 | .ndo_set_multicast_list = ieee80211_set_multicast_list, | 674 | .ndo_set_multicast_list = ieee80211_set_multicast_list, |
661 | .ndo_change_mtu = ieee80211_change_mtu, | 675 | .ndo_change_mtu = ieee80211_change_mtu, |
662 | .ndo_set_mac_address = eth_mac_addr, | 676 | .ndo_set_mac_address = ieee80211_change_mac, |
663 | .ndo_select_queue = ieee80211_netdev_select_queue, | 677 | .ndo_select_queue = ieee80211_netdev_select_queue, |
664 | }; | 678 | }; |
665 | 679 | ||
@@ -779,7 +793,7 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, | |||
779 | * and goes into the requested mode. | 793 | * and goes into the requested mode. |
780 | */ | 794 | */ |
781 | 795 | ||
782 | if (netif_running(sdata->dev)) | 796 | if (ieee80211_sdata_running(sdata)) |
783 | return -EBUSY; | 797 | return -EBUSY; |
784 | 798 | ||
785 | /* Purge and reset type-dependent state. */ | 799 | /* Purge and reset type-dependent state. */ |
@@ -833,6 +847,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, | |||
833 | /* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */ | 847 | /* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */ |
834 | sdata = netdev_priv(ndev); | 848 | sdata = netdev_priv(ndev); |
835 | ndev->ieee80211_ptr = &sdata->wdev; | 849 | ndev->ieee80211_ptr = &sdata->wdev; |
850 | memcpy(sdata->vif.addr, ndev->dev_addr, ETH_ALEN); | ||
851 | memcpy(sdata->name, ndev->name, IFNAMSIZ); | ||
836 | 852 | ||
837 | /* initialise type-independent data */ | 853 | /* initialise type-independent data */ |
838 | sdata->wdev.wiphy = local->hw.wiphy; | 854 | sdata->wdev.wiphy = local->hw.wiphy; |
@@ -844,8 +860,12 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, | |||
844 | 860 | ||
845 | INIT_LIST_HEAD(&sdata->key_list); | 861 | INIT_LIST_HEAD(&sdata->key_list); |
846 | 862 | ||
847 | sdata->force_unicast_rateidx = -1; | 863 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) { |
848 | sdata->max_ratectrl_rateidx = -1; | 864 | struct ieee80211_supported_band *sband; |
865 | sband = local->hw.wiphy->bands[i]; | ||
866 | sdata->rc_rateidx_mask[i] = | ||
867 | sband ? (1 << sband->n_bitrates) - 1 : 0; | ||
868 | } | ||
849 | 869 | ||
850 | /* setup type-dependent data */ | 870 | /* setup type-dependent data */ |
851 | ieee80211_setup_sdata(sdata, type); | 871 | ieee80211_setup_sdata(sdata, type); |
@@ -938,6 +958,8 @@ static u32 ieee80211_idle_on(struct ieee80211_local *local) | |||
938 | wiphy_name(local->hw.wiphy)); | 958 | wiphy_name(local->hw.wiphy)); |
939 | #endif | 959 | #endif |
940 | 960 | ||
961 | drv_flush(local, false); | ||
962 | |||
941 | local->hw.conf.flags |= IEEE80211_CONF_IDLE; | 963 | local->hw.conf.flags |= IEEE80211_CONF_IDLE; |
942 | return IEEE80211_CONF_CHANGE_IDLE; | 964 | return IEEE80211_CONF_CHANGE_IDLE; |
943 | } | 965 | } |
@@ -947,16 +969,18 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local) | |||
947 | struct ieee80211_sub_if_data *sdata; | 969 | struct ieee80211_sub_if_data *sdata; |
948 | int count = 0; | 970 | int count = 0; |
949 | 971 | ||
972 | if (!list_empty(&local->work_list)) | ||
973 | return ieee80211_idle_off(local, "working"); | ||
974 | |||
950 | if (local->scanning) | 975 | if (local->scanning) |
951 | return ieee80211_idle_off(local, "scanning"); | 976 | return ieee80211_idle_off(local, "scanning"); |
952 | 977 | ||
953 | list_for_each_entry(sdata, &local->interfaces, list) { | 978 | list_for_each_entry(sdata, &local->interfaces, list) { |
954 | if (!netif_running(sdata->dev)) | 979 | if (!ieee80211_sdata_running(sdata)) |
955 | continue; | 980 | continue; |
956 | /* do not count disabled managed interfaces */ | 981 | /* do not count disabled managed interfaces */ |
957 | if (sdata->vif.type == NL80211_IFTYPE_STATION && | 982 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
958 | !sdata->u.mgd.associated && | 983 | !sdata->u.mgd.associated) |
959 | list_empty(&sdata->u.mgd.work_list)) | ||
960 | continue; | 984 | continue; |
961 | /* do not count unused IBSS interfaces */ | 985 | /* do not count unused IBSS interfaces */ |
962 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && | 986 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && |
@@ -984,3 +1008,41 @@ void ieee80211_recalc_idle(struct ieee80211_local *local) | |||
984 | if (chg) | 1008 | if (chg) |
985 | ieee80211_hw_config(local, chg); | 1009 | ieee80211_hw_config(local, chg); |
986 | } | 1010 | } |
1011 | |||
1012 | static int netdev_notify(struct notifier_block *nb, | ||
1013 | unsigned long state, | ||
1014 | void *ndev) | ||
1015 | { | ||
1016 | struct net_device *dev = ndev; | ||
1017 | struct ieee80211_sub_if_data *sdata; | ||
1018 | |||
1019 | if (state != NETDEV_CHANGENAME) | ||
1020 | return 0; | ||
1021 | |||
1022 | if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) | ||
1023 | return 0; | ||
1024 | |||
1025 | if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid) | ||
1026 | return 0; | ||
1027 | |||
1028 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1029 | |||
1030 | memcpy(sdata->name, sdata->name, IFNAMSIZ); | ||
1031 | |||
1032 | ieee80211_debugfs_rename_netdev(sdata); | ||
1033 | return 0; | ||
1034 | } | ||
1035 | |||
1036 | static struct notifier_block mac80211_netdev_notifier = { | ||
1037 | .notifier_call = netdev_notify, | ||
1038 | }; | ||
1039 | |||
1040 | int ieee80211_iface_init(void) | ||
1041 | { | ||
1042 | return register_netdevice_notifier(&mac80211_netdev_notifier); | ||
1043 | } | ||
1044 | |||
1045 | void ieee80211_iface_exit(void) | ||
1046 | { | ||
1047 | unregister_netdevice_notifier(&mac80211_netdev_notifier); | ||
1048 | } | ||
diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 659a42d529e3..8160d9c5372e 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c | |||
@@ -139,7 +139,7 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key) | |||
139 | struct ieee80211_sub_if_data, | 139 | struct ieee80211_sub_if_data, |
140 | u.ap); | 140 | u.ap); |
141 | 141 | ||
142 | ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf); | 142 | ret = drv_set_key(key->local, SET_KEY, sdata, sta, &key->conf); |
143 | 143 | ||
144 | if (!ret) { | 144 | if (!ret) { |
145 | spin_lock_bh(&todo_lock); | 145 | spin_lock_bh(&todo_lock); |
@@ -181,7 +181,7 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) | |||
181 | struct ieee80211_sub_if_data, | 181 | struct ieee80211_sub_if_data, |
182 | u.ap); | 182 | u.ap); |
183 | 183 | ||
184 | ret = drv_set_key(key->local, DISABLE_KEY, &sdata->vif, | 184 | ret = drv_set_key(key->local, DISABLE_KEY, sdata, |
185 | sta, &key->conf); | 185 | sta, &key->conf); |
186 | 186 | ||
187 | if (ret) | 187 | if (ret) |
@@ -421,7 +421,7 @@ void ieee80211_key_link(struct ieee80211_key *key, | |||
421 | */ | 421 | */ |
422 | 422 | ||
423 | /* same here, the AP could be using QoS */ | 423 | /* same here, the AP could be using QoS */ |
424 | ap = sta_info_get(key->local, key->sdata->u.mgd.bssid); | 424 | ap = sta_info_get(key->sdata, key->sdata->u.mgd.bssid); |
425 | if (ap) { | 425 | if (ap) { |
426 | if (test_sta_flags(ap, WLAN_STA_WME)) | 426 | if (test_sta_flags(ap, WLAN_STA_WME)) |
427 | key->conf.flags |= | 427 | key->conf.flags |= |
@@ -443,7 +443,7 @@ void ieee80211_key_link(struct ieee80211_key *key, | |||
443 | add_todo(old_key, KEY_FLAG_TODO_DELETE); | 443 | add_todo(old_key, KEY_FLAG_TODO_DELETE); |
444 | 444 | ||
445 | add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS); | 445 | add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS); |
446 | if (netif_running(sdata->dev)) | 446 | if (ieee80211_sdata_running(sdata)) |
447 | add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD); | 447 | add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD); |
448 | 448 | ||
449 | spin_unlock_irqrestore(&sdata->local->key_lock, flags); | 449 | spin_unlock_irqrestore(&sdata->local->key_lock, flags); |
@@ -509,7 +509,7 @@ void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata) | |||
509 | { | 509 | { |
510 | ASSERT_RTNL(); | 510 | ASSERT_RTNL(); |
511 | 511 | ||
512 | if (WARN_ON(!netif_running(sdata->dev))) | 512 | if (WARN_ON(!ieee80211_sdata_running(sdata))) |
513 | return; | 513 | return; |
514 | 514 | ||
515 | ieee80211_todo_for_each_key(sdata, KEY_FLAG_TODO_HWACCEL_ADD); | 515 | ieee80211_todo_for_each_key(sdata, KEY_FLAG_TODO_HWACCEL_ADD); |
diff --git a/net/mac80211/key.h b/net/mac80211/key.h index a49f93b79e92..bdc2968c2bbe 100644 --- a/net/mac80211/key.h +++ b/net/mac80211/key.h | |||
@@ -59,11 +59,17 @@ enum ieee80211_internal_key_flags { | |||
59 | KEY_FLAG_TODO_DEFMGMTKEY = BIT(6), | 59 | KEY_FLAG_TODO_DEFMGMTKEY = BIT(6), |
60 | }; | 60 | }; |
61 | 61 | ||
62 | enum ieee80211_internal_tkip_state { | ||
63 | TKIP_STATE_NOT_INIT, | ||
64 | TKIP_STATE_PHASE1_DONE, | ||
65 | TKIP_STATE_PHASE1_HW_UPLOADED, | ||
66 | }; | ||
67 | |||
62 | struct tkip_ctx { | 68 | struct tkip_ctx { |
63 | u32 iv32; | 69 | u32 iv32; |
64 | u16 iv16; | 70 | u16 iv16; |
65 | u16 p1k[5]; | 71 | u16 p1k[5]; |
66 | int initialized; | 72 | enum ieee80211_internal_tkip_state state; |
67 | }; | 73 | }; |
68 | 74 | ||
69 | struct ieee80211_key { | 75 | struct ieee80211_key { |
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 0d2d94881f1f..ec8f767ba95b 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/skbuff.h> | 17 | #include <linux/skbuff.h> |
18 | #include <linux/etherdevice.h> | 18 | #include <linux/etherdevice.h> |
19 | #include <linux/if_arp.h> | 19 | #include <linux/if_arp.h> |
20 | #include <linux/wireless.h> | ||
21 | #include <linux/rtnetlink.h> | 20 | #include <linux/rtnetlink.h> |
22 | #include <linux/bitmap.h> | 21 | #include <linux/bitmap.h> |
23 | #include <linux/pm_qos_params.h> | 22 | #include <linux/pm_qos_params.h> |
@@ -32,7 +31,12 @@ | |||
32 | #include "led.h" | 31 | #include "led.h" |
33 | #include "cfg.h" | 32 | #include "cfg.h" |
34 | #include "debugfs.h" | 33 | #include "debugfs.h" |
35 | #include "debugfs_netdev.h" | 34 | |
35 | |||
36 | bool ieee80211_disable_40mhz_24ghz; | ||
37 | module_param(ieee80211_disable_40mhz_24ghz, bool, 0644); | ||
38 | MODULE_PARM_DESC(ieee80211_disable_40mhz_24ghz, | ||
39 | "Disable 40MHz support in the 2.4GHz band"); | ||
36 | 40 | ||
37 | void ieee80211_configure_filter(struct ieee80211_local *local) | 41 | void ieee80211_configure_filter(struct ieee80211_local *local) |
38 | { | 42 | { |
@@ -102,6 +106,9 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) | |||
102 | if (scan_chan) { | 106 | if (scan_chan) { |
103 | chan = scan_chan; | 107 | chan = scan_chan; |
104 | channel_type = NL80211_CHAN_NO_HT; | 108 | channel_type = NL80211_CHAN_NO_HT; |
109 | } else if (local->tmp_channel) { | ||
110 | chan = scan_chan = local->tmp_channel; | ||
111 | channel_type = local->tmp_channel_type; | ||
105 | } else { | 112 | } else { |
106 | chan = local->oper_channel; | 113 | chan = local->oper_channel; |
107 | channel_type = local->oper_channel_type; | 114 | channel_type = local->oper_channel_type; |
@@ -114,6 +121,18 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) | |||
114 | changed |= IEEE80211_CONF_CHANGE_CHANNEL; | 121 | changed |= IEEE80211_CONF_CHANGE_CHANNEL; |
115 | } | 122 | } |
116 | 123 | ||
124 | if (!conf_is_ht(&local->hw.conf)) { | ||
125 | /* | ||
126 | * mac80211.h documents that this is only valid | ||
127 | * when the channel is set to an HT type, and | ||
128 | * that otherwise STATIC is used. | ||
129 | */ | ||
130 | local->hw.conf.smps_mode = IEEE80211_SMPS_STATIC; | ||
131 | } else if (local->hw.conf.smps_mode != local->smps_mode) { | ||
132 | local->hw.conf.smps_mode = local->smps_mode; | ||
133 | changed |= IEEE80211_CONF_CHANGE_SMPS; | ||
134 | } | ||
135 | |||
117 | if (scan_chan) | 136 | if (scan_chan) |
118 | power = chan->max_power; | 137 | power = chan->max_power; |
119 | else | 138 | else |
@@ -173,7 +192,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | |||
173 | } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | 192 | } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) |
174 | sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid; | 193 | sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid; |
175 | else if (sdata->vif.type == NL80211_IFTYPE_AP) | 194 | else if (sdata->vif.type == NL80211_IFTYPE_AP) |
176 | sdata->vif.bss_conf.bssid = sdata->dev->dev_addr; | 195 | sdata->vif.bss_conf.bssid = sdata->vif.addr; |
177 | else if (ieee80211_vif_is_mesh(&sdata->vif)) { | 196 | else if (ieee80211_vif_is_mesh(&sdata->vif)) { |
178 | sdata->vif.bss_conf.bssid = zero; | 197 | sdata->vif.bss_conf.bssid = zero; |
179 | } else { | 198 | } else { |
@@ -195,7 +214,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | |||
195 | } | 214 | } |
196 | 215 | ||
197 | if (changed & BSS_CHANGED_BEACON_ENABLED) { | 216 | if (changed & BSS_CHANGED_BEACON_ENABLED) { |
198 | if (local->quiescing || !netif_running(sdata->dev) || | 217 | if (local->quiescing || !ieee80211_sdata_running(sdata) || |
199 | test_bit(SCAN_SW_SCANNING, &local->scanning)) { | 218 | test_bit(SCAN_SW_SCANNING, &local->scanning)) { |
200 | sdata->vif.bss_conf.enable_beacon = false; | 219 | sdata->vif.bss_conf.enable_beacon = false; |
201 | } else { | 220 | } else { |
@@ -223,8 +242,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | |||
223 | } | 242 | } |
224 | } | 243 | } |
225 | 244 | ||
226 | drv_bss_info_changed(local, &sdata->vif, | 245 | drv_bss_info_changed(local, sdata, &sdata->vif.bss_conf, changed); |
227 | &sdata->vif.bss_conf, changed); | ||
228 | } | 246 | } |
229 | 247 | ||
230 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata) | 248 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata) |
@@ -299,6 +317,16 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw) | |||
299 | } | 317 | } |
300 | EXPORT_SYMBOL(ieee80211_restart_hw); | 318 | EXPORT_SYMBOL(ieee80211_restart_hw); |
301 | 319 | ||
320 | static void ieee80211_recalc_smps_work(struct work_struct *work) | ||
321 | { | ||
322 | struct ieee80211_local *local = | ||
323 | container_of(work, struct ieee80211_local, recalc_smps); | ||
324 | |||
325 | mutex_lock(&local->iflist_mtx); | ||
326 | ieee80211_recalc_smps(local, NULL); | ||
327 | mutex_unlock(&local->iflist_mtx); | ||
328 | } | ||
329 | |||
302 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | 330 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, |
303 | const struct ieee80211_ops *ops) | 331 | const struct ieee80211_ops *ops) |
304 | { | 332 | { |
@@ -333,9 +361,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
333 | WIPHY_FLAG_4ADDR_STATION; | 361 | WIPHY_FLAG_4ADDR_STATION; |
334 | wiphy->privid = mac80211_wiphy_privid; | 362 | wiphy->privid = mac80211_wiphy_privid; |
335 | 363 | ||
336 | /* Yes, putting cfg80211_bss into ieee80211_bss is a hack */ | 364 | wiphy->bss_priv_size = sizeof(struct ieee80211_bss); |
337 | wiphy->bss_priv_size = sizeof(struct ieee80211_bss) - | ||
338 | sizeof(struct cfg80211_bss); | ||
339 | 365 | ||
340 | local = wiphy_priv(wiphy); | 366 | local = wiphy_priv(wiphy); |
341 | 367 | ||
@@ -358,6 +384,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
358 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; | 384 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
359 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; | 385 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
360 | local->user_power_level = -1; | 386 | local->user_power_level = -1; |
387 | local->uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; | ||
388 | local->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; | ||
361 | 389 | ||
362 | INIT_LIST_HEAD(&local->interfaces); | 390 | INIT_LIST_HEAD(&local->interfaces); |
363 | mutex_init(&local->iflist_mtx); | 391 | mutex_init(&local->iflist_mtx); |
@@ -369,9 +397,13 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
369 | 397 | ||
370 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work); | 398 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work); |
371 | 399 | ||
400 | ieee80211_work_init(local); | ||
401 | |||
372 | INIT_WORK(&local->restart_work, ieee80211_restart_work); | 402 | INIT_WORK(&local->restart_work, ieee80211_restart_work); |
373 | 403 | ||
374 | INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter); | 404 | INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter); |
405 | INIT_WORK(&local->recalc_smps, ieee80211_recalc_smps_work); | ||
406 | local->smps_mode = IEEE80211_SMPS_OFF; | ||
375 | 407 | ||
376 | INIT_WORK(&local->dynamic_ps_enable_work, | 408 | INIT_WORK(&local->dynamic_ps_enable_work, |
377 | ieee80211_dynamic_ps_enable_work); | 409 | ieee80211_dynamic_ps_enable_work); |
@@ -461,6 +493,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
461 | else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) | 493 | else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) |
462 | local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC; | 494 | local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC; |
463 | 495 | ||
496 | WARN((local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD) | ||
497 | && (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK), | ||
498 | "U-APSD not supported with HW_PS_NULLFUNC_STACK\n"); | ||
499 | |||
464 | /* | 500 | /* |
465 | * Calculate scan IE length -- we need this to alloc | 501 | * Calculate scan IE length -- we need this to alloc |
466 | * memory and to subtract from the driver limit. It | 502 | * memory and to subtract from the driver limit. It |
@@ -674,11 +710,19 @@ static int __init ieee80211_init(void) | |||
674 | 710 | ||
675 | ret = rc80211_pid_init(); | 711 | ret = rc80211_pid_init(); |
676 | if (ret) | 712 | if (ret) |
677 | return ret; | 713 | goto err_pid; |
678 | 714 | ||
679 | ieee80211_debugfs_netdev_init(); | 715 | ret = ieee80211_iface_init(); |
716 | if (ret) | ||
717 | goto err_netdev; | ||
680 | 718 | ||
681 | return 0; | 719 | return 0; |
720 | err_netdev: | ||
721 | rc80211_pid_exit(); | ||
722 | err_pid: | ||
723 | rc80211_minstrel_exit(); | ||
724 | |||
725 | return ret; | ||
682 | } | 726 | } |
683 | 727 | ||
684 | static void __exit ieee80211_exit(void) | 728 | static void __exit ieee80211_exit(void) |
@@ -695,7 +739,7 @@ static void __exit ieee80211_exit(void) | |||
695 | if (mesh_allocated) | 739 | if (mesh_allocated) |
696 | ieee80211s_stop(); | 740 | ieee80211s_stop(); |
697 | 741 | ||
698 | ieee80211_debugfs_netdev_exit(); | 742 | ieee80211_iface_exit(); |
699 | } | 743 | } |
700 | 744 | ||
701 | 745 | ||
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 6a4331429598..61080c5fad50 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -457,7 +457,7 @@ static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata, | |||
457 | 457 | ||
458 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 458 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
459 | printk(KERN_DEBUG "%s: running mesh housekeeping\n", | 459 | printk(KERN_DEBUG "%s: running mesh housekeeping\n", |
460 | sdata->dev->name); | 460 | sdata->name); |
461 | #endif | 461 | #endif |
462 | 462 | ||
463 | ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT); | 463 | ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT); |
@@ -565,7 +565,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
565 | 565 | ||
566 | /* ignore ProbeResp to foreign address */ | 566 | /* ignore ProbeResp to foreign address */ |
567 | if (stype == IEEE80211_STYPE_PROBE_RESP && | 567 | if (stype == IEEE80211_STYPE_PROBE_RESP && |
568 | compare_ether_addr(mgmt->da, sdata->dev->dev_addr)) | 568 | compare_ether_addr(mgmt->da, sdata->vif.addr)) |
569 | return; | 569 | return; |
570 | 570 | ||
571 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; | 571 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; |
@@ -645,7 +645,7 @@ static void ieee80211_mesh_work(struct work_struct *work) | |||
645 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 645 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
646 | struct sk_buff *skb; | 646 | struct sk_buff *skb; |
647 | 647 | ||
648 | if (!netif_running(sdata->dev)) | 648 | if (!ieee80211_sdata_running(sdata)) |
649 | return; | 649 | return; |
650 | 650 | ||
651 | if (local->scanning) | 651 | if (local->scanning) |
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index d28acb6b1f81..ce84237ebad3 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -128,9 +128,9 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
128 | IEEE80211_STYPE_ACTION); | 128 | IEEE80211_STYPE_ACTION); |
129 | 129 | ||
130 | memcpy(mgmt->da, da, ETH_ALEN); | 130 | memcpy(mgmt->da, da, ETH_ALEN); |
131 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 131 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
132 | /* BSSID == SA */ | 132 | /* BSSID == SA */ |
133 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | 133 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
134 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; | 134 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; |
135 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; | 135 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; |
136 | 136 | ||
@@ -222,7 +222,7 @@ int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, | |||
222 | IEEE80211_STYPE_ACTION); | 222 | IEEE80211_STYPE_ACTION); |
223 | 223 | ||
224 | memcpy(mgmt->da, ra, ETH_ALEN); | 224 | memcpy(mgmt->da, ra, ETH_ALEN); |
225 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 225 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
226 | /* BSSID is left zeroed, wildcard value */ | 226 | /* BSSID is left zeroed, wildcard value */ |
227 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; | 227 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; |
228 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; | 228 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; |
@@ -335,7 +335,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
335 | bool process = true; | 335 | bool process = true; |
336 | 336 | ||
337 | rcu_read_lock(); | 337 | rcu_read_lock(); |
338 | sta = sta_info_get(local, mgmt->sa); | 338 | sta = sta_info_get(sdata, mgmt->sa); |
339 | if (!sta) { | 339 | if (!sta) { |
340 | rcu_read_unlock(); | 340 | rcu_read_unlock(); |
341 | return 0; | 341 | return 0; |
@@ -374,7 +374,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
374 | new_metric = MAX_METRIC; | 374 | new_metric = MAX_METRIC; |
375 | exp_time = TU_TO_EXP_TIME(orig_lifetime); | 375 | exp_time = TU_TO_EXP_TIME(orig_lifetime); |
376 | 376 | ||
377 | if (memcmp(orig_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) { | 377 | if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) { |
378 | /* This MP is the originator, we are not interested in this | 378 | /* This MP is the originator, we are not interested in this |
379 | * frame, except for updating transmitter's path info. | 379 | * frame, except for updating transmitter's path info. |
380 | */ | 380 | */ |
@@ -486,7 +486,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
486 | 486 | ||
487 | mhwmp_dbg("received PREQ from %pM\n", orig_addr); | 487 | mhwmp_dbg("received PREQ from %pM\n", orig_addr); |
488 | 488 | ||
489 | if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) { | 489 | if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) { |
490 | mhwmp_dbg("PREQ is for us\n"); | 490 | mhwmp_dbg("PREQ is for us\n"); |
491 | forward = false; | 491 | forward = false; |
492 | reply = true; | 492 | reply = true; |
@@ -579,7 +579,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
579 | * replies | 579 | * replies |
580 | */ | 580 | */ |
581 | target_addr = PREP_IE_TARGET_ADDR(prep_elem); | 581 | target_addr = PREP_IE_TARGET_ADDR(prep_elem); |
582 | if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) | 582 | if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) |
583 | /* destination, no forwarding required */ | 583 | /* destination, no forwarding required */ |
584 | return; | 584 | return; |
585 | 585 | ||
@@ -890,7 +890,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
890 | target_flags = MP_F_RF; | 890 | target_flags = MP_F_RF; |
891 | 891 | ||
892 | spin_unlock_bh(&mpath->state_lock); | 892 | spin_unlock_bh(&mpath->state_lock); |
893 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr, | 893 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr, |
894 | cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, | 894 | cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, |
895 | cpu_to_le32(mpath->sn), broadcast_addr, 0, | 895 | cpu_to_le32(mpath->sn), broadcast_addr, 0, |
896 | ttl, cpu_to_le32(lifetime), 0, | 896 | ttl, cpu_to_le32(lifetime), 0, |
@@ -939,7 +939,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
939 | if (time_after(jiffies, | 939 | if (time_after(jiffies, |
940 | mpath->exp_time - | 940 | mpath->exp_time - |
941 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && | 941 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && |
942 | !memcmp(sdata->dev->dev_addr, hdr->addr4, ETH_ALEN) && | 942 | !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) && |
943 | !(mpath->flags & MESH_PATH_RESOLVING) && | 943 | !(mpath->flags & MESH_PATH_RESOLVING) && |
944 | !(mpath->flags & MESH_PATH_FIXED)) { | 944 | !(mpath->flags & MESH_PATH_FIXED)) { |
945 | mesh_queue_preq(mpath, | 945 | mesh_queue_preq(mpath, |
@@ -1010,7 +1010,7 @@ mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) | |||
1010 | { | 1010 | { |
1011 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 1011 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
1012 | 1012 | ||
1013 | mesh_path_sel_frame_tx(MPATH_RANN, 0, sdata->dev->dev_addr, | 1013 | mesh_path_sel_frame_tx(MPATH_RANN, 0, sdata->vif.addr, |
1014 | cpu_to_le32(++ifmsh->sn), | 1014 | cpu_to_le32(++ifmsh->sn), |
1015 | 0, NULL, 0, broadcast_addr, | 1015 | 0, NULL, 0, broadcast_addr, |
1016 | 0, MESH_TTL, 0, 0, 0, sdata); | 1016 | 0, MESH_TTL, 0, 0, 0, sdata); |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 0192cfdacae4..2312efe04c62 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -260,7 +260,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) | |||
260 | int err = 0; | 260 | int err = 0; |
261 | u32 hash_idx; | 261 | u32 hash_idx; |
262 | 262 | ||
263 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) | 263 | if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0) |
264 | /* never add ourselves as neighbours */ | 264 | /* never add ourselves as neighbours */ |
265 | return -ENOTSUPP; | 265 | return -ENOTSUPP; |
266 | 266 | ||
@@ -377,7 +377,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) | |||
377 | int err = 0; | 377 | int err = 0; |
378 | u32 hash_idx; | 378 | u32 hash_idx; |
379 | 379 | ||
380 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) | 380 | if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0) |
381 | /* never add ourselves as neighbours */ | 381 | /* never add ourselves as neighbours */ |
382 | return -ENOTSUPP; | 382 | return -ENOTSUPP; |
383 | 383 | ||
@@ -605,7 +605,7 @@ void mesh_path_discard_frame(struct sk_buff *skb, | |||
605 | struct mesh_path *mpath; | 605 | struct mesh_path *mpath; |
606 | u32 sn = 0; | 606 | u32 sn = 0; |
607 | 607 | ||
608 | if (memcmp(hdr->addr4, sdata->dev->dev_addr, ETH_ALEN) != 0) { | 608 | if (memcmp(hdr->addr4, sdata->vif.addr, ETH_ALEN) != 0) { |
609 | u8 *ra, *da; | 609 | u8 *ra, *da; |
610 | 610 | ||
611 | da = hdr->addr3; | 611 | da = hdr->addr3; |
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 0f7c6e6a4248..7985e5150898 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -169,7 +169,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, | |||
169 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 169 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
170 | IEEE80211_STYPE_ACTION); | 170 | IEEE80211_STYPE_ACTION); |
171 | memcpy(mgmt->da, da, ETH_ALEN); | 171 | memcpy(mgmt->da, da, ETH_ALEN); |
172 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 172 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
173 | /* BSSID is left zeroed, wildcard value */ | 173 | /* BSSID is left zeroed, wildcard value */ |
174 | mgmt->u.action.category = MESH_PLINK_CATEGORY; | 174 | mgmt->u.action.category = MESH_PLINK_CATEGORY; |
175 | mgmt->u.action.u.plink_action.action_code = action; | 175 | mgmt->u.action.u.plink_action.action_code = action; |
@@ -234,7 +234,7 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data | |||
234 | 234 | ||
235 | rcu_read_lock(); | 235 | rcu_read_lock(); |
236 | 236 | ||
237 | sta = sta_info_get(local, hw_addr); | 237 | sta = sta_info_get(sdata, hw_addr); |
238 | if (!sta) { | 238 | if (!sta) { |
239 | sta = mesh_plink_alloc(sdata, hw_addr, rates); | 239 | sta = mesh_plink_alloc(sdata, hw_addr, rates); |
240 | if (!sta) { | 240 | if (!sta) { |
@@ -455,7 +455,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m | |||
455 | 455 | ||
456 | rcu_read_lock(); | 456 | rcu_read_lock(); |
457 | 457 | ||
458 | sta = sta_info_get(local, mgmt->sa); | 458 | sta = sta_info_get(sdata, mgmt->sa); |
459 | if (!sta && ftype != PLINK_OPEN) { | 459 | if (!sta && ftype != PLINK_OPEN) { |
460 | mpl_dbg("Mesh plink: cls or cnf from unknown peer\n"); | 460 | mpl_dbg("Mesh plink: cls or cnf from unknown peer\n"); |
461 | rcu_read_unlock(); | 461 | rcu_read_unlock(); |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 05a18f43e1bf..1e1d16c55ee5 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -75,11 +75,8 @@ enum rx_mgmt_action { | |||
75 | /* caller must call cfg80211_send_disassoc() */ | 75 | /* caller must call cfg80211_send_disassoc() */ |
76 | RX_MGMT_CFG80211_DISASSOC, | 76 | RX_MGMT_CFG80211_DISASSOC, |
77 | 77 | ||
78 | /* caller must call cfg80211_auth_timeout() & free work */ | 78 | /* caller must tell cfg80211 about internal error */ |
79 | RX_MGMT_CFG80211_AUTH_TO, | 79 | RX_MGMT_CFG80211_ASSOC_ERROR, |
80 | |||
81 | /* caller must call cfg80211_assoc_timeout() & free work */ | ||
82 | RX_MGMT_CFG80211_ASSOC_TO, | ||
83 | }; | 80 | }; |
84 | 81 | ||
85 | /* utils */ | 82 | /* utils */ |
@@ -122,27 +119,6 @@ static int ecw2cw(int ecw) | |||
122 | return (1 << ecw) - 1; | 119 | return (1 << ecw) - 1; |
123 | } | 120 | } |
124 | 121 | ||
125 | static int ieee80211_compatible_rates(struct ieee80211_bss *bss, | ||
126 | struct ieee80211_supported_band *sband, | ||
127 | u32 *rates) | ||
128 | { | ||
129 | int i, j, count; | ||
130 | *rates = 0; | ||
131 | count = 0; | ||
132 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
133 | int rate = (bss->supp_rates[i] & 0x7F) * 5; | ||
134 | |||
135 | for (j = 0; j < sband->n_bitrates; j++) | ||
136 | if (sband->bitrates[j].bitrate == rate) { | ||
137 | *rates |= BIT(j); | ||
138 | count++; | ||
139 | break; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | return count; | ||
144 | } | ||
145 | |||
146 | /* | 122 | /* |
147 | * ieee80211_enable_ht should be called only after the operating band | 123 | * ieee80211_enable_ht should be called only after the operating band |
148 | * has been determined as ht configuration depends on the hw's | 124 | * has been determined as ht configuration depends on the hw's |
@@ -202,7 +178,7 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, | |||
202 | ieee80211_hw_config(local, 0); | 178 | ieee80211_hw_config(local, 0); |
203 | 179 | ||
204 | rcu_read_lock(); | 180 | rcu_read_lock(); |
205 | sta = sta_info_get(local, bssid); | 181 | sta = sta_info_get(sdata, bssid); |
206 | if (sta) | 182 | if (sta) |
207 | rate_control_rate_update(local, sband, sta, | 183 | rate_control_rate_update(local, sband, sta, |
208 | IEEE80211_RC_HT_CHANGED); | 184 | IEEE80211_RC_HT_CHANGED); |
@@ -228,209 +204,6 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, | |||
228 | 204 | ||
229 | /* frame sending functions */ | 205 | /* frame sending functions */ |
230 | 206 | ||
231 | static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, | ||
232 | struct ieee80211_mgd_work *wk) | ||
233 | { | ||
234 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
235 | struct ieee80211_local *local = sdata->local; | ||
236 | struct sk_buff *skb; | ||
237 | struct ieee80211_mgmt *mgmt; | ||
238 | u8 *pos; | ||
239 | const u8 *ies, *ht_ie; | ||
240 | int i, len, count, rates_len, supp_rates_len; | ||
241 | u16 capab; | ||
242 | int wmm = 0; | ||
243 | struct ieee80211_supported_band *sband; | ||
244 | u32 rates = 0; | ||
245 | |||
246 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | ||
247 | sizeof(*mgmt) + 200 + wk->ie_len + | ||
248 | wk->ssid_len); | ||
249 | if (!skb) { | ||
250 | printk(KERN_DEBUG "%s: failed to allocate buffer for assoc " | ||
251 | "frame\n", sdata->dev->name); | ||
252 | return; | ||
253 | } | ||
254 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
255 | |||
256 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
257 | |||
258 | capab = ifmgd->capab; | ||
259 | |||
260 | if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) { | ||
261 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) | ||
262 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; | ||
263 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) | ||
264 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; | ||
265 | } | ||
266 | |||
267 | if (wk->bss->cbss.capability & WLAN_CAPABILITY_PRIVACY) | ||
268 | capab |= WLAN_CAPABILITY_PRIVACY; | ||
269 | if (wk->bss->wmm_used) | ||
270 | wmm = 1; | ||
271 | |||
272 | /* get all rates supported by the device and the AP as | ||
273 | * some APs don't like getting a superset of their rates | ||
274 | * in the association request (e.g. D-Link DAP 1353 in | ||
275 | * b-only mode) */ | ||
276 | rates_len = ieee80211_compatible_rates(wk->bss, sband, &rates); | ||
277 | |||
278 | if ((wk->bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && | ||
279 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) | ||
280 | capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; | ||
281 | |||
282 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | ||
283 | memset(mgmt, 0, 24); | ||
284 | memcpy(mgmt->da, wk->bss->cbss.bssid, ETH_ALEN); | ||
285 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
286 | memcpy(mgmt->bssid, wk->bss->cbss.bssid, ETH_ALEN); | ||
287 | |||
288 | if (!is_zero_ether_addr(wk->prev_bssid)) { | ||
289 | skb_put(skb, 10); | ||
290 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
291 | IEEE80211_STYPE_REASSOC_REQ); | ||
292 | mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); | ||
293 | mgmt->u.reassoc_req.listen_interval = | ||
294 | cpu_to_le16(local->hw.conf.listen_interval); | ||
295 | memcpy(mgmt->u.reassoc_req.current_ap, wk->prev_bssid, | ||
296 | ETH_ALEN); | ||
297 | } else { | ||
298 | skb_put(skb, 4); | ||
299 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
300 | IEEE80211_STYPE_ASSOC_REQ); | ||
301 | mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); | ||
302 | mgmt->u.assoc_req.listen_interval = | ||
303 | cpu_to_le16(local->hw.conf.listen_interval); | ||
304 | } | ||
305 | |||
306 | /* SSID */ | ||
307 | ies = pos = skb_put(skb, 2 + wk->ssid_len); | ||
308 | *pos++ = WLAN_EID_SSID; | ||
309 | *pos++ = wk->ssid_len; | ||
310 | memcpy(pos, wk->ssid, wk->ssid_len); | ||
311 | |||
312 | /* add all rates which were marked to be used above */ | ||
313 | supp_rates_len = rates_len; | ||
314 | if (supp_rates_len > 8) | ||
315 | supp_rates_len = 8; | ||
316 | |||
317 | len = sband->n_bitrates; | ||
318 | pos = skb_put(skb, supp_rates_len + 2); | ||
319 | *pos++ = WLAN_EID_SUPP_RATES; | ||
320 | *pos++ = supp_rates_len; | ||
321 | |||
322 | count = 0; | ||
323 | for (i = 0; i < sband->n_bitrates; i++) { | ||
324 | if (BIT(i) & rates) { | ||
325 | int rate = sband->bitrates[i].bitrate; | ||
326 | *pos++ = (u8) (rate / 5); | ||
327 | if (++count == 8) | ||
328 | break; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | if (rates_len > count) { | ||
333 | pos = skb_put(skb, rates_len - count + 2); | ||
334 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
335 | *pos++ = rates_len - count; | ||
336 | |||
337 | for (i++; i < sband->n_bitrates; i++) { | ||
338 | if (BIT(i) & rates) { | ||
339 | int rate = sband->bitrates[i].bitrate; | ||
340 | *pos++ = (u8) (rate / 5); | ||
341 | } | ||
342 | } | ||
343 | } | ||
344 | |||
345 | if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) { | ||
346 | /* 1. power capabilities */ | ||
347 | pos = skb_put(skb, 4); | ||
348 | *pos++ = WLAN_EID_PWR_CAPABILITY; | ||
349 | *pos++ = 2; | ||
350 | *pos++ = 0; /* min tx power */ | ||
351 | *pos++ = local->hw.conf.channel->max_power; /* max tx power */ | ||
352 | |||
353 | /* 2. supported channels */ | ||
354 | /* TODO: get this in reg domain format */ | ||
355 | pos = skb_put(skb, 2 * sband->n_channels + 2); | ||
356 | *pos++ = WLAN_EID_SUPPORTED_CHANNELS; | ||
357 | *pos++ = 2 * sband->n_channels; | ||
358 | for (i = 0; i < sband->n_channels; i++) { | ||
359 | *pos++ = ieee80211_frequency_to_channel( | ||
360 | sband->channels[i].center_freq); | ||
361 | *pos++ = 1; /* one channel in the subband*/ | ||
362 | } | ||
363 | } | ||
364 | |||
365 | if (wk->ie_len && wk->ie) { | ||
366 | pos = skb_put(skb, wk->ie_len); | ||
367 | memcpy(pos, wk->ie, wk->ie_len); | ||
368 | } | ||
369 | |||
370 | if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) { | ||
371 | pos = skb_put(skb, 9); | ||
372 | *pos++ = WLAN_EID_VENDOR_SPECIFIC; | ||
373 | *pos++ = 7; /* len */ | ||
374 | *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */ | ||
375 | *pos++ = 0x50; | ||
376 | *pos++ = 0xf2; | ||
377 | *pos++ = 2; /* WME */ | ||
378 | *pos++ = 0; /* WME info */ | ||
379 | *pos++ = 1; /* WME ver */ | ||
380 | *pos++ = 0; | ||
381 | } | ||
382 | |||
383 | /* wmm support is a must to HT */ | ||
384 | /* | ||
385 | * IEEE802.11n does not allow TKIP/WEP as pairwise | ||
386 | * ciphers in HT mode. We still associate in non-ht | ||
387 | * mode (11a/b/g) if any one of these ciphers is | ||
388 | * configured as pairwise. | ||
389 | */ | ||
390 | if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && | ||
391 | sband->ht_cap.ht_supported && | ||
392 | (ht_ie = ieee80211_bss_get_ie(&wk->bss->cbss, WLAN_EID_HT_INFORMATION)) && | ||
393 | ht_ie[1] >= sizeof(struct ieee80211_ht_info) && | ||
394 | (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N))) { | ||
395 | struct ieee80211_ht_info *ht_info = | ||
396 | (struct ieee80211_ht_info *)(ht_ie + 2); | ||
397 | u16 cap = sband->ht_cap.cap; | ||
398 | __le16 tmp; | ||
399 | u32 flags = local->hw.conf.channel->flags; | ||
400 | |||
401 | switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { | ||
402 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: | ||
403 | if (flags & IEEE80211_CHAN_NO_HT40PLUS) { | ||
404 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||
405 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
406 | } | ||
407 | break; | ||
408 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: | ||
409 | if (flags & IEEE80211_CHAN_NO_HT40MINUS) { | ||
410 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||
411 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
412 | } | ||
413 | break; | ||
414 | } | ||
415 | |||
416 | tmp = cpu_to_le16(cap); | ||
417 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); | ||
418 | *pos++ = WLAN_EID_HT_CAPABILITY; | ||
419 | *pos++ = sizeof(struct ieee80211_ht_cap); | ||
420 | memset(pos, 0, sizeof(struct ieee80211_ht_cap)); | ||
421 | memcpy(pos, &tmp, sizeof(u16)); | ||
422 | pos += sizeof(u16); | ||
423 | /* TODO: needs a define here for << 2 */ | ||
424 | *pos++ = sband->ht_cap.ampdu_factor | | ||
425 | (sband->ht_cap.ampdu_density << 2); | ||
426 | memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); | ||
427 | } | ||
428 | |||
429 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
430 | ieee80211_tx_skb(sdata, skb); | ||
431 | } | ||
432 | |||
433 | |||
434 | static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | 207 | static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, |
435 | const u8 *bssid, u16 stype, u16 reason, | 208 | const u8 *bssid, u16 stype, u16 reason, |
436 | void *cookie) | 209 | void *cookie) |
@@ -443,7 +216,7 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
443 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); | 216 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); |
444 | if (!skb) { | 217 | if (!skb) { |
445 | printk(KERN_DEBUG "%s: failed to allocate buffer for " | 218 | printk(KERN_DEBUG "%s: failed to allocate buffer for " |
446 | "deauth/disassoc frame\n", sdata->dev->name); | 219 | "deauth/disassoc frame\n", sdata->name); |
447 | return; | 220 | return; |
448 | } | 221 | } |
449 | skb_reserve(skb, local->hw.extra_tx_headroom); | 222 | skb_reserve(skb, local->hw.extra_tx_headroom); |
@@ -451,7 +224,7 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
451 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | 224 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
452 | memset(mgmt, 0, 24); | 225 | memset(mgmt, 0, 24); |
453 | memcpy(mgmt->da, bssid, ETH_ALEN); | 226 | memcpy(mgmt->da, bssid, ETH_ALEN); |
454 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 227 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
455 | memcpy(mgmt->bssid, bssid, ETH_ALEN); | 228 | memcpy(mgmt->bssid, bssid, ETH_ALEN); |
456 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); | 229 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); |
457 | skb_put(skb, 2); | 230 | skb_put(skb, 2); |
@@ -476,30 +249,15 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
476 | void ieee80211_send_pspoll(struct ieee80211_local *local, | 249 | void ieee80211_send_pspoll(struct ieee80211_local *local, |
477 | struct ieee80211_sub_if_data *sdata) | 250 | struct ieee80211_sub_if_data *sdata) |
478 | { | 251 | { |
479 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
480 | struct ieee80211_pspoll *pspoll; | 252 | struct ieee80211_pspoll *pspoll; |
481 | struct sk_buff *skb; | 253 | struct sk_buff *skb; |
482 | u16 fc; | ||
483 | 254 | ||
484 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); | 255 | skb = ieee80211_pspoll_get(&local->hw, &sdata->vif); |
485 | if (!skb) { | 256 | if (!skb) |
486 | printk(KERN_DEBUG "%s: failed to allocate buffer for " | ||
487 | "pspoll frame\n", sdata->dev->name); | ||
488 | return; | 257 | return; |
489 | } | ||
490 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
491 | 258 | ||
492 | pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll)); | 259 | pspoll = (struct ieee80211_pspoll *) skb->data; |
493 | memset(pspoll, 0, sizeof(*pspoll)); | 260 | pspoll->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
494 | fc = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM; | ||
495 | pspoll->frame_control = cpu_to_le16(fc); | ||
496 | pspoll->aid = cpu_to_le16(ifmgd->aid); | ||
497 | |||
498 | /* aid in PS-Poll has its two MSBs each set to 1 */ | ||
499 | pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); | ||
500 | |||
501 | memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN); | ||
502 | memcpy(pspoll->ta, sdata->dev->dev_addr, ETH_ALEN); | ||
503 | 261 | ||
504 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 262 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
505 | ieee80211_tx_skb(sdata, skb); | 263 | ieee80211_tx_skb(sdata, skb); |
@@ -510,30 +268,47 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local, | |||
510 | int powersave) | 268 | int powersave) |
511 | { | 269 | { |
512 | struct sk_buff *skb; | 270 | struct sk_buff *skb; |
271 | struct ieee80211_hdr_3addr *nullfunc; | ||
272 | |||
273 | skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif); | ||
274 | if (!skb) | ||
275 | return; | ||
276 | |||
277 | nullfunc = (struct ieee80211_hdr_3addr *) skb->data; | ||
278 | if (powersave) | ||
279 | nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); | ||
280 | |||
281 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
282 | ieee80211_tx_skb(sdata, skb); | ||
283 | } | ||
284 | |||
285 | static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, | ||
286 | struct ieee80211_sub_if_data *sdata) | ||
287 | { | ||
288 | struct sk_buff *skb; | ||
513 | struct ieee80211_hdr *nullfunc; | 289 | struct ieee80211_hdr *nullfunc; |
514 | __le16 fc; | 290 | __le16 fc; |
515 | 291 | ||
516 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) | 292 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) |
517 | return; | 293 | return; |
518 | 294 | ||
519 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); | 295 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30); |
520 | if (!skb) { | 296 | if (!skb) { |
521 | printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc " | 297 | printk(KERN_DEBUG "%s: failed to allocate buffer for 4addr " |
522 | "frame\n", sdata->dev->name); | 298 | "nullfunc frame\n", sdata->name); |
523 | return; | 299 | return; |
524 | } | 300 | } |
525 | skb_reserve(skb, local->hw.extra_tx_headroom); | 301 | skb_reserve(skb, local->hw.extra_tx_headroom); |
526 | 302 | ||
527 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); | 303 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 30); |
528 | memset(nullfunc, 0, 24); | 304 | memset(nullfunc, 0, 30); |
529 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | | 305 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | |
530 | IEEE80211_FCTL_TODS); | 306 | IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
531 | if (powersave) | ||
532 | fc |= cpu_to_le16(IEEE80211_FCTL_PM); | ||
533 | nullfunc->frame_control = fc; | 307 | nullfunc->frame_control = fc; |
534 | memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN); | 308 | memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN); |
535 | memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); | 309 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); |
536 | memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN); | 310 | memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN); |
311 | memcpy(nullfunc->addr4, sdata->vif.addr, ETH_ALEN); | ||
537 | 312 | ||
538 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 313 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
539 | ieee80211_tx_skb(sdata, skb); | 314 | ieee80211_tx_skb(sdata, skb); |
@@ -546,7 +321,7 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
546 | container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); | 321 | container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); |
547 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 322 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
548 | 323 | ||
549 | if (!netif_running(sdata->dev)) | 324 | if (!ieee80211_sdata_running(sdata)) |
550 | return; | 325 | return; |
551 | 326 | ||
552 | mutex_lock(&ifmgd->mtx); | 327 | mutex_lock(&ifmgd->mtx); |
@@ -557,7 +332,7 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
557 | ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL); | 332 | ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL); |
558 | 333 | ||
559 | /* XXX: shouldn't really modify cfg80211-owned data! */ | 334 | /* XXX: shouldn't really modify cfg80211-owned data! */ |
560 | ifmgd->associated->cbss.channel = sdata->local->oper_channel; | 335 | ifmgd->associated->channel = sdata->local->oper_channel; |
561 | 336 | ||
562 | ieee80211_wake_queues_by_reason(&sdata->local->hw, | 337 | ieee80211_wake_queues_by_reason(&sdata->local->hw, |
563 | IEEE80211_QUEUE_STOP_REASON_CSA); | 338 | IEEE80211_QUEUE_STOP_REASON_CSA); |
@@ -584,6 +359,8 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
584 | struct ieee80211_channel_sw_ie *sw_elem, | 359 | struct ieee80211_channel_sw_ie *sw_elem, |
585 | struct ieee80211_bss *bss) | 360 | struct ieee80211_bss *bss) |
586 | { | 361 | { |
362 | struct cfg80211_bss *cbss = | ||
363 | container_of((void *)bss, struct cfg80211_bss, priv); | ||
587 | struct ieee80211_channel *new_ch; | 364 | struct ieee80211_channel *new_ch; |
588 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 365 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
589 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num); | 366 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num); |
@@ -617,7 +394,7 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
617 | mod_timer(&ifmgd->chswitch_timer, | 394 | mod_timer(&ifmgd->chswitch_timer, |
618 | jiffies + | 395 | jiffies + |
619 | msecs_to_jiffies(sw_elem->count * | 396 | msecs_to_jiffies(sw_elem->count * |
620 | bss->cbss.beacon_interval)); | 397 | cbss->beacon_interval)); |
621 | } | 398 | } |
622 | } | 399 | } |
623 | 400 | ||
@@ -691,8 +468,13 @@ void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency) | |||
691 | return; | 468 | return; |
692 | } | 469 | } |
693 | 470 | ||
471 | if (!list_empty(&local->work_list)) { | ||
472 | local->ps_sdata = NULL; | ||
473 | goto change; | ||
474 | } | ||
475 | |||
694 | list_for_each_entry(sdata, &local->interfaces, list) { | 476 | list_for_each_entry(sdata, &local->interfaces, list) { |
695 | if (!netif_running(sdata->dev)) | 477 | if (!ieee80211_sdata_running(sdata)) |
696 | continue; | 478 | continue; |
697 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 479 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
698 | continue; | 480 | continue; |
@@ -701,7 +483,7 @@ void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency) | |||
701 | } | 483 | } |
702 | 484 | ||
703 | if (count == 1 && found->u.mgd.powersave && | 485 | if (count == 1 && found->u.mgd.powersave && |
704 | found->u.mgd.associated && list_empty(&found->u.mgd.work_list) && | 486 | found->u.mgd.associated && |
705 | !(found->u.mgd.flags & (IEEE80211_STA_BEACON_POLL | | 487 | !(found->u.mgd.flags & (IEEE80211_STA_BEACON_POLL | |
706 | IEEE80211_STA_CONNECTION_POLL))) { | 488 | IEEE80211_STA_CONNECTION_POLL))) { |
707 | s32 beaconint_us; | 489 | s32 beaconint_us; |
@@ -729,6 +511,7 @@ void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency) | |||
729 | local->ps_sdata = NULL; | 511 | local->ps_sdata = NULL; |
730 | } | 512 | } |
731 | 513 | ||
514 | change: | ||
732 | ieee80211_change_ps(local); | 515 | ieee80211_change_ps(local); |
733 | } | 516 | } |
734 | 517 | ||
@@ -786,9 +569,9 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, | |||
786 | struct ieee80211_tx_queue_params params; | 569 | struct ieee80211_tx_queue_params params; |
787 | size_t left; | 570 | size_t left; |
788 | int count; | 571 | int count; |
789 | u8 *pos; | 572 | u8 *pos, uapsd_queues = 0; |
790 | 573 | ||
791 | if (!(ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) | 574 | if (local->hw.queues < 4) |
792 | return; | 575 | return; |
793 | 576 | ||
794 | if (!wmm_param) | 577 | if (!wmm_param) |
@@ -796,6 +579,10 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, | |||
796 | 579 | ||
797 | if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) | 580 | if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) |
798 | return; | 581 | return; |
582 | |||
583 | if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) | ||
584 | uapsd_queues = local->uapsd_queues; | ||
585 | |||
799 | count = wmm_param[6] & 0x0f; | 586 | count = wmm_param[6] & 0x0f; |
800 | if (count == ifmgd->wmm_last_param_set) | 587 | if (count == ifmgd->wmm_last_param_set) |
801 | return; | 588 | return; |
@@ -810,6 +597,7 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, | |||
810 | for (; left >= 4; left -= 4, pos += 4) { | 597 | for (; left >= 4; left -= 4, pos += 4) { |
811 | int aci = (pos[0] >> 5) & 0x03; | 598 | int aci = (pos[0] >> 5) & 0x03; |
812 | int acm = (pos[0] >> 4) & 0x01; | 599 | int acm = (pos[0] >> 4) & 0x01; |
600 | bool uapsd = false; | ||
813 | int queue; | 601 | int queue; |
814 | 602 | ||
815 | switch (aci) { | 603 | switch (aci) { |
@@ -817,22 +605,30 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, | |||
817 | queue = 3; | 605 | queue = 3; |
818 | if (acm) | 606 | if (acm) |
819 | local->wmm_acm |= BIT(1) | BIT(2); /* BK/- */ | 607 | local->wmm_acm |= BIT(1) | BIT(2); /* BK/- */ |
608 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) | ||
609 | uapsd = true; | ||
820 | break; | 610 | break; |
821 | case 2: /* AC_VI */ | 611 | case 2: /* AC_VI */ |
822 | queue = 1; | 612 | queue = 1; |
823 | if (acm) | 613 | if (acm) |
824 | local->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */ | 614 | local->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */ |
615 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) | ||
616 | uapsd = true; | ||
825 | break; | 617 | break; |
826 | case 3: /* AC_VO */ | 618 | case 3: /* AC_VO */ |
827 | queue = 0; | 619 | queue = 0; |
828 | if (acm) | 620 | if (acm) |
829 | local->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */ | 621 | local->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */ |
622 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) | ||
623 | uapsd = true; | ||
830 | break; | 624 | break; |
831 | case 0: /* AC_BE */ | 625 | case 0: /* AC_BE */ |
832 | default: | 626 | default: |
833 | queue = 2; | 627 | queue = 2; |
834 | if (acm) | 628 | if (acm) |
835 | local->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */ | 629 | local->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */ |
630 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) | ||
631 | uapsd = true; | ||
836 | break; | 632 | break; |
837 | } | 633 | } |
838 | 634 | ||
@@ -840,11 +636,14 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, | |||
840 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); | 636 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); |
841 | params.cw_min = ecw2cw(pos[1] & 0x0f); | 637 | params.cw_min = ecw2cw(pos[1] & 0x0f); |
842 | params.txop = get_unaligned_le16(pos + 2); | 638 | params.txop = get_unaligned_le16(pos + 2); |
639 | params.uapsd = uapsd; | ||
640 | |||
843 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 641 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
844 | printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d " | 642 | printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d " |
845 | "cWmin=%d cWmax=%d txop=%d\n", | 643 | "cWmin=%d cWmax=%d txop=%d uapsd=%d\n", |
846 | wiphy_name(local->hw.wiphy), queue, aci, acm, | 644 | wiphy_name(local->hw.wiphy), queue, aci, acm, |
847 | params.aifs, params.cw_min, params.cw_max, params.txop); | 645 | params.aifs, params.cw_min, params.cw_max, params.txop, |
646 | params.uapsd); | ||
848 | #endif | 647 | #endif |
849 | if (drv_conf_tx(local, queue, ¶ms) && local->ops->conf_tx) | 648 | if (drv_conf_tx(local, queue, ¶ms) && local->ops->conf_tx) |
850 | printk(KERN_DEBUG "%s: failed to set TX queue " | 649 | printk(KERN_DEBUG "%s: failed to set TX queue " |
@@ -871,6 +670,8 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, | |||
871 | } | 670 | } |
872 | 671 | ||
873 | use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); | 672 | use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); |
673 | if (sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) | ||
674 | use_short_slot = true; | ||
874 | 675 | ||
875 | if (use_protection != bss_conf->use_cts_prot) { | 676 | if (use_protection != bss_conf->use_cts_prot) { |
876 | bss_conf->use_cts_prot = use_protection; | 677 | bss_conf->use_cts_prot = use_protection; |
@@ -891,25 +692,24 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, | |||
891 | } | 692 | } |
892 | 693 | ||
893 | static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | 694 | static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, |
894 | struct ieee80211_mgd_work *wk, | 695 | struct cfg80211_bss *cbss, |
895 | u32 bss_info_changed) | 696 | u32 bss_info_changed) |
896 | { | 697 | { |
698 | struct ieee80211_bss *bss = (void *)cbss->priv; | ||
897 | struct ieee80211_local *local = sdata->local; | 699 | struct ieee80211_local *local = sdata->local; |
898 | struct ieee80211_bss *bss = wk->bss; | ||
899 | 700 | ||
900 | bss_info_changed |= BSS_CHANGED_ASSOC; | 701 | bss_info_changed |= BSS_CHANGED_ASSOC; |
901 | /* set timing information */ | 702 | /* set timing information */ |
902 | sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval; | 703 | sdata->vif.bss_conf.beacon_int = cbss->beacon_interval; |
903 | sdata->vif.bss_conf.timestamp = bss->cbss.tsf; | 704 | sdata->vif.bss_conf.timestamp = cbss->tsf; |
904 | sdata->vif.bss_conf.dtim_period = bss->dtim_period; | 705 | sdata->vif.bss_conf.dtim_period = bss->dtim_period; |
905 | 706 | ||
906 | bss_info_changed |= BSS_CHANGED_BEACON_INT; | 707 | bss_info_changed |= BSS_CHANGED_BEACON_INT; |
907 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, | 708 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, |
908 | bss->cbss.capability, bss->has_erp_value, bss->erp_value); | 709 | cbss->capability, bss->has_erp_value, bss->erp_value); |
909 | 710 | ||
910 | sdata->u.mgd.associated = bss; | 711 | sdata->u.mgd.associated = cbss; |
911 | sdata->u.mgd.old_associate_work = wk; | 712 | memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN); |
912 | memcpy(sdata->u.mgd.bssid, bss->cbss.bssid, ETH_ALEN); | ||
913 | 713 | ||
914 | /* just to be sure */ | 714 | /* just to be sure */ |
915 | sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | | 715 | sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | |
@@ -940,99 +740,14 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
940 | 740 | ||
941 | mutex_lock(&local->iflist_mtx); | 741 | mutex_lock(&local->iflist_mtx); |
942 | ieee80211_recalc_ps(local, -1); | 742 | ieee80211_recalc_ps(local, -1); |
743 | ieee80211_recalc_smps(local, sdata); | ||
943 | mutex_unlock(&local->iflist_mtx); | 744 | mutex_unlock(&local->iflist_mtx); |
944 | 745 | ||
945 | netif_tx_start_all_queues(sdata->dev); | 746 | netif_tx_start_all_queues(sdata->dev); |
946 | netif_carrier_on(sdata->dev); | 747 | netif_carrier_on(sdata->dev); |
947 | } | 748 | } |
948 | 749 | ||
949 | static enum rx_mgmt_action __must_check | 750 | static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata) |
950 | ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata, | ||
951 | struct ieee80211_mgd_work *wk) | ||
952 | { | ||
953 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
954 | struct ieee80211_local *local = sdata->local; | ||
955 | |||
956 | wk->tries++; | ||
957 | if (wk->tries > IEEE80211_AUTH_MAX_TRIES) { | ||
958 | printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n", | ||
959 | sdata->dev->name, wk->bss->cbss.bssid); | ||
960 | |||
961 | /* | ||
962 | * Most likely AP is not in the range so remove the | ||
963 | * bss struct for that AP. | ||
964 | */ | ||
965 | cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss); | ||
966 | |||
967 | /* | ||
968 | * We might have a pending scan which had no chance to run yet | ||
969 | * due to work needing to be done. Hence, queue the STAs work | ||
970 | * again for that. | ||
971 | */ | ||
972 | ieee80211_queue_work(&local->hw, &ifmgd->work); | ||
973 | return RX_MGMT_CFG80211_AUTH_TO; | ||
974 | } | ||
975 | |||
976 | printk(KERN_DEBUG "%s: direct probe to AP %pM (try %d)\n", | ||
977 | sdata->dev->name, wk->bss->cbss.bssid, | ||
978 | wk->tries); | ||
979 | |||
980 | /* | ||
981 | * Direct probe is sent to broadcast address as some APs | ||
982 | * will not answer to direct packet in unassociated state. | ||
983 | */ | ||
984 | ieee80211_send_probe_req(sdata, NULL, wk->ssid, wk->ssid_len, NULL, 0); | ||
985 | |||
986 | wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; | ||
987 | run_again(ifmgd, wk->timeout); | ||
988 | |||
989 | return RX_MGMT_NONE; | ||
990 | } | ||
991 | |||
992 | |||
993 | static enum rx_mgmt_action __must_check | ||
994 | ieee80211_authenticate(struct ieee80211_sub_if_data *sdata, | ||
995 | struct ieee80211_mgd_work *wk) | ||
996 | { | ||
997 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
998 | struct ieee80211_local *local = sdata->local; | ||
999 | |||
1000 | wk->tries++; | ||
1001 | if (wk->tries > IEEE80211_AUTH_MAX_TRIES) { | ||
1002 | printk(KERN_DEBUG "%s: authentication with AP %pM" | ||
1003 | " timed out\n", | ||
1004 | sdata->dev->name, wk->bss->cbss.bssid); | ||
1005 | |||
1006 | /* | ||
1007 | * Most likely AP is not in the range so remove the | ||
1008 | * bss struct for that AP. | ||
1009 | */ | ||
1010 | cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss); | ||
1011 | |||
1012 | /* | ||
1013 | * We might have a pending scan which had no chance to run yet | ||
1014 | * due to work needing to be done. Hence, queue the STAs work | ||
1015 | * again for that. | ||
1016 | */ | ||
1017 | ieee80211_queue_work(&local->hw, &ifmgd->work); | ||
1018 | return RX_MGMT_CFG80211_AUTH_TO; | ||
1019 | } | ||
1020 | |||
1021 | printk(KERN_DEBUG "%s: authenticate with AP %pM (try %d)\n", | ||
1022 | sdata->dev->name, wk->bss->cbss.bssid, wk->tries); | ||
1023 | |||
1024 | ieee80211_send_auth(sdata, 1, wk->auth_alg, wk->ie, wk->ie_len, | ||
1025 | wk->bss->cbss.bssid, NULL, 0, 0); | ||
1026 | wk->auth_transaction = 2; | ||
1027 | |||
1028 | wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; | ||
1029 | run_again(ifmgd, wk->timeout); | ||
1030 | |||
1031 | return RX_MGMT_NONE; | ||
1032 | } | ||
1033 | |||
1034 | static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | ||
1035 | bool deauth) | ||
1036 | { | 751 | { |
1037 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 752 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1038 | struct ieee80211_local *local = sdata->local; | 753 | struct ieee80211_local *local = sdata->local; |
@@ -1045,21 +760,11 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1045 | if (WARN_ON(!ifmgd->associated)) | 760 | if (WARN_ON(!ifmgd->associated)) |
1046 | return; | 761 | return; |
1047 | 762 | ||
1048 | memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); | 763 | memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN); |
1049 | 764 | ||
1050 | ifmgd->associated = NULL; | 765 | ifmgd->associated = NULL; |
1051 | memset(ifmgd->bssid, 0, ETH_ALEN); | 766 | memset(ifmgd->bssid, 0, ETH_ALEN); |
1052 | 767 | ||
1053 | if (deauth) { | ||
1054 | kfree(ifmgd->old_associate_work); | ||
1055 | ifmgd->old_associate_work = NULL; | ||
1056 | } else { | ||
1057 | struct ieee80211_mgd_work *wk = ifmgd->old_associate_work; | ||
1058 | |||
1059 | wk->state = IEEE80211_MGD_STATE_IDLE; | ||
1060 | list_add(&wk->list, &ifmgd->work_list); | ||
1061 | } | ||
1062 | |||
1063 | /* | 768 | /* |
1064 | * we need to commit the associated = NULL change because the | 769 | * we need to commit the associated = NULL change because the |
1065 | * scan code uses that to determine whether this iface should | 770 | * scan code uses that to determine whether this iface should |
@@ -1078,7 +783,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1078 | netif_carrier_off(sdata->dev); | 783 | netif_carrier_off(sdata->dev); |
1079 | 784 | ||
1080 | rcu_read_lock(); | 785 | rcu_read_lock(); |
1081 | sta = sta_info_get(local, bssid); | 786 | sta = sta_info_get(sdata, bssid); |
1082 | if (sta) | 787 | if (sta) |
1083 | ieee80211_sta_tear_down_BA_sessions(sta); | 788 | ieee80211_sta_tear_down_BA_sessions(sta); |
1084 | rcu_read_unlock(); | 789 | rcu_read_unlock(); |
@@ -1115,7 +820,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1115 | 820 | ||
1116 | rcu_read_lock(); | 821 | rcu_read_lock(); |
1117 | 822 | ||
1118 | sta = sta_info_get(local, bssid); | 823 | sta = sta_info_get(sdata, bssid); |
1119 | if (!sta) { | 824 | if (!sta) { |
1120 | rcu_read_unlock(); | 825 | rcu_read_unlock(); |
1121 | return; | 826 | return; |
@@ -1128,44 +833,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1128 | sta_info_destroy(sta); | 833 | sta_info_destroy(sta); |
1129 | } | 834 | } |
1130 | 835 | ||
1131 | static enum rx_mgmt_action __must_check | ||
1132 | ieee80211_associate(struct ieee80211_sub_if_data *sdata, | ||
1133 | struct ieee80211_mgd_work *wk) | ||
1134 | { | ||
1135 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
1136 | struct ieee80211_local *local = sdata->local; | ||
1137 | |||
1138 | wk->tries++; | ||
1139 | if (wk->tries > IEEE80211_ASSOC_MAX_TRIES) { | ||
1140 | printk(KERN_DEBUG "%s: association with AP %pM" | ||
1141 | " timed out\n", | ||
1142 | sdata->dev->name, wk->bss->cbss.bssid); | ||
1143 | |||
1144 | /* | ||
1145 | * Most likely AP is not in the range so remove the | ||
1146 | * bss struct for that AP. | ||
1147 | */ | ||
1148 | cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss); | ||
1149 | |||
1150 | /* | ||
1151 | * We might have a pending scan which had no chance to run yet | ||
1152 | * due to work needing to be done. Hence, queue the STAs work | ||
1153 | * again for that. | ||
1154 | */ | ||
1155 | ieee80211_queue_work(&local->hw, &ifmgd->work); | ||
1156 | return RX_MGMT_CFG80211_ASSOC_TO; | ||
1157 | } | ||
1158 | |||
1159 | printk(KERN_DEBUG "%s: associate with AP %pM (try %d)\n", | ||
1160 | sdata->dev->name, wk->bss->cbss.bssid, wk->tries); | ||
1161 | ieee80211_send_assoc(sdata, wk); | ||
1162 | |||
1163 | wk->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; | ||
1164 | run_again(ifmgd, wk->timeout); | ||
1165 | |||
1166 | return RX_MGMT_NONE; | ||
1167 | } | ||
1168 | |||
1169 | void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, | 836 | void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, |
1170 | struct ieee80211_hdr *hdr) | 837 | struct ieee80211_hdr *hdr) |
1171 | { | 838 | { |
@@ -1189,8 +856,8 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) | |||
1189 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 856 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1190 | const u8 *ssid; | 857 | const u8 *ssid; |
1191 | 858 | ||
1192 | ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID); | 859 | ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); |
1193 | ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid, | 860 | ieee80211_send_probe_req(sdata, ifmgd->associated->bssid, |
1194 | ssid + 2, ssid[1], NULL, 0); | 861 | ssid + 2, ssid[1], NULL, 0); |
1195 | 862 | ||
1196 | ifmgd->probe_send_count++; | 863 | ifmgd->probe_send_count++; |
@@ -1204,12 +871,15 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata, | |||
1204 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 871 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1205 | bool already = false; | 872 | bool already = false; |
1206 | 873 | ||
1207 | if (!netif_running(sdata->dev)) | 874 | if (!ieee80211_sdata_running(sdata)) |
1208 | return; | 875 | return; |
1209 | 876 | ||
1210 | if (sdata->local->scanning) | 877 | if (sdata->local->scanning) |
1211 | return; | 878 | return; |
1212 | 879 | ||
880 | if (sdata->local->tmp_channel) | ||
881 | return; | ||
882 | |||
1213 | mutex_lock(&ifmgd->mtx); | 883 | mutex_lock(&ifmgd->mtx); |
1214 | 884 | ||
1215 | if (!ifmgd->associated) | 885 | if (!ifmgd->associated) |
@@ -1218,7 +888,7 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata, | |||
1218 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 888 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
1219 | if (beacon && net_ratelimit()) | 889 | if (beacon && net_ratelimit()) |
1220 | printk(KERN_DEBUG "%s: detected beacon loss from AP " | 890 | printk(KERN_DEBUG "%s: detected beacon loss from AP " |
1221 | "- sending probe request\n", sdata->dev->name); | 891 | "- sending probe request\n", sdata->name); |
1222 | #endif | 892 | #endif |
1223 | 893 | ||
1224 | /* | 894 | /* |
@@ -1271,88 +941,8 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif) | |||
1271 | } | 941 | } |
1272 | EXPORT_SYMBOL(ieee80211_beacon_loss); | 942 | EXPORT_SYMBOL(ieee80211_beacon_loss); |
1273 | 943 | ||
1274 | static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata, | ||
1275 | struct ieee80211_mgd_work *wk) | ||
1276 | { | ||
1277 | wk->state = IEEE80211_MGD_STATE_IDLE; | ||
1278 | printk(KERN_DEBUG "%s: authenticated\n", sdata->dev->name); | ||
1279 | } | ||
1280 | |||
1281 | |||
1282 | static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | ||
1283 | struct ieee80211_mgd_work *wk, | ||
1284 | struct ieee80211_mgmt *mgmt, | ||
1285 | size_t len) | ||
1286 | { | ||
1287 | u8 *pos; | ||
1288 | struct ieee802_11_elems elems; | ||
1289 | |||
1290 | pos = mgmt->u.auth.variable; | ||
1291 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | ||
1292 | if (!elems.challenge) | ||
1293 | return; | ||
1294 | ieee80211_send_auth(sdata, 3, wk->auth_alg, | ||
1295 | elems.challenge - 2, elems.challenge_len + 2, | ||
1296 | wk->bss->cbss.bssid, | ||
1297 | wk->key, wk->key_len, wk->key_idx); | ||
1298 | wk->auth_transaction = 4; | ||
1299 | } | ||
1300 | |||
1301 | static enum rx_mgmt_action __must_check | ||
1302 | ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | ||
1303 | struct ieee80211_mgd_work *wk, | ||
1304 | struct ieee80211_mgmt *mgmt, size_t len) | ||
1305 | { | ||
1306 | u16 auth_alg, auth_transaction, status_code; | ||
1307 | |||
1308 | if (wk->state != IEEE80211_MGD_STATE_AUTH) | ||
1309 | return RX_MGMT_NONE; | ||
1310 | |||
1311 | if (len < 24 + 6) | ||
1312 | return RX_MGMT_NONE; | ||
1313 | |||
1314 | if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0) | ||
1315 | return RX_MGMT_NONE; | ||
1316 | |||
1317 | if (memcmp(wk->bss->cbss.bssid, mgmt->bssid, ETH_ALEN) != 0) | ||
1318 | return RX_MGMT_NONE; | ||
1319 | |||
1320 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | ||
1321 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); | ||
1322 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | ||
1323 | |||
1324 | if (auth_alg != wk->auth_alg || | ||
1325 | auth_transaction != wk->auth_transaction) | ||
1326 | return RX_MGMT_NONE; | ||
1327 | |||
1328 | if (status_code != WLAN_STATUS_SUCCESS) { | ||
1329 | list_del(&wk->list); | ||
1330 | kfree(wk); | ||
1331 | return RX_MGMT_CFG80211_AUTH; | ||
1332 | } | ||
1333 | |||
1334 | switch (wk->auth_alg) { | ||
1335 | case WLAN_AUTH_OPEN: | ||
1336 | case WLAN_AUTH_LEAP: | ||
1337 | case WLAN_AUTH_FT: | ||
1338 | ieee80211_auth_completed(sdata, wk); | ||
1339 | return RX_MGMT_CFG80211_AUTH; | ||
1340 | case WLAN_AUTH_SHARED_KEY: | ||
1341 | if (wk->auth_transaction == 4) { | ||
1342 | ieee80211_auth_completed(sdata, wk); | ||
1343 | return RX_MGMT_CFG80211_AUTH; | ||
1344 | } else | ||
1345 | ieee80211_auth_challenge(sdata, wk, mgmt, len); | ||
1346 | break; | ||
1347 | } | ||
1348 | |||
1349 | return RX_MGMT_NONE; | ||
1350 | } | ||
1351 | |||
1352 | |||
1353 | static enum rx_mgmt_action __must_check | 944 | static enum rx_mgmt_action __must_check |
1354 | ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, | 945 | ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, |
1355 | struct ieee80211_mgd_work *wk, | ||
1356 | struct ieee80211_mgmt *mgmt, size_t len) | 946 | struct ieee80211_mgmt *mgmt, size_t len) |
1357 | { | 947 | { |
1358 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 948 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
@@ -1364,23 +954,15 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, | |||
1364 | 954 | ||
1365 | ASSERT_MGD_MTX(ifmgd); | 955 | ASSERT_MGD_MTX(ifmgd); |
1366 | 956 | ||
1367 | if (wk) | 957 | bssid = ifmgd->associated->bssid; |
1368 | bssid = wk->bss->cbss.bssid; | ||
1369 | else | ||
1370 | bssid = ifmgd->associated->cbss.bssid; | ||
1371 | 958 | ||
1372 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); | 959 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); |
1373 | 960 | ||
1374 | printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n", | 961 | printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n", |
1375 | sdata->dev->name, bssid, reason_code); | 962 | sdata->name, bssid, reason_code); |
1376 | 963 | ||
1377 | if (!wk) { | 964 | ieee80211_set_disassoc(sdata); |
1378 | ieee80211_set_disassoc(sdata, true); | 965 | ieee80211_recalc_idle(sdata->local); |
1379 | ieee80211_recalc_idle(sdata->local); | ||
1380 | } else { | ||
1381 | list_del(&wk->list); | ||
1382 | kfree(wk); | ||
1383 | } | ||
1384 | 966 | ||
1385 | return RX_MGMT_CFG80211_DEAUTH; | 967 | return RX_MGMT_CFG80211_DEAUTH; |
1386 | } | 968 | } |
@@ -1401,123 +983,72 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1401 | if (WARN_ON(!ifmgd->associated)) | 983 | if (WARN_ON(!ifmgd->associated)) |
1402 | return RX_MGMT_NONE; | 984 | return RX_MGMT_NONE; |
1403 | 985 | ||
1404 | if (WARN_ON(memcmp(ifmgd->associated->cbss.bssid, mgmt->sa, ETH_ALEN))) | 986 | if (WARN_ON(memcmp(ifmgd->associated->bssid, mgmt->sa, ETH_ALEN))) |
1405 | return RX_MGMT_NONE; | 987 | return RX_MGMT_NONE; |
1406 | 988 | ||
1407 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); | 989 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); |
1408 | 990 | ||
1409 | printk(KERN_DEBUG "%s: disassociated from %pM (Reason: %u)\n", | 991 | printk(KERN_DEBUG "%s: disassociated from %pM (Reason: %u)\n", |
1410 | sdata->dev->name, mgmt->sa, reason_code); | 992 | sdata->name, mgmt->sa, reason_code); |
1411 | 993 | ||
1412 | ieee80211_set_disassoc(sdata, false); | 994 | ieee80211_set_disassoc(sdata); |
1413 | ieee80211_recalc_idle(sdata->local); | 995 | ieee80211_recalc_idle(sdata->local); |
1414 | return RX_MGMT_CFG80211_DISASSOC; | 996 | return RX_MGMT_CFG80211_DISASSOC; |
1415 | } | 997 | } |
1416 | 998 | ||
1417 | 999 | ||
1418 | static enum rx_mgmt_action __must_check | 1000 | static bool ieee80211_assoc_success(struct ieee80211_work *wk, |
1419 | ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | 1001 | struct ieee80211_mgmt *mgmt, size_t len) |
1420 | struct ieee80211_mgd_work *wk, | ||
1421 | struct ieee80211_mgmt *mgmt, size_t len, | ||
1422 | bool reassoc) | ||
1423 | { | 1002 | { |
1003 | struct ieee80211_sub_if_data *sdata = wk->sdata; | ||
1424 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1004 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1425 | struct ieee80211_local *local = sdata->local; | 1005 | struct ieee80211_local *local = sdata->local; |
1426 | struct ieee80211_supported_band *sband; | 1006 | struct ieee80211_supported_band *sband; |
1427 | struct sta_info *sta; | 1007 | struct sta_info *sta; |
1008 | struct cfg80211_bss *cbss = wk->assoc.bss; | ||
1009 | u8 *pos; | ||
1428 | u32 rates, basic_rates; | 1010 | u32 rates, basic_rates; |
1429 | u16 capab_info, status_code, aid; | 1011 | u16 capab_info, aid; |
1430 | struct ieee802_11_elems elems; | 1012 | struct ieee802_11_elems elems; |
1431 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; | 1013 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
1432 | u8 *pos; | ||
1433 | u32 changed = 0; | 1014 | u32 changed = 0; |
1434 | int i, j; | 1015 | int i, j, err; |
1435 | bool have_higher_than_11mbit = false, newsta = false; | 1016 | bool have_higher_than_11mbit = false; |
1436 | u16 ap_ht_cap_flags; | 1017 | u16 ap_ht_cap_flags; |
1437 | 1018 | ||
1438 | /* | 1019 | /* AssocResp and ReassocResp have identical structure */ |
1439 | * AssocResp and ReassocResp have identical structure, so process both | ||
1440 | * of them in this function. | ||
1441 | */ | ||
1442 | |||
1443 | if (len < 24 + 6) | ||
1444 | return RX_MGMT_NONE; | ||
1445 | |||
1446 | if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0) | ||
1447 | return RX_MGMT_NONE; | ||
1448 | 1020 | ||
1449 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); | ||
1450 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); | ||
1451 | aid = le16_to_cpu(mgmt->u.assoc_resp.aid); | 1021 | aid = le16_to_cpu(mgmt->u.assoc_resp.aid); |
1452 | 1022 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); | |
1453 | printk(KERN_DEBUG "%s: RX %sssocResp from %pM (capab=0x%x " | ||
1454 | "status=%d aid=%d)\n", | ||
1455 | sdata->dev->name, reassoc ? "Rea" : "A", mgmt->sa, | ||
1456 | capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); | ||
1457 | |||
1458 | pos = mgmt->u.assoc_resp.variable; | ||
1459 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | ||
1460 | |||
1461 | if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && | ||
1462 | elems.timeout_int && elems.timeout_int_len == 5 && | ||
1463 | elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { | ||
1464 | u32 tu, ms; | ||
1465 | tu = get_unaligned_le32(elems.timeout_int + 1); | ||
1466 | ms = tu * 1024 / 1000; | ||
1467 | printk(KERN_DEBUG "%s: AP rejected association temporarily; " | ||
1468 | "comeback duration %u TU (%u ms)\n", | ||
1469 | sdata->dev->name, tu, ms); | ||
1470 | wk->timeout = jiffies + msecs_to_jiffies(ms); | ||
1471 | if (ms > IEEE80211_ASSOC_TIMEOUT) | ||
1472 | run_again(ifmgd, jiffies + msecs_to_jiffies(ms)); | ||
1473 | return RX_MGMT_NONE; | ||
1474 | } | ||
1475 | |||
1476 | if (status_code != WLAN_STATUS_SUCCESS) { | ||
1477 | printk(KERN_DEBUG "%s: AP denied association (code=%d)\n", | ||
1478 | sdata->dev->name, status_code); | ||
1479 | wk->state = IEEE80211_MGD_STATE_IDLE; | ||
1480 | return RX_MGMT_CFG80211_ASSOC; | ||
1481 | } | ||
1482 | 1023 | ||
1483 | if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) | 1024 | if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) |
1484 | printk(KERN_DEBUG "%s: invalid aid value %d; bits 15:14 not " | 1025 | printk(KERN_DEBUG "%s: invalid aid value %d; bits 15:14 not " |
1485 | "set\n", sdata->dev->name, aid); | 1026 | "set\n", sdata->name, aid); |
1486 | aid &= ~(BIT(15) | BIT(14)); | 1027 | aid &= ~(BIT(15) | BIT(14)); |
1487 | 1028 | ||
1029 | pos = mgmt->u.assoc_resp.variable; | ||
1030 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | ||
1031 | |||
1488 | if (!elems.supp_rates) { | 1032 | if (!elems.supp_rates) { |
1489 | printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n", | 1033 | printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n", |
1490 | sdata->dev->name); | 1034 | sdata->name); |
1491 | return RX_MGMT_NONE; | 1035 | return false; |
1492 | } | 1036 | } |
1493 | 1037 | ||
1494 | printk(KERN_DEBUG "%s: associated\n", sdata->dev->name); | ||
1495 | ifmgd->aid = aid; | 1038 | ifmgd->aid = aid; |
1496 | 1039 | ||
1497 | rcu_read_lock(); | 1040 | sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL); |
1498 | |||
1499 | /* Add STA entry for the AP */ | ||
1500 | sta = sta_info_get(local, wk->bss->cbss.bssid); | ||
1501 | if (!sta) { | 1041 | if (!sta) { |
1502 | newsta = true; | 1042 | printk(KERN_DEBUG "%s: failed to alloc STA entry for" |
1503 | 1043 | " the AP\n", sdata->name); | |
1504 | rcu_read_unlock(); | 1044 | return false; |
1505 | |||
1506 | sta = sta_info_alloc(sdata, wk->bss->cbss.bssid, GFP_KERNEL); | ||
1507 | if (!sta) { | ||
1508 | printk(KERN_DEBUG "%s: failed to alloc STA entry for" | ||
1509 | " the AP\n", sdata->dev->name); | ||
1510 | return RX_MGMT_NONE; | ||
1511 | } | ||
1512 | |||
1513 | set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC | | ||
1514 | WLAN_STA_ASSOC_AP); | ||
1515 | if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) | ||
1516 | set_sta_flags(sta, WLAN_STA_AUTHORIZED); | ||
1517 | |||
1518 | rcu_read_lock(); | ||
1519 | } | 1045 | } |
1520 | 1046 | ||
1047 | set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC | | ||
1048 | WLAN_STA_ASSOC_AP); | ||
1049 | if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) | ||
1050 | set_sta_flags(sta, WLAN_STA_AUTHORIZED); | ||
1051 | |||
1521 | rates = 0; | 1052 | rates = 0; |
1522 | basic_rates = 0; | 1053 | basic_rates = 0; |
1523 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 1054 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
@@ -1580,40 +1111,40 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1580 | if (elems.wmm_param) | 1111 | if (elems.wmm_param) |
1581 | set_sta_flags(sta, WLAN_STA_WME); | 1112 | set_sta_flags(sta, WLAN_STA_WME); |
1582 | 1113 | ||
1583 | if (newsta) { | 1114 | err = sta_info_insert(sta); |
1584 | int err = sta_info_insert(sta); | 1115 | sta = NULL; |
1585 | if (err) { | 1116 | if (err) { |
1586 | printk(KERN_DEBUG "%s: failed to insert STA entry for" | 1117 | printk(KERN_DEBUG "%s: failed to insert STA entry for" |
1587 | " the AP (error %d)\n", sdata->dev->name, err); | 1118 | " the AP (error %d)\n", sdata->name, err); |
1588 | rcu_read_unlock(); | 1119 | return false; |
1589 | return RX_MGMT_NONE; | ||
1590 | } | ||
1591 | } | 1120 | } |
1592 | 1121 | ||
1593 | rcu_read_unlock(); | ||
1594 | |||
1595 | if (elems.wmm_param) | 1122 | if (elems.wmm_param) |
1596 | ieee80211_sta_wmm_params(local, ifmgd, elems.wmm_param, | 1123 | ieee80211_sta_wmm_params(local, ifmgd, elems.wmm_param, |
1597 | elems.wmm_param_len); | 1124 | elems.wmm_param_len); |
1598 | else | 1125 | else |
1599 | ieee80211_set_wmm_default(sdata); | 1126 | ieee80211_set_wmm_default(sdata); |
1600 | 1127 | ||
1128 | local->oper_channel = wk->chan; | ||
1129 | |||
1601 | if (elems.ht_info_elem && elems.wmm_param && | 1130 | if (elems.ht_info_elem && elems.wmm_param && |
1602 | (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && | 1131 | (sdata->local->hw.queues >= 4) && |
1603 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) | 1132 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
1604 | changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, | 1133 | changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, |
1605 | wk->bss->cbss.bssid, | 1134 | cbss->bssid, ap_ht_cap_flags); |
1606 | ap_ht_cap_flags); | ||
1607 | |||
1608 | /* delete work item -- must be before set_associated for PS */ | ||
1609 | list_del(&wk->list); | ||
1610 | 1135 | ||
1611 | /* set AID and assoc capability, | 1136 | /* set AID and assoc capability, |
1612 | * ieee80211_set_associated() will tell the driver */ | 1137 | * ieee80211_set_associated() will tell the driver */ |
1613 | bss_conf->aid = aid; | 1138 | bss_conf->aid = aid; |
1614 | bss_conf->assoc_capability = capab_info; | 1139 | bss_conf->assoc_capability = capab_info; |
1615 | /* this will take ownership of wk */ | 1140 | ieee80211_set_associated(sdata, cbss, changed); |
1616 | ieee80211_set_associated(sdata, wk, changed); | 1141 | |
1142 | /* | ||
1143 | * If we're using 4-addr mode, let the AP know that we're | ||
1144 | * doing so, so that it can create the STA VLAN on its side | ||
1145 | */ | ||
1146 | if (ifmgd->use_4addr) | ||
1147 | ieee80211_send_4addr_nullfunc(local, sdata); | ||
1617 | 1148 | ||
1618 | /* | 1149 | /* |
1619 | * Start timer to probe the connection to the AP now. | 1150 | * Start timer to probe the connection to the AP now. |
@@ -1622,7 +1153,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1622 | ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt); | 1153 | ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt); |
1623 | mod_beacon_timer(sdata); | 1154 | mod_beacon_timer(sdata); |
1624 | 1155 | ||
1625 | return RX_MGMT_CFG80211_ASSOC; | 1156 | return true; |
1626 | } | 1157 | } |
1627 | 1158 | ||
1628 | 1159 | ||
@@ -1657,7 +1188,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
1657 | return; | 1188 | return; |
1658 | 1189 | ||
1659 | if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) && | 1190 | if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) && |
1660 | (memcmp(mgmt->bssid, sdata->u.mgd.associated->cbss.bssid, | 1191 | (memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, |
1661 | ETH_ALEN) == 0)) { | 1192 | ETH_ALEN) == 0)) { |
1662 | struct ieee80211_channel_sw_ie *sw_elem = | 1193 | struct ieee80211_channel_sw_ie *sw_elem = |
1663 | (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem; | 1194 | (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem; |
@@ -1667,19 +1198,19 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
1667 | 1198 | ||
1668 | 1199 | ||
1669 | static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | 1200 | static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, |
1670 | struct ieee80211_mgd_work *wk, | 1201 | struct sk_buff *skb) |
1671 | struct ieee80211_mgmt *mgmt, size_t len, | ||
1672 | struct ieee80211_rx_status *rx_status) | ||
1673 | { | 1202 | { |
1203 | struct ieee80211_mgmt *mgmt = (void *)skb->data; | ||
1674 | struct ieee80211_if_managed *ifmgd; | 1204 | struct ieee80211_if_managed *ifmgd; |
1675 | size_t baselen; | 1205 | struct ieee80211_rx_status *rx_status = (void *) skb->cb; |
1206 | size_t baselen, len = skb->len; | ||
1676 | struct ieee802_11_elems elems; | 1207 | struct ieee802_11_elems elems; |
1677 | 1208 | ||
1678 | ifmgd = &sdata->u.mgd; | 1209 | ifmgd = &sdata->u.mgd; |
1679 | 1210 | ||
1680 | ASSERT_MGD_MTX(ifmgd); | 1211 | ASSERT_MGD_MTX(ifmgd); |
1681 | 1212 | ||
1682 | if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) | 1213 | if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) |
1683 | return; /* ignore ProbeResp to foreign address */ | 1214 | return; /* ignore ProbeResp to foreign address */ |
1684 | 1215 | ||
1685 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; | 1216 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; |
@@ -1691,17 +1222,8 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | |||
1691 | 1222 | ||
1692 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); | 1223 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); |
1693 | 1224 | ||
1694 | /* direct probe may be part of the association flow */ | ||
1695 | if (wk && wk->state == IEEE80211_MGD_STATE_PROBE) { | ||
1696 | printk(KERN_DEBUG "%s: direct probe responded\n", | ||
1697 | sdata->dev->name); | ||
1698 | wk->tries = 0; | ||
1699 | wk->state = IEEE80211_MGD_STATE_AUTH; | ||
1700 | WARN_ON(ieee80211_authenticate(sdata, wk) != RX_MGMT_NONE); | ||
1701 | } | ||
1702 | |||
1703 | if (ifmgd->associated && | 1225 | if (ifmgd->associated && |
1704 | memcmp(mgmt->bssid, ifmgd->associated->cbss.bssid, ETH_ALEN) == 0 && | 1226 | memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0 && |
1705 | ifmgd->flags & (IEEE80211_STA_BEACON_POLL | | 1227 | ifmgd->flags & (IEEE80211_STA_BEACON_POLL | |
1706 | IEEE80211_STA_CONNECTION_POLL)) { | 1228 | IEEE80211_STA_CONNECTION_POLL)) { |
1707 | ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | | 1229 | ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | |
@@ -1774,7 +1296,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
1774 | if (!ifmgd->associated) | 1296 | if (!ifmgd->associated) |
1775 | return; | 1297 | return; |
1776 | 1298 | ||
1777 | bssid = ifmgd->associated->cbss.bssid; | 1299 | bssid = ifmgd->associated->bssid; |
1778 | 1300 | ||
1779 | /* | 1301 | /* |
1780 | * And in theory even frames from a different AP we were just | 1302 | * And in theory even frames from a different AP we were just |
@@ -1787,7 +1309,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
1787 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 1309 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
1788 | if (net_ratelimit()) { | 1310 | if (net_ratelimit()) { |
1789 | printk(KERN_DEBUG "%s: cancelling probereq poll due " | 1311 | printk(KERN_DEBUG "%s: cancelling probereq poll due " |
1790 | "to a received beacon\n", sdata->dev->name); | 1312 | "to a received beacon\n", sdata->name); |
1791 | } | 1313 | } |
1792 | #endif | 1314 | #endif |
1793 | ifmgd->flags &= ~IEEE80211_STA_BEACON_POLL; | 1315 | ifmgd->flags &= ~IEEE80211_STA_BEACON_POLL; |
@@ -1865,7 +1387,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
1865 | 1387 | ||
1866 | rcu_read_lock(); | 1388 | rcu_read_lock(); |
1867 | 1389 | ||
1868 | sta = sta_info_get(local, bssid); | 1390 | sta = sta_info_get(sdata, bssid); |
1869 | if (WARN_ON(!sta)) { | 1391 | if (WARN_ON(!sta)) { |
1870 | rcu_read_unlock(); | 1392 | rcu_read_unlock(); |
1871 | return; | 1393 | return; |
@@ -1913,9 +1435,6 @@ ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, | |||
1913 | switch (fc & IEEE80211_FCTL_STYPE) { | 1435 | switch (fc & IEEE80211_FCTL_STYPE) { |
1914 | case IEEE80211_STYPE_PROBE_RESP: | 1436 | case IEEE80211_STYPE_PROBE_RESP: |
1915 | case IEEE80211_STYPE_BEACON: | 1437 | case IEEE80211_STYPE_BEACON: |
1916 | case IEEE80211_STYPE_AUTH: | ||
1917 | case IEEE80211_STYPE_ASSOC_RESP: | ||
1918 | case IEEE80211_STYPE_REASSOC_RESP: | ||
1919 | case IEEE80211_STYPE_DEAUTH: | 1438 | case IEEE80211_STYPE_DEAUTH: |
1920 | case IEEE80211_STYPE_DISASSOC: | 1439 | case IEEE80211_STYPE_DISASSOC: |
1921 | case IEEE80211_STYPE_ACTION: | 1440 | case IEEE80211_STYPE_ACTION: |
@@ -1933,7 +1452,6 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
1933 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1452 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1934 | struct ieee80211_rx_status *rx_status; | 1453 | struct ieee80211_rx_status *rx_status; |
1935 | struct ieee80211_mgmt *mgmt; | 1454 | struct ieee80211_mgmt *mgmt; |
1936 | struct ieee80211_mgd_work *wk; | ||
1937 | enum rx_mgmt_action rma = RX_MGMT_NONE; | 1455 | enum rx_mgmt_action rma = RX_MGMT_NONE; |
1938 | u16 fc; | 1456 | u16 fc; |
1939 | 1457 | ||
@@ -1944,20 +1462,17 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
1944 | mutex_lock(&ifmgd->mtx); | 1462 | mutex_lock(&ifmgd->mtx); |
1945 | 1463 | ||
1946 | if (ifmgd->associated && | 1464 | if (ifmgd->associated && |
1947 | memcmp(ifmgd->associated->cbss.bssid, mgmt->bssid, | 1465 | memcmp(ifmgd->associated->bssid, mgmt->bssid, ETH_ALEN) == 0) { |
1948 | ETH_ALEN) == 0) { | ||
1949 | switch (fc & IEEE80211_FCTL_STYPE) { | 1466 | switch (fc & IEEE80211_FCTL_STYPE) { |
1950 | case IEEE80211_STYPE_BEACON: | 1467 | case IEEE80211_STYPE_BEACON: |
1951 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, | 1468 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, |
1952 | rx_status); | 1469 | rx_status); |
1953 | break; | 1470 | break; |
1954 | case IEEE80211_STYPE_PROBE_RESP: | 1471 | case IEEE80211_STYPE_PROBE_RESP: |
1955 | ieee80211_rx_mgmt_probe_resp(sdata, NULL, mgmt, | 1472 | ieee80211_rx_mgmt_probe_resp(sdata, skb); |
1956 | skb->len, rx_status); | ||
1957 | break; | 1473 | break; |
1958 | case IEEE80211_STYPE_DEAUTH: | 1474 | case IEEE80211_STYPE_DEAUTH: |
1959 | rma = ieee80211_rx_mgmt_deauth(sdata, NULL, | 1475 | rma = ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); |
1960 | mgmt, skb->len); | ||
1961 | break; | 1476 | break; |
1962 | case IEEE80211_STYPE_DISASSOC: | 1477 | case IEEE80211_STYPE_DISASSOC: |
1963 | rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); | 1478 | rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); |
@@ -1968,7 +1483,7 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
1968 | 1483 | ||
1969 | ieee80211_sta_process_chanswitch(sdata, | 1484 | ieee80211_sta_process_chanswitch(sdata, |
1970 | &mgmt->u.action.u.chan_switch.sw_elem, | 1485 | &mgmt->u.action.u.chan_switch.sw_elem, |
1971 | ifmgd->associated); | 1486 | (void *)ifmgd->associated->priv); |
1972 | break; | 1487 | break; |
1973 | } | 1488 | } |
1974 | mutex_unlock(&ifmgd->mtx); | 1489 | mutex_unlock(&ifmgd->mtx); |
@@ -1989,58 +1504,11 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
1989 | goto out; | 1504 | goto out; |
1990 | } | 1505 | } |
1991 | 1506 | ||
1992 | list_for_each_entry(wk, &ifmgd->work_list, list) { | ||
1993 | if (memcmp(wk->bss->cbss.bssid, mgmt->bssid, ETH_ALEN) != 0) | ||
1994 | continue; | ||
1995 | |||
1996 | switch (fc & IEEE80211_FCTL_STYPE) { | ||
1997 | case IEEE80211_STYPE_PROBE_RESP: | ||
1998 | ieee80211_rx_mgmt_probe_resp(sdata, wk, mgmt, skb->len, | ||
1999 | rx_status); | ||
2000 | break; | ||
2001 | case IEEE80211_STYPE_AUTH: | ||
2002 | rma = ieee80211_rx_mgmt_auth(sdata, wk, mgmt, skb->len); | ||
2003 | break; | ||
2004 | case IEEE80211_STYPE_ASSOC_RESP: | ||
2005 | rma = ieee80211_rx_mgmt_assoc_resp(sdata, wk, mgmt, | ||
2006 | skb->len, false); | ||
2007 | break; | ||
2008 | case IEEE80211_STYPE_REASSOC_RESP: | ||
2009 | rma = ieee80211_rx_mgmt_assoc_resp(sdata, wk, mgmt, | ||
2010 | skb->len, true); | ||
2011 | break; | ||
2012 | case IEEE80211_STYPE_DEAUTH: | ||
2013 | rma = ieee80211_rx_mgmt_deauth(sdata, wk, mgmt, | ||
2014 | skb->len); | ||
2015 | break; | ||
2016 | } | ||
2017 | /* | ||
2018 | * We've processed this frame for that work, so it can't | ||
2019 | * belong to another work struct. | ||
2020 | * NB: this is also required for correctness because the | ||
2021 | * called functions can free 'wk', and for 'rma'! | ||
2022 | */ | ||
2023 | break; | ||
2024 | } | ||
2025 | |||
2026 | mutex_unlock(&ifmgd->mtx); | 1507 | mutex_unlock(&ifmgd->mtx); |
2027 | 1508 | ||
2028 | switch (rma) { | 1509 | if (skb->len >= 24 + 2 /* mgmt + deauth reason */ && |
2029 | case RX_MGMT_NONE: | 1510 | (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_DEAUTH) |
2030 | /* no action */ | ||
2031 | break; | ||
2032 | case RX_MGMT_CFG80211_AUTH: | ||
2033 | cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, skb->len); | ||
2034 | break; | ||
2035 | case RX_MGMT_CFG80211_ASSOC: | ||
2036 | cfg80211_send_rx_assoc(sdata->dev, (u8 *) mgmt, skb->len); | ||
2037 | break; | ||
2038 | case RX_MGMT_CFG80211_DEAUTH: | ||
2039 | cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); | 1511 | cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); |
2040 | break; | ||
2041 | default: | ||
2042 | WARN(1, "unexpected: %d", rma); | ||
2043 | } | ||
2044 | 1512 | ||
2045 | out: | 1513 | out: |
2046 | kfree_skb(skb); | 1514 | kfree_skb(skb); |
@@ -2068,12 +1536,8 @@ static void ieee80211_sta_work(struct work_struct *work) | |||
2068 | struct ieee80211_local *local = sdata->local; | 1536 | struct ieee80211_local *local = sdata->local; |
2069 | struct ieee80211_if_managed *ifmgd; | 1537 | struct ieee80211_if_managed *ifmgd; |
2070 | struct sk_buff *skb; | 1538 | struct sk_buff *skb; |
2071 | struct ieee80211_mgd_work *wk, *tmp; | ||
2072 | LIST_HEAD(free_work); | ||
2073 | enum rx_mgmt_action rma; | ||
2074 | bool anybusy = false; | ||
2075 | 1539 | ||
2076 | if (!netif_running(sdata->dev)) | 1540 | if (!ieee80211_sdata_running(sdata)) |
2077 | return; | 1541 | return; |
2078 | 1542 | ||
2079 | if (local->scanning) | 1543 | if (local->scanning) |
@@ -2104,7 +1568,7 @@ static void ieee80211_sta_work(struct work_struct *work) | |||
2104 | ifmgd->associated) { | 1568 | ifmgd->associated) { |
2105 | u8 bssid[ETH_ALEN]; | 1569 | u8 bssid[ETH_ALEN]; |
2106 | 1570 | ||
2107 | memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); | 1571 | memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN); |
2108 | if (time_is_after_jiffies(ifmgd->probe_timeout)) | 1572 | if (time_is_after_jiffies(ifmgd->probe_timeout)) |
2109 | run_again(ifmgd, ifmgd->probe_timeout); | 1573 | run_again(ifmgd, ifmgd->probe_timeout); |
2110 | 1574 | ||
@@ -2126,7 +1590,7 @@ static void ieee80211_sta_work(struct work_struct *work) | |||
2126 | printk(KERN_DEBUG "No probe response from AP %pM" | 1590 | printk(KERN_DEBUG "No probe response from AP %pM" |
2127 | " after %dms, disconnecting.\n", | 1591 | " after %dms, disconnecting.\n", |
2128 | bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); | 1592 | bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); |
2129 | ieee80211_set_disassoc(sdata, true); | 1593 | ieee80211_set_disassoc(sdata); |
2130 | ieee80211_recalc_idle(local); | 1594 | ieee80211_recalc_idle(local); |
2131 | mutex_unlock(&ifmgd->mtx); | 1595 | mutex_unlock(&ifmgd->mtx); |
2132 | /* | 1596 | /* |
@@ -2141,87 +1605,7 @@ static void ieee80211_sta_work(struct work_struct *work) | |||
2141 | } | 1605 | } |
2142 | } | 1606 | } |
2143 | 1607 | ||
2144 | |||
2145 | ieee80211_recalc_idle(local); | ||
2146 | |||
2147 | list_for_each_entry_safe(wk, tmp, &ifmgd->work_list, list) { | ||
2148 | if (time_is_after_jiffies(wk->timeout)) { | ||
2149 | /* | ||
2150 | * This work item isn't supposed to be worked on | ||
2151 | * right now, but take care to adjust the timer | ||
2152 | * properly. | ||
2153 | */ | ||
2154 | run_again(ifmgd, wk->timeout); | ||
2155 | continue; | ||
2156 | } | ||
2157 | |||
2158 | switch (wk->state) { | ||
2159 | default: | ||
2160 | WARN_ON(1); | ||
2161 | /* fall through */ | ||
2162 | case IEEE80211_MGD_STATE_IDLE: | ||
2163 | /* nothing */ | ||
2164 | rma = RX_MGMT_NONE; | ||
2165 | break; | ||
2166 | case IEEE80211_MGD_STATE_PROBE: | ||
2167 | rma = ieee80211_direct_probe(sdata, wk); | ||
2168 | break; | ||
2169 | case IEEE80211_MGD_STATE_AUTH: | ||
2170 | rma = ieee80211_authenticate(sdata, wk); | ||
2171 | break; | ||
2172 | case IEEE80211_MGD_STATE_ASSOC: | ||
2173 | rma = ieee80211_associate(sdata, wk); | ||
2174 | break; | ||
2175 | } | ||
2176 | |||
2177 | switch (rma) { | ||
2178 | case RX_MGMT_NONE: | ||
2179 | /* no action required */ | ||
2180 | break; | ||
2181 | case RX_MGMT_CFG80211_AUTH_TO: | ||
2182 | case RX_MGMT_CFG80211_ASSOC_TO: | ||
2183 | list_del(&wk->list); | ||
2184 | list_add(&wk->list, &free_work); | ||
2185 | wk->tries = rma; /* small abuse but only local */ | ||
2186 | break; | ||
2187 | default: | ||
2188 | WARN(1, "unexpected: %d", rma); | ||
2189 | } | ||
2190 | } | ||
2191 | |||
2192 | list_for_each_entry(wk, &ifmgd->work_list, list) { | ||
2193 | if (wk->state != IEEE80211_MGD_STATE_IDLE) { | ||
2194 | anybusy = true; | ||
2195 | break; | ||
2196 | } | ||
2197 | } | ||
2198 | if (!anybusy && | ||
2199 | test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) | ||
2200 | ieee80211_queue_delayed_work(&local->hw, | ||
2201 | &local->scan_work, | ||
2202 | round_jiffies_relative(0)); | ||
2203 | |||
2204 | mutex_unlock(&ifmgd->mtx); | 1608 | mutex_unlock(&ifmgd->mtx); |
2205 | |||
2206 | list_for_each_entry_safe(wk, tmp, &free_work, list) { | ||
2207 | switch (wk->tries) { | ||
2208 | case RX_MGMT_CFG80211_AUTH_TO: | ||
2209 | cfg80211_send_auth_timeout(sdata->dev, | ||
2210 | wk->bss->cbss.bssid); | ||
2211 | break; | ||
2212 | case RX_MGMT_CFG80211_ASSOC_TO: | ||
2213 | cfg80211_send_assoc_timeout(sdata->dev, | ||
2214 | wk->bss->cbss.bssid); | ||
2215 | break; | ||
2216 | default: | ||
2217 | WARN(1, "unexpected: %d", wk->tries); | ||
2218 | } | ||
2219 | |||
2220 | list_del(&wk->list); | ||
2221 | kfree(wk); | ||
2222 | } | ||
2223 | |||
2224 | ieee80211_recalc_idle(local); | ||
2225 | } | 1609 | } |
2226 | 1610 | ||
2227 | static void ieee80211_sta_bcn_mon_timer(unsigned long data) | 1611 | static void ieee80211_sta_bcn_mon_timer(unsigned long data) |
@@ -2330,14 +1714,14 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) | |||
2330 | (unsigned long) sdata); | 1714 | (unsigned long) sdata); |
2331 | skb_queue_head_init(&ifmgd->skb_queue); | 1715 | skb_queue_head_init(&ifmgd->skb_queue); |
2332 | 1716 | ||
2333 | INIT_LIST_HEAD(&ifmgd->work_list); | ||
2334 | |||
2335 | ifmgd->capab = WLAN_CAPABILITY_ESS; | ||
2336 | ifmgd->flags = 0; | 1717 | ifmgd->flags = 0; |
2337 | if (sdata->local->hw.queues >= 4) | ||
2338 | ifmgd->flags |= IEEE80211_STA_WMM_ENABLED; | ||
2339 | 1718 | ||
2340 | mutex_init(&ifmgd->mtx); | 1719 | mutex_init(&ifmgd->mtx); |
1720 | |||
1721 | if (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) | ||
1722 | ifmgd->req_smps = IEEE80211_SMPS_AUTOMATIC; | ||
1723 | else | ||
1724 | ifmgd->req_smps = IEEE80211_SMPS_OFF; | ||
2341 | } | 1725 | } |
2342 | 1726 | ||
2343 | /* scan finished notification */ | 1727 | /* scan finished notification */ |
@@ -2368,12 +1752,34 @@ int ieee80211_max_network_latency(struct notifier_block *nb, | |||
2368 | } | 1752 | } |
2369 | 1753 | ||
2370 | /* config hooks */ | 1754 | /* config hooks */ |
1755 | static enum work_done_result | ||
1756 | ieee80211_probe_auth_done(struct ieee80211_work *wk, | ||
1757 | struct sk_buff *skb) | ||
1758 | { | ||
1759 | if (!skb) { | ||
1760 | cfg80211_send_auth_timeout(wk->sdata->dev, wk->filter_ta); | ||
1761 | return WORK_DONE_DESTROY; | ||
1762 | } | ||
1763 | |||
1764 | if (wk->type == IEEE80211_WORK_AUTH) { | ||
1765 | cfg80211_send_rx_auth(wk->sdata->dev, skb->data, skb->len); | ||
1766 | return WORK_DONE_DESTROY; | ||
1767 | } | ||
1768 | |||
1769 | mutex_lock(&wk->sdata->u.mgd.mtx); | ||
1770 | ieee80211_rx_mgmt_probe_resp(wk->sdata, skb); | ||
1771 | mutex_unlock(&wk->sdata->u.mgd.mtx); | ||
1772 | |||
1773 | wk->type = IEEE80211_WORK_AUTH; | ||
1774 | wk->probe_auth.tries = 0; | ||
1775 | return WORK_DONE_REQUEUE; | ||
1776 | } | ||
1777 | |||
2371 | int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, | 1778 | int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, |
2372 | struct cfg80211_auth_request *req) | 1779 | struct cfg80211_auth_request *req) |
2373 | { | 1780 | { |
2374 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
2375 | const u8 *ssid; | 1781 | const u8 *ssid; |
2376 | struct ieee80211_mgd_work *wk; | 1782 | struct ieee80211_work *wk; |
2377 | u16 auth_alg; | 1783 | u16 auth_alg; |
2378 | 1784 | ||
2379 | switch (req->auth_type) { | 1785 | switch (req->auth_type) { |
@@ -2397,7 +1803,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, | |||
2397 | if (!wk) | 1803 | if (!wk) |
2398 | return -ENOMEM; | 1804 | return -ENOMEM; |
2399 | 1805 | ||
2400 | wk->bss = (void *)req->bss; | 1806 | memcpy(wk->filter_ta, req->bss->bssid, ETH_ALEN); |
2401 | 1807 | ||
2402 | if (req->ie && req->ie_len) { | 1808 | if (req->ie && req->ie_len) { |
2403 | memcpy(wk->ie, req->ie, req->ie_len); | 1809 | memcpy(wk->ie, req->ie, req->ie_len); |
@@ -2405,66 +1811,76 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, | |||
2405 | } | 1811 | } |
2406 | 1812 | ||
2407 | if (req->key && req->key_len) { | 1813 | if (req->key && req->key_len) { |
2408 | wk->key_len = req->key_len; | 1814 | wk->probe_auth.key_len = req->key_len; |
2409 | wk->key_idx = req->key_idx; | 1815 | wk->probe_auth.key_idx = req->key_idx; |
2410 | memcpy(wk->key, req->key, req->key_len); | 1816 | memcpy(wk->probe_auth.key, req->key, req->key_len); |
2411 | } | 1817 | } |
2412 | 1818 | ||
2413 | ssid = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); | 1819 | ssid = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); |
2414 | memcpy(wk->ssid, ssid + 2, ssid[1]); | 1820 | memcpy(wk->probe_auth.ssid, ssid + 2, ssid[1]); |
2415 | wk->ssid_len = ssid[1]; | 1821 | wk->probe_auth.ssid_len = ssid[1]; |
2416 | 1822 | ||
2417 | wk->state = IEEE80211_MGD_STATE_PROBE; | 1823 | wk->probe_auth.algorithm = auth_alg; |
2418 | wk->auth_alg = auth_alg; | 1824 | wk->probe_auth.privacy = req->bss->capability & WLAN_CAPABILITY_PRIVACY; |
2419 | wk->timeout = jiffies; /* run right away */ | ||
2420 | 1825 | ||
2421 | /* | 1826 | wk->type = IEEE80211_WORK_DIRECT_PROBE; |
2422 | * XXX: if still associated need to tell AP that we're going | 1827 | wk->chan = req->bss->channel; |
2423 | * to sleep and then change channel etc. | 1828 | wk->sdata = sdata; |
2424 | */ | 1829 | wk->done = ieee80211_probe_auth_done; |
2425 | sdata->local->oper_channel = req->bss->channel; | ||
2426 | ieee80211_hw_config(sdata->local, 0); | ||
2427 | |||
2428 | mutex_lock(&ifmgd->mtx); | ||
2429 | list_add(&wk->list, &sdata->u.mgd.work_list); | ||
2430 | mutex_unlock(&ifmgd->mtx); | ||
2431 | 1830 | ||
2432 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.work); | 1831 | ieee80211_add_work(wk); |
2433 | return 0; | 1832 | return 0; |
2434 | } | 1833 | } |
2435 | 1834 | ||
2436 | int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | 1835 | static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, |
2437 | struct cfg80211_assoc_request *req) | 1836 | struct sk_buff *skb) |
2438 | { | 1837 | { |
2439 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1838 | struct ieee80211_mgmt *mgmt; |
2440 | struct ieee80211_mgd_work *wk, *found = NULL; | 1839 | u16 status; |
2441 | int i, err; | ||
2442 | 1840 | ||
2443 | mutex_lock(&ifmgd->mtx); | 1841 | if (!skb) { |
1842 | cfg80211_send_assoc_timeout(wk->sdata->dev, wk->filter_ta); | ||
1843 | return WORK_DONE_DESTROY; | ||
1844 | } | ||
2444 | 1845 | ||
2445 | list_for_each_entry(wk, &ifmgd->work_list, list) { | 1846 | mgmt = (void *)skb->data; |
2446 | if (&wk->bss->cbss == req->bss && | 1847 | status = le16_to_cpu(mgmt->u.assoc_resp.status_code); |
2447 | wk->state == IEEE80211_MGD_STATE_IDLE) { | 1848 | |
2448 | found = wk; | 1849 | if (status == WLAN_STATUS_SUCCESS) { |
2449 | break; | 1850 | mutex_lock(&wk->sdata->u.mgd.mtx); |
1851 | if (!ieee80211_assoc_success(wk, mgmt, skb->len)) { | ||
1852 | mutex_unlock(&wk->sdata->u.mgd.mtx); | ||
1853 | /* oops -- internal error -- send timeout for now */ | ||
1854 | cfg80211_send_assoc_timeout(wk->sdata->dev, | ||
1855 | wk->filter_ta); | ||
1856 | return WORK_DONE_DESTROY; | ||
2450 | } | 1857 | } |
1858 | mutex_unlock(&wk->sdata->u.mgd.mtx); | ||
2451 | } | 1859 | } |
2452 | 1860 | ||
2453 | if (!found) { | 1861 | cfg80211_send_rx_assoc(wk->sdata->dev, skb->data, skb->len); |
2454 | err = -ENOLINK; | 1862 | return WORK_DONE_DESTROY; |
2455 | goto out; | 1863 | } |
2456 | } | ||
2457 | 1864 | ||
2458 | list_del(&found->list); | 1865 | int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, |
1866 | struct cfg80211_assoc_request *req) | ||
1867 | { | ||
1868 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
1869 | struct ieee80211_bss *bss = (void *)req->bss->priv; | ||
1870 | struct ieee80211_work *wk; | ||
1871 | const u8 *ssid; | ||
1872 | int i; | ||
2459 | 1873 | ||
2460 | wk = krealloc(found, sizeof(*wk) + req->ie_len, GFP_KERNEL); | 1874 | mutex_lock(&ifmgd->mtx); |
2461 | if (!wk) { | 1875 | if (ifmgd->associated) { |
2462 | list_add(&found->list, &ifmgd->work_list); | 1876 | mutex_unlock(&ifmgd->mtx); |
2463 | err = -ENOMEM; | 1877 | return -EALREADY; |
2464 | goto out; | ||
2465 | } | 1878 | } |
1879 | mutex_unlock(&ifmgd->mtx); | ||
2466 | 1880 | ||
2467 | list_add(&wk->list, &ifmgd->work_list); | 1881 | wk = kzalloc(sizeof(*wk) + req->ie_len, GFP_KERNEL); |
1882 | if (!wk) | ||
1883 | return -ENOMEM; | ||
2468 | 1884 | ||
2469 | ifmgd->flags &= ~IEEE80211_STA_DISABLE_11N; | 1885 | ifmgd->flags &= ~IEEE80211_STA_DISABLE_11N; |
2470 | 1886 | ||
@@ -2474,8 +1890,6 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | |||
2474 | req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) | 1890 | req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) |
2475 | ifmgd->flags |= IEEE80211_STA_DISABLE_11N; | 1891 | ifmgd->flags |= IEEE80211_STA_DISABLE_11N; |
2476 | 1892 | ||
2477 | sdata->local->oper_channel = req->bss->channel; | ||
2478 | ieee80211_hw_config(sdata->local, 0); | ||
2479 | 1893 | ||
2480 | if (req->ie && req->ie_len) { | 1894 | if (req->ie && req->ie_len) { |
2481 | memcpy(wk->ie, req->ie, req->ie_len); | 1895 | memcpy(wk->ie, req->ie, req->ie_len); |
@@ -2483,12 +1897,55 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | |||
2483 | } else | 1897 | } else |
2484 | wk->ie_len = 0; | 1898 | wk->ie_len = 0; |
2485 | 1899 | ||
1900 | wk->assoc.bss = req->bss; | ||
1901 | |||
1902 | memcpy(wk->filter_ta, req->bss->bssid, ETH_ALEN); | ||
1903 | |||
1904 | /* new association always uses requested smps mode */ | ||
1905 | if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) { | ||
1906 | if (ifmgd->powersave) | ||
1907 | ifmgd->ap_smps = IEEE80211_SMPS_DYNAMIC; | ||
1908 | else | ||
1909 | ifmgd->ap_smps = IEEE80211_SMPS_OFF; | ||
1910 | } else | ||
1911 | ifmgd->ap_smps = ifmgd->req_smps; | ||
1912 | |||
1913 | wk->assoc.smps = ifmgd->ap_smps; | ||
1914 | /* | ||
1915 | * IEEE802.11n does not allow TKIP/WEP as pairwise ciphers in HT mode. | ||
1916 | * We still associate in non-HT mode (11a/b/g) if any one of these | ||
1917 | * ciphers is configured as pairwise. | ||
1918 | * We can set this to true for non-11n hardware, that'll be checked | ||
1919 | * separately along with the peer capabilities. | ||
1920 | */ | ||
1921 | wk->assoc.use_11n = !(ifmgd->flags & IEEE80211_STA_DISABLE_11N); | ||
1922 | wk->assoc.capability = req->bss->capability; | ||
1923 | wk->assoc.wmm_used = bss->wmm_used; | ||
1924 | wk->assoc.supp_rates = bss->supp_rates; | ||
1925 | wk->assoc.supp_rates_len = bss->supp_rates_len; | ||
1926 | wk->assoc.ht_information_ie = | ||
1927 | ieee80211_bss_get_ie(req->bss, WLAN_EID_HT_INFORMATION); | ||
1928 | |||
1929 | if (bss->wmm_used && bss->uapsd_supported && | ||
1930 | (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)) { | ||
1931 | wk->assoc.uapsd_used = true; | ||
1932 | ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; | ||
1933 | } else { | ||
1934 | wk->assoc.uapsd_used = false; | ||
1935 | ifmgd->flags &= ~IEEE80211_STA_UAPSD_ENABLED; | ||
1936 | } | ||
1937 | |||
1938 | ssid = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); | ||
1939 | memcpy(wk->assoc.ssid, ssid + 2, ssid[1]); | ||
1940 | wk->assoc.ssid_len = ssid[1]; | ||
1941 | |||
2486 | if (req->prev_bssid) | 1942 | if (req->prev_bssid) |
2487 | memcpy(wk->prev_bssid, req->prev_bssid, ETH_ALEN); | 1943 | memcpy(wk->assoc.prev_bssid, req->prev_bssid, ETH_ALEN); |
2488 | 1944 | ||
2489 | wk->state = IEEE80211_MGD_STATE_ASSOC; | 1945 | wk->type = IEEE80211_WORK_ASSOC; |
2490 | wk->tries = 0; | 1946 | wk->chan = req->bss->channel; |
2491 | wk->timeout = jiffies; /* run right away */ | 1947 | wk->sdata = sdata; |
1948 | wk->done = ieee80211_assoc_done; | ||
2492 | 1949 | ||
2493 | if (req->use_mfp) { | 1950 | if (req->use_mfp) { |
2494 | ifmgd->mfp = IEEE80211_MFP_REQUIRED; | 1951 | ifmgd->mfp = IEEE80211_MFP_REQUIRED; |
@@ -2503,69 +1960,59 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | |||
2503 | else | 1960 | else |
2504 | ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT; | 1961 | ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT; |
2505 | 1962 | ||
2506 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.work); | 1963 | ieee80211_add_work(wk); |
2507 | 1964 | return 0; | |
2508 | err = 0; | ||
2509 | |||
2510 | out: | ||
2511 | mutex_unlock(&ifmgd->mtx); | ||
2512 | return err; | ||
2513 | } | 1965 | } |
2514 | 1966 | ||
2515 | int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, | 1967 | int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, |
2516 | struct cfg80211_deauth_request *req, | 1968 | struct cfg80211_deauth_request *req, |
2517 | void *cookie) | 1969 | void *cookie) |
2518 | { | 1970 | { |
1971 | struct ieee80211_local *local = sdata->local; | ||
2519 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1972 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
2520 | struct ieee80211_mgd_work *wk; | 1973 | struct ieee80211_work *wk; |
2521 | const u8 *bssid = NULL; | 1974 | const u8 *bssid = req->bss->bssid; |
2522 | bool not_auth_yet = false; | ||
2523 | 1975 | ||
2524 | mutex_lock(&ifmgd->mtx); | 1976 | mutex_lock(&ifmgd->mtx); |
2525 | 1977 | ||
2526 | if (ifmgd->associated && &ifmgd->associated->cbss == req->bss) { | 1978 | if (ifmgd->associated == req->bss) { |
2527 | bssid = req->bss->bssid; | 1979 | bssid = req->bss->bssid; |
2528 | ieee80211_set_disassoc(sdata, true); | 1980 | ieee80211_set_disassoc(sdata); |
2529 | } else list_for_each_entry(wk, &ifmgd->work_list, list) { | 1981 | mutex_unlock(&ifmgd->mtx); |
2530 | if (&wk->bss->cbss == req->bss) { | 1982 | } else { |
2531 | bssid = req->bss->bssid; | 1983 | bool not_auth_yet = false; |
2532 | if (wk->state == IEEE80211_MGD_STATE_PROBE) | 1984 | |
2533 | not_auth_yet = true; | 1985 | mutex_unlock(&ifmgd->mtx); |
1986 | |||
1987 | mutex_lock(&local->work_mtx); | ||
1988 | list_for_each_entry(wk, &local->work_list, list) { | ||
1989 | if (wk->type != IEEE80211_WORK_DIRECT_PROBE) | ||
1990 | continue; | ||
1991 | if (memcmp(req->bss->bssid, wk->filter_ta, ETH_ALEN)) | ||
1992 | continue; | ||
1993 | not_auth_yet = true; | ||
2534 | list_del(&wk->list); | 1994 | list_del(&wk->list); |
2535 | kfree(wk); | 1995 | free_work(wk); |
2536 | break; | 1996 | break; |
2537 | } | 1997 | } |
2538 | } | 1998 | mutex_unlock(&local->work_mtx); |
2539 | |||
2540 | /* | ||
2541 | * If somebody requests authentication and we haven't | ||
2542 | * sent out an auth frame yet there's no need to send | ||
2543 | * out a deauth frame either. If the state was PROBE, | ||
2544 | * then this is the case. If it's AUTH we have sent a | ||
2545 | * frame, and if it's IDLE we have completed the auth | ||
2546 | * process already. | ||
2547 | */ | ||
2548 | if (not_auth_yet) { | ||
2549 | mutex_unlock(&ifmgd->mtx); | ||
2550 | __cfg80211_auth_canceled(sdata->dev, bssid); | ||
2551 | return 0; | ||
2552 | } | ||
2553 | 1999 | ||
2554 | /* | 2000 | /* |
2555 | * cfg80211 should catch this ... but it's racy since | 2001 | * If somebody requests authentication and we haven't |
2556 | * we can receive a deauth frame, process it, hand it | 2002 | * sent out an auth frame yet there's no need to send |
2557 | * to cfg80211 while that's in a locked section already | 2003 | * out a deauth frame either. If the state was PROBE, |
2558 | * trying to tell us that the user wants to disconnect. | 2004 | * then this is the case. If it's AUTH we have sent a |
2559 | */ | 2005 | * frame, and if it's IDLE we have completed the auth |
2560 | if (!bssid) { | 2006 | * process already. |
2561 | mutex_unlock(&ifmgd->mtx); | 2007 | */ |
2562 | return -ENOLINK; | 2008 | if (not_auth_yet) { |
2009 | __cfg80211_auth_canceled(sdata->dev, bssid); | ||
2010 | return 0; | ||
2011 | } | ||
2563 | } | 2012 | } |
2564 | 2013 | ||
2565 | mutex_unlock(&ifmgd->mtx); | ||
2566 | |||
2567 | printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n", | 2014 | printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n", |
2568 | sdata->dev->name, bssid, req->reason_code); | 2015 | sdata->name, bssid, req->reason_code); |
2569 | 2016 | ||
2570 | ieee80211_send_deauth_disassoc(sdata, bssid, | 2017 | ieee80211_send_deauth_disassoc(sdata, bssid, |
2571 | IEEE80211_STYPE_DEAUTH, req->reason_code, | 2018 | IEEE80211_STYPE_DEAUTH, req->reason_code, |
@@ -2590,15 +2037,15 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, | |||
2590 | * to cfg80211 while that's in a locked section already | 2037 | * to cfg80211 while that's in a locked section already |
2591 | * trying to tell us that the user wants to disconnect. | 2038 | * trying to tell us that the user wants to disconnect. |
2592 | */ | 2039 | */ |
2593 | if (&ifmgd->associated->cbss != req->bss) { | 2040 | if (ifmgd->associated != req->bss) { |
2594 | mutex_unlock(&ifmgd->mtx); | 2041 | mutex_unlock(&ifmgd->mtx); |
2595 | return -ENOLINK; | 2042 | return -ENOLINK; |
2596 | } | 2043 | } |
2597 | 2044 | ||
2598 | printk(KERN_DEBUG "%s: disassociating from %pM by local choice (reason=%d)\n", | 2045 | printk(KERN_DEBUG "%s: disassociating from %pM by local choice (reason=%d)\n", |
2599 | sdata->dev->name, req->bss->bssid, req->reason_code); | 2046 | sdata->name, req->bss->bssid, req->reason_code); |
2600 | 2047 | ||
2601 | ieee80211_set_disassoc(sdata, false); | 2048 | ieee80211_set_disassoc(sdata); |
2602 | 2049 | ||
2603 | mutex_unlock(&ifmgd->mtx); | 2050 | mutex_unlock(&ifmgd->mtx); |
2604 | 2051 | ||
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c new file mode 100644 index 000000000000..c36b1911987a --- /dev/null +++ b/net/mac80211/offchannel.c | |||
@@ -0,0 +1,170 @@ | |||
1 | /* | ||
2 | * Off-channel operation helpers | ||
3 | * | ||
4 | * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi> | ||
5 | * Copyright 2004, Instant802 Networks, Inc. | ||
6 | * Copyright 2005, Devicescape Software, Inc. | ||
7 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> | ||
8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> | ||
9 | * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | #include <net/mac80211.h> | ||
16 | #include "ieee80211_i.h" | ||
17 | |||
18 | /* | ||
19 | * inform AP that we will go to sleep so that it will buffer the frames | ||
20 | * while we scan | ||
21 | */ | ||
22 | static void ieee80211_offchannel_ps_enable(struct ieee80211_sub_if_data *sdata) | ||
23 | { | ||
24 | struct ieee80211_local *local = sdata->local; | ||
25 | |||
26 | local->offchannel_ps_enabled = false; | ||
27 | |||
28 | /* FIXME: what to do when local->pspolling is true? */ | ||
29 | |||
30 | del_timer_sync(&local->dynamic_ps_timer); | ||
31 | cancel_work_sync(&local->dynamic_ps_enable_work); | ||
32 | |||
33 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { | ||
34 | local->offchannel_ps_enabled = true; | ||
35 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; | ||
36 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | ||
37 | } | ||
38 | |||
39 | if (!(local->offchannel_ps_enabled) || | ||
40 | !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) | ||
41 | /* | ||
42 | * If power save was enabled, no need to send a nullfunc | ||
43 | * frame because AP knows that we are sleeping. But if the | ||
44 | * hardware is creating the nullfunc frame for power save | ||
45 | * status (ie. IEEE80211_HW_PS_NULLFUNC_STACK is not | ||
46 | * enabled) and power save was enabled, the firmware just | ||
47 | * sent a null frame with power save disabled. So we need | ||
48 | * to send a new nullfunc frame to inform the AP that we | ||
49 | * are again sleeping. | ||
50 | */ | ||
51 | ieee80211_send_nullfunc(local, sdata, 1); | ||
52 | } | ||
53 | |||
54 | /* inform AP that we are awake again, unless power save is enabled */ | ||
55 | static void ieee80211_offchannel_ps_disable(struct ieee80211_sub_if_data *sdata) | ||
56 | { | ||
57 | struct ieee80211_local *local = sdata->local; | ||
58 | |||
59 | if (!local->ps_sdata) | ||
60 | ieee80211_send_nullfunc(local, sdata, 0); | ||
61 | else if (local->offchannel_ps_enabled) { | ||
62 | /* | ||
63 | * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware | ||
64 | * will send a nullfunc frame with the powersave bit set | ||
65 | * even though the AP already knows that we are sleeping. | ||
66 | * This could be avoided by sending a null frame with power | ||
67 | * save bit disabled before enabling the power save, but | ||
68 | * this doesn't gain anything. | ||
69 | * | ||
70 | * When IEEE80211_HW_PS_NULLFUNC_STACK is enabled, no need | ||
71 | * to send a nullfunc frame because AP already knows that | ||
72 | * we are sleeping, let's just enable power save mode in | ||
73 | * hardware. | ||
74 | */ | ||
75 | local->hw.conf.flags |= IEEE80211_CONF_PS; | ||
76 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | ||
77 | } else if (local->hw.conf.dynamic_ps_timeout > 0) { | ||
78 | /* | ||
79 | * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer | ||
80 | * had been running before leaving the operating channel, | ||
81 | * restart the timer now and send a nullfunc frame to inform | ||
82 | * the AP that we are awake. | ||
83 | */ | ||
84 | ieee80211_send_nullfunc(local, sdata, 0); | ||
85 | mod_timer(&local->dynamic_ps_timer, jiffies + | ||
86 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void ieee80211_offchannel_stop_beaconing(struct ieee80211_local *local) | ||
91 | { | ||
92 | struct ieee80211_sub_if_data *sdata; | ||
93 | |||
94 | mutex_lock(&local->iflist_mtx); | ||
95 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
96 | if (!ieee80211_sdata_running(sdata)) | ||
97 | continue; | ||
98 | |||
99 | /* disable beaconing */ | ||
100 | if (sdata->vif.type == NL80211_IFTYPE_AP || | ||
101 | sdata->vif.type == NL80211_IFTYPE_ADHOC || | ||
102 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) | ||
103 | ieee80211_bss_info_change_notify( | ||
104 | sdata, BSS_CHANGED_BEACON_ENABLED); | ||
105 | |||
106 | /* | ||
107 | * only handle non-STA interfaces here, STA interfaces | ||
108 | * are handled in ieee80211_offchannel_stop_station(), | ||
109 | * e.g., from the background scan state machine. | ||
110 | * | ||
111 | * In addition, do not stop monitor interface to allow it to be | ||
112 | * used from user space controlled off-channel operations. | ||
113 | */ | ||
114 | if (sdata->vif.type != NL80211_IFTYPE_STATION && | ||
115 | sdata->vif.type != NL80211_IFTYPE_MONITOR) | ||
116 | netif_tx_stop_all_queues(sdata->dev); | ||
117 | } | ||
118 | mutex_unlock(&local->iflist_mtx); | ||
119 | } | ||
120 | |||
121 | void ieee80211_offchannel_stop_station(struct ieee80211_local *local) | ||
122 | { | ||
123 | struct ieee80211_sub_if_data *sdata; | ||
124 | |||
125 | /* | ||
126 | * notify the AP about us leaving the channel and stop all STA interfaces | ||
127 | */ | ||
128 | mutex_lock(&local->iflist_mtx); | ||
129 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
130 | if (!ieee80211_sdata_running(sdata)) | ||
131 | continue; | ||
132 | |||
133 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
134 | netif_tx_stop_all_queues(sdata->dev); | ||
135 | if (sdata->u.mgd.associated) | ||
136 | ieee80211_offchannel_ps_enable(sdata); | ||
137 | } | ||
138 | } | ||
139 | mutex_unlock(&local->iflist_mtx); | ||
140 | } | ||
141 | |||
142 | void ieee80211_offchannel_return(struct ieee80211_local *local, | ||
143 | bool enable_beaconing) | ||
144 | { | ||
145 | struct ieee80211_sub_if_data *sdata; | ||
146 | |||
147 | mutex_lock(&local->iflist_mtx); | ||
148 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
149 | if (!ieee80211_sdata_running(sdata)) | ||
150 | continue; | ||
151 | |||
152 | /* Tell AP we're back */ | ||
153 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
154 | if (sdata->u.mgd.associated) | ||
155 | ieee80211_offchannel_ps_disable(sdata); | ||
156 | } | ||
157 | |||
158 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) | ||
159 | netif_tx_wake_all_queues(sdata->dev); | ||
160 | |||
161 | /* re-enable beaconing */ | ||
162 | if (enable_beaconing && | ||
163 | (sdata->vif.type == NL80211_IFTYPE_AP || | ||
164 | sdata->vif.type == NL80211_IFTYPE_ADHOC || | ||
165 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT)) | ||
166 | ieee80211_bss_info_change_notify( | ||
167 | sdata, BSS_CHANGED_BEACON_ENABLED); | ||
168 | } | ||
169 | mutex_unlock(&local->iflist_mtx); | ||
170 | } | ||
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index e535f1c988fe..47f818959ad7 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c | |||
@@ -10,7 +10,6 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
10 | { | 10 | { |
11 | struct ieee80211_local *local = hw_to_local(hw); | 11 | struct ieee80211_local *local = hw_to_local(hw); |
12 | struct ieee80211_sub_if_data *sdata; | 12 | struct ieee80211_sub_if_data *sdata; |
13 | struct ieee80211_if_init_conf conf; | ||
14 | struct sta_info *sta; | 13 | struct sta_info *sta; |
15 | unsigned long flags; | 14 | unsigned long flags; |
16 | 15 | ||
@@ -65,7 +64,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
65 | struct ieee80211_sub_if_data, | 64 | struct ieee80211_sub_if_data, |
66 | u.ap); | 65 | u.ap); |
67 | 66 | ||
68 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_REMOVE, | 67 | drv_sta_notify(local, sdata, STA_NOTIFY_REMOVE, |
69 | &sta->sta); | 68 | &sta->sta); |
70 | } | 69 | } |
71 | 70 | ||
@@ -93,17 +92,14 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
93 | break; | 92 | break; |
94 | } | 93 | } |
95 | 94 | ||
96 | if (!netif_running(sdata->dev)) | 95 | if (!ieee80211_sdata_running(sdata)) |
97 | continue; | 96 | continue; |
98 | 97 | ||
99 | /* disable beaconing */ | 98 | /* disable beaconing */ |
100 | ieee80211_bss_info_change_notify(sdata, | 99 | ieee80211_bss_info_change_notify(sdata, |
101 | BSS_CHANGED_BEACON_ENABLED); | 100 | BSS_CHANGED_BEACON_ENABLED); |
102 | 101 | ||
103 | conf.vif = &sdata->vif; | 102 | drv_remove_interface(local, &sdata->vif); |
104 | conf.type = sdata->vif.type; | ||
105 | conf.mac_addr = sdata->dev->dev_addr; | ||
106 | drv_remove_interface(local, &conf); | ||
107 | } | 103 | } |
108 | 104 | ||
109 | /* stop hardware - this must stop RX */ | 105 | /* stop hardware - this must stop RX */ |
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index b9007f80cb92..c74b7c85403c 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c | |||
@@ -207,6 +207,27 @@ static bool rc_no_data_or_no_ack(struct ieee80211_tx_rate_control *txrc) | |||
207 | return ((info->flags & IEEE80211_TX_CTL_NO_ACK) || !ieee80211_is_data(fc)); | 207 | return ((info->flags & IEEE80211_TX_CTL_NO_ACK) || !ieee80211_is_data(fc)); |
208 | } | 208 | } |
209 | 209 | ||
210 | static void rc_send_low_broadcast(s8 *idx, u32 basic_rates, u8 max_rate_idx) | ||
211 | { | ||
212 | u8 i; | ||
213 | |||
214 | if (basic_rates == 0) | ||
215 | return; /* assume basic rates unknown and accept rate */ | ||
216 | if (*idx < 0) | ||
217 | return; | ||
218 | if (basic_rates & (1 << *idx)) | ||
219 | return; /* selected rate is a basic rate */ | ||
220 | |||
221 | for (i = *idx + 1; i <= max_rate_idx; i++) { | ||
222 | if (basic_rates & (1 << i)) { | ||
223 | *idx = i; | ||
224 | return; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | /* could not find a basic rate; use original selection */ | ||
229 | } | ||
230 | |||
210 | bool rate_control_send_low(struct ieee80211_sta *sta, | 231 | bool rate_control_send_low(struct ieee80211_sta *sta, |
211 | void *priv_sta, | 232 | void *priv_sta, |
212 | struct ieee80211_tx_rate_control *txrc) | 233 | struct ieee80211_tx_rate_control *txrc) |
@@ -218,12 +239,48 @@ bool rate_control_send_low(struct ieee80211_sta *sta, | |||
218 | info->control.rates[0].count = | 239 | info->control.rates[0].count = |
219 | (info->flags & IEEE80211_TX_CTL_NO_ACK) ? | 240 | (info->flags & IEEE80211_TX_CTL_NO_ACK) ? |
220 | 1 : txrc->hw->max_rate_tries; | 241 | 1 : txrc->hw->max_rate_tries; |
242 | if (!sta && txrc->ap) | ||
243 | rc_send_low_broadcast(&info->control.rates[0].idx, | ||
244 | txrc->bss_conf->basic_rates, | ||
245 | txrc->sband->n_bitrates); | ||
221 | return true; | 246 | return true; |
222 | } | 247 | } |
223 | return false; | 248 | return false; |
224 | } | 249 | } |
225 | EXPORT_SYMBOL(rate_control_send_low); | 250 | EXPORT_SYMBOL(rate_control_send_low); |
226 | 251 | ||
252 | static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, | ||
253 | int n_bitrates, u32 mask) | ||
254 | { | ||
255 | int j; | ||
256 | |||
257 | /* See whether the selected rate or anything below it is allowed. */ | ||
258 | for (j = rate->idx; j >= 0; j--) { | ||
259 | if (mask & (1 << j)) { | ||
260 | /* Okay, found a suitable rate. Use it. */ | ||
261 | rate->idx = j; | ||
262 | return; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | /* Try to find a higher rate that would be allowed */ | ||
267 | for (j = rate->idx + 1; j < n_bitrates; j++) { | ||
268 | if (mask & (1 << j)) { | ||
269 | /* Okay, found a suitable rate. Use it. */ | ||
270 | rate->idx = j; | ||
271 | return; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /* | ||
276 | * Uh.. No suitable rate exists. This should not really happen with | ||
277 | * sane TX rate mask configurations. However, should someone manage to | ||
278 | * configure supported rates and TX rate mask in incompatible way, | ||
279 | * allow the frame to be transmitted with whatever the rate control | ||
280 | * selected. | ||
281 | */ | ||
282 | } | ||
283 | |||
227 | void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | 284 | void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, |
228 | struct sta_info *sta, | 285 | struct sta_info *sta, |
229 | struct ieee80211_tx_rate_control *txrc) | 286 | struct ieee80211_tx_rate_control *txrc) |
@@ -233,6 +290,7 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | |||
233 | struct ieee80211_sta *ista = NULL; | 290 | struct ieee80211_sta *ista = NULL; |
234 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); | 291 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); |
235 | int i; | 292 | int i; |
293 | u32 mask; | ||
236 | 294 | ||
237 | if (sta) { | 295 | if (sta) { |
238 | ista = &sta->sta; | 296 | ista = &sta->sta; |
@@ -245,23 +303,31 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | |||
245 | info->control.rates[i].count = 1; | 303 | info->control.rates[i].count = 1; |
246 | } | 304 | } |
247 | 305 | ||
248 | if (sta && sdata->force_unicast_rateidx > -1) { | 306 | ref->ops->get_rate(ref->priv, ista, priv_sta, txrc); |
249 | info->control.rates[0].idx = sdata->force_unicast_rateidx; | ||
250 | } else { | ||
251 | ref->ops->get_rate(ref->priv, ista, priv_sta, txrc); | ||
252 | info->flags |= IEEE80211_TX_INTFL_RCALGO; | ||
253 | } | ||
254 | 307 | ||
255 | /* | 308 | /* |
256 | * try to enforce the maximum rate the user wanted | 309 | * Try to enforce the rateidx mask the user wanted. skip this if the |
310 | * default mask (allow all rates) is used to save some processing for | ||
311 | * the common case. | ||
257 | */ | 312 | */ |
258 | if (sdata->max_ratectrl_rateidx > -1) | 313 | mask = sdata->rc_rateidx_mask[info->band]; |
314 | if (mask != (1 << txrc->sband->n_bitrates) - 1) { | ||
315 | if (sta) { | ||
316 | /* Filter out rates that the STA does not support */ | ||
317 | mask &= sta->sta.supp_rates[info->band]; | ||
318 | } | ||
319 | /* | ||
320 | * Make sure the rate index selected for each TX rate is | ||
321 | * included in the configured mask and change the rate indexes | ||
322 | * if needed. | ||
323 | */ | ||
259 | for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { | 324 | for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { |
325 | /* Rate masking supports only legacy rates for now */ | ||
260 | if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) | 326 | if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) |
261 | continue; | 327 | continue; |
262 | info->control.rates[i].idx = | 328 | rate_idx_match_mask(&info->control.rates[i], |
263 | min_t(s8, info->control.rates[i].idx, | 329 | txrc->sband->n_bitrates, mask); |
264 | sdata->max_ratectrl_rateidx); | 330 | } |
265 | } | 331 | } |
266 | 332 | ||
267 | BUG_ON(info->control.rates[0].idx < 0); | 333 | BUG_ON(info->control.rates[0].idx < 0); |
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h index cb9bd1f65e27..669dddd40521 100644 --- a/net/mac80211/rate.h +++ b/net/mac80211/rate.h | |||
@@ -44,10 +44,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local, | |||
44 | struct rate_control_ref *ref = local->rate_ctrl; | 44 | struct rate_control_ref *ref = local->rate_ctrl; |
45 | struct ieee80211_sta *ista = &sta->sta; | 45 | struct ieee80211_sta *ista = &sta->sta; |
46 | void *priv_sta = sta->rate_ctrl_priv; | 46 | void *priv_sta = sta->rate_ctrl_priv; |
47 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 47 | ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb); |
48 | |||
49 | if (likely(info->flags & IEEE80211_TX_INTFL_RCALGO)) | ||
50 | ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb); | ||
51 | } | 48 | } |
52 | 49 | ||
53 | 50 | ||
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 82a30c1bf3ab..a8e15b84c05b 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -283,15 +283,15 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
283 | skb->protocol = htons(ETH_P_802_2); | 283 | skb->protocol = htons(ETH_P_802_2); |
284 | 284 | ||
285 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 285 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
286 | if (!netif_running(sdata->dev)) | ||
287 | continue; | ||
288 | |||
289 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) | 286 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) |
290 | continue; | 287 | continue; |
291 | 288 | ||
292 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) | 289 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) |
293 | continue; | 290 | continue; |
294 | 291 | ||
292 | if (!ieee80211_sdata_running(sdata)) | ||
293 | continue; | ||
294 | |||
295 | if (prev_dev) { | 295 | if (prev_dev) { |
296 | skb2 = skb_clone(skb, GFP_ATOMIC); | 296 | skb2 = skb_clone(skb, GFP_ATOMIC); |
297 | if (skb2) { | 297 | if (skb2) { |
@@ -361,7 +361,9 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) | |||
361 | * boundary. In the case of regular frames, this simply means aligning the | 361 | * boundary. In the case of regular frames, this simply means aligning the |
362 | * payload to a four-byte boundary (because either the IP header is directly | 362 | * payload to a four-byte boundary (because either the IP header is directly |
363 | * contained, or IV/RFC1042 headers that have a length divisible by four are | 363 | * contained, or IV/RFC1042 headers that have a length divisible by four are |
364 | * in front of it). | 364 | * in front of it). If the payload data is not properly aligned and the |
365 | * architecture doesn't support efficient unaligned operations, mac80211 | ||
366 | * will align the data. | ||
365 | * | 367 | * |
366 | * With A-MSDU frames, however, the payload data address must yield two modulo | 368 | * With A-MSDU frames, however, the payload data address must yield two modulo |
367 | * four because there are 14-byte 802.3 headers within the A-MSDU frames that | 369 | * four because there are 14-byte 802.3 headers within the A-MSDU frames that |
@@ -375,25 +377,10 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) | |||
375 | */ | 377 | */ |
376 | static void ieee80211_verify_alignment(struct ieee80211_rx_data *rx) | 378 | static void ieee80211_verify_alignment(struct ieee80211_rx_data *rx) |
377 | { | 379 | { |
378 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 380 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
379 | int hdrlen; | 381 | WARN_ONCE((unsigned long)rx->skb->data & 1, |
380 | 382 | "unaligned packet at 0x%p\n", rx->skb->data); | |
381 | #ifndef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT | ||
382 | return; | ||
383 | #endif | 383 | #endif |
384 | |||
385 | if (WARN_ONCE((unsigned long)rx->skb->data & 1, | ||
386 | "unaligned packet at 0x%p\n", rx->skb->data)) | ||
387 | return; | ||
388 | |||
389 | if (!ieee80211_is_data_present(hdr->frame_control)) | ||
390 | return; | ||
391 | |||
392 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | ||
393 | if (rx->flags & IEEE80211_RX_AMSDU) | ||
394 | hdrlen += ETH_HLEN; | ||
395 | WARN_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3, | ||
396 | "unaligned IP payload at 0x%p\n", rx->skb->data + hdrlen); | ||
397 | } | 384 | } |
398 | 385 | ||
399 | 386 | ||
@@ -476,7 +463,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
476 | { | 463 | { |
477 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 464 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
478 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); | 465 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); |
479 | char *dev_addr = rx->sdata->dev->dev_addr; | 466 | char *dev_addr = rx->sdata->vif.addr; |
480 | 467 | ||
481 | if (ieee80211_is_data(hdr->frame_control)) { | 468 | if (ieee80211_is_data(hdr->frame_control)) { |
482 | if (is_multicast_ether_addr(hdr->addr1)) { | 469 | if (is_multicast_ether_addr(hdr->addr1)) { |
@@ -1021,10 +1008,10 @@ static void ap_sta_ps_start(struct sta_info *sta) | |||
1021 | 1008 | ||
1022 | atomic_inc(&sdata->bss->num_sta_ps); | 1009 | atomic_inc(&sdata->bss->num_sta_ps); |
1023 | set_sta_flags(sta, WLAN_STA_PS_STA); | 1010 | set_sta_flags(sta, WLAN_STA_PS_STA); |
1024 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta); | 1011 | drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta); |
1025 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1012 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
1026 | printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", | 1013 | printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", |
1027 | sdata->dev->name, sta->sta.addr, sta->sta.aid); | 1014 | sdata->name, sta->sta.addr, sta->sta.aid); |
1028 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1015 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
1029 | } | 1016 | } |
1030 | 1017 | ||
@@ -1038,13 +1025,13 @@ static void ap_sta_ps_end(struct sta_info *sta) | |||
1038 | 1025 | ||
1039 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1026 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
1040 | printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", | 1027 | printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", |
1041 | sdata->dev->name, sta->sta.addr, sta->sta.aid); | 1028 | sdata->name, sta->sta.addr, sta->sta.aid); |
1042 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1029 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
1043 | 1030 | ||
1044 | if (test_sta_flags(sta, WLAN_STA_PS_DRIVER)) { | 1031 | if (test_sta_flags(sta, WLAN_STA_PS_DRIVER)) { |
1045 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1032 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
1046 | printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", | 1033 | printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", |
1047 | sdata->dev->name, sta->sta.addr, sta->sta.aid); | 1034 | sdata->name, sta->sta.addr, sta->sta.aid); |
1048 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1035 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
1049 | return; | 1036 | return; |
1050 | } | 1037 | } |
@@ -1124,6 +1111,18 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
1124 | if (ieee80211_is_nullfunc(hdr->frame_control) || | 1111 | if (ieee80211_is_nullfunc(hdr->frame_control) || |
1125 | ieee80211_is_qos_nullfunc(hdr->frame_control)) { | 1112 | ieee80211_is_qos_nullfunc(hdr->frame_control)) { |
1126 | I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); | 1113 | I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); |
1114 | |||
1115 | /* | ||
1116 | * If we receive a 4-addr nullfunc frame from a STA | ||
1117 | * that was not moved to a 4-addr STA vlan yet, drop | ||
1118 | * the frame to the monitor interface, to make sure | ||
1119 | * that hostapd sees it | ||
1120 | */ | ||
1121 | if (ieee80211_has_a4(hdr->frame_control) && | ||
1122 | (rx->sdata->vif.type == NL80211_IFTYPE_AP || | ||
1123 | (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | ||
1124 | !rx->sdata->u.vlan.sta))) | ||
1125 | return RX_DROP_MONITOR; | ||
1127 | /* | 1126 | /* |
1128 | * Update counter and free packet here to avoid | 1127 | * Update counter and free packet here to avoid |
1129 | * counting this as a dropped packed. | 1128 | * counting this as a dropped packed. |
@@ -1156,7 +1155,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata, | |||
1156 | printk(KERN_DEBUG "%s: RX reassembly removed oldest " | 1155 | printk(KERN_DEBUG "%s: RX reassembly removed oldest " |
1157 | "fragment entry (idx=%d age=%lu seq=%d last_frag=%d " | 1156 | "fragment entry (idx=%d age=%lu seq=%d last_frag=%d " |
1158 | "addr1=%pM addr2=%pM\n", | 1157 | "addr1=%pM addr2=%pM\n", |
1159 | sdata->dev->name, idx, | 1158 | sdata->name, idx, |
1160 | jiffies - entry->first_frag_time, entry->seq, | 1159 | jiffies - entry->first_frag_time, entry->seq, |
1161 | entry->last_frag, hdr->addr1, hdr->addr2); | 1160 | entry->last_frag, hdr->addr1, hdr->addr2); |
1162 | #endif | 1161 | #endif |
@@ -1424,7 +1423,6 @@ static int | |||
1424 | __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | 1423 | __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) |
1425 | { | 1424 | { |
1426 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 1425 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1427 | struct net_device *dev = sdata->dev; | ||
1428 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 1426 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
1429 | 1427 | ||
1430 | if (ieee80211_has_a4(hdr->frame_control) && | 1428 | if (ieee80211_has_a4(hdr->frame_control) && |
@@ -1436,7 +1434,7 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1436 | (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr))) | 1434 | (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr))) |
1437 | return -1; | 1435 | return -1; |
1438 | 1436 | ||
1439 | return ieee80211_data_to_8023(rx->skb, dev->dev_addr, sdata->vif.type); | 1437 | return ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type); |
1440 | } | 1438 | } |
1441 | 1439 | ||
1442 | /* | 1440 | /* |
@@ -1453,7 +1451,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) | |||
1453 | * of whether the frame was encrypted or not. | 1451 | * of whether the frame was encrypted or not. |
1454 | */ | 1452 | */ |
1455 | if (ehdr->h_proto == htons(ETH_P_PAE) && | 1453 | if (ehdr->h_proto == htons(ETH_P_PAE) && |
1456 | (compare_ether_addr(ehdr->h_dest, rx->sdata->dev->dev_addr) == 0 || | 1454 | (compare_ether_addr(ehdr->h_dest, rx->sdata->vif.addr) == 0 || |
1457 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) | 1455 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) |
1458 | return true; | 1456 | return true; |
1459 | 1457 | ||
@@ -1472,7 +1470,6 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1472 | { | 1470 | { |
1473 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 1471 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1474 | struct net_device *dev = sdata->dev; | 1472 | struct net_device *dev = sdata->dev; |
1475 | struct ieee80211_local *local = rx->local; | ||
1476 | struct sk_buff *skb, *xmit_skb; | 1473 | struct sk_buff *skb, *xmit_skb; |
1477 | struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; | 1474 | struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; |
1478 | struct sta_info *dsta; | 1475 | struct sta_info *dsta; |
@@ -1495,8 +1492,8 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1495 | printk(KERN_DEBUG "%s: failed to clone " | 1492 | printk(KERN_DEBUG "%s: failed to clone " |
1496 | "multicast frame\n", dev->name); | 1493 | "multicast frame\n", dev->name); |
1497 | } else { | 1494 | } else { |
1498 | dsta = sta_info_get(local, skb->data); | 1495 | dsta = sta_info_get(sdata, skb->data); |
1499 | if (dsta && dsta->sdata->dev == dev) { | 1496 | if (dsta) { |
1500 | /* | 1497 | /* |
1501 | * The destination station is associated to | 1498 | * The destination station is associated to |
1502 | * this AP (in this VLAN), so send the frame | 1499 | * this AP (in this VLAN), so send the frame |
@@ -1512,7 +1509,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1512 | if (skb) { | 1509 | if (skb) { |
1513 | int align __maybe_unused; | 1510 | int align __maybe_unused; |
1514 | 1511 | ||
1515 | #if defined(CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT) || !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) | 1512 | #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
1516 | /* | 1513 | /* |
1517 | * 'align' will only take the values 0 or 2 here | 1514 | * 'align' will only take the values 0 or 2 here |
1518 | * since all frames are required to be aligned | 1515 | * since all frames are required to be aligned |
@@ -1556,16 +1553,10 @@ static ieee80211_rx_result debug_noinline | |||
1556 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | 1553 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) |
1557 | { | 1554 | { |
1558 | struct net_device *dev = rx->sdata->dev; | 1555 | struct net_device *dev = rx->sdata->dev; |
1559 | struct ieee80211_local *local = rx->local; | 1556 | struct sk_buff *skb = rx->skb; |
1560 | u16 ethertype; | ||
1561 | u8 *payload; | ||
1562 | struct sk_buff *skb = rx->skb, *frame = NULL; | ||
1563 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 1557 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
1564 | __le16 fc = hdr->frame_control; | 1558 | __le16 fc = hdr->frame_control; |
1565 | const struct ethhdr *eth; | 1559 | struct sk_buff_head frame_list; |
1566 | int remaining, err; | ||
1567 | u8 dst[ETH_ALEN]; | ||
1568 | u8 src[ETH_ALEN]; | ||
1569 | 1560 | ||
1570 | if (unlikely(!ieee80211_is_data(fc))) | 1561 | if (unlikely(!ieee80211_is_data(fc))) |
1571 | return RX_CONTINUE; | 1562 | return RX_CONTINUE; |
@@ -1576,94 +1567,34 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1576 | if (!(rx->flags & IEEE80211_RX_AMSDU)) | 1567 | if (!(rx->flags & IEEE80211_RX_AMSDU)) |
1577 | return RX_CONTINUE; | 1568 | return RX_CONTINUE; |
1578 | 1569 | ||
1579 | err = __ieee80211_data_to_8023(rx); | 1570 | if (ieee80211_has_a4(hdr->frame_control) && |
1580 | if (unlikely(err)) | 1571 | rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
1572 | !rx->sdata->u.vlan.sta) | ||
1581 | return RX_DROP_UNUSABLE; | 1573 | return RX_DROP_UNUSABLE; |
1582 | 1574 | ||
1583 | skb->dev = dev; | 1575 | if (is_multicast_ether_addr(hdr->addr1) && |
1584 | 1576 | ((rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | |
1585 | dev->stats.rx_packets++; | 1577 | rx->sdata->u.vlan.sta) || |
1586 | dev->stats.rx_bytes += skb->len; | 1578 | (rx->sdata->vif.type == NL80211_IFTYPE_STATION && |
1587 | 1579 | rx->sdata->u.mgd.use_4addr))) | |
1588 | /* skip the wrapping header */ | ||
1589 | eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr)); | ||
1590 | if (!eth) | ||
1591 | return RX_DROP_UNUSABLE; | 1580 | return RX_DROP_UNUSABLE; |
1592 | 1581 | ||
1593 | while (skb != frame) { | 1582 | skb->dev = dev; |
1594 | u8 padding; | 1583 | __skb_queue_head_init(&frame_list); |
1595 | __be16 len = eth->h_proto; | ||
1596 | unsigned int subframe_len = sizeof(struct ethhdr) + ntohs(len); | ||
1597 | |||
1598 | remaining = skb->len; | ||
1599 | memcpy(dst, eth->h_dest, ETH_ALEN); | ||
1600 | memcpy(src, eth->h_source, ETH_ALEN); | ||
1601 | 1584 | ||
1602 | padding = ((4 - subframe_len) & 0x3); | 1585 | ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr, |
1603 | /* the last MSDU has no padding */ | 1586 | rx->sdata->vif.type, |
1604 | if (subframe_len > remaining) | 1587 | rx->local->hw.extra_tx_headroom); |
1605 | return RX_DROP_UNUSABLE; | ||
1606 | 1588 | ||
1607 | skb_pull(skb, sizeof(struct ethhdr)); | 1589 | while (!skb_queue_empty(&frame_list)) { |
1608 | /* if last subframe reuse skb */ | 1590 | rx->skb = __skb_dequeue(&frame_list); |
1609 | if (remaining <= subframe_len + padding) | ||
1610 | frame = skb; | ||
1611 | else { | ||
1612 | /* | ||
1613 | * Allocate and reserve two bytes more for payload | ||
1614 | * alignment since sizeof(struct ethhdr) is 14. | ||
1615 | */ | ||
1616 | frame = dev_alloc_skb( | ||
1617 | ALIGN(local->hw.extra_tx_headroom, 4) + | ||
1618 | subframe_len + 2); | ||
1619 | |||
1620 | if (frame == NULL) | ||
1621 | return RX_DROP_UNUSABLE; | ||
1622 | |||
1623 | skb_reserve(frame, | ||
1624 | ALIGN(local->hw.extra_tx_headroom, 4) + | ||
1625 | sizeof(struct ethhdr) + 2); | ||
1626 | memcpy(skb_put(frame, ntohs(len)), skb->data, | ||
1627 | ntohs(len)); | ||
1628 | |||
1629 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + | ||
1630 | padding); | ||
1631 | if (!eth) { | ||
1632 | dev_kfree_skb(frame); | ||
1633 | return RX_DROP_UNUSABLE; | ||
1634 | } | ||
1635 | } | ||
1636 | |||
1637 | skb_reset_network_header(frame); | ||
1638 | frame->dev = dev; | ||
1639 | frame->priority = skb->priority; | ||
1640 | rx->skb = frame; | ||
1641 | |||
1642 | payload = frame->data; | ||
1643 | ethertype = (payload[6] << 8) | payload[7]; | ||
1644 | |||
1645 | if (likely((compare_ether_addr(payload, rfc1042_header) == 0 && | ||
1646 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || | ||
1647 | compare_ether_addr(payload, | ||
1648 | bridge_tunnel_header) == 0)) { | ||
1649 | /* remove RFC1042 or Bridge-Tunnel | ||
1650 | * encapsulation and replace EtherType */ | ||
1651 | skb_pull(frame, 6); | ||
1652 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | ||
1653 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | ||
1654 | } else { | ||
1655 | memcpy(skb_push(frame, sizeof(__be16)), | ||
1656 | &len, sizeof(__be16)); | ||
1657 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | ||
1658 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | ||
1659 | } | ||
1660 | 1591 | ||
1661 | if (!ieee80211_frame_allowed(rx, fc)) { | 1592 | if (!ieee80211_frame_allowed(rx, fc)) { |
1662 | if (skb == frame) /* last frame */ | 1593 | dev_kfree_skb(rx->skb); |
1663 | return RX_DROP_UNUSABLE; | ||
1664 | dev_kfree_skb(frame); | ||
1665 | continue; | 1594 | continue; |
1666 | } | 1595 | } |
1596 | dev->stats.rx_packets++; | ||
1597 | dev->stats.rx_bytes += rx->skb->len; | ||
1667 | 1598 | ||
1668 | ieee80211_deliver_skb(rx); | 1599 | ieee80211_deliver_skb(rx); |
1669 | } | 1600 | } |
@@ -1721,7 +1652,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1721 | 1652 | ||
1722 | /* Frame has reached destination. Don't forward */ | 1653 | /* Frame has reached destination. Don't forward */ |
1723 | if (!is_multicast_ether_addr(hdr->addr1) && | 1654 | if (!is_multicast_ether_addr(hdr->addr1) && |
1724 | compare_ether_addr(sdata->dev->dev_addr, hdr->addr3) == 0) | 1655 | compare_ether_addr(sdata->vif.addr, hdr->addr3) == 0) |
1725 | return RX_CONTINUE; | 1656 | return RX_CONTINUE; |
1726 | 1657 | ||
1727 | mesh_hdr->ttl--; | 1658 | mesh_hdr->ttl--; |
@@ -1738,10 +1669,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1738 | 1669 | ||
1739 | if (!fwd_skb && net_ratelimit()) | 1670 | if (!fwd_skb && net_ratelimit()) |
1740 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", | 1671 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", |
1741 | sdata->dev->name); | 1672 | sdata->name); |
1742 | 1673 | ||
1743 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; | 1674 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; |
1744 | memcpy(fwd_hdr->addr2, sdata->dev->dev_addr, ETH_ALEN); | 1675 | memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN); |
1745 | info = IEEE80211_SKB_CB(fwd_skb); | 1676 | info = IEEE80211_SKB_CB(fwd_skb); |
1746 | memset(info, 0, sizeof(*info)); | 1677 | memset(info, 0, sizeof(*info)); |
1747 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 1678 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
@@ -1872,7 +1803,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, | |||
1872 | struct sk_buff *skb; | 1803 | struct sk_buff *skb; |
1873 | struct ieee80211_mgmt *resp; | 1804 | struct ieee80211_mgmt *resp; |
1874 | 1805 | ||
1875 | if (compare_ether_addr(mgmt->da, sdata->dev->dev_addr) != 0) { | 1806 | if (compare_ether_addr(mgmt->da, sdata->vif.addr) != 0) { |
1876 | /* Not to own unicast address */ | 1807 | /* Not to own unicast address */ |
1877 | return; | 1808 | return; |
1878 | } | 1809 | } |
@@ -1896,7 +1827,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, | |||
1896 | resp = (struct ieee80211_mgmt *) skb_put(skb, 24); | 1827 | resp = (struct ieee80211_mgmt *) skb_put(skb, 24); |
1897 | memset(resp, 0, 24); | 1828 | memset(resp, 0, 24); |
1898 | memcpy(resp->da, mgmt->sa, ETH_ALEN); | 1829 | memcpy(resp->da, mgmt->sa, ETH_ALEN); |
1899 | memcpy(resp->sa, sdata->dev->dev_addr, ETH_ALEN); | 1830 | memcpy(resp->sa, sdata->vif.addr, ETH_ALEN); |
1900 | memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN); | 1831 | memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
1901 | resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 1832 | resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
1902 | IEEE80211_STYPE_ACTION); | 1833 | IEEE80211_STYPE_ACTION); |
@@ -2032,6 +1963,7 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | |||
2032 | { | 1963 | { |
2033 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 1964 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
2034 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | 1965 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; |
1966 | ieee80211_rx_result rxs; | ||
2035 | 1967 | ||
2036 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | 1968 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) |
2037 | return RX_DROP_MONITOR; | 1969 | return RX_DROP_MONITOR; |
@@ -2039,6 +1971,10 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | |||
2039 | if (ieee80211_drop_unencrypted(rx, mgmt->frame_control)) | 1971 | if (ieee80211_drop_unencrypted(rx, mgmt->frame_control)) |
2040 | return RX_DROP_MONITOR; | 1972 | return RX_DROP_MONITOR; |
2041 | 1973 | ||
1974 | rxs = ieee80211_work_rx_mgmt(rx->sdata, rx->skb); | ||
1975 | if (rxs != RX_CONTINUE) | ||
1976 | return rxs; | ||
1977 | |||
2042 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 1978 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
2043 | return ieee80211_mesh_rx_mgmt(sdata, rx->skb); | 1979 | return ieee80211_mesh_rx_mgmt(sdata, rx->skb); |
2044 | 1980 | ||
@@ -2143,7 +2079,7 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, | |||
2143 | skb->protocol = htons(ETH_P_802_2); | 2079 | skb->protocol = htons(ETH_P_802_2); |
2144 | 2080 | ||
2145 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 2081 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
2146 | if (!netif_running(sdata->dev)) | 2082 | if (!ieee80211_sdata_running(sdata)) |
2147 | continue; | 2083 | continue; |
2148 | 2084 | ||
2149 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR || | 2085 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR || |
@@ -2280,7 +2216,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2280 | if (!bssid && !sdata->u.mgd.use_4addr) | 2216 | if (!bssid && !sdata->u.mgd.use_4addr) |
2281 | return 0; | 2217 | return 0; |
2282 | if (!multicast && | 2218 | if (!multicast && |
2283 | compare_ether_addr(sdata->dev->dev_addr, hdr->addr1) != 0) { | 2219 | compare_ether_addr(sdata->vif.addr, hdr->addr1) != 0) { |
2284 | if (!(sdata->dev->flags & IFF_PROMISC)) | 2220 | if (!(sdata->dev->flags & IFF_PROMISC)) |
2285 | return 0; | 2221 | return 0; |
2286 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2222 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
@@ -2297,7 +2233,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2297 | return 0; | 2233 | return 0; |
2298 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2234 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
2299 | } else if (!multicast && | 2235 | } else if (!multicast && |
2300 | compare_ether_addr(sdata->dev->dev_addr, | 2236 | compare_ether_addr(sdata->vif.addr, |
2301 | hdr->addr1) != 0) { | 2237 | hdr->addr1) != 0) { |
2302 | if (!(sdata->dev->flags & IFF_PROMISC)) | 2238 | if (!(sdata->dev->flags & IFF_PROMISC)) |
2303 | return 0; | 2239 | return 0; |
@@ -2314,7 +2250,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2314 | break; | 2250 | break; |
2315 | case NL80211_IFTYPE_MESH_POINT: | 2251 | case NL80211_IFTYPE_MESH_POINT: |
2316 | if (!multicast && | 2252 | if (!multicast && |
2317 | compare_ether_addr(sdata->dev->dev_addr, | 2253 | compare_ether_addr(sdata->vif.addr, |
2318 | hdr->addr1) != 0) { | 2254 | hdr->addr1) != 0) { |
2319 | if (!(sdata->dev->flags & IFF_PROMISC)) | 2255 | if (!(sdata->dev->flags & IFF_PROMISC)) |
2320 | return 0; | 2256 | return 0; |
@@ -2325,11 +2261,11 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2325 | case NL80211_IFTYPE_AP_VLAN: | 2261 | case NL80211_IFTYPE_AP_VLAN: |
2326 | case NL80211_IFTYPE_AP: | 2262 | case NL80211_IFTYPE_AP: |
2327 | if (!bssid) { | 2263 | if (!bssid) { |
2328 | if (compare_ether_addr(sdata->dev->dev_addr, | 2264 | if (compare_ether_addr(sdata->vif.addr, |
2329 | hdr->addr1)) | 2265 | hdr->addr1)) |
2330 | return 0; | 2266 | return 0; |
2331 | } else if (!ieee80211_bssid_match(bssid, | 2267 | } else if (!ieee80211_bssid_match(bssid, |
2332 | sdata->dev->dev_addr)) { | 2268 | sdata->vif.addr)) { |
2333 | if (!(rx->flags & IEEE80211_RX_IN_SCAN)) | 2269 | if (!(rx->flags & IEEE80211_RX_IN_SCAN)) |
2334 | return 0; | 2270 | return 0; |
2335 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2271 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
@@ -2368,6 +2304,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2368 | int prepares; | 2304 | int prepares; |
2369 | struct ieee80211_sub_if_data *prev = NULL; | 2305 | struct ieee80211_sub_if_data *prev = NULL; |
2370 | struct sk_buff *skb_new; | 2306 | struct sk_buff *skb_new; |
2307 | struct sta_info *sta, *tmp; | ||
2308 | bool found_sta = false; | ||
2371 | 2309 | ||
2372 | hdr = (struct ieee80211_hdr *)skb->data; | 2310 | hdr = (struct ieee80211_hdr *)skb->data; |
2373 | memset(&rx, 0, sizeof(rx)); | 2311 | memset(&rx, 0, sizeof(rx)); |
@@ -2384,68 +2322,76 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2384 | ieee80211_parse_qos(&rx); | 2322 | ieee80211_parse_qos(&rx); |
2385 | ieee80211_verify_alignment(&rx); | 2323 | ieee80211_verify_alignment(&rx); |
2386 | 2324 | ||
2387 | rx.sta = sta_info_get(local, hdr->addr2); | 2325 | if (ieee80211_is_data(hdr->frame_control)) { |
2388 | if (rx.sta) | 2326 | for_each_sta_info(local, hdr->addr2, sta, tmp) { |
2389 | rx.sdata = rx.sta->sdata; | 2327 | rx.sta = sta; |
2390 | 2328 | found_sta = true; | |
2391 | if (rx.sdata && ieee80211_is_data(hdr->frame_control)) { | 2329 | rx.sdata = sta->sdata; |
2392 | rx.flags |= IEEE80211_RX_RA_MATCH; | 2330 | |
2393 | prepares = prepare_for_handlers(rx.sdata, &rx, hdr); | 2331 | rx.flags |= IEEE80211_RX_RA_MATCH; |
2394 | if (prepares) { | 2332 | prepares = prepare_for_handlers(rx.sdata, &rx, hdr); |
2395 | if (status->flag & RX_FLAG_MMIC_ERROR) { | 2333 | if (prepares) { |
2396 | if (rx.flags & IEEE80211_RX_RA_MATCH) | 2334 | if (status->flag & RX_FLAG_MMIC_ERROR) { |
2397 | ieee80211_rx_michael_mic_report(hdr, &rx); | 2335 | if (rx.flags & IEEE80211_RX_RA_MATCH) |
2398 | } else | 2336 | ieee80211_rx_michael_mic_report(hdr, &rx); |
2399 | prev = rx.sdata; | 2337 | } else |
2338 | prev = rx.sdata; | ||
2339 | } | ||
2400 | } | 2340 | } |
2401 | } else list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 2341 | } |
2402 | if (!netif_running(sdata->dev)) | 2342 | if (!found_sta) { |
2403 | continue; | 2343 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
2344 | if (!ieee80211_sdata_running(sdata)) | ||
2345 | continue; | ||
2404 | 2346 | ||
2405 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR || | 2347 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR || |
2406 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 2348 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
2407 | continue; | 2349 | continue; |
2408 | 2350 | ||
2409 | rx.flags |= IEEE80211_RX_RA_MATCH; | 2351 | rx.sta = sta_info_get(sdata, hdr->addr2); |
2410 | prepares = prepare_for_handlers(sdata, &rx, hdr); | ||
2411 | 2352 | ||
2412 | if (!prepares) | 2353 | rx.flags |= IEEE80211_RX_RA_MATCH; |
2413 | continue; | 2354 | prepares = prepare_for_handlers(sdata, &rx, hdr); |
2414 | 2355 | ||
2415 | if (status->flag & RX_FLAG_MMIC_ERROR) { | 2356 | if (!prepares) |
2416 | rx.sdata = sdata; | 2357 | continue; |
2417 | if (rx.flags & IEEE80211_RX_RA_MATCH) | ||
2418 | ieee80211_rx_michael_mic_report(hdr, &rx); | ||
2419 | continue; | ||
2420 | } | ||
2421 | 2358 | ||
2422 | /* | 2359 | if (status->flag & RX_FLAG_MMIC_ERROR) { |
2423 | * frame is destined for this interface, but if it's not | 2360 | rx.sdata = sdata; |
2424 | * also for the previous one we handle that after the | 2361 | if (rx.flags & IEEE80211_RX_RA_MATCH) |
2425 | * loop to avoid copying the SKB once too much | 2362 | ieee80211_rx_michael_mic_report(hdr, |
2426 | */ | 2363 | &rx); |
2364 | continue; | ||
2365 | } | ||
2427 | 2366 | ||
2428 | if (!prev) { | 2367 | /* |
2429 | prev = sdata; | 2368 | * frame is destined for this interface, but if it's |
2430 | continue; | 2369 | * not also for the previous one we handle that after |
2431 | } | 2370 | * the loop to avoid copying the SKB once too much |
2371 | */ | ||
2432 | 2372 | ||
2433 | /* | 2373 | if (!prev) { |
2434 | * frame was destined for the previous interface | 2374 | prev = sdata; |
2435 | * so invoke RX handlers for it | 2375 | continue; |
2436 | */ | 2376 | } |
2437 | 2377 | ||
2438 | skb_new = skb_copy(skb, GFP_ATOMIC); | 2378 | /* |
2439 | if (!skb_new) { | 2379 | * frame was destined for the previous interface |
2440 | if (net_ratelimit()) | 2380 | * so invoke RX handlers for it |
2441 | printk(KERN_DEBUG "%s: failed to copy " | 2381 | */ |
2442 | "multicast frame for %s\n", | 2382 | |
2443 | wiphy_name(local->hw.wiphy), | 2383 | skb_new = skb_copy(skb, GFP_ATOMIC); |
2444 | prev->dev->name); | 2384 | if (!skb_new) { |
2445 | continue; | 2385 | if (net_ratelimit()) |
2386 | printk(KERN_DEBUG "%s: failed to copy " | ||
2387 | "multicast frame for %s\n", | ||
2388 | wiphy_name(local->hw.wiphy), | ||
2389 | prev->name); | ||
2390 | continue; | ||
2391 | } | ||
2392 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate); | ||
2393 | prev = sdata; | ||
2446 | } | 2394 | } |
2447 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate); | ||
2448 | prev = sdata; | ||
2449 | } | 2395 | } |
2450 | if (prev) | 2396 | if (prev) |
2451 | ieee80211_invoke_rx_handlers(prev, &rx, skb, rate); | 2397 | ieee80211_invoke_rx_handlers(prev, &rx, skb, rate); |
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index f934c9620b73..9afe2f9885dc 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * published by the Free Software Foundation. | 12 | * published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/wireless.h> | ||
16 | #include <linux/if_arp.h> | 15 | #include <linux/if_arp.h> |
17 | #include <linux/rtnetlink.h> | 16 | #include <linux/rtnetlink.h> |
18 | #include <net/mac80211.h> | 17 | #include <net/mac80211.h> |
@@ -29,16 +28,19 @@ struct ieee80211_bss * | |||
29 | ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, | 28 | ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, |
30 | u8 *ssid, u8 ssid_len) | 29 | u8 *ssid, u8 ssid_len) |
31 | { | 30 | { |
32 | return (void *)cfg80211_get_bss(local->hw.wiphy, | 31 | struct cfg80211_bss *cbss; |
33 | ieee80211_get_channel(local->hw.wiphy, | 32 | |
34 | freq), | 33 | cbss = cfg80211_get_bss(local->hw.wiphy, |
35 | bssid, ssid, ssid_len, | 34 | ieee80211_get_channel(local->hw.wiphy, freq), |
36 | 0, 0); | 35 | bssid, ssid, ssid_len, 0, 0); |
36 | if (!cbss) | ||
37 | return NULL; | ||
38 | return (void *)cbss->priv; | ||
37 | } | 39 | } |
38 | 40 | ||
39 | static void ieee80211_rx_bss_free(struct cfg80211_bss *cbss) | 41 | static void ieee80211_rx_bss_free(struct cfg80211_bss *cbss) |
40 | { | 42 | { |
41 | struct ieee80211_bss *bss = (void *)cbss; | 43 | struct ieee80211_bss *bss = (void *)cbss->priv; |
42 | 44 | ||
43 | kfree(bss_mesh_id(bss)); | 45 | kfree(bss_mesh_id(bss)); |
44 | kfree(bss_mesh_cfg(bss)); | 46 | kfree(bss_mesh_cfg(bss)); |
@@ -47,7 +49,26 @@ static void ieee80211_rx_bss_free(struct cfg80211_bss *cbss) | |||
47 | void ieee80211_rx_bss_put(struct ieee80211_local *local, | 49 | void ieee80211_rx_bss_put(struct ieee80211_local *local, |
48 | struct ieee80211_bss *bss) | 50 | struct ieee80211_bss *bss) |
49 | { | 51 | { |
50 | cfg80211_put_bss((struct cfg80211_bss *)bss); | 52 | if (!bss) |
53 | return; | ||
54 | cfg80211_put_bss(container_of((void *)bss, struct cfg80211_bss, priv)); | ||
55 | } | ||
56 | |||
57 | static bool is_uapsd_supported(struct ieee802_11_elems *elems) | ||
58 | { | ||
59 | u8 qos_info; | ||
60 | |||
61 | if (elems->wmm_info && elems->wmm_info_len == 7 | ||
62 | && elems->wmm_info[5] == 1) | ||
63 | qos_info = elems->wmm_info[6]; | ||
64 | else if (elems->wmm_param && elems->wmm_param_len == 24 | ||
65 | && elems->wmm_param[5] == 1) | ||
66 | qos_info = elems->wmm_param[6]; | ||
67 | else | ||
68 | /* no valid wmm information or parameter element found */ | ||
69 | return false; | ||
70 | |||
71 | return qos_info & IEEE80211_WMM_IE_AP_QOSINFO_UAPSD; | ||
51 | } | 72 | } |
52 | 73 | ||
53 | struct ieee80211_bss * | 74 | struct ieee80211_bss * |
@@ -59,6 +80,7 @@ ieee80211_bss_info_update(struct ieee80211_local *local, | |||
59 | struct ieee80211_channel *channel, | 80 | struct ieee80211_channel *channel, |
60 | bool beacon) | 81 | bool beacon) |
61 | { | 82 | { |
83 | struct cfg80211_bss *cbss; | ||
62 | struct ieee80211_bss *bss; | 84 | struct ieee80211_bss *bss; |
63 | int clen; | 85 | int clen; |
64 | s32 signal = 0; | 86 | s32 signal = 0; |
@@ -68,13 +90,14 @@ ieee80211_bss_info_update(struct ieee80211_local *local, | |||
68 | else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) | 90 | else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) |
69 | signal = (rx_status->signal * 100) / local->hw.max_signal; | 91 | signal = (rx_status->signal * 100) / local->hw.max_signal; |
70 | 92 | ||
71 | bss = (void *)cfg80211_inform_bss_frame(local->hw.wiphy, channel, | 93 | cbss = cfg80211_inform_bss_frame(local->hw.wiphy, channel, |
72 | mgmt, len, signal, GFP_ATOMIC); | 94 | mgmt, len, signal, GFP_ATOMIC); |
73 | 95 | ||
74 | if (!bss) | 96 | if (!cbss) |
75 | return NULL; | 97 | return NULL; |
76 | 98 | ||
77 | bss->cbss.free_priv = ieee80211_rx_bss_free; | 99 | cbss->free_priv = ieee80211_rx_bss_free; |
100 | bss = (void *)cbss->priv; | ||
78 | 101 | ||
79 | /* save the ERP value so that it is available at association time */ | 102 | /* save the ERP value so that it is available at association time */ |
80 | if (elems->erp_info && elems->erp_info_len >= 1) { | 103 | if (elems->erp_info && elems->erp_info_len >= 1) { |
@@ -111,6 +134,7 @@ ieee80211_bss_info_update(struct ieee80211_local *local, | |||
111 | } | 134 | } |
112 | 135 | ||
113 | bss->wmm_used = elems->wmm_param || elems->wmm_info; | 136 | bss->wmm_used = elems->wmm_param || elems->wmm_info; |
137 | bss->uapsd_supported = is_uapsd_supported(elems); | ||
114 | 138 | ||
115 | if (!beacon) | 139 | if (!beacon) |
116 | bss->last_probe_resp = jiffies; | 140 | bss->last_probe_resp = jiffies; |
@@ -147,7 +171,7 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) | |||
147 | presp = ieee80211_is_probe_resp(fc); | 171 | presp = ieee80211_is_probe_resp(fc); |
148 | if (presp) { | 172 | if (presp) { |
149 | /* ignore ProbeResp to foreign address */ | 173 | /* ignore ProbeResp to foreign address */ |
150 | if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) | 174 | if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) |
151 | return RX_DROP_MONITOR; | 175 | return RX_DROP_MONITOR; |
152 | 176 | ||
153 | presp = true; | 177 | presp = true; |
@@ -220,82 +244,9 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local) | |||
220 | return true; | 244 | return true; |
221 | } | 245 | } |
222 | 246 | ||
223 | /* | ||
224 | * inform AP that we will go to sleep so that it will buffer the frames | ||
225 | * while we scan | ||
226 | */ | ||
227 | static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata) | ||
228 | { | ||
229 | struct ieee80211_local *local = sdata->local; | ||
230 | |||
231 | local->scan_ps_enabled = false; | ||
232 | |||
233 | /* FIXME: what to do when local->pspolling is true? */ | ||
234 | |||
235 | del_timer_sync(&local->dynamic_ps_timer); | ||
236 | cancel_work_sync(&local->dynamic_ps_enable_work); | ||
237 | |||
238 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { | ||
239 | local->scan_ps_enabled = true; | ||
240 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; | ||
241 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | ||
242 | } | ||
243 | |||
244 | if (!(local->scan_ps_enabled) || | ||
245 | !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) | ||
246 | /* | ||
247 | * If power save was enabled, no need to send a nullfunc | ||
248 | * frame because AP knows that we are sleeping. But if the | ||
249 | * hardware is creating the nullfunc frame for power save | ||
250 | * status (ie. IEEE80211_HW_PS_NULLFUNC_STACK is not | ||
251 | * enabled) and power save was enabled, the firmware just | ||
252 | * sent a null frame with power save disabled. So we need | ||
253 | * to send a new nullfunc frame to inform the AP that we | ||
254 | * are again sleeping. | ||
255 | */ | ||
256 | ieee80211_send_nullfunc(local, sdata, 1); | ||
257 | } | ||
258 | |||
259 | /* inform AP that we are awake again, unless power save is enabled */ | ||
260 | static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata) | ||
261 | { | ||
262 | struct ieee80211_local *local = sdata->local; | ||
263 | |||
264 | if (!local->ps_sdata) | ||
265 | ieee80211_send_nullfunc(local, sdata, 0); | ||
266 | else if (local->scan_ps_enabled) { | ||
267 | /* | ||
268 | * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware | ||
269 | * will send a nullfunc frame with the powersave bit set | ||
270 | * even though the AP already knows that we are sleeping. | ||
271 | * This could be avoided by sending a null frame with power | ||
272 | * save bit disabled before enabling the power save, but | ||
273 | * this doesn't gain anything. | ||
274 | * | ||
275 | * When IEEE80211_HW_PS_NULLFUNC_STACK is enabled, no need | ||
276 | * to send a nullfunc frame because AP already knows that | ||
277 | * we are sleeping, let's just enable power save mode in | ||
278 | * hardware. | ||
279 | */ | ||
280 | local->hw.conf.flags |= IEEE80211_CONF_PS; | ||
281 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | ||
282 | } else if (local->hw.conf.dynamic_ps_timeout > 0) { | ||
283 | /* | ||
284 | * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer | ||
285 | * had been running before leaving the operating channel, | ||
286 | * restart the timer now and send a nullfunc frame to inform | ||
287 | * the AP that we are awake. | ||
288 | */ | ||
289 | ieee80211_send_nullfunc(local, sdata, 0); | ||
290 | mod_timer(&local->dynamic_ps_timer, jiffies + | ||
291 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | ||
292 | } | ||
293 | } | ||
294 | |||
295 | void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | 247 | void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) |
296 | { | 248 | { |
297 | struct ieee80211_local *local = hw_to_local(hw); | 249 | struct ieee80211_local *local = hw_to_local(hw); |
298 | struct ieee80211_sub_if_data *sdata; | ||
299 | bool was_hw_scan; | 250 | bool was_hw_scan; |
300 | 251 | ||
301 | mutex_lock(&local->scan_mtx); | 252 | mutex_lock(&local->scan_mtx); |
@@ -344,41 +295,19 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
344 | 295 | ||
345 | drv_sw_scan_complete(local); | 296 | drv_sw_scan_complete(local); |
346 | 297 | ||
347 | mutex_lock(&local->iflist_mtx); | 298 | ieee80211_offchannel_return(local, true); |
348 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
349 | if (!netif_running(sdata->dev)) | ||
350 | continue; | ||
351 | |||
352 | /* Tell AP we're back */ | ||
353 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
354 | if (sdata->u.mgd.associated) { | ||
355 | ieee80211_scan_ps_disable(sdata); | ||
356 | netif_tx_wake_all_queues(sdata->dev); | ||
357 | } | ||
358 | } else | ||
359 | netif_tx_wake_all_queues(sdata->dev); | ||
360 | |||
361 | /* re-enable beaconing */ | ||
362 | if (sdata->vif.type == NL80211_IFTYPE_AP || | ||
363 | sdata->vif.type == NL80211_IFTYPE_ADHOC || | ||
364 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) | ||
365 | ieee80211_bss_info_change_notify( | ||
366 | sdata, BSS_CHANGED_BEACON_ENABLED); | ||
367 | } | ||
368 | mutex_unlock(&local->iflist_mtx); | ||
369 | 299 | ||
370 | done: | 300 | done: |
371 | ieee80211_recalc_idle(local); | 301 | ieee80211_recalc_idle(local); |
372 | ieee80211_mlme_notify_scan_completed(local); | 302 | ieee80211_mlme_notify_scan_completed(local); |
373 | ieee80211_ibss_notify_scan_completed(local); | 303 | ieee80211_ibss_notify_scan_completed(local); |
374 | ieee80211_mesh_notify_scan_completed(local); | 304 | ieee80211_mesh_notify_scan_completed(local); |
305 | ieee80211_queue_work(&local->hw, &local->work_work); | ||
375 | } | 306 | } |
376 | EXPORT_SYMBOL(ieee80211_scan_completed); | 307 | EXPORT_SYMBOL(ieee80211_scan_completed); |
377 | 308 | ||
378 | static int ieee80211_start_sw_scan(struct ieee80211_local *local) | 309 | static int ieee80211_start_sw_scan(struct ieee80211_local *local) |
379 | { | 310 | { |
380 | struct ieee80211_sub_if_data *sdata; | ||
381 | |||
382 | /* | 311 | /* |
383 | * Hardware/driver doesn't support hw_scan, so use software | 312 | * Hardware/driver doesn't support hw_scan, so use software |
384 | * scanning instead. First send a nullfunc frame with power save | 313 | * scanning instead. First send a nullfunc frame with power save |
@@ -394,33 +323,15 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) | |||
394 | */ | 323 | */ |
395 | drv_sw_scan_start(local); | 324 | drv_sw_scan_start(local); |
396 | 325 | ||
397 | mutex_lock(&local->iflist_mtx); | 326 | ieee80211_offchannel_stop_beaconing(local); |
398 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
399 | if (!netif_running(sdata->dev)) | ||
400 | continue; | ||
401 | |||
402 | /* disable beaconing */ | ||
403 | if (sdata->vif.type == NL80211_IFTYPE_AP || | ||
404 | sdata->vif.type == NL80211_IFTYPE_ADHOC || | ||
405 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) | ||
406 | ieee80211_bss_info_change_notify( | ||
407 | sdata, BSS_CHANGED_BEACON_ENABLED); | ||
408 | |||
409 | /* | ||
410 | * only handle non-STA interfaces here, STA interfaces | ||
411 | * are handled in the scan state machine | ||
412 | */ | ||
413 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
414 | netif_tx_stop_all_queues(sdata->dev); | ||
415 | } | ||
416 | mutex_unlock(&local->iflist_mtx); | ||
417 | 327 | ||
418 | local->next_scan_state = SCAN_DECISION; | 328 | local->next_scan_state = SCAN_DECISION; |
419 | local->scan_channel_idx = 0; | 329 | local->scan_channel_idx = 0; |
420 | 330 | ||
331 | drv_flush(local, false); | ||
332 | |||
421 | ieee80211_configure_filter(local); | 333 | ieee80211_configure_filter(local); |
422 | 334 | ||
423 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ | ||
424 | ieee80211_queue_delayed_work(&local->hw, | 335 | ieee80211_queue_delayed_work(&local->hw, |
425 | &local->scan_work, | 336 | &local->scan_work, |
426 | IEEE80211_CHANNEL_TIME); | 337 | IEEE80211_CHANNEL_TIME); |
@@ -433,7 +344,6 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
433 | struct cfg80211_scan_request *req) | 344 | struct cfg80211_scan_request *req) |
434 | { | 345 | { |
435 | struct ieee80211_local *local = sdata->local; | 346 | struct ieee80211_local *local = sdata->local; |
436 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
437 | int rc; | 347 | int rc; |
438 | 348 | ||
439 | if (local->scan_req) | 349 | if (local->scan_req) |
@@ -463,11 +373,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
463 | local->scan_req = req; | 373 | local->scan_req = req; |
464 | local->scan_sdata = sdata; | 374 | local->scan_sdata = sdata; |
465 | 375 | ||
466 | if (req != local->int_scan_req && | 376 | if (!list_empty(&local->work_list)) { |
467 | sdata->vif.type == NL80211_IFTYPE_STATION && | 377 | /* wait for the work to finish/time out */ |
468 | !list_empty(&ifmgd->work_list)) { | ||
469 | /* actually wait for the work it's doing to finish/time out */ | ||
470 | set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); | ||
471 | return 0; | 378 | return 0; |
472 | } | 379 | } |
473 | 380 | ||
@@ -526,7 +433,7 @@ static int ieee80211_scan_state_decision(struct ieee80211_local *local, | |||
526 | /* check if at least one STA interface is associated */ | 433 | /* check if at least one STA interface is associated */ |
527 | mutex_lock(&local->iflist_mtx); | 434 | mutex_lock(&local->iflist_mtx); |
528 | list_for_each_entry(sdata, &local->interfaces, list) { | 435 | list_for_each_entry(sdata, &local->interfaces, list) { |
529 | if (!netif_running(sdata->dev)) | 436 | if (!ieee80211_sdata_running(sdata)) |
530 | continue; | 437 | continue; |
531 | 438 | ||
532 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 439 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
@@ -564,56 +471,35 @@ static int ieee80211_scan_state_decision(struct ieee80211_local *local, | |||
564 | static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *local, | 471 | static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *local, |
565 | unsigned long *next_delay) | 472 | unsigned long *next_delay) |
566 | { | 473 | { |
567 | struct ieee80211_sub_if_data *sdata; | 474 | ieee80211_offchannel_stop_station(local); |
475 | |||
476 | __set_bit(SCAN_OFF_CHANNEL, &local->scanning); | ||
568 | 477 | ||
569 | /* | 478 | /* |
570 | * notify the AP about us leaving the channel and stop all STA interfaces | 479 | * What if the nullfunc frames didn't arrive? |
571 | */ | 480 | */ |
572 | mutex_lock(&local->iflist_mtx); | 481 | drv_flush(local, false); |
573 | list_for_each_entry(sdata, &local->interfaces, list) { | 482 | if (local->ops->flush) |
574 | if (!netif_running(sdata->dev)) | 483 | *next_delay = 0; |
575 | continue; | 484 | else |
576 | 485 | *next_delay = HZ / 10; | |
577 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
578 | netif_tx_stop_all_queues(sdata->dev); | ||
579 | if (sdata->u.mgd.associated) | ||
580 | ieee80211_scan_ps_enable(sdata); | ||
581 | } | ||
582 | } | ||
583 | mutex_unlock(&local->iflist_mtx); | ||
584 | |||
585 | __set_bit(SCAN_OFF_CHANNEL, &local->scanning); | ||
586 | 486 | ||
587 | /* advance to the next channel to be scanned */ | 487 | /* advance to the next channel to be scanned */ |
588 | *next_delay = HZ / 10; | ||
589 | local->next_scan_state = SCAN_SET_CHANNEL; | 488 | local->next_scan_state = SCAN_SET_CHANNEL; |
590 | } | 489 | } |
591 | 490 | ||
592 | static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *local, | 491 | static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *local, |
593 | unsigned long *next_delay) | 492 | unsigned long *next_delay) |
594 | { | 493 | { |
595 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | ||
596 | |||
597 | /* switch back to the operating channel */ | 494 | /* switch back to the operating channel */ |
598 | local->scan_channel = NULL; | 495 | local->scan_channel = NULL; |
599 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); | 496 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
600 | 497 | ||
601 | /* | 498 | /* |
602 | * notify the AP about us being back and restart all STA interfaces | 499 | * Only re-enable station mode interface now; beaconing will be |
500 | * re-enabled once the full scan has been completed. | ||
603 | */ | 501 | */ |
604 | mutex_lock(&local->iflist_mtx); | 502 | ieee80211_offchannel_return(local, false); |
605 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
606 | if (!netif_running(sdata->dev)) | ||
607 | continue; | ||
608 | |||
609 | /* Tell AP we're back */ | ||
610 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
611 | if (sdata->u.mgd.associated) | ||
612 | ieee80211_scan_ps_disable(sdata); | ||
613 | netif_tx_wake_all_queues(sdata->dev); | ||
614 | } | ||
615 | } | ||
616 | mutex_unlock(&local->iflist_mtx); | ||
617 | 503 | ||
618 | __clear_bit(SCAN_OFF_CHANNEL, &local->scanning); | 504 | __clear_bit(SCAN_OFF_CHANNEL, &local->scanning); |
619 | 505 | ||
@@ -727,7 +613,7 @@ void ieee80211_scan_work(struct work_struct *work) | |||
727 | /* | 613 | /* |
728 | * Avoid re-scheduling when the sdata is going away. | 614 | * Avoid re-scheduling when the sdata is going away. |
729 | */ | 615 | */ |
730 | if (!netif_running(sdata->dev)) { | 616 | if (!ieee80211_sdata_running(sdata)) { |
731 | ieee80211_scan_completed(&local->hw, true); | 617 | ieee80211_scan_completed(&local->hw, true); |
732 | return; | 618 | return; |
733 | } | 619 | } |
diff --git a/net/mac80211/spectmgmt.c b/net/mac80211/spectmgmt.c index aa743a895cf9..7733f66ee2c4 100644 --- a/net/mac80211/spectmgmt.c +++ b/net/mac80211/spectmgmt.c | |||
@@ -35,7 +35,7 @@ static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_da | |||
35 | 35 | ||
36 | if (!skb) { | 36 | if (!skb) { |
37 | printk(KERN_ERR "%s: failed to allocate buffer for " | 37 | printk(KERN_ERR "%s: failed to allocate buffer for " |
38 | "measurement report frame\n", sdata->dev->name); | 38 | "measurement report frame\n", sdata->name); |
39 | return; | 39 | return; |
40 | } | 40 | } |
41 | 41 | ||
@@ -43,7 +43,7 @@ static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_da | |||
43 | msr_report = (struct ieee80211_mgmt *)skb_put(skb, 24); | 43 | msr_report = (struct ieee80211_mgmt *)skb_put(skb, 24); |
44 | memset(msr_report, 0, 24); | 44 | memset(msr_report, 0, 24); |
45 | memcpy(msr_report->da, da, ETH_ALEN); | 45 | memcpy(msr_report->da, da, ETH_ALEN); |
46 | memcpy(msr_report->sa, sdata->dev->dev_addr, ETH_ALEN); | 46 | memcpy(msr_report->sa, sdata->vif.addr, ETH_ALEN); |
47 | memcpy(msr_report->bssid, bssid, ETH_ALEN); | 47 | memcpy(msr_report->bssid, bssid, ETH_ALEN); |
48 | msr_report->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 48 | msr_report->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
49 | IEEE80211_STYPE_ACTION); | 49 | IEEE80211_STYPE_ACTION); |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 71f370dd24bc..f735826f055c 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -103,13 +103,37 @@ static int sta_info_hash_del(struct ieee80211_local *local, | |||
103 | } | 103 | } |
104 | 104 | ||
105 | /* protected by RCU */ | 105 | /* protected by RCU */ |
106 | struct sta_info *sta_info_get(struct ieee80211_local *local, const u8 *addr) | 106 | struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, |
107 | const u8 *addr) | ||
107 | { | 108 | { |
109 | struct ieee80211_local *local = sdata->local; | ||
108 | struct sta_info *sta; | 110 | struct sta_info *sta; |
109 | 111 | ||
110 | sta = rcu_dereference(local->sta_hash[STA_HASH(addr)]); | 112 | sta = rcu_dereference(local->sta_hash[STA_HASH(addr)]); |
111 | while (sta) { | 113 | while (sta) { |
112 | if (memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) | 114 | if (sta->sdata == sdata && |
115 | memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) | ||
116 | break; | ||
117 | sta = rcu_dereference(sta->hnext); | ||
118 | } | ||
119 | return sta; | ||
120 | } | ||
121 | |||
122 | /* | ||
123 | * Get sta info either from the specified interface | ||
124 | * or from one of its vlans | ||
125 | */ | ||
126 | struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, | ||
127 | const u8 *addr) | ||
128 | { | ||
129 | struct ieee80211_local *local = sdata->local; | ||
130 | struct sta_info *sta; | ||
131 | |||
132 | sta = rcu_dereference(local->sta_hash[STA_HASH(addr)]); | ||
133 | while (sta) { | ||
134 | if ((sta->sdata == sdata || | ||
135 | sta->sdata->bss == sdata->bss) && | ||
136 | memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) | ||
113 | break; | 137 | break; |
114 | sta = rcu_dereference(sta->hnext); | 138 | sta = rcu_dereference(sta->hnext); |
115 | } | 139 | } |
@@ -356,6 +380,7 @@ int sta_info_insert(struct sta_info *sta) | |||
356 | { | 380 | { |
357 | struct ieee80211_local *local = sta->local; | 381 | struct ieee80211_local *local = sta->local; |
358 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 382 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
383 | struct station_info sinfo; | ||
359 | unsigned long flags; | 384 | unsigned long flags; |
360 | int err = 0; | 385 | int err = 0; |
361 | 386 | ||
@@ -364,12 +389,12 @@ int sta_info_insert(struct sta_info *sta) | |||
364 | * something inserts a STA (on one CPU) without holding the RTNL | 389 | * something inserts a STA (on one CPU) without holding the RTNL |
365 | * and another CPU turns off the net device. | 390 | * and another CPU turns off the net device. |
366 | */ | 391 | */ |
367 | if (unlikely(!netif_running(sdata->dev))) { | 392 | if (unlikely(!ieee80211_sdata_running(sdata))) { |
368 | err = -ENETDOWN; | 393 | err = -ENETDOWN; |
369 | goto out_free; | 394 | goto out_free; |
370 | } | 395 | } |
371 | 396 | ||
372 | if (WARN_ON(compare_ether_addr(sta->sta.addr, sdata->dev->dev_addr) == 0 || | 397 | if (WARN_ON(compare_ether_addr(sta->sta.addr, sdata->vif.addr) == 0 || |
373 | is_multicast_ether_addr(sta->sta.addr))) { | 398 | is_multicast_ether_addr(sta->sta.addr))) { |
374 | err = -EINVAL; | 399 | err = -EINVAL; |
375 | goto out_free; | 400 | goto out_free; |
@@ -377,7 +402,7 @@ int sta_info_insert(struct sta_info *sta) | |||
377 | 402 | ||
378 | spin_lock_irqsave(&local->sta_lock, flags); | 403 | spin_lock_irqsave(&local->sta_lock, flags); |
379 | /* check if STA exists already */ | 404 | /* check if STA exists already */ |
380 | if (sta_info_get(local, sta->sta.addr)) { | 405 | if (sta_info_get(sdata, sta->sta.addr)) { |
381 | spin_unlock_irqrestore(&local->sta_lock, flags); | 406 | spin_unlock_irqrestore(&local->sta_lock, flags); |
382 | err = -EEXIST; | 407 | err = -EEXIST; |
383 | goto out_free; | 408 | goto out_free; |
@@ -394,7 +419,7 @@ int sta_info_insert(struct sta_info *sta) | |||
394 | struct ieee80211_sub_if_data, | 419 | struct ieee80211_sub_if_data, |
395 | u.ap); | 420 | u.ap); |
396 | 421 | ||
397 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_ADD, &sta->sta); | 422 | drv_sta_notify(local, sdata, STA_NOTIFY_ADD, &sta->sta); |
398 | sdata = sta->sdata; | 423 | sdata = sta->sdata; |
399 | } | 424 | } |
400 | 425 | ||
@@ -405,6 +430,10 @@ int sta_info_insert(struct sta_info *sta) | |||
405 | 430 | ||
406 | spin_unlock_irqrestore(&local->sta_lock, flags); | 431 | spin_unlock_irqrestore(&local->sta_lock, flags); |
407 | 432 | ||
433 | sinfo.filled = 0; | ||
434 | sinfo.generation = local->sta_generation; | ||
435 | cfg80211_new_sta(sdata->dev, sta->sta.addr, &sinfo, GFP_ATOMIC); | ||
436 | |||
408 | #ifdef CONFIG_MAC80211_DEBUGFS | 437 | #ifdef CONFIG_MAC80211_DEBUGFS |
409 | /* | 438 | /* |
410 | * Debugfs entry adding might sleep, so schedule process | 439 | * Debugfs entry adding might sleep, so schedule process |
@@ -534,7 +563,7 @@ static void __sta_info_unlink(struct sta_info **sta) | |||
534 | struct ieee80211_sub_if_data, | 563 | struct ieee80211_sub_if_data, |
535 | u.ap); | 564 | u.ap); |
536 | 565 | ||
537 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_REMOVE, | 566 | drv_sta_notify(local, sdata, STA_NOTIFY_REMOVE, |
538 | &(*sta)->sta); | 567 | &(*sta)->sta); |
539 | sdata = (*sta)->sdata; | 568 | sdata = (*sta)->sdata; |
540 | } | 569 | } |
@@ -828,7 +857,7 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, | |||
828 | if (time_after(jiffies, sta->last_rx + exp_time)) { | 857 | if (time_after(jiffies, sta->last_rx + exp_time)) { |
829 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 858 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
830 | printk(KERN_DEBUG "%s: expiring inactive STA %pM\n", | 859 | printk(KERN_DEBUG "%s: expiring inactive STA %pM\n", |
831 | sdata->dev->name, sta->sta.addr); | 860 | sdata->name, sta->sta.addr); |
832 | #endif | 861 | #endif |
833 | __sta_info_unlink(&sta); | 862 | __sta_info_unlink(&sta); |
834 | if (sta) | 863 | if (sta) |
@@ -843,11 +872,12 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, | |||
843 | struct ieee80211_sta *ieee80211_find_sta_by_hw(struct ieee80211_hw *hw, | 872 | struct ieee80211_sta *ieee80211_find_sta_by_hw(struct ieee80211_hw *hw, |
844 | const u8 *addr) | 873 | const u8 *addr) |
845 | { | 874 | { |
846 | struct sta_info *sta = sta_info_get(hw_to_local(hw), addr); | 875 | struct sta_info *sta, *nxt; |
847 | 876 | ||
848 | if (!sta) | 877 | /* Just return a random station ... first in list ... */ |
849 | return NULL; | 878 | for_each_sta_info(hw_to_local(hw), addr, sta, nxt) |
850 | return &sta->sta; | 879 | return &sta->sta; |
880 | return NULL; | ||
851 | } | 881 | } |
852 | EXPORT_SYMBOL_GPL(ieee80211_find_sta_by_hw); | 882 | EXPORT_SYMBOL_GPL(ieee80211_find_sta_by_hw); |
853 | 883 | ||
@@ -872,7 +902,7 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) | |||
872 | struct ieee80211_local *local = sdata->local; | 902 | struct ieee80211_local *local = sdata->local; |
873 | int sent, buffered; | 903 | int sent, buffered; |
874 | 904 | ||
875 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_AWAKE, &sta->sta); | 905 | drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); |
876 | 906 | ||
877 | if (!skb_queue_empty(&sta->ps_tx_buf)) | 907 | if (!skb_queue_empty(&sta->ps_tx_buf)) |
878 | sta_info_clear_tim_bit(sta); | 908 | sta_info_clear_tim_bit(sta); |
@@ -885,7 +915,7 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) | |||
885 | 915 | ||
886 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 916 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
887 | printk(KERN_DEBUG "%s: STA %pM aid %d sending %d filtered/%d PS frames " | 917 | printk(KERN_DEBUG "%s: STA %pM aid %d sending %d filtered/%d PS frames " |
888 | "since STA not sleeping anymore\n", sdata->dev->name, | 918 | "since STA not sleeping anymore\n", sdata->name, |
889 | sta->sta.addr, sta->sta.aid, sent - buffered, buffered); | 919 | sta->sta.addr, sta->sta.aid, sent - buffered, buffered); |
890 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 920 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
891 | } | 921 | } |
@@ -944,7 +974,7 @@ void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta) | |||
944 | */ | 974 | */ |
945 | printk(KERN_DEBUG "%s: STA %pM sent PS Poll even " | 975 | printk(KERN_DEBUG "%s: STA %pM sent PS Poll even " |
946 | "though there are no buffered frames for it\n", | 976 | "though there are no buffered frames for it\n", |
947 | sdata->dev->name, sta->sta.addr); | 977 | sdata->name, sta->sta.addr); |
948 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 978 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
949 | } | 979 | } |
950 | } | 980 | } |
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index b4810f6aa94f..6f79bba5706e 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h | |||
@@ -403,9 +403,37 @@ static inline u32 get_sta_flags(struct sta_info *sta) | |||
403 | #define STA_INFO_CLEANUP_INTERVAL (10 * HZ) | 403 | #define STA_INFO_CLEANUP_INTERVAL (10 * HZ) |
404 | 404 | ||
405 | /* | 405 | /* |
406 | * Get a STA info, must have be under RCU read lock. | 406 | * Get a STA info, must be under RCU read lock. |
407 | */ | 407 | */ |
408 | struct sta_info *sta_info_get(struct ieee80211_local *local, const u8 *addr); | 408 | struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, |
409 | const u8 *addr); | ||
410 | |||
411 | struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, | ||
412 | const u8 *addr); | ||
413 | |||
414 | static inline | ||
415 | void for_each_sta_info_type_check(struct ieee80211_local *local, | ||
416 | const u8 *addr, | ||
417 | struct sta_info *sta, | ||
418 | struct sta_info *nxt) | ||
419 | { | ||
420 | } | ||
421 | |||
422 | #define for_each_sta_info(local, _addr, sta, nxt) \ | ||
423 | for ( /* initialise loop */ \ | ||
424 | sta = rcu_dereference(local->sta_hash[STA_HASH(_addr)]),\ | ||
425 | nxt = sta ? rcu_dereference(sta->hnext) : NULL; \ | ||
426 | /* typecheck */ \ | ||
427 | for_each_sta_info_type_check(local, (_addr), sta, nxt), \ | ||
428 | /* continue condition */ \ | ||
429 | sta; \ | ||
430 | /* advance loop */ \ | ||
431 | sta = nxt, \ | ||
432 | nxt = sta ? rcu_dereference(sta->hnext) : NULL \ | ||
433 | ) \ | ||
434 | /* compare address and run code only if it matches */ \ | ||
435 | if (memcmp(sta->sta.addr, (_addr), ETH_ALEN) == 0) | ||
436 | |||
409 | /* | 437 | /* |
410 | * Get STA info by index, BROKEN! | 438 | * Get STA info by index, BROKEN! |
411 | */ | 439 | */ |
diff --git a/net/mac80211/status.c b/net/mac80211/status.c index d78f36c64c7b..0ebcdda24200 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c | |||
@@ -134,6 +134,40 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local, | |||
134 | dev_kfree_skb(skb); | 134 | dev_kfree_skb(skb); |
135 | } | 135 | } |
136 | 136 | ||
137 | static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb) | ||
138 | { | ||
139 | struct ieee80211_mgmt *mgmt = (void *) skb->data; | ||
140 | struct ieee80211_local *local = sta->local; | ||
141 | struct ieee80211_sub_if_data *sdata = sta->sdata; | ||
142 | |||
143 | if (ieee80211_is_action(mgmt->frame_control) && | ||
144 | sdata->vif.type == NL80211_IFTYPE_STATION && | ||
145 | mgmt->u.action.category == WLAN_CATEGORY_HT && | ||
146 | mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS) { | ||
147 | /* | ||
148 | * This update looks racy, but isn't -- if we come | ||
149 | * here we've definitely got a station that we're | ||
150 | * talking to, and on a managed interface that can | ||
151 | * only be the AP. And the only other place updating | ||
152 | * this variable is before we're associated. | ||
153 | */ | ||
154 | switch (mgmt->u.action.u.ht_smps.smps_control) { | ||
155 | case WLAN_HT_SMPS_CONTROL_DYNAMIC: | ||
156 | sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_DYNAMIC; | ||
157 | break; | ||
158 | case WLAN_HT_SMPS_CONTROL_STATIC: | ||
159 | sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_STATIC; | ||
160 | break; | ||
161 | case WLAN_HT_SMPS_CONTROL_DISABLED: | ||
162 | default: /* shouldn't happen since we don't send that */ | ||
163 | sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_OFF; | ||
164 | break; | ||
165 | } | ||
166 | |||
167 | ieee80211_queue_work(&local->hw, &local->recalc_smps); | ||
168 | } | ||
169 | } | ||
170 | |||
137 | void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | 171 | void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) |
138 | { | 172 | { |
139 | struct sk_buff *skb2; | 173 | struct sk_buff *skb2; |
@@ -146,7 +180,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
146 | struct ieee80211_tx_status_rtap_hdr *rthdr; | 180 | struct ieee80211_tx_status_rtap_hdr *rthdr; |
147 | struct ieee80211_sub_if_data *sdata; | 181 | struct ieee80211_sub_if_data *sdata; |
148 | struct net_device *prev_dev = NULL; | 182 | struct net_device *prev_dev = NULL; |
149 | struct sta_info *sta; | 183 | struct sta_info *sta, *tmp; |
150 | int retry_count = -1, i; | 184 | int retry_count = -1, i; |
151 | bool injected; | 185 | bool injected; |
152 | 186 | ||
@@ -166,9 +200,11 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
166 | 200 | ||
167 | sband = local->hw.wiphy->bands[info->band]; | 201 | sband = local->hw.wiphy->bands[info->band]; |
168 | 202 | ||
169 | sta = sta_info_get(local, hdr->addr1); | 203 | for_each_sta_info(local, hdr->addr1, sta, tmp) { |
204 | /* skip wrong virtual interface */ | ||
205 | if (memcmp(hdr->addr2, sta->sdata->vif.addr, ETH_ALEN)) | ||
206 | continue; | ||
170 | 207 | ||
171 | if (sta) { | ||
172 | if (!(info->flags & IEEE80211_TX_STAT_ACK) && | 208 | if (!(info->flags & IEEE80211_TX_STAT_ACK) && |
173 | test_sta_flags(sta, WLAN_STA_PS_STA)) { | 209 | test_sta_flags(sta, WLAN_STA_PS_STA)) { |
174 | /* | 210 | /* |
@@ -208,6 +244,10 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
208 | rate_control_tx_status(local, sband, sta, skb); | 244 | rate_control_tx_status(local, sband, sta, skb); |
209 | if (ieee80211_vif_is_mesh(&sta->sdata->vif)) | 245 | if (ieee80211_vif_is_mesh(&sta->sdata->vif)) |
210 | ieee80211s_update_metric(local, sta, skb); | 246 | ieee80211s_update_metric(local, sta, skb); |
247 | |||
248 | if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && | ||
249 | (info->flags & IEEE80211_TX_STAT_ACK)) | ||
250 | ieee80211_frame_acked(sta, skb); | ||
211 | } | 251 | } |
212 | 252 | ||
213 | rcu_read_unlock(); | 253 | rcu_read_unlock(); |
@@ -311,7 +351,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
311 | rcu_read_lock(); | 351 | rcu_read_lock(); |
312 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 352 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
313 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { | 353 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { |
314 | if (!netif_running(sdata->dev)) | 354 | if (!ieee80211_sdata_running(sdata)) |
315 | continue; | 355 | continue; |
316 | 356 | ||
317 | if ((sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) && | 357 | if ((sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) && |
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c index 4921d724b6c7..b73454a507f9 100644 --- a/net/mac80211/tkip.c +++ b/net/mac80211/tkip.c | |||
@@ -100,7 +100,7 @@ static void tkip_mixing_phase1(const u8 *tk, struct tkip_ctx *ctx, | |||
100 | p1k[3] += tkipS(p1k[2] ^ get_unaligned_le16(tk + 12 + j)); | 100 | p1k[3] += tkipS(p1k[2] ^ get_unaligned_le16(tk + 12 + j)); |
101 | p1k[4] += tkipS(p1k[3] ^ get_unaligned_le16(tk + 0 + j)) + i; | 101 | p1k[4] += tkipS(p1k[3] ^ get_unaligned_le16(tk + 0 + j)) + i; |
102 | } | 102 | } |
103 | ctx->initialized = 1; | 103 | ctx->state = TKIP_STATE_PHASE1_DONE; |
104 | } | 104 | } |
105 | 105 | ||
106 | static void tkip_mixing_phase2(const u8 *tk, struct tkip_ctx *ctx, | 106 | static void tkip_mixing_phase2(const u8 *tk, struct tkip_ctx *ctx, |
@@ -183,7 +183,7 @@ void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf, | |||
183 | /* Update the p1k only when the iv16 in the packet wraps around, this | 183 | /* Update the p1k only when the iv16 in the packet wraps around, this |
184 | * might occur after the wrap around of iv16 in the key in case of | 184 | * might occur after the wrap around of iv16 in the key in case of |
185 | * fragmented packets. */ | 185 | * fragmented packets. */ |
186 | if (iv16 == 0 || !ctx->initialized) | 186 | if (iv16 == 0 || ctx->state == TKIP_STATE_NOT_INIT) |
187 | tkip_mixing_phase1(tk, ctx, hdr->addr2, iv32); | 187 | tkip_mixing_phase1(tk, ctx, hdr->addr2, iv32); |
188 | 188 | ||
189 | if (type == IEEE80211_TKIP_P1_KEY) { | 189 | if (type == IEEE80211_TKIP_P1_KEY) { |
@@ -209,7 +209,7 @@ void ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm, | |||
209 | const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; | 209 | const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; |
210 | 210 | ||
211 | /* Calculate per-packet key */ | 211 | /* Calculate per-packet key */ |
212 | if (ctx->iv16 == 0 || !ctx->initialized) | 212 | if (ctx->iv16 == 0 || ctx->state == TKIP_STATE_NOT_INIT) |
213 | tkip_mixing_phase1(tk, ctx, ta, ctx->iv32); | 213 | tkip_mixing_phase1(tk, ctx, ta, ctx->iv32); |
214 | 214 | ||
215 | tkip_mixing_phase2(tk, ctx, ctx->iv16, rc4key); | 215 | tkip_mixing_phase2(tk, ctx, ctx->iv16, rc4key); |
@@ -259,7 +259,7 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm, | |||
259 | if ((keyid >> 6) != key->conf.keyidx) | 259 | if ((keyid >> 6) != key->conf.keyidx) |
260 | return TKIP_DECRYPT_INVALID_KEYIDX; | 260 | return TKIP_DECRYPT_INVALID_KEYIDX; |
261 | 261 | ||
262 | if (key->u.tkip.rx[queue].initialized && | 262 | if (key->u.tkip.rx[queue].state != TKIP_STATE_NOT_INIT && |
263 | (iv32 < key->u.tkip.rx[queue].iv32 || | 263 | (iv32 < key->u.tkip.rx[queue].iv32 || |
264 | (iv32 == key->u.tkip.rx[queue].iv32 && | 264 | (iv32 == key->u.tkip.rx[queue].iv32 && |
265 | iv16 <= key->u.tkip.rx[queue].iv16))) { | 265 | iv16 <= key->u.tkip.rx[queue].iv16))) { |
@@ -275,11 +275,11 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm, | |||
275 | 275 | ||
276 | if (only_iv) { | 276 | if (only_iv) { |
277 | res = TKIP_DECRYPT_OK; | 277 | res = TKIP_DECRYPT_OK; |
278 | key->u.tkip.rx[queue].initialized = 1; | 278 | key->u.tkip.rx[queue].state = TKIP_STATE_PHASE1_HW_UPLOADED; |
279 | goto done; | 279 | goto done; |
280 | } | 280 | } |
281 | 281 | ||
282 | if (!key->u.tkip.rx[queue].initialized || | 282 | if (key->u.tkip.rx[queue].state == TKIP_STATE_NOT_INIT || |
283 | key->u.tkip.rx[queue].iv32 != iv32) { | 283 | key->u.tkip.rx[queue].iv32 != iv32) { |
284 | /* IV16 wrapped around - perform TKIP phase 1 */ | 284 | /* IV16 wrapped around - perform TKIP phase 1 */ |
285 | tkip_mixing_phase1(tk, &key->u.tkip.rx[queue], ta, iv32); | 285 | tkip_mixing_phase1(tk, &key->u.tkip.rx[queue], ta, iv32); |
@@ -299,18 +299,20 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm, | |||
299 | printk("\n"); | 299 | printk("\n"); |
300 | } | 300 | } |
301 | #endif | 301 | #endif |
302 | if (key->local->ops->update_tkip_key && | 302 | } |
303 | key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { | 303 | if (key->local->ops->update_tkip_key && |
304 | static const u8 bcast[ETH_ALEN] = | 304 | key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && |
305 | {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; | 305 | key->u.tkip.rx[queue].state != TKIP_STATE_PHASE1_HW_UPLOADED) { |
306 | const u8 *sta_addr = key->sta->sta.addr; | 306 | static const u8 bcast[ETH_ALEN] = |
307 | 307 | {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
308 | if (is_multicast_ether_addr(ra)) | 308 | const u8 *sta_addr = key->sta->sta.addr; |
309 | sta_addr = bcast; | 309 | |
310 | 310 | if (is_multicast_ether_addr(ra)) | |
311 | drv_update_tkip_key(key->local, &key->conf, sta_addr, | 311 | sta_addr = bcast; |
312 | iv32, key->u.tkip.rx[queue].p1k); | 312 | |
313 | } | 313 | drv_update_tkip_key(key->local, &key->conf, sta_addr, |
314 | iv32, key->u.tkip.rx[queue].p1k); | ||
315 | key->u.tkip.rx[queue].state = TKIP_STATE_PHASE1_HW_UPLOADED; | ||
314 | } | 316 | } |
315 | 317 | ||
316 | tkip_mixing_phase2(tk, &key->u.tkip.rx[queue], iv16, rc4key); | 318 | tkip_mixing_phase2(tk, &key->u.tkip.rx[queue], iv16, rc4key); |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index ac210b586702..daf81048c1f7 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -180,6 +180,71 @@ static int inline is_ieee80211_device(struct ieee80211_local *local, | |||
180 | } | 180 | } |
181 | 181 | ||
182 | /* tx handlers */ | 182 | /* tx handlers */ |
183 | static ieee80211_tx_result debug_noinline | ||
184 | ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx) | ||
185 | { | ||
186 | struct ieee80211_local *local = tx->local; | ||
187 | struct ieee80211_if_managed *ifmgd; | ||
188 | |||
189 | /* driver doesn't support power save */ | ||
190 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) | ||
191 | return TX_CONTINUE; | ||
192 | |||
193 | /* hardware does dynamic power save */ | ||
194 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) | ||
195 | return TX_CONTINUE; | ||
196 | |||
197 | /* dynamic power save disabled */ | ||
198 | if (local->hw.conf.dynamic_ps_timeout <= 0) | ||
199 | return TX_CONTINUE; | ||
200 | |||
201 | /* we are scanning, don't enable power save */ | ||
202 | if (local->scanning) | ||
203 | return TX_CONTINUE; | ||
204 | |||
205 | if (!local->ps_sdata) | ||
206 | return TX_CONTINUE; | ||
207 | |||
208 | /* No point if we're going to suspend */ | ||
209 | if (local->quiescing) | ||
210 | return TX_CONTINUE; | ||
211 | |||
212 | /* dynamic ps is supported only in managed mode */ | ||
213 | if (tx->sdata->vif.type != NL80211_IFTYPE_STATION) | ||
214 | return TX_CONTINUE; | ||
215 | |||
216 | ifmgd = &tx->sdata->u.mgd; | ||
217 | |||
218 | /* | ||
219 | * Don't wakeup from power save if u-apsd is enabled, voip ac has | ||
220 | * u-apsd enabled and the frame is in voip class. This effectively | ||
221 | * means that even if all access categories have u-apsd enabled, in | ||
222 | * practise u-apsd is only used with the voip ac. This is a | ||
223 | * workaround for the case when received voip class packets do not | ||
224 | * have correct qos tag for some reason, due the network or the | ||
225 | * peer application. | ||
226 | * | ||
227 | * Note: local->uapsd_queues access is racy here. If the value is | ||
228 | * changed via debugfs, user needs to reassociate manually to have | ||
229 | * everything in sync. | ||
230 | */ | ||
231 | if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) | ||
232 | && (local->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) | ||
233 | && skb_get_queue_mapping(tx->skb) == 0) | ||
234 | return TX_CONTINUE; | ||
235 | |||
236 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { | ||
237 | ieee80211_stop_queues_by_reason(&local->hw, | ||
238 | IEEE80211_QUEUE_STOP_REASON_PS); | ||
239 | ieee80211_queue_work(&local->hw, | ||
240 | &local->dynamic_ps_disable_work); | ||
241 | } | ||
242 | |||
243 | mod_timer(&local->dynamic_ps_timer, jiffies + | ||
244 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | ||
245 | |||
246 | return TX_CONTINUE; | ||
247 | } | ||
183 | 248 | ||
184 | static ieee80211_tx_result debug_noinline | 249 | static ieee80211_tx_result debug_noinline |
185 | ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) | 250 | ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) |
@@ -223,7 +288,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) | |||
223 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 288 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
224 | printk(KERN_DEBUG "%s: dropped data frame to not " | 289 | printk(KERN_DEBUG "%s: dropped data frame to not " |
225 | "associated station %pM\n", | 290 | "associated station %pM\n", |
226 | tx->dev->name, hdr->addr1); | 291 | tx->sdata->name, hdr->addr1); |
227 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 292 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
228 | I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); | 293 | I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); |
229 | return TX_DROP; | 294 | return TX_DROP; |
@@ -331,7 +396,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
331 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 396 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
332 | if (net_ratelimit()) | 397 | if (net_ratelimit()) |
333 | printk(KERN_DEBUG "%s: BC TX buffer full - dropping the oldest frame\n", | 398 | printk(KERN_DEBUG "%s: BC TX buffer full - dropping the oldest frame\n", |
334 | tx->dev->name); | 399 | tx->sdata->name); |
335 | #endif | 400 | #endif |
336 | dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf)); | 401 | dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf)); |
337 | } else | 402 | } else |
@@ -391,7 +456,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
391 | if (net_ratelimit()) { | 456 | if (net_ratelimit()) { |
392 | printk(KERN_DEBUG "%s: STA %pM TX " | 457 | printk(KERN_DEBUG "%s: STA %pM TX " |
393 | "buffer full - dropping oldest frame\n", | 458 | "buffer full - dropping oldest frame\n", |
394 | tx->dev->name, sta->sta.addr); | 459 | tx->sdata->name, sta->sta.addr); |
395 | } | 460 | } |
396 | #endif | 461 | #endif |
397 | dev_kfree_skb(old); | 462 | dev_kfree_skb(old); |
@@ -416,7 +481,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
416 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 481 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
417 | else if (unlikely(staflags & WLAN_STA_PS_STA)) { | 482 | else if (unlikely(staflags & WLAN_STA_PS_STA)) { |
418 | printk(KERN_DEBUG "%s: STA %pM in PS mode, but pspoll " | 483 | printk(KERN_DEBUG "%s: STA %pM in PS mode, but pspoll " |
419 | "set -> send frame\n", tx->dev->name, | 484 | "set -> send frame\n", tx->sdata->name, |
420 | sta->sta.addr); | 485 | sta->sta.addr); |
421 | } | 486 | } |
422 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 487 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
@@ -519,7 +584,12 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
519 | txrc.bss_conf = &tx->sdata->vif.bss_conf; | 584 | txrc.bss_conf = &tx->sdata->vif.bss_conf; |
520 | txrc.skb = tx->skb; | 585 | txrc.skb = tx->skb; |
521 | txrc.reported_rate.idx = -1; | 586 | txrc.reported_rate.idx = -1; |
522 | txrc.max_rate_idx = tx->sdata->max_ratectrl_rateidx; | 587 | txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[tx->channel->band]; |
588 | if (txrc.rate_idx_mask == (1 << sband->n_bitrates) - 1) | ||
589 | txrc.max_rate_idx = -1; | ||
590 | else | ||
591 | txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; | ||
592 | txrc.ap = tx->sdata->vif.type == NL80211_IFTYPE_AP; | ||
523 | 593 | ||
524 | /* set up RTS protection if desired */ | 594 | /* set up RTS protection if desired */ |
525 | if (len > tx->local->hw.wiphy->rts_threshold) { | 595 | if (len > tx->local->hw.wiphy->rts_threshold) { |
@@ -549,7 +619,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
549 | "%s: Dropped data frame as no usable bitrate found while " | 619 | "%s: Dropped data frame as no usable bitrate found while " |
550 | "scanning and associated. Target station: " | 620 | "scanning and associated. Target station: " |
551 | "%pM on %d GHz band\n", | 621 | "%pM on %d GHz band\n", |
552 | tx->dev->name, hdr->addr1, | 622 | tx->sdata->name, hdr->addr1, |
553 | tx->channel->band ? 5 : 2)) | 623 | tx->channel->band ? 5 : 2)) |
554 | return TX_DROP; | 624 | return TX_DROP; |
555 | 625 | ||
@@ -1021,7 +1091,6 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, | |||
1021 | 1091 | ||
1022 | memset(tx, 0, sizeof(*tx)); | 1092 | memset(tx, 0, sizeof(*tx)); |
1023 | tx->skb = skb; | 1093 | tx->skb = skb; |
1024 | tx->dev = sdata->dev; /* use original interface */ | ||
1025 | tx->local = local; | 1094 | tx->local = local; |
1026 | tx->sdata = sdata; | 1095 | tx->sdata = sdata; |
1027 | tx->channel = local->hw.conf.channel; | 1096 | tx->channel = local->hw.conf.channel; |
@@ -1052,10 +1121,13 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, | |||
1052 | 1121 | ||
1053 | hdr = (struct ieee80211_hdr *) skb->data; | 1122 | hdr = (struct ieee80211_hdr *) skb->data; |
1054 | 1123 | ||
1055 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 1124 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { |
1056 | tx->sta = rcu_dereference(sdata->u.vlan.sta); | 1125 | tx->sta = rcu_dereference(sdata->u.vlan.sta); |
1126 | if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr) | ||
1127 | return TX_DROP; | ||
1128 | } | ||
1057 | if (!tx->sta) | 1129 | if (!tx->sta) |
1058 | tx->sta = sta_info_get(local, hdr->addr1); | 1130 | tx->sta = sta_info_get(sdata, hdr->addr1); |
1059 | 1131 | ||
1060 | if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && | 1132 | if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && |
1061 | (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION)) { | 1133 | (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION)) { |
@@ -1216,6 +1288,7 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) | |||
1216 | goto txh_done; \ | 1288 | goto txh_done; \ |
1217 | } while (0) | 1289 | } while (0) |
1218 | 1290 | ||
1291 | CALL_TXH(ieee80211_tx_h_dynamic_ps); | ||
1219 | CALL_TXH(ieee80211_tx_h_check_assoc); | 1292 | CALL_TXH(ieee80211_tx_h_check_assoc); |
1220 | CALL_TXH(ieee80211_tx_h_ps_buf); | 1293 | CALL_TXH(ieee80211_tx_h_ps_buf); |
1221 | CALL_TXH(ieee80211_tx_h_select_key); | 1294 | CALL_TXH(ieee80211_tx_h_select_key); |
@@ -1398,34 +1471,6 @@ static int ieee80211_skb_resize(struct ieee80211_local *local, | |||
1398 | return 0; | 1471 | return 0; |
1399 | } | 1472 | } |
1400 | 1473 | ||
1401 | static bool need_dynamic_ps(struct ieee80211_local *local) | ||
1402 | { | ||
1403 | /* driver doesn't support power save */ | ||
1404 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) | ||
1405 | return false; | ||
1406 | |||
1407 | /* hardware does dynamic power save */ | ||
1408 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) | ||
1409 | return false; | ||
1410 | |||
1411 | /* dynamic power save disabled */ | ||
1412 | if (local->hw.conf.dynamic_ps_timeout <= 0) | ||
1413 | return false; | ||
1414 | |||
1415 | /* we are scanning, don't enable power save */ | ||
1416 | if (local->scanning) | ||
1417 | return false; | ||
1418 | |||
1419 | if (!local->ps_sdata) | ||
1420 | return false; | ||
1421 | |||
1422 | /* No point if we're going to suspend */ | ||
1423 | if (local->quiescing) | ||
1424 | return false; | ||
1425 | |||
1426 | return true; | ||
1427 | } | ||
1428 | |||
1429 | static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, | 1474 | static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, |
1430 | struct sk_buff *skb) | 1475 | struct sk_buff *skb) |
1431 | { | 1476 | { |
@@ -1436,18 +1481,6 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, | |||
1436 | int headroom; | 1481 | int headroom; |
1437 | bool may_encrypt; | 1482 | bool may_encrypt; |
1438 | 1483 | ||
1439 | if (need_dynamic_ps(local)) { | ||
1440 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { | ||
1441 | ieee80211_stop_queues_by_reason(&local->hw, | ||
1442 | IEEE80211_QUEUE_STOP_REASON_PS); | ||
1443 | ieee80211_queue_work(&local->hw, | ||
1444 | &local->dynamic_ps_disable_work); | ||
1445 | } | ||
1446 | |||
1447 | mod_timer(&local->dynamic_ps_timer, jiffies + | ||
1448 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | ||
1449 | } | ||
1450 | |||
1451 | rcu_read_lock(); | 1484 | rcu_read_lock(); |
1452 | 1485 | ||
1453 | if (unlikely(sdata->vif.type == NL80211_IFTYPE_MONITOR)) { | 1486 | if (unlikely(sdata->vif.type == NL80211_IFTYPE_MONITOR)) { |
@@ -1474,11 +1507,11 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, | |||
1474 | 1507 | ||
1475 | list_for_each_entry_rcu(tmp_sdata, &local->interfaces, | 1508 | list_for_each_entry_rcu(tmp_sdata, &local->interfaces, |
1476 | list) { | 1509 | list) { |
1477 | if (!netif_running(tmp_sdata->dev)) | 1510 | if (!ieee80211_sdata_running(tmp_sdata)) |
1478 | continue; | 1511 | continue; |
1479 | if (tmp_sdata->vif.type != NL80211_IFTYPE_AP) | 1512 | if (tmp_sdata->vif.type != NL80211_IFTYPE_AP) |
1480 | continue; | 1513 | continue; |
1481 | if (compare_ether_addr(tmp_sdata->dev->dev_addr, | 1514 | if (compare_ether_addr(tmp_sdata->vif.addr, |
1482 | hdr->addr2) == 0) { | 1515 | hdr->addr2) == 0) { |
1483 | sdata = tmp_sdata; | 1516 | sdata = tmp_sdata; |
1484 | break; | 1517 | break; |
@@ -1642,7 +1675,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1642 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | 1675 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
1643 | /* RA TA DA SA */ | 1676 | /* RA TA DA SA */ |
1644 | memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); | 1677 | memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); |
1645 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | 1678 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); |
1646 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1679 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1647 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | 1680 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); |
1648 | hdrlen = 30; | 1681 | hdrlen = 30; |
@@ -1656,7 +1689,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1656 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS); | 1689 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS); |
1657 | /* DA BSSID SA */ | 1690 | /* DA BSSID SA */ |
1658 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | 1691 | memcpy(hdr.addr1, skb->data, ETH_ALEN); |
1659 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | 1692 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); |
1660 | memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); | 1693 | memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); |
1661 | hdrlen = 24; | 1694 | hdrlen = 24; |
1662 | break; | 1695 | break; |
@@ -1664,7 +1697,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1664 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | 1697 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
1665 | /* RA TA DA SA */ | 1698 | /* RA TA DA SA */ |
1666 | memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN); | 1699 | memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN); |
1667 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | 1700 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); |
1668 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1701 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1669 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | 1702 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); |
1670 | hdrlen = 30; | 1703 | hdrlen = 30; |
@@ -1678,8 +1711,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1678 | goto fail; | 1711 | goto fail; |
1679 | } | 1712 | } |
1680 | 1713 | ||
1681 | if (compare_ether_addr(dev->dev_addr, | 1714 | if (compare_ether_addr(sdata->vif.addr, |
1682 | skb->data + ETH_ALEN) == 0) { | 1715 | skb->data + ETH_ALEN) == 0) { |
1683 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, | 1716 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, |
1684 | skb->data, skb->data + ETH_ALEN); | 1717 | skb->data, skb->data + ETH_ALEN); |
1685 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, | 1718 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, |
@@ -1709,7 +1742,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1709 | } | 1742 | } |
1710 | } | 1743 | } |
1711 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, | 1744 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, |
1712 | mesh_da, dev->dev_addr); | 1745 | mesh_da, sdata->vif.addr); |
1713 | rcu_read_unlock(); | 1746 | rcu_read_unlock(); |
1714 | if (is_mesh_mcast) | 1747 | if (is_mesh_mcast) |
1715 | meshhdrlen = | 1748 | meshhdrlen = |
@@ -1734,7 +1767,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1734 | if (sdata->u.mgd.use_4addr && ethertype != ETH_P_PAE) { | 1767 | if (sdata->u.mgd.use_4addr && ethertype != ETH_P_PAE) { |
1735 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | 1768 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
1736 | /* RA TA DA SA */ | 1769 | /* RA TA DA SA */ |
1737 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | 1770 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); |
1738 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1771 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1739 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | 1772 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); |
1740 | hdrlen = 30; | 1773 | hdrlen = 30; |
@@ -1765,9 +1798,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1765 | */ | 1798 | */ |
1766 | if (!is_multicast_ether_addr(hdr.addr1)) { | 1799 | if (!is_multicast_ether_addr(hdr.addr1)) { |
1767 | rcu_read_lock(); | 1800 | rcu_read_lock(); |
1768 | sta = sta_info_get(local, hdr.addr1); | 1801 | sta = sta_info_get(sdata, hdr.addr1); |
1769 | /* XXX: in the future, use sdata to look up the sta */ | 1802 | if (sta) |
1770 | if (sta && sta->sdata == sdata) | ||
1771 | sta_flags = get_sta_flags(sta); | 1803 | sta_flags = get_sta_flags(sta); |
1772 | rcu_read_unlock(); | 1804 | rcu_read_unlock(); |
1773 | } | 1805 | } |
@@ -1786,7 +1818,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1786 | unlikely(!is_multicast_ether_addr(hdr.addr1) && | 1818 | unlikely(!is_multicast_ether_addr(hdr.addr1) && |
1787 | !(sta_flags & WLAN_STA_AUTHORIZED) && | 1819 | !(sta_flags & WLAN_STA_AUTHORIZED) && |
1788 | !(ethertype == ETH_P_PAE && | 1820 | !(ethertype == ETH_P_PAE && |
1789 | compare_ether_addr(dev->dev_addr, | 1821 | compare_ether_addr(sdata->vif.addr, |
1790 | skb->data + ETH_ALEN) == 0))) { | 1822 | skb->data + ETH_ALEN) == 0))) { |
1791 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 1823 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
1792 | if (net_ratelimit()) | 1824 | if (net_ratelimit()) |
@@ -1926,7 +1958,7 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local, | |||
1926 | ieee80211_tx(sdata, skb, true); | 1958 | ieee80211_tx(sdata, skb, true); |
1927 | } else { | 1959 | } else { |
1928 | hdr = (struct ieee80211_hdr *)skb->data; | 1960 | hdr = (struct ieee80211_hdr *)skb->data; |
1929 | sta = sta_info_get(local, hdr->addr1); | 1961 | sta = sta_info_get(sdata, hdr->addr1); |
1930 | 1962 | ||
1931 | ret = __ieee80211_tx(local, &skb, sta, true); | 1963 | ret = __ieee80211_tx(local, &skb, sta, true); |
1932 | if (ret != IEEE80211_TX_OK) | 1964 | if (ret != IEEE80211_TX_OK) |
@@ -2062,6 +2094,7 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2062 | struct beacon_data *beacon; | 2094 | struct beacon_data *beacon; |
2063 | struct ieee80211_supported_band *sband; | 2095 | struct ieee80211_supported_band *sband; |
2064 | enum ieee80211_band band = local->hw.conf.channel->band; | 2096 | enum ieee80211_band band = local->hw.conf.channel->band; |
2097 | struct ieee80211_tx_rate_control txrc; | ||
2065 | 2098 | ||
2066 | sband = local->hw.wiphy->bands[band]; | 2099 | sband = local->hw.wiphy->bands[band]; |
2067 | 2100 | ||
@@ -2150,8 +2183,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2150 | mgmt->frame_control = | 2183 | mgmt->frame_control = |
2151 | cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); | 2184 | cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
2152 | memset(mgmt->da, 0xff, ETH_ALEN); | 2185 | memset(mgmt->da, 0xff, ETH_ALEN); |
2153 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 2186 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
2154 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | 2187 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
2155 | mgmt->u.beacon.beacon_int = | 2188 | mgmt->u.beacon.beacon_int = |
2156 | cpu_to_le16(sdata->vif.bss_conf.beacon_int); | 2189 | cpu_to_le16(sdata->vif.bss_conf.beacon_int); |
2157 | mgmt->u.beacon.capab_info = 0x0; /* 0x0 for MPs */ | 2190 | mgmt->u.beacon.capab_info = 0x0; /* 0x0 for MPs */ |
@@ -2169,21 +2202,25 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2169 | info = IEEE80211_SKB_CB(skb); | 2202 | info = IEEE80211_SKB_CB(skb); |
2170 | 2203 | ||
2171 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 2204 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
2205 | info->flags |= IEEE80211_TX_CTL_NO_ACK; | ||
2172 | info->band = band; | 2206 | info->band = band; |
2173 | /* | 2207 | |
2174 | * XXX: For now, always use the lowest rate | 2208 | memset(&txrc, 0, sizeof(txrc)); |
2175 | */ | 2209 | txrc.hw = hw; |
2176 | info->control.rates[0].idx = 0; | 2210 | txrc.sband = sband; |
2177 | info->control.rates[0].count = 1; | 2211 | txrc.bss_conf = &sdata->vif.bss_conf; |
2178 | info->control.rates[1].idx = -1; | 2212 | txrc.skb = skb; |
2179 | info->control.rates[2].idx = -1; | 2213 | txrc.reported_rate.idx = -1; |
2180 | info->control.rates[3].idx = -1; | 2214 | txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; |
2181 | info->control.rates[4].idx = -1; | 2215 | if (txrc.rate_idx_mask == (1 << sband->n_bitrates) - 1) |
2182 | BUILD_BUG_ON(IEEE80211_TX_MAX_RATES != 5); | 2216 | txrc.max_rate_idx = -1; |
2217 | else | ||
2218 | txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; | ||
2219 | txrc.ap = true; | ||
2220 | rate_control_get_rate(sdata, NULL, &txrc); | ||
2183 | 2221 | ||
2184 | info->control.vif = vif; | 2222 | info->control.vif = vif; |
2185 | 2223 | ||
2186 | info->flags |= IEEE80211_TX_CTL_NO_ACK; | ||
2187 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | 2224 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
2188 | info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; | 2225 | info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; |
2189 | out: | 2226 | out: |
@@ -2192,6 +2229,134 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2192 | } | 2229 | } |
2193 | EXPORT_SYMBOL(ieee80211_beacon_get_tim); | 2230 | EXPORT_SYMBOL(ieee80211_beacon_get_tim); |
2194 | 2231 | ||
2232 | struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw, | ||
2233 | struct ieee80211_vif *vif) | ||
2234 | { | ||
2235 | struct ieee80211_sub_if_data *sdata; | ||
2236 | struct ieee80211_if_managed *ifmgd; | ||
2237 | struct ieee80211_pspoll *pspoll; | ||
2238 | struct ieee80211_local *local; | ||
2239 | struct sk_buff *skb; | ||
2240 | |||
2241 | if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) | ||
2242 | return NULL; | ||
2243 | |||
2244 | sdata = vif_to_sdata(vif); | ||
2245 | ifmgd = &sdata->u.mgd; | ||
2246 | local = sdata->local; | ||
2247 | |||
2248 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); | ||
2249 | if (!skb) { | ||
2250 | printk(KERN_DEBUG "%s: failed to allocate buffer for " | ||
2251 | "pspoll template\n", sdata->name); | ||
2252 | return NULL; | ||
2253 | } | ||
2254 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
2255 | |||
2256 | pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll)); | ||
2257 | memset(pspoll, 0, sizeof(*pspoll)); | ||
2258 | pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | | ||
2259 | IEEE80211_STYPE_PSPOLL); | ||
2260 | pspoll->aid = cpu_to_le16(ifmgd->aid); | ||
2261 | |||
2262 | /* aid in PS-Poll has its two MSBs each set to 1 */ | ||
2263 | pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); | ||
2264 | |||
2265 | memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN); | ||
2266 | memcpy(pspoll->ta, vif->addr, ETH_ALEN); | ||
2267 | |||
2268 | return skb; | ||
2269 | } | ||
2270 | EXPORT_SYMBOL(ieee80211_pspoll_get); | ||
2271 | |||
2272 | struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw, | ||
2273 | struct ieee80211_vif *vif) | ||
2274 | { | ||
2275 | struct ieee80211_hdr_3addr *nullfunc; | ||
2276 | struct ieee80211_sub_if_data *sdata; | ||
2277 | struct ieee80211_if_managed *ifmgd; | ||
2278 | struct ieee80211_local *local; | ||
2279 | struct sk_buff *skb; | ||
2280 | |||
2281 | if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) | ||
2282 | return NULL; | ||
2283 | |||
2284 | sdata = vif_to_sdata(vif); | ||
2285 | ifmgd = &sdata->u.mgd; | ||
2286 | local = sdata->local; | ||
2287 | |||
2288 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*nullfunc)); | ||
2289 | if (!skb) { | ||
2290 | printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc " | ||
2291 | "template\n", sdata->name); | ||
2292 | return NULL; | ||
2293 | } | ||
2294 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
2295 | |||
2296 | nullfunc = (struct ieee80211_hdr_3addr *) skb_put(skb, | ||
2297 | sizeof(*nullfunc)); | ||
2298 | memset(nullfunc, 0, sizeof(*nullfunc)); | ||
2299 | nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | | ||
2300 | IEEE80211_STYPE_NULLFUNC | | ||
2301 | IEEE80211_FCTL_TODS); | ||
2302 | memcpy(nullfunc->addr1, ifmgd->bssid, ETH_ALEN); | ||
2303 | memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); | ||
2304 | memcpy(nullfunc->addr3, ifmgd->bssid, ETH_ALEN); | ||
2305 | |||
2306 | return skb; | ||
2307 | } | ||
2308 | EXPORT_SYMBOL(ieee80211_nullfunc_get); | ||
2309 | |||
2310 | struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, | ||
2311 | struct ieee80211_vif *vif, | ||
2312 | const u8 *ssid, size_t ssid_len, | ||
2313 | const u8 *ie, size_t ie_len) | ||
2314 | { | ||
2315 | struct ieee80211_sub_if_data *sdata; | ||
2316 | struct ieee80211_local *local; | ||
2317 | struct ieee80211_hdr_3addr *hdr; | ||
2318 | struct sk_buff *skb; | ||
2319 | size_t ie_ssid_len; | ||
2320 | u8 *pos; | ||
2321 | |||
2322 | sdata = vif_to_sdata(vif); | ||
2323 | local = sdata->local; | ||
2324 | ie_ssid_len = 2 + ssid_len; | ||
2325 | |||
2326 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + | ||
2327 | ie_ssid_len + ie_len); | ||
2328 | if (!skb) { | ||
2329 | printk(KERN_DEBUG "%s: failed to allocate buffer for probe " | ||
2330 | "request template\n", sdata->name); | ||
2331 | return NULL; | ||
2332 | } | ||
2333 | |||
2334 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
2335 | |||
2336 | hdr = (struct ieee80211_hdr_3addr *) skb_put(skb, sizeof(*hdr)); | ||
2337 | memset(hdr, 0, sizeof(*hdr)); | ||
2338 | hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
2339 | IEEE80211_STYPE_PROBE_REQ); | ||
2340 | memset(hdr->addr1, 0xff, ETH_ALEN); | ||
2341 | memcpy(hdr->addr2, vif->addr, ETH_ALEN); | ||
2342 | memset(hdr->addr3, 0xff, ETH_ALEN); | ||
2343 | |||
2344 | pos = skb_put(skb, ie_ssid_len); | ||
2345 | *pos++ = WLAN_EID_SSID; | ||
2346 | *pos++ = ssid_len; | ||
2347 | if (ssid) | ||
2348 | memcpy(pos, ssid, ssid_len); | ||
2349 | pos += ssid_len; | ||
2350 | |||
2351 | if (ie) { | ||
2352 | pos = skb_put(skb, ie_len); | ||
2353 | memcpy(pos, ie, ie_len); | ||
2354 | } | ||
2355 | |||
2356 | return skb; | ||
2357 | } | ||
2358 | EXPORT_SYMBOL(ieee80211_probereq_get); | ||
2359 | |||
2195 | void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 2360 | void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
2196 | const void *frame, size_t frame_len, | 2361 | const void *frame, size_t frame_len, |
2197 | const struct ieee80211_tx_info *frame_txctl, | 2362 | const struct ieee80211_tx_info *frame_txctl, |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 3848140313f5..ca170b417da6 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/skbuff.h> | 18 | #include <linux/skbuff.h> |
19 | #include <linux/etherdevice.h> | 19 | #include <linux/etherdevice.h> |
20 | #include <linux/if_arp.h> | 20 | #include <linux/if_arp.h> |
21 | #include <linux/wireless.h> | ||
22 | #include <linux/bitmap.h> | 21 | #include <linux/bitmap.h> |
23 | #include <linux/crc32.h> | 22 | #include <linux/crc32.h> |
24 | #include <net/net_namespace.h> | 23 | #include <net/net_namespace.h> |
@@ -480,8 +479,8 @@ void ieee80211_iterate_active_interfaces( | |||
480 | case NL80211_IFTYPE_MESH_POINT: | 479 | case NL80211_IFTYPE_MESH_POINT: |
481 | break; | 480 | break; |
482 | } | 481 | } |
483 | if (netif_running(sdata->dev)) | 482 | if (ieee80211_sdata_running(sdata)) |
484 | iterator(data, sdata->dev->dev_addr, | 483 | iterator(data, sdata->vif.addr, |
485 | &sdata->vif); | 484 | &sdata->vif); |
486 | } | 485 | } |
487 | 486 | ||
@@ -514,8 +513,8 @@ void ieee80211_iterate_active_interfaces_atomic( | |||
514 | case NL80211_IFTYPE_MESH_POINT: | 513 | case NL80211_IFTYPE_MESH_POINT: |
515 | break; | 514 | break; |
516 | } | 515 | } |
517 | if (netif_running(sdata->dev)) | 516 | if (ieee80211_sdata_running(sdata)) |
518 | iterator(data, sdata->dev->dev_addr, | 517 | iterator(data, sdata->vif.addr, |
519 | &sdata->vif); | 518 | &sdata->vif); |
520 | } | 519 | } |
521 | 520 | ||
@@ -793,6 +792,8 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata) | |||
793 | break; | 792 | break; |
794 | } | 793 | } |
795 | 794 | ||
795 | qparam.uapsd = false; | ||
796 | |||
796 | drv_conf_tx(local, queue, &qparam); | 797 | drv_conf_tx(local, queue, &qparam); |
797 | } | 798 | } |
798 | } | 799 | } |
@@ -860,7 +861,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | |||
860 | sizeof(*mgmt) + 6 + extra_len); | 861 | sizeof(*mgmt) + 6 + extra_len); |
861 | if (!skb) { | 862 | if (!skb) { |
862 | printk(KERN_DEBUG "%s: failed to allocate buffer for auth " | 863 | printk(KERN_DEBUG "%s: failed to allocate buffer for auth " |
863 | "frame\n", sdata->dev->name); | 864 | "frame\n", sdata->name); |
864 | return; | 865 | return; |
865 | } | 866 | } |
866 | skb_reserve(skb, local->hw.extra_tx_headroom); | 867 | skb_reserve(skb, local->hw.extra_tx_headroom); |
@@ -870,7 +871,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | |||
870 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 871 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
871 | IEEE80211_STYPE_AUTH); | 872 | IEEE80211_STYPE_AUTH); |
872 | memcpy(mgmt->da, bssid, ETH_ALEN); | 873 | memcpy(mgmt->da, bssid, ETH_ALEN); |
873 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 874 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
874 | memcpy(mgmt->bssid, bssid, ETH_ALEN); | 875 | memcpy(mgmt->bssid, bssid, ETH_ALEN); |
875 | mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); | 876 | mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); |
876 | mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); | 877 | mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); |
@@ -893,43 +894,87 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, | |||
893 | enum ieee80211_band band) | 894 | enum ieee80211_band band) |
894 | { | 895 | { |
895 | struct ieee80211_supported_band *sband; | 896 | struct ieee80211_supported_band *sband; |
896 | u8 *pos, *supp_rates_len, *esupp_rates_len = NULL; | 897 | u8 *pos; |
897 | int i; | 898 | size_t offset = 0, noffset; |
899 | int supp_rates_len, i; | ||
898 | 900 | ||
899 | sband = local->hw.wiphy->bands[band]; | 901 | sband = local->hw.wiphy->bands[band]; |
900 | 902 | ||
901 | pos = buffer; | 903 | pos = buffer; |
902 | 904 | ||
905 | supp_rates_len = min_t(int, sband->n_bitrates, 8); | ||
906 | |||
903 | *pos++ = WLAN_EID_SUPP_RATES; | 907 | *pos++ = WLAN_EID_SUPP_RATES; |
904 | supp_rates_len = pos; | 908 | *pos++ = supp_rates_len; |
905 | *pos++ = 0; | 909 | |
906 | 910 | for (i = 0; i < supp_rates_len; i++) { | |
907 | for (i = 0; i < sband->n_bitrates; i++) { | 911 | int rate = sband->bitrates[i].bitrate; |
908 | struct ieee80211_rate *rate = &sband->bitrates[i]; | 912 | *pos++ = (u8) (rate / 5); |
909 | 913 | } | |
910 | if (esupp_rates_len) { | 914 | |
911 | *esupp_rates_len += 1; | 915 | /* insert "request information" if in custom IEs */ |
912 | } else if (*supp_rates_len == 8) { | 916 | if (ie && ie_len) { |
913 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 917 | static const u8 before_extrates[] = { |
914 | esupp_rates_len = pos; | 918 | WLAN_EID_SSID, |
915 | *pos++ = 1; | 919 | WLAN_EID_SUPP_RATES, |
916 | } else | 920 | WLAN_EID_REQUEST, |
917 | *supp_rates_len += 1; | 921 | }; |
922 | noffset = ieee80211_ie_split(ie, ie_len, | ||
923 | before_extrates, | ||
924 | ARRAY_SIZE(before_extrates), | ||
925 | offset); | ||
926 | memcpy(pos, ie + offset, noffset - offset); | ||
927 | pos += noffset - offset; | ||
928 | offset = noffset; | ||
929 | } | ||
930 | |||
931 | if (sband->n_bitrates > i) { | ||
932 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
933 | *pos++ = sband->n_bitrates - i; | ||
918 | 934 | ||
919 | *pos++ = rate->bitrate / 5; | 935 | for (; i < sband->n_bitrates; i++) { |
936 | int rate = sband->bitrates[i].bitrate; | ||
937 | *pos++ = (u8) (rate / 5); | ||
938 | } | ||
939 | } | ||
940 | |||
941 | /* insert custom IEs that go before HT */ | ||
942 | if (ie && ie_len) { | ||
943 | static const u8 before_ht[] = { | ||
944 | WLAN_EID_SSID, | ||
945 | WLAN_EID_SUPP_RATES, | ||
946 | WLAN_EID_REQUEST, | ||
947 | WLAN_EID_EXT_SUPP_RATES, | ||
948 | WLAN_EID_DS_PARAMS, | ||
949 | WLAN_EID_SUPPORTED_REGULATORY_CLASSES, | ||
950 | }; | ||
951 | noffset = ieee80211_ie_split(ie, ie_len, | ||
952 | before_ht, ARRAY_SIZE(before_ht), | ||
953 | offset); | ||
954 | memcpy(pos, ie + offset, noffset - offset); | ||
955 | pos += noffset - offset; | ||
956 | offset = noffset; | ||
920 | } | 957 | } |
921 | 958 | ||
922 | if (sband->ht_cap.ht_supported) { | 959 | if (sband->ht_cap.ht_supported) { |
923 | __le16 tmp = cpu_to_le16(sband->ht_cap.cap); | 960 | u16 cap = sband->ht_cap.cap; |
961 | __le16 tmp; | ||
962 | |||
963 | if (ieee80211_disable_40mhz_24ghz && | ||
964 | sband->band == IEEE80211_BAND_2GHZ) { | ||
965 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||
966 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
967 | } | ||
924 | 968 | ||
925 | *pos++ = WLAN_EID_HT_CAPABILITY; | 969 | *pos++ = WLAN_EID_HT_CAPABILITY; |
926 | *pos++ = sizeof(struct ieee80211_ht_cap); | 970 | *pos++ = sizeof(struct ieee80211_ht_cap); |
927 | memset(pos, 0, sizeof(struct ieee80211_ht_cap)); | 971 | memset(pos, 0, sizeof(struct ieee80211_ht_cap)); |
972 | tmp = cpu_to_le16(cap); | ||
928 | memcpy(pos, &tmp, sizeof(u16)); | 973 | memcpy(pos, &tmp, sizeof(u16)); |
929 | pos += sizeof(u16); | 974 | pos += sizeof(u16); |
930 | /* TODO: needs a define here for << 2 */ | ||
931 | *pos++ = sband->ht_cap.ampdu_factor | | 975 | *pos++ = sband->ht_cap.ampdu_factor | |
932 | (sband->ht_cap.ampdu_density << 2); | 976 | (sband->ht_cap.ampdu_density << |
977 | IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); | ||
933 | memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); | 978 | memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); |
934 | pos += sizeof(sband->ht_cap.mcs); | 979 | pos += sizeof(sband->ht_cap.mcs); |
935 | pos += 2 + 4 + 1; /* ext info, BF cap, antsel */ | 980 | pos += 2 + 4 + 1; /* ext info, BF cap, antsel */ |
@@ -940,9 +985,11 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, | |||
940 | * that calculates local->scan_ies_len. | 985 | * that calculates local->scan_ies_len. |
941 | */ | 986 | */ |
942 | 987 | ||
943 | if (ie) { | 988 | /* add any remaining custom IEs */ |
944 | memcpy(pos, ie, ie_len); | 989 | if (ie && ie_len) { |
945 | pos += ie_len; | 990 | noffset = ie_len; |
991 | memcpy(pos, ie + offset, noffset - offset); | ||
992 | pos += noffset - offset; | ||
946 | } | 993 | } |
947 | 994 | ||
948 | return pos - buffer; | 995 | return pos - buffer; |
@@ -955,40 +1002,33 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, | |||
955 | struct ieee80211_local *local = sdata->local; | 1002 | struct ieee80211_local *local = sdata->local; |
956 | struct sk_buff *skb; | 1003 | struct sk_buff *skb; |
957 | struct ieee80211_mgmt *mgmt; | 1004 | struct ieee80211_mgmt *mgmt; |
958 | u8 *pos; | 1005 | size_t buf_len; |
959 | 1006 | u8 *buf; | |
960 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + 200 + | 1007 | |
961 | ie_len); | 1008 | /* FIXME: come up with a proper value */ |
962 | if (!skb) { | 1009 | buf = kmalloc(200 + ie_len, GFP_KERNEL); |
963 | printk(KERN_DEBUG "%s: failed to allocate buffer for probe " | 1010 | if (!buf) { |
964 | "request\n", sdata->dev->name); | 1011 | printk(KERN_DEBUG "%s: failed to allocate temporary IE " |
1012 | "buffer\n", sdata->name); | ||
965 | return; | 1013 | return; |
966 | } | 1014 | } |
967 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
968 | 1015 | ||
969 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | 1016 | buf_len = ieee80211_build_preq_ies(local, buf, ie, ie_len, |
970 | memset(mgmt, 0, 24); | 1017 | local->hw.conf.channel->band); |
971 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 1018 | |
972 | IEEE80211_STYPE_PROBE_REQ); | 1019 | skb = ieee80211_probereq_get(&local->hw, &sdata->vif, |
973 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 1020 | ssid, ssid_len, |
1021 | buf, buf_len); | ||
1022 | |||
974 | if (dst) { | 1023 | if (dst) { |
1024 | mgmt = (struct ieee80211_mgmt *) skb->data; | ||
975 | memcpy(mgmt->da, dst, ETH_ALEN); | 1025 | memcpy(mgmt->da, dst, ETH_ALEN); |
976 | memcpy(mgmt->bssid, dst, ETH_ALEN); | 1026 | memcpy(mgmt->bssid, dst, ETH_ALEN); |
977 | } else { | ||
978 | memset(mgmt->da, 0xff, ETH_ALEN); | ||
979 | memset(mgmt->bssid, 0xff, ETH_ALEN); | ||
980 | } | 1027 | } |
981 | pos = skb_put(skb, 2 + ssid_len); | ||
982 | *pos++ = WLAN_EID_SSID; | ||
983 | *pos++ = ssid_len; | ||
984 | memcpy(pos, ssid, ssid_len); | ||
985 | pos += ssid_len; | ||
986 | |||
987 | skb_put(skb, ieee80211_build_preq_ies(local, pos, ie, ie_len, | ||
988 | local->hw.conf.channel->band)); | ||
989 | 1028 | ||
990 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 1029 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
991 | ieee80211_tx_skb(sdata, skb); | 1030 | ieee80211_tx_skb(sdata, skb); |
1031 | kfree(buf); | ||
992 | } | 1032 | } |
993 | 1033 | ||
994 | u32 ieee80211_sta_get_rates(struct ieee80211_local *local, | 1034 | u32 ieee80211_sta_get_rates(struct ieee80211_local *local, |
@@ -1032,16 +1072,15 @@ void ieee80211_stop_device(struct ieee80211_local *local) | |||
1032 | ieee80211_led_radio(local, false); | 1072 | ieee80211_led_radio(local, false); |
1033 | 1073 | ||
1034 | cancel_work_sync(&local->reconfig_filter); | 1074 | cancel_work_sync(&local->reconfig_filter); |
1035 | drv_stop(local); | ||
1036 | 1075 | ||
1037 | flush_workqueue(local->workqueue); | 1076 | flush_workqueue(local->workqueue); |
1077 | drv_stop(local); | ||
1038 | } | 1078 | } |
1039 | 1079 | ||
1040 | int ieee80211_reconfig(struct ieee80211_local *local) | 1080 | int ieee80211_reconfig(struct ieee80211_local *local) |
1041 | { | 1081 | { |
1042 | struct ieee80211_hw *hw = &local->hw; | 1082 | struct ieee80211_hw *hw = &local->hw; |
1043 | struct ieee80211_sub_if_data *sdata; | 1083 | struct ieee80211_sub_if_data *sdata; |
1044 | struct ieee80211_if_init_conf conf; | ||
1045 | struct sta_info *sta; | 1084 | struct sta_info *sta; |
1046 | unsigned long flags; | 1085 | unsigned long flags; |
1047 | int res; | 1086 | int res; |
@@ -1061,7 +1100,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1061 | if (res) { | 1100 | if (res) { |
1062 | WARN(local->suspended, "Harware became unavailable " | 1101 | WARN(local->suspended, "Harware became unavailable " |
1063 | "upon resume. This is could be a software issue" | 1102 | "upon resume. This is could be a software issue" |
1064 | "prior to suspend or a harware issue\n"); | 1103 | "prior to suspend or a hardware issue\n"); |
1065 | return res; | 1104 | return res; |
1066 | } | 1105 | } |
1067 | 1106 | ||
@@ -1072,12 +1111,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1072 | list_for_each_entry(sdata, &local->interfaces, list) { | 1111 | list_for_each_entry(sdata, &local->interfaces, list) { |
1073 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && | 1112 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
1074 | sdata->vif.type != NL80211_IFTYPE_MONITOR && | 1113 | sdata->vif.type != NL80211_IFTYPE_MONITOR && |
1075 | netif_running(sdata->dev)) { | 1114 | ieee80211_sdata_running(sdata)) |
1076 | conf.vif = &sdata->vif; | 1115 | res = drv_add_interface(local, &sdata->vif); |
1077 | conf.type = sdata->vif.type; | ||
1078 | conf.mac_addr = sdata->dev->dev_addr; | ||
1079 | res = drv_add_interface(local, &conf); | ||
1080 | } | ||
1081 | } | 1116 | } |
1082 | 1117 | ||
1083 | /* add STAs back */ | 1118 | /* add STAs back */ |
@@ -1090,7 +1125,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1090 | struct ieee80211_sub_if_data, | 1125 | struct ieee80211_sub_if_data, |
1091 | u.ap); | 1126 | u.ap); |
1092 | 1127 | ||
1093 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_ADD, | 1128 | drv_sta_notify(local, sdata, STA_NOTIFY_ADD, |
1094 | &sta->sta); | 1129 | &sta->sta); |
1095 | } | 1130 | } |
1096 | spin_unlock_irqrestore(&local->sta_lock, flags); | 1131 | spin_unlock_irqrestore(&local->sta_lock, flags); |
@@ -1119,7 +1154,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1119 | /* Finally also reconfigure all the BSS information */ | 1154 | /* Finally also reconfigure all the BSS information */ |
1120 | list_for_each_entry(sdata, &local->interfaces, list) { | 1155 | list_for_each_entry(sdata, &local->interfaces, list) { |
1121 | u32 changed = ~0; | 1156 | u32 changed = ~0; |
1122 | if (!netif_running(sdata->dev)) | 1157 | if (!ieee80211_sdata_running(sdata)) |
1123 | continue; | 1158 | continue; |
1124 | switch (sdata->vif.type) { | 1159 | switch (sdata->vif.type) { |
1125 | case NL80211_IFTYPE_STATION: | 1160 | case NL80211_IFTYPE_STATION: |
@@ -1147,7 +1182,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1147 | 1182 | ||
1148 | /* add back keys */ | 1183 | /* add back keys */ |
1149 | list_for_each_entry(sdata, &local->interfaces, list) | 1184 | list_for_each_entry(sdata, &local->interfaces, list) |
1150 | if (netif_running(sdata->dev)) | 1185 | if (ieee80211_sdata_running(sdata)) |
1151 | ieee80211_enable_keys(sdata); | 1186 | ieee80211_enable_keys(sdata); |
1152 | 1187 | ||
1153 | ieee80211_wake_queues_by_reason(hw, | 1188 | ieee80211_wake_queues_by_reason(hw, |
@@ -1194,3 +1229,133 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1194 | return 0; | 1229 | return 0; |
1195 | } | 1230 | } |
1196 | 1231 | ||
1232 | static int check_mgd_smps(struct ieee80211_if_managed *ifmgd, | ||
1233 | enum ieee80211_smps_mode *smps_mode) | ||
1234 | { | ||
1235 | if (ifmgd->associated) { | ||
1236 | *smps_mode = ifmgd->ap_smps; | ||
1237 | |||
1238 | if (*smps_mode == IEEE80211_SMPS_AUTOMATIC) { | ||
1239 | if (ifmgd->powersave) | ||
1240 | *smps_mode = IEEE80211_SMPS_DYNAMIC; | ||
1241 | else | ||
1242 | *smps_mode = IEEE80211_SMPS_OFF; | ||
1243 | } | ||
1244 | |||
1245 | return 1; | ||
1246 | } | ||
1247 | |||
1248 | return 0; | ||
1249 | } | ||
1250 | |||
1251 | /* must hold iflist_mtx */ | ||
1252 | void ieee80211_recalc_smps(struct ieee80211_local *local, | ||
1253 | struct ieee80211_sub_if_data *forsdata) | ||
1254 | { | ||
1255 | struct ieee80211_sub_if_data *sdata; | ||
1256 | enum ieee80211_smps_mode smps_mode = IEEE80211_SMPS_OFF; | ||
1257 | int count = 0; | ||
1258 | |||
1259 | if (forsdata) | ||
1260 | WARN_ON(!mutex_is_locked(&forsdata->u.mgd.mtx)); | ||
1261 | |||
1262 | WARN_ON(!mutex_is_locked(&local->iflist_mtx)); | ||
1263 | |||
1264 | /* | ||
1265 | * This function could be improved to handle multiple | ||
1266 | * interfaces better, but right now it makes any | ||
1267 | * non-station interfaces force SM PS to be turned | ||
1268 | * off. If there are multiple station interfaces it | ||
1269 | * could also use the best possible mode, e.g. if | ||
1270 | * one is in static and the other in dynamic then | ||
1271 | * dynamic is ok. | ||
1272 | */ | ||
1273 | |||
1274 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
1275 | if (!netif_running(sdata->dev)) | ||
1276 | continue; | ||
1277 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
1278 | goto set; | ||
1279 | if (sdata != forsdata) { | ||
1280 | /* | ||
1281 | * This nested is ok -- we are holding the iflist_mtx | ||
1282 | * so can't get here twice or so. But it's required | ||
1283 | * since normally we acquire it first and then the | ||
1284 | * iflist_mtx. | ||
1285 | */ | ||
1286 | mutex_lock_nested(&sdata->u.mgd.mtx, SINGLE_DEPTH_NESTING); | ||
1287 | count += check_mgd_smps(&sdata->u.mgd, &smps_mode); | ||
1288 | mutex_unlock(&sdata->u.mgd.mtx); | ||
1289 | } else | ||
1290 | count += check_mgd_smps(&sdata->u.mgd, &smps_mode); | ||
1291 | |||
1292 | if (count > 1) { | ||
1293 | smps_mode = IEEE80211_SMPS_OFF; | ||
1294 | break; | ||
1295 | } | ||
1296 | } | ||
1297 | |||
1298 | if (smps_mode == local->smps_mode) | ||
1299 | return; | ||
1300 | |||
1301 | set: | ||
1302 | local->smps_mode = smps_mode; | ||
1303 | /* changed flag is auto-detected for this */ | ||
1304 | ieee80211_hw_config(local, 0); | ||
1305 | } | ||
1306 | |||
1307 | static bool ieee80211_id_in_list(const u8 *ids, int n_ids, u8 id) | ||
1308 | { | ||
1309 | int i; | ||
1310 | |||
1311 | for (i = 0; i < n_ids; i++) | ||
1312 | if (ids[i] == id) | ||
1313 | return true; | ||
1314 | return false; | ||
1315 | } | ||
1316 | |||
1317 | /** | ||
1318 | * ieee80211_ie_split - split an IE buffer according to ordering | ||
1319 | * | ||
1320 | * @ies: the IE buffer | ||
1321 | * @ielen: the length of the IE buffer | ||
1322 | * @ids: an array with element IDs that are allowed before | ||
1323 | * the split | ||
1324 | * @n_ids: the size of the element ID array | ||
1325 | * @offset: offset where to start splitting in the buffer | ||
1326 | * | ||
1327 | * This function splits an IE buffer by updating the @offset | ||
1328 | * variable to point to the location where the buffer should be | ||
1329 | * split. | ||
1330 | * | ||
1331 | * It assumes that the given IE buffer is well-formed, this | ||
1332 | * has to be guaranteed by the caller! | ||
1333 | * | ||
1334 | * It also assumes that the IEs in the buffer are ordered | ||
1335 | * correctly, if not the result of using this function will not | ||
1336 | * be ordered correctly either, i.e. it does no reordering. | ||
1337 | * | ||
1338 | * The function returns the offset where the next part of the | ||
1339 | * buffer starts, which may be @ielen if the entire (remainder) | ||
1340 | * of the buffer should be used. | ||
1341 | */ | ||
1342 | size_t ieee80211_ie_split(const u8 *ies, size_t ielen, | ||
1343 | const u8 *ids, int n_ids, size_t offset) | ||
1344 | { | ||
1345 | size_t pos = offset; | ||
1346 | |||
1347 | while (pos < ielen && ieee80211_id_in_list(ids, n_ids, ies[pos])) | ||
1348 | pos += 2 + ies[pos + 1]; | ||
1349 | |||
1350 | return pos; | ||
1351 | } | ||
1352 | |||
1353 | size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset) | ||
1354 | { | ||
1355 | size_t pos = offset; | ||
1356 | |||
1357 | while (pos < ielen && ies[pos] != WLAN_EID_VENDOR_SPECIFIC) | ||
1358 | pos += 2 + ies[pos + 1]; | ||
1359 | |||
1360 | return pos; | ||
1361 | } | ||
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index 79d887dae738..34e6d02da779 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c | |||
@@ -96,7 +96,7 @@ u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata, | |||
96 | } | 96 | } |
97 | 97 | ||
98 | if (!sta && ra && !is_multicast_ether_addr(ra)) { | 98 | if (!sta && ra && !is_multicast_ether_addr(ra)) { |
99 | sta = sta_info_get(local, ra); | 99 | sta = sta_info_get(sdata, ra); |
100 | if (sta) | 100 | if (sta) |
101 | sta_flags = get_sta_flags(sta); | 101 | sta_flags = get_sta_flags(sta); |
102 | } | 102 | } |
diff --git a/net/mac80211/work.c b/net/mac80211/work.c new file mode 100644 index 000000000000..81bd5d592bb4 --- /dev/null +++ b/net/mac80211/work.c | |||
@@ -0,0 +1,1098 @@ | |||
1 | /* | ||
2 | * mac80211 work implementation | ||
3 | * | ||
4 | * Copyright 2003-2008, Jouni Malinen <j@w1.fi> | ||
5 | * Copyright 2004, Instant802 Networks, Inc. | ||
6 | * Copyright 2005, Devicescape Software, Inc. | ||
7 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> | ||
8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> | ||
9 | * Copyright 2009, Johannes Berg <johannes@sipsolutions.net> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/delay.h> | ||
17 | #include <linux/if_ether.h> | ||
18 | #include <linux/skbuff.h> | ||
19 | #include <linux/if_arp.h> | ||
20 | #include <linux/etherdevice.h> | ||
21 | #include <linux/crc32.h> | ||
22 | #include <net/mac80211.h> | ||
23 | #include <asm/unaligned.h> | ||
24 | |||
25 | #include "ieee80211_i.h" | ||
26 | #include "rate.h" | ||
27 | |||
28 | #define IEEE80211_AUTH_TIMEOUT (HZ / 5) | ||
29 | #define IEEE80211_AUTH_MAX_TRIES 3 | ||
30 | #define IEEE80211_ASSOC_TIMEOUT (HZ / 5) | ||
31 | #define IEEE80211_ASSOC_MAX_TRIES 3 | ||
32 | #define IEEE80211_MAX_PROBE_TRIES 5 | ||
33 | |||
34 | enum work_action { | ||
35 | WORK_ACT_NONE, | ||
36 | WORK_ACT_TIMEOUT, | ||
37 | WORK_ACT_DONE, | ||
38 | }; | ||
39 | |||
40 | |||
41 | /* utils */ | ||
42 | static inline void ASSERT_WORK_MTX(struct ieee80211_local *local) | ||
43 | { | ||
44 | WARN_ON(!mutex_is_locked(&local->work_mtx)); | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * We can have multiple work items (and connection probing) | ||
49 | * scheduling this timer, but we need to take care to only | ||
50 | * reschedule it when it should fire _earlier_ than it was | ||
51 | * asked for before, or if it's not pending right now. This | ||
52 | * function ensures that. Note that it then is required to | ||
53 | * run this function for all timeouts after the first one | ||
54 | * has happened -- the work that runs from this timer will | ||
55 | * do that. | ||
56 | */ | ||
57 | static void run_again(struct ieee80211_local *local, | ||
58 | unsigned long timeout) | ||
59 | { | ||
60 | ASSERT_WORK_MTX(local); | ||
61 | |||
62 | if (!timer_pending(&local->work_timer) || | ||
63 | time_before(timeout, local->work_timer.expires)) | ||
64 | mod_timer(&local->work_timer, timeout); | ||
65 | } | ||
66 | |||
67 | static void work_free_rcu(struct rcu_head *head) | ||
68 | { | ||
69 | struct ieee80211_work *wk = | ||
70 | container_of(head, struct ieee80211_work, rcu_head); | ||
71 | |||
72 | kfree(wk); | ||
73 | } | ||
74 | |||
75 | void free_work(struct ieee80211_work *wk) | ||
76 | { | ||
77 | call_rcu(&wk->rcu_head, work_free_rcu); | ||
78 | } | ||
79 | |||
80 | static int ieee80211_compatible_rates(const u8 *supp_rates, int supp_rates_len, | ||
81 | struct ieee80211_supported_band *sband, | ||
82 | u32 *rates) | ||
83 | { | ||
84 | int i, j, count; | ||
85 | *rates = 0; | ||
86 | count = 0; | ||
87 | for (i = 0; i < supp_rates_len; i++) { | ||
88 | int rate = (supp_rates[i] & 0x7F) * 5; | ||
89 | |||
90 | for (j = 0; j < sband->n_bitrates; j++) | ||
91 | if (sband->bitrates[j].bitrate == rate) { | ||
92 | *rates |= BIT(j); | ||
93 | count++; | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | return count; | ||
99 | } | ||
100 | |||
101 | /* frame sending functions */ | ||
102 | |||
103 | static void ieee80211_add_ht_ie(struct sk_buff *skb, const u8 *ht_info_ie, | ||
104 | struct ieee80211_supported_band *sband, | ||
105 | struct ieee80211_channel *channel, | ||
106 | enum ieee80211_smps_mode smps) | ||
107 | { | ||
108 | struct ieee80211_ht_info *ht_info; | ||
109 | u8 *pos; | ||
110 | u32 flags = channel->flags; | ||
111 | u16 cap = sband->ht_cap.cap; | ||
112 | __le16 tmp; | ||
113 | |||
114 | if (!sband->ht_cap.ht_supported) | ||
115 | return; | ||
116 | |||
117 | if (!ht_info_ie) | ||
118 | return; | ||
119 | |||
120 | if (ht_info_ie[1] < sizeof(struct ieee80211_ht_info)) | ||
121 | return; | ||
122 | |||
123 | ht_info = (struct ieee80211_ht_info *)(ht_info_ie + 2); | ||
124 | |||
125 | /* determine capability flags */ | ||
126 | |||
127 | if (ieee80211_disable_40mhz_24ghz && | ||
128 | sband->band == IEEE80211_BAND_2GHZ) { | ||
129 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||
130 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
131 | } | ||
132 | |||
133 | switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { | ||
134 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: | ||
135 | if (flags & IEEE80211_CHAN_NO_HT40PLUS) { | ||
136 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||
137 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
138 | } | ||
139 | break; | ||
140 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: | ||
141 | if (flags & IEEE80211_CHAN_NO_HT40MINUS) { | ||
142 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||
143 | cap &= ~IEEE80211_HT_CAP_SGI_40; | ||
144 | } | ||
145 | break; | ||
146 | } | ||
147 | |||
148 | /* set SM PS mode properly */ | ||
149 | cap &= ~IEEE80211_HT_CAP_SM_PS; | ||
150 | switch (smps) { | ||
151 | case IEEE80211_SMPS_AUTOMATIC: | ||
152 | case IEEE80211_SMPS_NUM_MODES: | ||
153 | WARN_ON(1); | ||
154 | case IEEE80211_SMPS_OFF: | ||
155 | cap |= WLAN_HT_CAP_SM_PS_DISABLED << | ||
156 | IEEE80211_HT_CAP_SM_PS_SHIFT; | ||
157 | break; | ||
158 | case IEEE80211_SMPS_STATIC: | ||
159 | cap |= WLAN_HT_CAP_SM_PS_STATIC << | ||
160 | IEEE80211_HT_CAP_SM_PS_SHIFT; | ||
161 | break; | ||
162 | case IEEE80211_SMPS_DYNAMIC: | ||
163 | cap |= WLAN_HT_CAP_SM_PS_DYNAMIC << | ||
164 | IEEE80211_HT_CAP_SM_PS_SHIFT; | ||
165 | break; | ||
166 | } | ||
167 | |||
168 | /* reserve and fill IE */ | ||
169 | |||
170 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2); | ||
171 | *pos++ = WLAN_EID_HT_CAPABILITY; | ||
172 | *pos++ = sizeof(struct ieee80211_ht_cap); | ||
173 | memset(pos, 0, sizeof(struct ieee80211_ht_cap)); | ||
174 | |||
175 | /* capability flags */ | ||
176 | tmp = cpu_to_le16(cap); | ||
177 | memcpy(pos, &tmp, sizeof(u16)); | ||
178 | pos += sizeof(u16); | ||
179 | |||
180 | /* AMPDU parameters */ | ||
181 | *pos++ = sband->ht_cap.ampdu_factor | | ||
182 | (sband->ht_cap.ampdu_density << | ||
183 | IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); | ||
184 | |||
185 | /* MCS set */ | ||
186 | memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); | ||
187 | pos += sizeof(sband->ht_cap.mcs); | ||
188 | |||
189 | /* extended capabilities */ | ||
190 | pos += sizeof(__le16); | ||
191 | |||
192 | /* BF capabilities */ | ||
193 | pos += sizeof(__le32); | ||
194 | |||
195 | /* antenna selection */ | ||
196 | pos += sizeof(u8); | ||
197 | } | ||
198 | |||
199 | static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, | ||
200 | struct ieee80211_work *wk) | ||
201 | { | ||
202 | struct ieee80211_local *local = sdata->local; | ||
203 | struct sk_buff *skb; | ||
204 | struct ieee80211_mgmt *mgmt; | ||
205 | u8 *pos, qos_info; | ||
206 | const u8 *ies; | ||
207 | size_t offset = 0, noffset; | ||
208 | int i, len, count, rates_len, supp_rates_len; | ||
209 | u16 capab; | ||
210 | struct ieee80211_supported_band *sband; | ||
211 | u32 rates = 0; | ||
212 | |||
213 | sband = local->hw.wiphy->bands[wk->chan->band]; | ||
214 | |||
215 | /* | ||
216 | * Get all rates supported by the device and the AP as | ||
217 | * some APs don't like getting a superset of their rates | ||
218 | * in the association request (e.g. D-Link DAP 1353 in | ||
219 | * b-only mode)... | ||
220 | */ | ||
221 | rates_len = ieee80211_compatible_rates(wk->assoc.supp_rates, | ||
222 | wk->assoc.supp_rates_len, | ||
223 | sband, &rates); | ||
224 | |||
225 | skb = alloc_skb(local->hw.extra_tx_headroom + | ||
226 | sizeof(*mgmt) + /* bit too much but doesn't matter */ | ||
227 | 2 + wk->assoc.ssid_len + /* SSID */ | ||
228 | 4 + rates_len + /* (extended) rates */ | ||
229 | 4 + /* power capability */ | ||
230 | 2 + 2 * sband->n_channels + /* supported channels */ | ||
231 | 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ | ||
232 | wk->ie_len + /* extra IEs */ | ||
233 | 9, /* WMM */ | ||
234 | GFP_KERNEL); | ||
235 | if (!skb) { | ||
236 | printk(KERN_DEBUG "%s: failed to allocate buffer for assoc " | ||
237 | "frame\n", sdata->name); | ||
238 | return; | ||
239 | } | ||
240 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
241 | |||
242 | capab = WLAN_CAPABILITY_ESS; | ||
243 | |||
244 | if (sband->band == IEEE80211_BAND_2GHZ) { | ||
245 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) | ||
246 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; | ||
247 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) | ||
248 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; | ||
249 | } | ||
250 | |||
251 | if (wk->assoc.capability & WLAN_CAPABILITY_PRIVACY) | ||
252 | capab |= WLAN_CAPABILITY_PRIVACY; | ||
253 | |||
254 | if ((wk->assoc.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && | ||
255 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) | ||
256 | capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; | ||
257 | |||
258 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | ||
259 | memset(mgmt, 0, 24); | ||
260 | memcpy(mgmt->da, wk->filter_ta, ETH_ALEN); | ||
261 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); | ||
262 | memcpy(mgmt->bssid, wk->filter_ta, ETH_ALEN); | ||
263 | |||
264 | if (!is_zero_ether_addr(wk->assoc.prev_bssid)) { | ||
265 | skb_put(skb, 10); | ||
266 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
267 | IEEE80211_STYPE_REASSOC_REQ); | ||
268 | mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); | ||
269 | mgmt->u.reassoc_req.listen_interval = | ||
270 | cpu_to_le16(local->hw.conf.listen_interval); | ||
271 | memcpy(mgmt->u.reassoc_req.current_ap, wk->assoc.prev_bssid, | ||
272 | ETH_ALEN); | ||
273 | } else { | ||
274 | skb_put(skb, 4); | ||
275 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
276 | IEEE80211_STYPE_ASSOC_REQ); | ||
277 | mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); | ||
278 | mgmt->u.assoc_req.listen_interval = | ||
279 | cpu_to_le16(local->hw.conf.listen_interval); | ||
280 | } | ||
281 | |||
282 | /* SSID */ | ||
283 | ies = pos = skb_put(skb, 2 + wk->assoc.ssid_len); | ||
284 | *pos++ = WLAN_EID_SSID; | ||
285 | *pos++ = wk->assoc.ssid_len; | ||
286 | memcpy(pos, wk->assoc.ssid, wk->assoc.ssid_len); | ||
287 | |||
288 | /* add all rates which were marked to be used above */ | ||
289 | supp_rates_len = rates_len; | ||
290 | if (supp_rates_len > 8) | ||
291 | supp_rates_len = 8; | ||
292 | |||
293 | len = sband->n_bitrates; | ||
294 | pos = skb_put(skb, supp_rates_len + 2); | ||
295 | *pos++ = WLAN_EID_SUPP_RATES; | ||
296 | *pos++ = supp_rates_len; | ||
297 | |||
298 | count = 0; | ||
299 | for (i = 0; i < sband->n_bitrates; i++) { | ||
300 | if (BIT(i) & rates) { | ||
301 | int rate = sband->bitrates[i].bitrate; | ||
302 | *pos++ = (u8) (rate / 5); | ||
303 | if (++count == 8) | ||
304 | break; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | if (rates_len > count) { | ||
309 | pos = skb_put(skb, rates_len - count + 2); | ||
310 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
311 | *pos++ = rates_len - count; | ||
312 | |||
313 | for (i++; i < sband->n_bitrates; i++) { | ||
314 | if (BIT(i) & rates) { | ||
315 | int rate = sband->bitrates[i].bitrate; | ||
316 | *pos++ = (u8) (rate / 5); | ||
317 | } | ||
318 | } | ||
319 | } | ||
320 | |||
321 | if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) { | ||
322 | /* 1. power capabilities */ | ||
323 | pos = skb_put(skb, 4); | ||
324 | *pos++ = WLAN_EID_PWR_CAPABILITY; | ||
325 | *pos++ = 2; | ||
326 | *pos++ = 0; /* min tx power */ | ||
327 | *pos++ = wk->chan->max_power; /* max tx power */ | ||
328 | |||
329 | /* 2. supported channels */ | ||
330 | /* TODO: get this in reg domain format */ | ||
331 | pos = skb_put(skb, 2 * sband->n_channels + 2); | ||
332 | *pos++ = WLAN_EID_SUPPORTED_CHANNELS; | ||
333 | *pos++ = 2 * sband->n_channels; | ||
334 | for (i = 0; i < sband->n_channels; i++) { | ||
335 | *pos++ = ieee80211_frequency_to_channel( | ||
336 | sband->channels[i].center_freq); | ||
337 | *pos++ = 1; /* one channel in the subband*/ | ||
338 | } | ||
339 | } | ||
340 | |||
341 | /* if present, add any custom IEs that go before HT */ | ||
342 | if (wk->ie_len && wk->ie) { | ||
343 | static const u8 before_ht[] = { | ||
344 | WLAN_EID_SSID, | ||
345 | WLAN_EID_SUPP_RATES, | ||
346 | WLAN_EID_EXT_SUPP_RATES, | ||
347 | WLAN_EID_PWR_CAPABILITY, | ||
348 | WLAN_EID_SUPPORTED_CHANNELS, | ||
349 | WLAN_EID_RSN, | ||
350 | WLAN_EID_QOS_CAPA, | ||
351 | WLAN_EID_RRM_ENABLED_CAPABILITIES, | ||
352 | WLAN_EID_MOBILITY_DOMAIN, | ||
353 | WLAN_EID_SUPPORTED_REGULATORY_CLASSES, | ||
354 | }; | ||
355 | noffset = ieee80211_ie_split(wk->ie, wk->ie_len, | ||
356 | before_ht, ARRAY_SIZE(before_ht), | ||
357 | offset); | ||
358 | pos = skb_put(skb, noffset - offset); | ||
359 | memcpy(pos, wk->ie + offset, noffset - offset); | ||
360 | offset = noffset; | ||
361 | } | ||
362 | |||
363 | if (wk->assoc.use_11n && wk->assoc.wmm_used && | ||
364 | local->hw.queues >= 4) | ||
365 | ieee80211_add_ht_ie(skb, wk->assoc.ht_information_ie, | ||
366 | sband, wk->chan, wk->assoc.smps); | ||
367 | |||
368 | /* if present, add any custom non-vendor IEs that go after HT */ | ||
369 | if (wk->ie_len && wk->ie) { | ||
370 | noffset = ieee80211_ie_split_vendor(wk->ie, wk->ie_len, | ||
371 | offset); | ||
372 | pos = skb_put(skb, noffset - offset); | ||
373 | memcpy(pos, wk->ie + offset, noffset - offset); | ||
374 | offset = noffset; | ||
375 | } | ||
376 | |||
377 | if (wk->assoc.wmm_used && local->hw.queues >= 4) { | ||
378 | if (wk->assoc.uapsd_used) { | ||
379 | qos_info = local->uapsd_queues; | ||
380 | qos_info |= (local->uapsd_max_sp_len << | ||
381 | IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT); | ||
382 | } else { | ||
383 | qos_info = 0; | ||
384 | } | ||
385 | |||
386 | pos = skb_put(skb, 9); | ||
387 | *pos++ = WLAN_EID_VENDOR_SPECIFIC; | ||
388 | *pos++ = 7; /* len */ | ||
389 | *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */ | ||
390 | *pos++ = 0x50; | ||
391 | *pos++ = 0xf2; | ||
392 | *pos++ = 2; /* WME */ | ||
393 | *pos++ = 0; /* WME info */ | ||
394 | *pos++ = 1; /* WME ver */ | ||
395 | *pos++ = qos_info; | ||
396 | } | ||
397 | |||
398 | /* add any remaining custom (i.e. vendor specific here) IEs */ | ||
399 | if (wk->ie_len && wk->ie) { | ||
400 | noffset = wk->ie_len; | ||
401 | pos = skb_put(skb, noffset - offset); | ||
402 | memcpy(pos, wk->ie + offset, noffset - offset); | ||
403 | } | ||
404 | |||
405 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
406 | ieee80211_tx_skb(sdata, skb); | ||
407 | } | ||
408 | |||
409 | static void ieee80211_remove_auth_bss(struct ieee80211_local *local, | ||
410 | struct ieee80211_work *wk) | ||
411 | { | ||
412 | struct cfg80211_bss *cbss; | ||
413 | u16 capa_val = WLAN_CAPABILITY_ESS; | ||
414 | |||
415 | if (wk->probe_auth.privacy) | ||
416 | capa_val |= WLAN_CAPABILITY_PRIVACY; | ||
417 | |||
418 | cbss = cfg80211_get_bss(local->hw.wiphy, wk->chan, wk->filter_ta, | ||
419 | wk->probe_auth.ssid, wk->probe_auth.ssid_len, | ||
420 | WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_PRIVACY, | ||
421 | capa_val); | ||
422 | if (!cbss) | ||
423 | return; | ||
424 | |||
425 | cfg80211_unlink_bss(local->hw.wiphy, cbss); | ||
426 | cfg80211_put_bss(cbss); | ||
427 | } | ||
428 | |||
429 | static enum work_action __must_check | ||
430 | ieee80211_direct_probe(struct ieee80211_work *wk) | ||
431 | { | ||
432 | struct ieee80211_sub_if_data *sdata = wk->sdata; | ||
433 | struct ieee80211_local *local = sdata->local; | ||
434 | |||
435 | wk->probe_auth.tries++; | ||
436 | if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { | ||
437 | printk(KERN_DEBUG "%s: direct probe to %pM timed out\n", | ||
438 | sdata->name, wk->filter_ta); | ||
439 | |||
440 | /* | ||
441 | * Most likely AP is not in the range so remove the | ||
442 | * bss struct for that AP. | ||
443 | */ | ||
444 | ieee80211_remove_auth_bss(local, wk); | ||
445 | |||
446 | return WORK_ACT_TIMEOUT; | ||
447 | } | ||
448 | |||
449 | printk(KERN_DEBUG "%s: direct probe to %pM (try %d)\n", | ||
450 | sdata->name, wk->filter_ta, wk->probe_auth.tries); | ||
451 | |||
452 | /* | ||
453 | * Direct probe is sent to broadcast address as some APs | ||
454 | * will not answer to direct packet in unassociated state. | ||
455 | */ | ||
456 | ieee80211_send_probe_req(sdata, NULL, wk->probe_auth.ssid, | ||
457 | wk->probe_auth.ssid_len, NULL, 0); | ||
458 | |||
459 | wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; | ||
460 | run_again(local, wk->timeout); | ||
461 | |||
462 | return WORK_ACT_NONE; | ||
463 | } | ||
464 | |||
465 | |||
466 | static enum work_action __must_check | ||
467 | ieee80211_authenticate(struct ieee80211_work *wk) | ||
468 | { | ||
469 | struct ieee80211_sub_if_data *sdata = wk->sdata; | ||
470 | struct ieee80211_local *local = sdata->local; | ||
471 | |||
472 | wk->probe_auth.tries++; | ||
473 | if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { | ||
474 | printk(KERN_DEBUG "%s: authentication with %pM" | ||
475 | " timed out\n", sdata->name, wk->filter_ta); | ||
476 | |||
477 | /* | ||
478 | * Most likely AP is not in the range so remove the | ||
479 | * bss struct for that AP. | ||
480 | */ | ||
481 | ieee80211_remove_auth_bss(local, wk); | ||
482 | |||
483 | return WORK_ACT_TIMEOUT; | ||
484 | } | ||
485 | |||
486 | printk(KERN_DEBUG "%s: authenticate with %pM (try %d)\n", | ||
487 | sdata->name, wk->filter_ta, wk->probe_auth.tries); | ||
488 | |||
489 | ieee80211_send_auth(sdata, 1, wk->probe_auth.algorithm, wk->ie, | ||
490 | wk->ie_len, wk->filter_ta, NULL, 0, 0); | ||
491 | wk->probe_auth.transaction = 2; | ||
492 | |||
493 | wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; | ||
494 | run_again(local, wk->timeout); | ||
495 | |||
496 | return WORK_ACT_NONE; | ||
497 | } | ||
498 | |||
499 | static enum work_action __must_check | ||
500 | ieee80211_associate(struct ieee80211_work *wk) | ||
501 | { | ||
502 | struct ieee80211_sub_if_data *sdata = wk->sdata; | ||
503 | struct ieee80211_local *local = sdata->local; | ||
504 | |||
505 | wk->assoc.tries++; | ||
506 | if (wk->assoc.tries > IEEE80211_ASSOC_MAX_TRIES) { | ||
507 | printk(KERN_DEBUG "%s: association with %pM" | ||
508 | " timed out\n", | ||
509 | sdata->name, wk->filter_ta); | ||
510 | |||
511 | /* | ||
512 | * Most likely AP is not in the range so remove the | ||
513 | * bss struct for that AP. | ||
514 | */ | ||
515 | if (wk->assoc.bss) | ||
516 | cfg80211_unlink_bss(local->hw.wiphy, wk->assoc.bss); | ||
517 | |||
518 | return WORK_ACT_TIMEOUT; | ||
519 | } | ||
520 | |||
521 | printk(KERN_DEBUG "%s: associate with %pM (try %d)\n", | ||
522 | sdata->name, wk->filter_ta, wk->assoc.tries); | ||
523 | ieee80211_send_assoc(sdata, wk); | ||
524 | |||
525 | wk->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; | ||
526 | run_again(local, wk->timeout); | ||
527 | |||
528 | return WORK_ACT_NONE; | ||
529 | } | ||
530 | |||
531 | static enum work_action __must_check | ||
532 | ieee80211_remain_on_channel_timeout(struct ieee80211_work *wk) | ||
533 | { | ||
534 | /* | ||
535 | * First time we run, do nothing -- the generic code will | ||
536 | * have switched to the right channel etc. | ||
537 | */ | ||
538 | if (!wk->remain.started) { | ||
539 | wk->remain.started = true; | ||
540 | wk->timeout = jiffies + msecs_to_jiffies(wk->remain.duration); | ||
541 | |||
542 | cfg80211_ready_on_channel(wk->sdata->dev, (unsigned long) wk, | ||
543 | wk->chan, wk->chan_type, | ||
544 | wk->remain.duration, GFP_KERNEL); | ||
545 | |||
546 | return WORK_ACT_NONE; | ||
547 | } | ||
548 | |||
549 | return WORK_ACT_TIMEOUT; | ||
550 | } | ||
551 | |||
552 | static void ieee80211_auth_challenge(struct ieee80211_work *wk, | ||
553 | struct ieee80211_mgmt *mgmt, | ||
554 | size_t len) | ||
555 | { | ||
556 | struct ieee80211_sub_if_data *sdata = wk->sdata; | ||
557 | u8 *pos; | ||
558 | struct ieee802_11_elems elems; | ||
559 | |||
560 | pos = mgmt->u.auth.variable; | ||
561 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | ||
562 | if (!elems.challenge) | ||
563 | return; | ||
564 | ieee80211_send_auth(sdata, 3, wk->probe_auth.algorithm, | ||
565 | elems.challenge - 2, elems.challenge_len + 2, | ||
566 | wk->filter_ta, wk->probe_auth.key, | ||
567 | wk->probe_auth.key_len, wk->probe_auth.key_idx); | ||
568 | wk->probe_auth.transaction = 4; | ||
569 | } | ||
570 | |||
571 | static enum work_action __must_check | ||
572 | ieee80211_rx_mgmt_auth(struct ieee80211_work *wk, | ||
573 | struct ieee80211_mgmt *mgmt, size_t len) | ||
574 | { | ||
575 | u16 auth_alg, auth_transaction, status_code; | ||
576 | |||
577 | if (wk->type != IEEE80211_WORK_AUTH) | ||
578 | return WORK_ACT_NONE; | ||
579 | |||
580 | if (len < 24 + 6) | ||
581 | return WORK_ACT_NONE; | ||
582 | |||
583 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | ||
584 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); | ||
585 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | ||
586 | |||
587 | if (auth_alg != wk->probe_auth.algorithm || | ||
588 | auth_transaction != wk->probe_auth.transaction) | ||
589 | return WORK_ACT_NONE; | ||
590 | |||
591 | if (status_code != WLAN_STATUS_SUCCESS) { | ||
592 | printk(KERN_DEBUG "%s: %pM denied authentication (status %d)\n", | ||
593 | wk->sdata->name, mgmt->sa, status_code); | ||
594 | return WORK_ACT_DONE; | ||
595 | } | ||
596 | |||
597 | switch (wk->probe_auth.algorithm) { | ||
598 | case WLAN_AUTH_OPEN: | ||
599 | case WLAN_AUTH_LEAP: | ||
600 | case WLAN_AUTH_FT: | ||
601 | break; | ||
602 | case WLAN_AUTH_SHARED_KEY: | ||
603 | if (wk->probe_auth.transaction != 4) { | ||
604 | ieee80211_auth_challenge(wk, mgmt, len); | ||
605 | /* need another frame */ | ||
606 | return WORK_ACT_NONE; | ||
607 | } | ||
608 | break; | ||
609 | default: | ||
610 | WARN_ON(1); | ||
611 | return WORK_ACT_NONE; | ||
612 | } | ||
613 | |||
614 | printk(KERN_DEBUG "%s: authenticated\n", wk->sdata->name); | ||
615 | return WORK_ACT_DONE; | ||
616 | } | ||
617 | |||
618 | static enum work_action __must_check | ||
619 | ieee80211_rx_mgmt_assoc_resp(struct ieee80211_work *wk, | ||
620 | struct ieee80211_mgmt *mgmt, size_t len, | ||
621 | bool reassoc) | ||
622 | { | ||
623 | struct ieee80211_sub_if_data *sdata = wk->sdata; | ||
624 | struct ieee80211_local *local = sdata->local; | ||
625 | u16 capab_info, status_code, aid; | ||
626 | struct ieee802_11_elems elems; | ||
627 | u8 *pos; | ||
628 | |||
629 | /* | ||
630 | * AssocResp and ReassocResp have identical structure, so process both | ||
631 | * of them in this function. | ||
632 | */ | ||
633 | |||
634 | if (len < 24 + 6) | ||
635 | return WORK_ACT_NONE; | ||
636 | |||
637 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); | ||
638 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); | ||
639 | aid = le16_to_cpu(mgmt->u.assoc_resp.aid); | ||
640 | |||
641 | printk(KERN_DEBUG "%s: RX %sssocResp from %pM (capab=0x%x " | ||
642 | "status=%d aid=%d)\n", | ||
643 | sdata->name, reassoc ? "Rea" : "A", mgmt->sa, | ||
644 | capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); | ||
645 | |||
646 | pos = mgmt->u.assoc_resp.variable; | ||
647 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | ||
648 | |||
649 | if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && | ||
650 | elems.timeout_int && elems.timeout_int_len == 5 && | ||
651 | elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { | ||
652 | u32 tu, ms; | ||
653 | tu = get_unaligned_le32(elems.timeout_int + 1); | ||
654 | ms = tu * 1024 / 1000; | ||
655 | printk(KERN_DEBUG "%s: %pM rejected association temporarily; " | ||
656 | "comeback duration %u TU (%u ms)\n", | ||
657 | sdata->name, mgmt->sa, tu, ms); | ||
658 | wk->timeout = jiffies + msecs_to_jiffies(ms); | ||
659 | if (ms > IEEE80211_ASSOC_TIMEOUT) | ||
660 | run_again(local, wk->timeout); | ||
661 | return WORK_ACT_NONE; | ||
662 | } | ||
663 | |||
664 | if (status_code != WLAN_STATUS_SUCCESS) | ||
665 | printk(KERN_DEBUG "%s: %pM denied association (code=%d)\n", | ||
666 | sdata->name, mgmt->sa, status_code); | ||
667 | else | ||
668 | printk(KERN_DEBUG "%s: associated\n", sdata->name); | ||
669 | |||
670 | return WORK_ACT_DONE; | ||
671 | } | ||
672 | |||
673 | static enum work_action __must_check | ||
674 | ieee80211_rx_mgmt_probe_resp(struct ieee80211_work *wk, | ||
675 | struct ieee80211_mgmt *mgmt, size_t len, | ||
676 | struct ieee80211_rx_status *rx_status) | ||
677 | { | ||
678 | struct ieee80211_sub_if_data *sdata = wk->sdata; | ||
679 | struct ieee80211_local *local = sdata->local; | ||
680 | size_t baselen; | ||
681 | |||
682 | ASSERT_WORK_MTX(local); | ||
683 | |||
684 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; | ||
685 | if (baselen > len) | ||
686 | return WORK_ACT_NONE; | ||
687 | |||
688 | printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name); | ||
689 | return WORK_ACT_DONE; | ||
690 | } | ||
691 | |||
692 | static void ieee80211_work_rx_queued_mgmt(struct ieee80211_local *local, | ||
693 | struct sk_buff *skb) | ||
694 | { | ||
695 | struct ieee80211_rx_status *rx_status; | ||
696 | struct ieee80211_mgmt *mgmt; | ||
697 | struct ieee80211_work *wk; | ||
698 | enum work_action rma = WORK_ACT_NONE; | ||
699 | u16 fc; | ||
700 | |||
701 | rx_status = (struct ieee80211_rx_status *) skb->cb; | ||
702 | mgmt = (struct ieee80211_mgmt *) skb->data; | ||
703 | fc = le16_to_cpu(mgmt->frame_control); | ||
704 | |||
705 | mutex_lock(&local->work_mtx); | ||
706 | |||
707 | list_for_each_entry(wk, &local->work_list, list) { | ||
708 | const u8 *bssid = NULL; | ||
709 | |||
710 | switch (wk->type) { | ||
711 | case IEEE80211_WORK_DIRECT_PROBE: | ||
712 | case IEEE80211_WORK_AUTH: | ||
713 | case IEEE80211_WORK_ASSOC: | ||
714 | bssid = wk->filter_ta; | ||
715 | break; | ||
716 | default: | ||
717 | continue; | ||
718 | } | ||
719 | |||
720 | /* | ||
721 | * Before queuing, we already verified mgmt->sa, | ||
722 | * so this is needed just for matching. | ||
723 | */ | ||
724 | if (compare_ether_addr(bssid, mgmt->bssid)) | ||
725 | continue; | ||
726 | |||
727 | switch (fc & IEEE80211_FCTL_STYPE) { | ||
728 | case IEEE80211_STYPE_PROBE_RESP: | ||
729 | rma = ieee80211_rx_mgmt_probe_resp(wk, mgmt, skb->len, | ||
730 | rx_status); | ||
731 | break; | ||
732 | case IEEE80211_STYPE_AUTH: | ||
733 | rma = ieee80211_rx_mgmt_auth(wk, mgmt, skb->len); | ||
734 | break; | ||
735 | case IEEE80211_STYPE_ASSOC_RESP: | ||
736 | rma = ieee80211_rx_mgmt_assoc_resp(wk, mgmt, | ||
737 | skb->len, false); | ||
738 | break; | ||
739 | case IEEE80211_STYPE_REASSOC_RESP: | ||
740 | rma = ieee80211_rx_mgmt_assoc_resp(wk, mgmt, | ||
741 | skb->len, true); | ||
742 | break; | ||
743 | default: | ||
744 | WARN_ON(1); | ||
745 | } | ||
746 | /* | ||
747 | * We've processed this frame for that work, so it can't | ||
748 | * belong to another work struct. | ||
749 | * NB: this is also required for correctness for 'rma'! | ||
750 | */ | ||
751 | break; | ||
752 | } | ||
753 | |||
754 | switch (rma) { | ||
755 | case WORK_ACT_NONE: | ||
756 | break; | ||
757 | case WORK_ACT_DONE: | ||
758 | list_del_rcu(&wk->list); | ||
759 | break; | ||
760 | default: | ||
761 | WARN(1, "unexpected: %d", rma); | ||
762 | } | ||
763 | |||
764 | mutex_unlock(&local->work_mtx); | ||
765 | |||
766 | if (rma != WORK_ACT_DONE) | ||
767 | goto out; | ||
768 | |||
769 | switch (wk->done(wk, skb)) { | ||
770 | case WORK_DONE_DESTROY: | ||
771 | free_work(wk); | ||
772 | break; | ||
773 | case WORK_DONE_REQUEUE: | ||
774 | synchronize_rcu(); | ||
775 | wk->started = false; /* restart */ | ||
776 | mutex_lock(&local->work_mtx); | ||
777 | list_add_tail(&wk->list, &local->work_list); | ||
778 | mutex_unlock(&local->work_mtx); | ||
779 | } | ||
780 | |||
781 | out: | ||
782 | kfree_skb(skb); | ||
783 | } | ||
784 | |||
785 | static void ieee80211_work_timer(unsigned long data) | ||
786 | { | ||
787 | struct ieee80211_local *local = (void *) data; | ||
788 | |||
789 | if (local->quiescing) | ||
790 | return; | ||
791 | |||
792 | ieee80211_queue_work(&local->hw, &local->work_work); | ||
793 | } | ||
794 | |||
795 | static void ieee80211_work_work(struct work_struct *work) | ||
796 | { | ||
797 | struct ieee80211_local *local = | ||
798 | container_of(work, struct ieee80211_local, work_work); | ||
799 | struct sk_buff *skb; | ||
800 | struct ieee80211_work *wk, *tmp; | ||
801 | LIST_HEAD(free_work); | ||
802 | enum work_action rma; | ||
803 | bool remain_off_channel = false; | ||
804 | |||
805 | if (local->scanning) | ||
806 | return; | ||
807 | |||
808 | /* | ||
809 | * ieee80211_queue_work() should have picked up most cases, | ||
810 | * here we'll pick the the rest. | ||
811 | */ | ||
812 | if (WARN(local->suspended, "work scheduled while going to suspend\n")) | ||
813 | return; | ||
814 | |||
815 | /* first process frames to avoid timing out while a frame is pending */ | ||
816 | while ((skb = skb_dequeue(&local->work_skb_queue))) | ||
817 | ieee80211_work_rx_queued_mgmt(local, skb); | ||
818 | |||
819 | ieee80211_recalc_idle(local); | ||
820 | |||
821 | mutex_lock(&local->work_mtx); | ||
822 | |||
823 | list_for_each_entry_safe(wk, tmp, &local->work_list, list) { | ||
824 | /* mark work as started if it's on the current off-channel */ | ||
825 | if (!wk->started && local->tmp_channel && | ||
826 | wk->chan == local->tmp_channel && | ||
827 | wk->chan_type == local->tmp_channel_type) { | ||
828 | wk->started = true; | ||
829 | wk->timeout = jiffies; | ||
830 | } | ||
831 | |||
832 | if (!wk->started && !local->tmp_channel) { | ||
833 | /* | ||
834 | * TODO: could optimize this by leaving the | ||
835 | * station vifs in awake mode if they | ||
836 | * happen to be on the same channel as | ||
837 | * the requested channel | ||
838 | */ | ||
839 | ieee80211_offchannel_stop_beaconing(local); | ||
840 | ieee80211_offchannel_stop_station(local); | ||
841 | |||
842 | local->tmp_channel = wk->chan; | ||
843 | local->tmp_channel_type = wk->chan_type; | ||
844 | ieee80211_hw_config(local, 0); | ||
845 | wk->started = true; | ||
846 | wk->timeout = jiffies; | ||
847 | } | ||
848 | |||
849 | /* don't try to work with items that aren't started */ | ||
850 | if (!wk->started) | ||
851 | continue; | ||
852 | |||
853 | if (time_is_after_jiffies(wk->timeout)) { | ||
854 | /* | ||
855 | * This work item isn't supposed to be worked on | ||
856 | * right now, but take care to adjust the timer | ||
857 | * properly. | ||
858 | */ | ||
859 | run_again(local, wk->timeout); | ||
860 | continue; | ||
861 | } | ||
862 | |||
863 | switch (wk->type) { | ||
864 | default: | ||
865 | WARN_ON(1); | ||
866 | /* nothing */ | ||
867 | rma = WORK_ACT_NONE; | ||
868 | break; | ||
869 | case IEEE80211_WORK_ABORT: | ||
870 | rma = WORK_ACT_TIMEOUT; | ||
871 | case IEEE80211_WORK_DIRECT_PROBE: | ||
872 | rma = ieee80211_direct_probe(wk); | ||
873 | break; | ||
874 | case IEEE80211_WORK_AUTH: | ||
875 | rma = ieee80211_authenticate(wk); | ||
876 | break; | ||
877 | case IEEE80211_WORK_ASSOC: | ||
878 | rma = ieee80211_associate(wk); | ||
879 | break; | ||
880 | case IEEE80211_WORK_REMAIN_ON_CHANNEL: | ||
881 | rma = ieee80211_remain_on_channel_timeout(wk); | ||
882 | break; | ||
883 | } | ||
884 | |||
885 | switch (rma) { | ||
886 | case WORK_ACT_NONE: | ||
887 | /* might have changed the timeout */ | ||
888 | run_again(local, wk->timeout); | ||
889 | break; | ||
890 | case WORK_ACT_TIMEOUT: | ||
891 | list_del_rcu(&wk->list); | ||
892 | synchronize_rcu(); | ||
893 | list_add(&wk->list, &free_work); | ||
894 | break; | ||
895 | default: | ||
896 | WARN(1, "unexpected: %d", rma); | ||
897 | } | ||
898 | } | ||
899 | |||
900 | list_for_each_entry(wk, &local->work_list, list) { | ||
901 | if (!wk->started) | ||
902 | continue; | ||
903 | if (wk->chan != local->tmp_channel) | ||
904 | continue; | ||
905 | if (wk->chan_type != local->tmp_channel_type) | ||
906 | continue; | ||
907 | remain_off_channel = true; | ||
908 | } | ||
909 | |||
910 | if (!remain_off_channel && local->tmp_channel) { | ||
911 | local->tmp_channel = NULL; | ||
912 | ieee80211_hw_config(local, 0); | ||
913 | ieee80211_offchannel_return(local, true); | ||
914 | /* give connection some time to breathe */ | ||
915 | run_again(local, jiffies + HZ/2); | ||
916 | } | ||
917 | |||
918 | if (list_empty(&local->work_list) && local->scan_req) | ||
919 | ieee80211_queue_delayed_work(&local->hw, | ||
920 | &local->scan_work, | ||
921 | round_jiffies_relative(0)); | ||
922 | |||
923 | mutex_unlock(&local->work_mtx); | ||
924 | |||
925 | ieee80211_recalc_idle(local); | ||
926 | |||
927 | list_for_each_entry_safe(wk, tmp, &free_work, list) { | ||
928 | wk->done(wk, NULL); | ||
929 | list_del(&wk->list); | ||
930 | kfree(wk); | ||
931 | } | ||
932 | } | ||
933 | |||
934 | void ieee80211_add_work(struct ieee80211_work *wk) | ||
935 | { | ||
936 | struct ieee80211_local *local; | ||
937 | |||
938 | if (WARN_ON(!wk->chan)) | ||
939 | return; | ||
940 | |||
941 | if (WARN_ON(!wk->sdata)) | ||
942 | return; | ||
943 | |||
944 | if (WARN_ON(!wk->done)) | ||
945 | return; | ||
946 | |||
947 | if (WARN_ON(!ieee80211_sdata_running(wk->sdata))) | ||
948 | return; | ||
949 | |||
950 | wk->started = false; | ||
951 | |||
952 | local = wk->sdata->local; | ||
953 | mutex_lock(&local->work_mtx); | ||
954 | list_add_tail(&wk->list, &local->work_list); | ||
955 | mutex_unlock(&local->work_mtx); | ||
956 | |||
957 | ieee80211_queue_work(&local->hw, &local->work_work); | ||
958 | } | ||
959 | |||
960 | void ieee80211_work_init(struct ieee80211_local *local) | ||
961 | { | ||
962 | mutex_init(&local->work_mtx); | ||
963 | INIT_LIST_HEAD(&local->work_list); | ||
964 | setup_timer(&local->work_timer, ieee80211_work_timer, | ||
965 | (unsigned long)local); | ||
966 | INIT_WORK(&local->work_work, ieee80211_work_work); | ||
967 | skb_queue_head_init(&local->work_skb_queue); | ||
968 | } | ||
969 | |||
970 | void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata) | ||
971 | { | ||
972 | struct ieee80211_local *local = sdata->local; | ||
973 | struct ieee80211_work *wk; | ||
974 | |||
975 | mutex_lock(&local->work_mtx); | ||
976 | list_for_each_entry(wk, &local->work_list, list) { | ||
977 | if (wk->sdata != sdata) | ||
978 | continue; | ||
979 | wk->type = IEEE80211_WORK_ABORT; | ||
980 | wk->started = true; | ||
981 | wk->timeout = jiffies; | ||
982 | } | ||
983 | mutex_unlock(&local->work_mtx); | ||
984 | |||
985 | /* run cleanups etc. */ | ||
986 | ieee80211_work_work(&local->work_work); | ||
987 | |||
988 | mutex_lock(&local->work_mtx); | ||
989 | list_for_each_entry(wk, &local->work_list, list) { | ||
990 | if (wk->sdata != sdata) | ||
991 | continue; | ||
992 | WARN_ON(1); | ||
993 | break; | ||
994 | } | ||
995 | mutex_unlock(&local->work_mtx); | ||
996 | } | ||
997 | |||
998 | ieee80211_rx_result ieee80211_work_rx_mgmt(struct ieee80211_sub_if_data *sdata, | ||
999 | struct sk_buff *skb) | ||
1000 | { | ||
1001 | struct ieee80211_local *local = sdata->local; | ||
1002 | struct ieee80211_mgmt *mgmt; | ||
1003 | struct ieee80211_work *wk; | ||
1004 | u16 fc; | ||
1005 | |||
1006 | if (skb->len < 24) | ||
1007 | return RX_DROP_MONITOR; | ||
1008 | |||
1009 | mgmt = (struct ieee80211_mgmt *) skb->data; | ||
1010 | fc = le16_to_cpu(mgmt->frame_control); | ||
1011 | |||
1012 | list_for_each_entry_rcu(wk, &local->work_list, list) { | ||
1013 | if (sdata != wk->sdata) | ||
1014 | continue; | ||
1015 | if (compare_ether_addr(wk->filter_ta, mgmt->sa)) | ||
1016 | continue; | ||
1017 | if (compare_ether_addr(wk->filter_ta, mgmt->bssid)) | ||
1018 | continue; | ||
1019 | |||
1020 | switch (fc & IEEE80211_FCTL_STYPE) { | ||
1021 | case IEEE80211_STYPE_AUTH: | ||
1022 | case IEEE80211_STYPE_PROBE_RESP: | ||
1023 | case IEEE80211_STYPE_ASSOC_RESP: | ||
1024 | case IEEE80211_STYPE_REASSOC_RESP: | ||
1025 | case IEEE80211_STYPE_DEAUTH: | ||
1026 | case IEEE80211_STYPE_DISASSOC: | ||
1027 | skb_queue_tail(&local->work_skb_queue, skb); | ||
1028 | ieee80211_queue_work(&local->hw, &local->work_work); | ||
1029 | return RX_QUEUED; | ||
1030 | } | ||
1031 | } | ||
1032 | |||
1033 | return RX_CONTINUE; | ||
1034 | } | ||
1035 | |||
1036 | static enum work_done_result ieee80211_remain_done(struct ieee80211_work *wk, | ||
1037 | struct sk_buff *skb) | ||
1038 | { | ||
1039 | /* | ||
1040 | * We are done serving the remain-on-channel command. | ||
1041 | */ | ||
1042 | cfg80211_remain_on_channel_expired(wk->sdata->dev, (unsigned long) wk, | ||
1043 | wk->chan, wk->chan_type, | ||
1044 | GFP_KERNEL); | ||
1045 | |||
1046 | return WORK_DONE_DESTROY; | ||
1047 | } | ||
1048 | |||
1049 | int ieee80211_wk_remain_on_channel(struct ieee80211_sub_if_data *sdata, | ||
1050 | struct ieee80211_channel *chan, | ||
1051 | enum nl80211_channel_type channel_type, | ||
1052 | unsigned int duration, u64 *cookie) | ||
1053 | { | ||
1054 | struct ieee80211_work *wk; | ||
1055 | |||
1056 | wk = kzalloc(sizeof(*wk), GFP_KERNEL); | ||
1057 | if (!wk) | ||
1058 | return -ENOMEM; | ||
1059 | |||
1060 | wk->type = IEEE80211_WORK_REMAIN_ON_CHANNEL; | ||
1061 | wk->chan = chan; | ||
1062 | wk->chan_type = channel_type; | ||
1063 | wk->sdata = sdata; | ||
1064 | wk->done = ieee80211_remain_done; | ||
1065 | |||
1066 | wk->remain.duration = duration; | ||
1067 | |||
1068 | *cookie = (unsigned long) wk; | ||
1069 | |||
1070 | ieee80211_add_work(wk); | ||
1071 | |||
1072 | return 0; | ||
1073 | } | ||
1074 | |||
1075 | int ieee80211_wk_cancel_remain_on_channel(struct ieee80211_sub_if_data *sdata, | ||
1076 | u64 cookie) | ||
1077 | { | ||
1078 | struct ieee80211_local *local = sdata->local; | ||
1079 | struct ieee80211_work *wk, *tmp; | ||
1080 | bool found = false; | ||
1081 | |||
1082 | mutex_lock(&local->work_mtx); | ||
1083 | list_for_each_entry_safe(wk, tmp, &local->work_list, list) { | ||
1084 | if ((unsigned long) wk == cookie) { | ||
1085 | wk->timeout = jiffies; | ||
1086 | found = true; | ||
1087 | break; | ||
1088 | } | ||
1089 | } | ||
1090 | mutex_unlock(&local->work_mtx); | ||
1091 | |||
1092 | if (!found) | ||
1093 | return -ENOENT; | ||
1094 | |||
1095 | ieee80211_queue_work(&local->hw, &local->work_work); | ||
1096 | |||
1097 | return 0; | ||
1098 | } | ||
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index d07ecda0a92d..a4b6e148c5de 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -681,9 +681,7 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) | |||
681 | int chains_to_skip = cb->args[0]; | 681 | int chains_to_skip = cb->args[0]; |
682 | int fams_to_skip = cb->args[1]; | 682 | int fams_to_skip = cb->args[1]; |
683 | 683 | ||
684 | for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { | 684 | for (i = chains_to_skip; i < GENL_FAM_TAB_SIZE; i++) { |
685 | if (i < chains_to_skip) | ||
686 | continue; | ||
687 | n = 0; | 685 | n = 0; |
688 | list_for_each_entry(rt, genl_family_chain(i), family_list) { | 686 | list_for_each_entry(rt, genl_family_chain(i), family_list) { |
689 | if (!rt->netnsok && !net_eq(net, &init_net)) | 687 | if (!rt->netnsok && !net_eq(net, &init_net)) |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index f126d18dbdc4..53633c5fdb1d 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -2457,7 +2457,7 @@ static const struct file_operations packet_seq_fops = { | |||
2457 | 2457 | ||
2458 | #endif | 2458 | #endif |
2459 | 2459 | ||
2460 | static int packet_net_init(struct net *net) | 2460 | static int __net_init packet_net_init(struct net *net) |
2461 | { | 2461 | { |
2462 | rwlock_init(&net->packet.sklist_lock); | 2462 | rwlock_init(&net->packet.sklist_lock); |
2463 | INIT_HLIST_HEAD(&net->packet.sklist); | 2463 | INIT_HLIST_HEAD(&net->packet.sklist); |
@@ -2468,7 +2468,7 @@ static int packet_net_init(struct net *net) | |||
2468 | return 0; | 2468 | return 0; |
2469 | } | 2469 | } |
2470 | 2470 | ||
2471 | static void packet_net_exit(struct net *net) | 2471 | static void __net_exit packet_net_exit(struct net *net) |
2472 | { | 2472 | { |
2473 | proc_net_remove(net, "packet"); | 2473 | proc_net_remove(net, "packet"); |
2474 | } | 2474 | } |
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c index 67f072e94d00..387197b579b1 100644 --- a/net/phonet/datagram.c +++ b/net/phonet/datagram.c | |||
@@ -75,7 +75,8 @@ static int pn_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
75 | struct sk_buff *skb; | 75 | struct sk_buff *skb; |
76 | int err; | 76 | int err; |
77 | 77 | ||
78 | if (msg->msg_flags & MSG_OOB) | 78 | if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_NOSIGNAL| |
79 | MSG_CMSG_COMPAT)) | ||
79 | return -EOPNOTSUPP; | 80 | return -EOPNOTSUPP; |
80 | 81 | ||
81 | if (msg->msg_name == NULL) | 82 | if (msg->msg_name == NULL) |
@@ -119,7 +120,8 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
119 | int rval = -EOPNOTSUPP; | 120 | int rval = -EOPNOTSUPP; |
120 | int copylen; | 121 | int copylen; |
121 | 122 | ||
122 | if (flags & MSG_OOB) | 123 | if (flags & ~(MSG_PEEK|MSG_TRUNC|MSG_DONTWAIT|MSG_NOSIGNAL| |
124 | MSG_CMSG_COMPAT)) | ||
123 | goto out_nofree; | 125 | goto out_nofree; |
124 | 126 | ||
125 | if (addr_len) | 127 | if (addr_len) |
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c index d183509d3fa6..d01208968c83 100644 --- a/net/phonet/pep-gprs.c +++ b/net/phonet/pep-gprs.c | |||
@@ -96,11 +96,11 @@ static int gprs_recv(struct gprs_dev *gp, struct sk_buff *skb) | |||
96 | goto drop; | 96 | goto drop; |
97 | } | 97 | } |
98 | 98 | ||
99 | if (likely(skb_headroom(skb) & 3)) { | 99 | if (skb_headroom(skb) & 3) { |
100 | struct sk_buff *rskb, *fs; | 100 | struct sk_buff *rskb, *fs; |
101 | int flen = 0; | 101 | int flen = 0; |
102 | 102 | ||
103 | /* Phonet Pipe data header is misaligned (3 bytes), | 103 | /* Phonet Pipe data header may be misaligned (3 bytes), |
104 | * so wrap the IP packet as a single fragment of an head-less | 104 | * so wrap the IP packet as a single fragment of an head-less |
105 | * socket buffer. The network stack will pull what it needs, | 105 | * socket buffer. The network stack will pull what it needs, |
106 | * but at least, the whole IP payload is not memcpy'd. */ | 106 | * but at least, the whole IP payload is not memcpy'd. */ |
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index b6356f3832f6..360cf377693e 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c | |||
@@ -354,6 +354,9 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
354 | queue = &pn->ctrlreq_queue; | 354 | queue = &pn->ctrlreq_queue; |
355 | goto queue; | 355 | goto queue; |
356 | 356 | ||
357 | case PNS_PIPE_ALIGNED_DATA: | ||
358 | __skb_pull(skb, 1); | ||
359 | /* fall through */ | ||
357 | case PNS_PIPE_DATA: | 360 | case PNS_PIPE_DATA: |
358 | __skb_pull(skb, 3); /* Pipe data header */ | 361 | __skb_pull(skb, 3); /* Pipe data header */ |
359 | if (!pn_flow_safe(pn->rx_fc)) { | 362 | if (!pn_flow_safe(pn->rx_fc)) { |
@@ -441,6 +444,7 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb) | |||
441 | struct sockaddr_pn dst; | 444 | struct sockaddr_pn dst; |
442 | u16 peer_type; | 445 | u16 peer_type; |
443 | u8 pipe_handle, enabled, n_sb; | 446 | u8 pipe_handle, enabled, n_sb; |
447 | u8 aligned = 0; | ||
444 | 448 | ||
445 | if (!pskb_pull(skb, sizeof(*hdr) + 4)) | 449 | if (!pskb_pull(skb, sizeof(*hdr) + 4)) |
446 | return -EINVAL; | 450 | return -EINVAL; |
@@ -479,6 +483,9 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb) | |||
479 | return -EINVAL; | 483 | return -EINVAL; |
480 | peer_type = (peer_type & 0xff00) | data[0]; | 484 | peer_type = (peer_type & 0xff00) | data[0]; |
481 | break; | 485 | break; |
486 | case PN_PIPE_SB_ALIGNED_DATA: | ||
487 | aligned = data[0] != 0; | ||
488 | break; | ||
482 | } | 489 | } |
483 | n_sb--; | 490 | n_sb--; |
484 | } | 491 | } |
@@ -510,6 +517,7 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb) | |||
510 | newpn->rx_credits = 0; | 517 | newpn->rx_credits = 0; |
511 | newpn->rx_fc = newpn->tx_fc = PN_LEGACY_FLOW_CONTROL; | 518 | newpn->rx_fc = newpn->tx_fc = PN_LEGACY_FLOW_CONTROL; |
512 | newpn->init_enable = enabled; | 519 | newpn->init_enable = enabled; |
520 | newpn->aligned = aligned; | ||
513 | 521 | ||
514 | BUG_ON(!skb_queue_empty(&newsk->sk_receive_queue)); | 522 | BUG_ON(!skb_queue_empty(&newsk->sk_receive_queue)); |
515 | skb_queue_head(&newsk->sk_receive_queue, skb); | 523 | skb_queue_head(&newsk->sk_receive_queue, skb); |
@@ -829,11 +837,15 @@ static int pipe_skb_send(struct sock *sk, struct sk_buff *skb) | |||
829 | return -ENOBUFS; | 837 | return -ENOBUFS; |
830 | } | 838 | } |
831 | 839 | ||
832 | skb_push(skb, 3); | 840 | skb_push(skb, 3 + pn->aligned); |
833 | skb_reset_transport_header(skb); | 841 | skb_reset_transport_header(skb); |
834 | ph = pnp_hdr(skb); | 842 | ph = pnp_hdr(skb); |
835 | ph->utid = 0; | 843 | ph->utid = 0; |
836 | ph->message_id = PNS_PIPE_DATA; | 844 | if (pn->aligned) { |
845 | ph->message_id = PNS_PIPE_ALIGNED_DATA; | ||
846 | ph->data[0] = 0; /* padding */ | ||
847 | } else | ||
848 | ph->message_id = PNS_PIPE_DATA; | ||
837 | ph->pipe_handle = pn->pipe_handle; | 849 | ph->pipe_handle = pn->pipe_handle; |
838 | 850 | ||
839 | return pn_skb_send(sk, skb, &pipe_srv); | 851 | return pn_skb_send(sk, skb, &pipe_srv); |
@@ -848,7 +860,9 @@ static int pep_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
848 | int flags = msg->msg_flags; | 860 | int flags = msg->msg_flags; |
849 | int err, done; | 861 | int err, done; |
850 | 862 | ||
851 | if (msg->msg_flags & MSG_OOB || !(msg->msg_flags & MSG_EOR)) | 863 | if ((msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_NOSIGNAL| |
864 | MSG_CMSG_COMPAT)) || | ||
865 | !(msg->msg_flags & MSG_EOR)) | ||
852 | return -EOPNOTSUPP; | 866 | return -EOPNOTSUPP; |
853 | 867 | ||
854 | skb = sock_alloc_send_skb(sk, MAX_PNPIPE_HEADER + len, | 868 | skb = sock_alloc_send_skb(sk, MAX_PNPIPE_HEADER + len, |
@@ -927,6 +941,9 @@ int pep_write(struct sock *sk, struct sk_buff *skb) | |||
927 | struct sk_buff *rskb, *fs; | 941 | struct sk_buff *rskb, *fs; |
928 | int flen = 0; | 942 | int flen = 0; |
929 | 943 | ||
944 | if (pep_sk(sk)->aligned) | ||
945 | return pipe_skb_send(sk, skb); | ||
946 | |||
930 | rskb = alloc_skb(MAX_PNPIPE_HEADER, GFP_ATOMIC); | 947 | rskb = alloc_skb(MAX_PNPIPE_HEADER, GFP_ATOMIC); |
931 | if (!rskb) { | 948 | if (!rskb) { |
932 | kfree_skb(skb); | 949 | kfree_skb(skb); |
@@ -966,6 +983,10 @@ static int pep_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
966 | struct sk_buff *skb; | 983 | struct sk_buff *skb; |
967 | int err; | 984 | int err; |
968 | 985 | ||
986 | if (flags & ~(MSG_OOB|MSG_PEEK|MSG_TRUNC|MSG_DONTWAIT|MSG_WAITALL| | ||
987 | MSG_NOSIGNAL|MSG_CMSG_COMPAT)) | ||
988 | return -EOPNOTSUPP; | ||
989 | |||
969 | if (unlikely(1 << sk->sk_state & (TCPF_LISTEN | TCPF_CLOSE))) | 990 | if (unlikely(1 << sk->sk_state & (TCPF_LISTEN | TCPF_CLOSE))) |
970 | return -ENOTCONN; | 991 | return -ENOTCONN; |
971 | 992 | ||
@@ -973,6 +994,8 @@ static int pep_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
973 | /* Dequeue and acknowledge control request */ | 994 | /* Dequeue and acknowledge control request */ |
974 | struct pep_sock *pn = pep_sk(sk); | 995 | struct pep_sock *pn = pep_sk(sk); |
975 | 996 | ||
997 | if (flags & MSG_PEEK) | ||
998 | return -EOPNOTSUPP; | ||
976 | skb = skb_dequeue(&pn->ctrlreq_queue); | 999 | skb = skb_dequeue(&pn->ctrlreq_queue); |
977 | if (skb) { | 1000 | if (skb) { |
978 | pep_ctrlreq_error(sk, skb, PN_PIPE_NO_ERROR, | 1001 | pep_ctrlreq_error(sk, skb, PN_PIPE_NO_ERROR, |
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index bc4a33bf2d3d..c597cc53a6fb 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c | |||
@@ -311,7 +311,7 @@ static struct notifier_block phonet_device_notifier = { | |||
311 | }; | 311 | }; |
312 | 312 | ||
313 | /* Per-namespace Phonet devices handling */ | 313 | /* Per-namespace Phonet devices handling */ |
314 | static int phonet_init_net(struct net *net) | 314 | static int __net_init phonet_init_net(struct net *net) |
315 | { | 315 | { |
316 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 316 | struct phonet_net *pnn = net_generic(net, phonet_net_id); |
317 | 317 | ||
@@ -324,7 +324,7 @@ static int phonet_init_net(struct net *net) | |||
324 | return 0; | 324 | return 0; |
325 | } | 325 | } |
326 | 326 | ||
327 | static void phonet_exit_net(struct net *net) | 327 | static void __net_exit phonet_exit_net(struct net *net) |
328 | { | 328 | { |
329 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 329 | struct phonet_net *pnn = net_generic(net, phonet_net_id); |
330 | struct net_device *dev; | 330 | struct net_device *dev; |
diff --git a/net/sctp/proc.c b/net/sctp/proc.c index d093cbfeaac4..a5ac6e0a8d9c 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <net/sctp/sctp.h> | 40 | #include <net/sctp/sctp.h> |
41 | #include <net/ip.h> /* for snmp_fold_field */ | 41 | #include <net/ip.h> /* for snmp_fold_field */ |
42 | 42 | ||
43 | static struct snmp_mib sctp_snmp_list[] = { | 43 | static const struct snmp_mib sctp_snmp_list[] = { |
44 | SNMP_MIB_ITEM("SctpCurrEstab", SCTP_MIB_CURRESTAB), | 44 | SNMP_MIB_ITEM("SctpCurrEstab", SCTP_MIB_CURRESTAB), |
45 | SNMP_MIB_ITEM("SctpActiveEstabs", SCTP_MIB_ACTIVEESTABS), | 45 | SNMP_MIB_ITEM("SctpActiveEstabs", SCTP_MIB_ACTIVEESTABS), |
46 | SNMP_MIB_ITEM("SctpPassiveEstabs", SCTP_MIB_PASSIVEESTABS), | 46 | SNMP_MIB_ITEM("SctpPassiveEstabs", SCTP_MIB_PASSIVEESTABS), |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 67fdac9d2d33..f6d1e59c4151 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -6359,7 +6359,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, | |||
6359 | struct sctp_association *asoc) | 6359 | struct sctp_association *asoc) |
6360 | { | 6360 | { |
6361 | struct inet_sock *inet = inet_sk(sk); | 6361 | struct inet_sock *inet = inet_sk(sk); |
6362 | struct inet_sock *newinet = inet_sk(newsk); | 6362 | struct inet_sock *newinet; |
6363 | 6363 | ||
6364 | newsk->sk_type = sk->sk_type; | 6364 | newsk->sk_type = sk->sk_type; |
6365 | newsk->sk_bound_dev_if = sk->sk_bound_dev_if; | 6365 | newsk->sk_bound_dev_if = sk->sk_bound_dev_if; |
diff --git a/net/sysctl_net.c b/net/sysctl_net.c index 0b15d7250c40..53196009160a 100644 --- a/net/sysctl_net.c +++ b/net/sysctl_net.c | |||
@@ -71,7 +71,7 @@ static struct ctl_table_root net_sysctl_ro_root = { | |||
71 | .permissions = net_ctl_ro_header_perms, | 71 | .permissions = net_ctl_ro_header_perms, |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static int sysctl_net_init(struct net *net) | 74 | static int __net_init sysctl_net_init(struct net *net) |
75 | { | 75 | { |
76 | setup_sysctl_set(&net->sysctls, | 76 | setup_sysctl_set(&net->sysctls, |
77 | &net_sysctl_ro_root.default_set, | 77 | &net_sysctl_ro_root.default_set, |
@@ -79,7 +79,7 @@ static int sysctl_net_init(struct net *net) | |||
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | static void sysctl_net_exit(struct net *net) | 82 | static void __net_exit sysctl_net_exit(struct net *net) |
83 | { | 83 | { |
84 | WARN_ON(!list_empty(&net->sysctls.list)); | 84 | WARN_ON(!list_empty(&net->sysctls.list)); |
85 | return; | 85 | return; |
diff --git a/net/tipc/Kconfig b/net/tipc/Kconfig index 3b30d1130b61..b74f78d0c033 100644 --- a/net/tipc/Kconfig +++ b/net/tipc/Kconfig | |||
@@ -10,7 +10,7 @@ menuconfig TIPC | |||
10 | specially designed for intra cluster communication. This protocol | 10 | specially designed for intra cluster communication. This protocol |
11 | originates from Ericsson where it has been used in carrier grade | 11 | originates from Ericsson where it has been used in carrier grade |
12 | cluster applications for many years. | 12 | cluster applications for many years. |
13 | 13 | ||
14 | For more information about TIPC, see http://tipc.sourceforge.net. | 14 | For more information about TIPC, see http://tipc.sourceforge.net. |
15 | 15 | ||
16 | This protocol support is also available as a module ( = code which | 16 | This protocol support is also available as a module ( = code which |
@@ -23,91 +23,76 @@ menuconfig TIPC | |||
23 | if TIPC | 23 | if TIPC |
24 | 24 | ||
25 | config TIPC_ADVANCED | 25 | config TIPC_ADVANCED |
26 | bool "TIPC: Advanced configuration" | 26 | bool "Advanced TIPC configuration" |
27 | default n | 27 | default n |
28 | help | 28 | help |
29 | Saying Y here will open some advanced configuration | 29 | Saying Y here will open some advanced configuration for TIPC. |
30 | for TIPC. Most users do not need to bother, so if | 30 | Most users do not need to bother; if unsure, just say N. |
31 | unsure, just say N. | ||
32 | 31 | ||
33 | config TIPC_ZONES | 32 | config TIPC_ZONES |
34 | int "Maximum number of zones in network" | 33 | int "Maximum number of zones in a network" |
35 | depends on TIPC_ADVANCED | 34 | depends on TIPC_ADVANCED |
35 | range 1 255 | ||
36 | default "3" | 36 | default "3" |
37 | help | 37 | help |
38 | Max number of zones inside TIPC network. Max supported value | 38 | Specifies how many zones can be supported in a TIPC network. |
39 | is 255 zones, minimum is 1 | 39 | Can range from 1 to 255 zones; default is 3. |
40 | 40 | ||
41 | Default is 3 zones in a network; setting this to higher | 41 | Setting this to a smaller value saves some memory; |
42 | allows more zones but might use more memory. | 42 | setting it to a higher value allows for more zones. |
43 | 43 | ||
44 | config TIPC_CLUSTERS | 44 | config TIPC_CLUSTERS |
45 | int "Maximum number of clusters in a zone" | 45 | int "Maximum number of clusters in a zone" |
46 | depends on TIPC_ADVANCED | 46 | depends on TIPC_ADVANCED |
47 | range 1 1 | ||
47 | default "1" | 48 | default "1" |
48 | help | 49 | help |
49 | ***Only 1 (one cluster in a zone) is supported by current code. | 50 | Specifies how many clusters can be supported in a TIPC zone. |
50 | Any value set here will be overridden.*** | ||
51 | |||
52 | (Max number of clusters inside TIPC zone. Max supported | ||
53 | value is 4095 clusters, minimum is 1. | ||
54 | 51 | ||
55 | Default is 1; setting this to smaller value might save | 52 | *** Currently TIPC only supports a single cluster per zone. *** |
56 | some memory, setting it to higher | ||
57 | allows more clusters and might consume more memory.) | ||
58 | 53 | ||
59 | config TIPC_NODES | 54 | config TIPC_NODES |
60 | int "Maximum number of nodes in cluster" | 55 | int "Maximum number of nodes in a cluster" |
61 | depends on TIPC_ADVANCED | 56 | depends on TIPC_ADVANCED |
57 | range 8 2047 | ||
62 | default "255" | 58 | default "255" |
63 | help | 59 | help |
64 | Maximum number of nodes inside a TIPC cluster. Maximum | 60 | Specifies how many nodes can be supported in a TIPC cluster. |
65 | supported value is 2047 nodes, minimum is 8. | 61 | Can range from 8 to 2047 nodes; default is 255. |
66 | |||
67 | Setting this to a smaller value saves some memory, | ||
68 | setting it to higher allows more nodes. | ||
69 | |||
70 | config TIPC_SLAVE_NODES | ||
71 | int "Maximum number of slave nodes in cluster" | ||
72 | depends on TIPC_ADVANCED | ||
73 | default "0" | ||
74 | help | ||
75 | ***This capability is not supported by current code.*** | ||
76 | |||
77 | Maximum number of slave nodes inside a TIPC cluster. Maximum | ||
78 | supported value is 2047 nodes, minimum is 0. | ||
79 | 62 | ||
80 | Setting this to a smaller value saves some memory, | 63 | Setting this to a smaller value saves some memory; |
81 | setting it to higher allows more nodes. | 64 | setting it to higher allows for more nodes. |
82 | 65 | ||
83 | config TIPC_PORTS | 66 | config TIPC_PORTS |
84 | int "Maximum number of ports in a node" | 67 | int "Maximum number of ports in a node" |
85 | depends on TIPC_ADVANCED | 68 | depends on TIPC_ADVANCED |
69 | range 127 65535 | ||
86 | default "8191" | 70 | default "8191" |
87 | help | 71 | help |
88 | Maximum number of ports within a node. Maximum | 72 | Specifies how many ports can be supported by a node. |
89 | supported value is 64535 nodes, minimum is 127. | 73 | Can range from 127 to 65535 ports; default is 8191. |
90 | 74 | ||
91 | Setting this to a smaller value saves some memory, | 75 | Setting this to a smaller value saves some memory, |
92 | setting it to higher allows more ports. | 76 | setting it to higher allows for more ports. |
93 | 77 | ||
94 | config TIPC_LOG | 78 | config TIPC_LOG |
95 | int "Size of log buffer" | 79 | int "Size of log buffer" |
96 | depends on TIPC_ADVANCED | 80 | depends on TIPC_ADVANCED |
97 | default 0 | 81 | range 0 32768 |
82 | default "0" | ||
98 | help | 83 | help |
99 | Size (in bytes) of TIPC's internal log buffer, which records the | 84 | Size (in bytes) of TIPC's internal log buffer, which records the |
100 | occurrence of significant events. Maximum supported value | 85 | occurrence of significant events. Can range from 0 to 32768 bytes; |
101 | is 32768 bytes, minimum is 0. | 86 | default is 0. |
102 | 87 | ||
103 | There is no need to enable the log buffer unless the node will be | 88 | There is no need to enable the log buffer unless the node will be |
104 | managed remotely via TIPC. | 89 | managed remotely via TIPC. |
105 | 90 | ||
106 | config TIPC_DEBUG | 91 | config TIPC_DEBUG |
107 | bool "Enable debugging support" | 92 | bool "Enable debug messages" |
108 | default n | 93 | default n |
109 | help | 94 | help |
110 | This will enable debugging of TIPC. | 95 | This enables debugging of TIPC. |
111 | 96 | ||
112 | Only say Y here if you are having trouble with TIPC. It will | 97 | Only say Y here if you are having trouble with TIPC. It will |
113 | enable the display of detailed information about what is going on. | 98 | enable the display of detailed information about what is going on. |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 3256bd7d398f..52c571fedbe0 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
@@ -189,11 +189,11 @@ static int __init tipc_init(void) | |||
189 | tipc_remote_management = 1; | 189 | tipc_remote_management = 1; |
190 | tipc_max_publications = 10000; | 190 | tipc_max_publications = 10000; |
191 | tipc_max_subscriptions = 2000; | 191 | tipc_max_subscriptions = 2000; |
192 | tipc_max_ports = delimit(CONFIG_TIPC_PORTS, 127, 65536); | 192 | tipc_max_ports = CONFIG_TIPC_PORTS; |
193 | tipc_max_zones = delimit(CONFIG_TIPC_ZONES, 1, 255); | 193 | tipc_max_zones = CONFIG_TIPC_ZONES; |
194 | tipc_max_clusters = delimit(CONFIG_TIPC_CLUSTERS, 1, 1); | 194 | tipc_max_clusters = CONFIG_TIPC_CLUSTERS; |
195 | tipc_max_nodes = delimit(CONFIG_TIPC_NODES, 8, 2047); | 195 | tipc_max_nodes = CONFIG_TIPC_NODES; |
196 | tipc_max_slaves = delimit(CONFIG_TIPC_SLAVE_NODES, 0, 2047); | 196 | tipc_max_slaves = CONFIG_TIPC_SLAVE_NODES; |
197 | tipc_net_id = 4711; | 197 | tipc_net_id = 4711; |
198 | 198 | ||
199 | if ((res = tipc_core_start())) | 199 | if ((res = tipc_core_start())) |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index f25511903115..9bc9b92bc099 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -2224,7 +2224,7 @@ static const struct net_proto_family unix_family_ops = { | |||
2224 | }; | 2224 | }; |
2225 | 2225 | ||
2226 | 2226 | ||
2227 | static int unix_net_init(struct net *net) | 2227 | static int __net_init unix_net_init(struct net *net) |
2228 | { | 2228 | { |
2229 | int error = -ENOMEM; | 2229 | int error = -ENOMEM; |
2230 | 2230 | ||
@@ -2243,7 +2243,7 @@ out: | |||
2243 | return error; | 2243 | return error; |
2244 | } | 2244 | } |
2245 | 2245 | ||
2246 | static void unix_net_exit(struct net *net) | 2246 | static void __net_exit unix_net_exit(struct net *net) |
2247 | { | 2247 | { |
2248 | unix_sysctl_unregister(net); | 2248 | unix_sysctl_unregister(net); |
2249 | proc_net_remove(net, "unix"); | 2249 | proc_net_remove(net, "unix"); |
diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 708f5df6b7f0..d095c7be10d0 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c | |||
@@ -31,7 +31,7 @@ static struct ctl_path unix_path[] = { | |||
31 | { }, | 31 | { }, |
32 | }; | 32 | }; |
33 | 33 | ||
34 | int unix_sysctl_register(struct net *net) | 34 | int __net_init unix_sysctl_register(struct net *net) |
35 | { | 35 | { |
36 | struct ctl_table *table; | 36 | struct ctl_table *table; |
37 | 37 | ||
diff --git a/net/wireless/.gitignore b/net/wireless/.gitignore new file mode 100644 index 000000000000..c33451b896d9 --- /dev/null +++ b/net/wireless/.gitignore | |||
@@ -0,0 +1 @@ | |||
regdb.c | |||
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index 90e93a5701aa..d0ee29063e5d 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig | |||
@@ -94,20 +94,21 @@ config CFG80211_DEBUGFS | |||
94 | 94 | ||
95 | If unsure, say N. | 95 | If unsure, say N. |
96 | 96 | ||
97 | config WIRELESS_OLD_REGULATORY | 97 | config CFG80211_INTERNAL_REGDB |
98 | bool "Old wireless static regulatory definitions" | 98 | bool "use statically compiled regulatory rules database" if EMBEDDED |
99 | default n | 99 | default n |
100 | depends on CFG80211 | 100 | depends on CFG80211 |
101 | ---help--- | 101 | ---help--- |
102 | This option enables the old static regulatory information | 102 | This option generates an internal data structure representing |
103 | and uses it within the new framework. This option is available | 103 | the wireless regulatory rules described in net/wireless/db.txt |
104 | for historical reasons and it is advised to leave it off. | 104 | and includes code to query that database. This is an alternative |
105 | to using CRDA for defining regulatory rules for the kernel. | ||
105 | 106 | ||
106 | For details see: | 107 | For details see: |
107 | 108 | ||
108 | http://wireless.kernel.org/en/developers/Regulatory | 109 | http://wireless.kernel.org/en/developers/Regulatory |
109 | 110 | ||
110 | Say N and if you say Y, please tell us why. The default is N. | 111 | Most distributions have a CRDA package. So if unsure, say N. |
111 | 112 | ||
112 | config CFG80211_WEXT | 113 | config CFG80211_WEXT |
113 | bool "cfg80211 wireless extensions compatibility" | 114 | bool "cfg80211 wireless extensions compatibility" |
diff --git a/net/wireless/Makefile b/net/wireless/Makefile index f07c8dc7aab2..e77e508126fa 100644 --- a/net/wireless/Makefile +++ b/net/wireless/Makefile | |||
@@ -13,5 +13,11 @@ cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o | |||
13 | cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o | 13 | cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o |
14 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o | 14 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o |
15 | cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o | 15 | cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o |
16 | cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o | ||
16 | 17 | ||
17 | ccflags-y += -D__CHECK_ENDIAN__ | 18 | ccflags-y += -D__CHECK_ENDIAN__ |
19 | |||
20 | $(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk | ||
21 | @$(AWK) -f $(srctree)/$(src)/genregdb.awk < $< > $@ | ||
22 | |||
23 | clean-files := regdb.c | ||
diff --git a/net/wireless/chan.c b/net/wireless/chan.c index a46ac6c9b365..bf1737fc9a7e 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c | |||
@@ -41,44 +41,57 @@ rdev_fixed_channel(struct cfg80211_registered_device *rdev, | |||
41 | return result; | 41 | return result; |
42 | } | 42 | } |
43 | 43 | ||
44 | int rdev_set_freq(struct cfg80211_registered_device *rdev, | 44 | struct ieee80211_channel * |
45 | struct wireless_dev *for_wdev, | 45 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, |
46 | int freq, enum nl80211_channel_type channel_type) | 46 | int freq, enum nl80211_channel_type channel_type) |
47 | { | 47 | { |
48 | struct ieee80211_channel *chan; | 48 | struct ieee80211_channel *chan; |
49 | struct ieee80211_sta_ht_cap *ht_cap; | 49 | struct ieee80211_sta_ht_cap *ht_cap; |
50 | int result; | ||
51 | |||
52 | if (rdev_fixed_channel(rdev, for_wdev)) | ||
53 | return -EBUSY; | ||
54 | |||
55 | if (!rdev->ops->set_channel) | ||
56 | return -EOPNOTSUPP; | ||
57 | 50 | ||
58 | chan = ieee80211_get_channel(&rdev->wiphy, freq); | 51 | chan = ieee80211_get_channel(&rdev->wiphy, freq); |
59 | 52 | ||
60 | /* Primary channel not allowed */ | 53 | /* Primary channel not allowed */ |
61 | if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) | 54 | if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) |
62 | return -EINVAL; | 55 | return NULL; |
63 | 56 | ||
64 | if (channel_type == NL80211_CHAN_HT40MINUS && | 57 | if (channel_type == NL80211_CHAN_HT40MINUS && |
65 | chan->flags & IEEE80211_CHAN_NO_HT40MINUS) | 58 | chan->flags & IEEE80211_CHAN_NO_HT40MINUS) |
66 | return -EINVAL; | 59 | return NULL; |
67 | else if (channel_type == NL80211_CHAN_HT40PLUS && | 60 | else if (channel_type == NL80211_CHAN_HT40PLUS && |
68 | chan->flags & IEEE80211_CHAN_NO_HT40PLUS) | 61 | chan->flags & IEEE80211_CHAN_NO_HT40PLUS) |
69 | return -EINVAL; | 62 | return NULL; |
70 | 63 | ||
71 | ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap; | 64 | ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap; |
72 | 65 | ||
73 | if (channel_type != NL80211_CHAN_NO_HT) { | 66 | if (channel_type != NL80211_CHAN_NO_HT) { |
74 | if (!ht_cap->ht_supported) | 67 | if (!ht_cap->ht_supported) |
75 | return -EINVAL; | 68 | return NULL; |
76 | 69 | ||
77 | if (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) || | 70 | if (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) || |
78 | ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT) | 71 | ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT) |
79 | return -EINVAL; | 72 | return NULL; |
80 | } | 73 | } |
81 | 74 | ||
75 | return chan; | ||
76 | } | ||
77 | |||
78 | int rdev_set_freq(struct cfg80211_registered_device *rdev, | ||
79 | struct wireless_dev *for_wdev, | ||
80 | int freq, enum nl80211_channel_type channel_type) | ||
81 | { | ||
82 | struct ieee80211_channel *chan; | ||
83 | int result; | ||
84 | |||
85 | if (rdev_fixed_channel(rdev, for_wdev)) | ||
86 | return -EBUSY; | ||
87 | |||
88 | if (!rdev->ops->set_channel) | ||
89 | return -EOPNOTSUPP; | ||
90 | |||
91 | chan = rdev_freq_to_chan(rdev, freq, channel_type); | ||
92 | if (!chan) | ||
93 | return -EINVAL; | ||
94 | |||
82 | result = rdev->ops->set_channel(&rdev->wiphy, chan, channel_type); | 95 | result = rdev->ops->set_channel(&rdev->wiphy, chan, channel_type); |
83 | if (result) | 96 | if (result) |
84 | return result; | 97 | return result; |
diff --git a/net/wireless/core.c b/net/wireless/core.c index 92b812442488..20db90246de5 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -402,6 +402,7 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) | |||
402 | rdev->wiphy.retry_long = 4; | 402 | rdev->wiphy.retry_long = 4; |
403 | rdev->wiphy.frag_threshold = (u32) -1; | 403 | rdev->wiphy.frag_threshold = (u32) -1; |
404 | rdev->wiphy.rts_threshold = (u32) -1; | 404 | rdev->wiphy.rts_threshold = (u32) -1; |
405 | rdev->wiphy.coverage_class = 0; | ||
405 | 406 | ||
406 | return &rdev->wiphy; | 407 | return &rdev->wiphy; |
407 | } | 408 | } |
diff --git a/net/wireless/core.h b/net/wireless/core.h index 4ef3efc94106..2d6a6b9c0c43 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
@@ -111,7 +111,8 @@ struct cfg80211_internal_bss { | |||
111 | unsigned long ts; | 111 | unsigned long ts; |
112 | struct kref ref; | 112 | struct kref ref; |
113 | atomic_t hold; | 113 | atomic_t hold; |
114 | bool ies_allocated; | 114 | bool beacon_ies_allocated; |
115 | bool proberesp_ies_allocated; | ||
115 | 116 | ||
116 | /* must be last because of priv member */ | 117 | /* must be last because of priv member */ |
117 | struct cfg80211_bss pub; | 118 | struct cfg80211_bss pub; |
@@ -374,10 +375,15 @@ void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev); | |||
374 | struct ieee80211_channel * | 375 | struct ieee80211_channel * |
375 | rdev_fixed_channel(struct cfg80211_registered_device *rdev, | 376 | rdev_fixed_channel(struct cfg80211_registered_device *rdev, |
376 | struct wireless_dev *for_wdev); | 377 | struct wireless_dev *for_wdev); |
378 | struct ieee80211_channel * | ||
379 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, | ||
380 | int freq, enum nl80211_channel_type channel_type); | ||
377 | int rdev_set_freq(struct cfg80211_registered_device *rdev, | 381 | int rdev_set_freq(struct cfg80211_registered_device *rdev, |
378 | struct wireless_dev *for_wdev, | 382 | struct wireless_dev *for_wdev, |
379 | int freq, enum nl80211_channel_type channel_type); | 383 | int freq, enum nl80211_channel_type channel_type); |
380 | 384 | ||
385 | u16 cfg80211_calculate_bitrate(struct rate_info *rate); | ||
386 | |||
381 | #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS | 387 | #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS |
382 | #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond) | 388 | #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond) |
383 | #else | 389 | #else |
diff --git a/net/wireless/db.txt b/net/wireless/db.txt new file mode 100644 index 000000000000..a2fc3a09ccdc --- /dev/null +++ b/net/wireless/db.txt | |||
@@ -0,0 +1,17 @@ | |||
1 | # | ||
2 | # This file is a placeholder to prevent accidental build breakage if someone | ||
3 | # enables CONFIG_CFG80211_INTERNAL_REGDB. Almost no one actually needs to | ||
4 | # enable that build option. | ||
5 | # | ||
6 | # You should be using CRDA instead. It is even better if you use the CRDA | ||
7 | # package provided by your distribution, since they will probably keep it | ||
8 | # up-to-date on your behalf. | ||
9 | # | ||
10 | # If you _really_ intend to use CONFIG_CFG80211_INTERNAL_REGDB then you will | ||
11 | # need to replace this file with one containing appropriately formatted | ||
12 | # regulatory rules that cover the regulatory domains you will be using. Your | ||
13 | # best option is to extract the db.txt file from the wireless-regdb git | ||
14 | # repository: | ||
15 | # | ||
16 | # git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git | ||
17 | # | ||
diff --git a/net/wireless/genregdb.awk b/net/wireless/genregdb.awk new file mode 100644 index 000000000000..3cc9e69880a8 --- /dev/null +++ b/net/wireless/genregdb.awk | |||
@@ -0,0 +1,118 @@ | |||
1 | #!/usr/bin/awk -f | ||
2 | # | ||
3 | # genregdb.awk -- generate regdb.c from db.txt | ||
4 | # | ||
5 | # Actually, it reads from stdin (presumed to be db.txt) and writes | ||
6 | # to stdout (presumed to be regdb.c), but close enough... | ||
7 | # | ||
8 | # Copyright 2009 John W. Linville <linville@tuxdriver.com> | ||
9 | # | ||
10 | # This program is free software; you can redistribute it and/or modify | ||
11 | # it under the terms of the GNU General Public License version 2 as | ||
12 | # published by the Free Software Foundation. | ||
13 | # | ||
14 | |||
15 | BEGIN { | ||
16 | active = 0 | ||
17 | rules = 0; | ||
18 | print "/*" | ||
19 | print " * DO NOT EDIT -- file generated from data in db.txt" | ||
20 | print " */" | ||
21 | print "" | ||
22 | print "#include <linux/nl80211.h>" | ||
23 | print "#include <net/cfg80211.h>" | ||
24 | print "" | ||
25 | regdb = "const struct ieee80211_regdomain *reg_regdb[] = {\n" | ||
26 | } | ||
27 | |||
28 | /^[ \t]*#/ { | ||
29 | # Ignore | ||
30 | } | ||
31 | |||
32 | !active && /^[ \t]*$/ { | ||
33 | # Ignore | ||
34 | } | ||
35 | |||
36 | !active && /country/ { | ||
37 | country=$2 | ||
38 | sub(/:/, "", country) | ||
39 | printf "static const struct ieee80211_regdomain regdom_%s = {\n", country | ||
40 | printf "\t.alpha2 = \"%s\",\n", country | ||
41 | printf "\t.reg_rules = {\n" | ||
42 | active = 1 | ||
43 | regdb = regdb "\t®dom_" country ",\n" | ||
44 | } | ||
45 | |||
46 | active && /^[ \t]*\(/ { | ||
47 | start = $1 | ||
48 | sub(/\(/, "", start) | ||
49 | end = $3 | ||
50 | bw = $5 | ||
51 | sub(/\),/, "", bw) | ||
52 | gain = $6 | ||
53 | sub(/\(/, "", gain) | ||
54 | sub(/,/, "", gain) | ||
55 | power = $7 | ||
56 | sub(/\)/, "", power) | ||
57 | sub(/,/, "", power) | ||
58 | # power might be in mW... | ||
59 | units = $8 | ||
60 | sub(/\)/, "", units) | ||
61 | sub(/,/, "", units) | ||
62 | if (units == "mW") { | ||
63 | if (power == 100) { | ||
64 | power = 20 | ||
65 | } else if (power == 200) { | ||
66 | power = 23 | ||
67 | } else if (power == 500) { | ||
68 | power = 27 | ||
69 | } else if (power == 1000) { | ||
70 | power = 30 | ||
71 | } else { | ||
72 | print "Unknown power value in database!" | ||
73 | } | ||
74 | } | ||
75 | flagstr = "" | ||
76 | for (i=8; i<=NF; i++) | ||
77 | flagstr = flagstr $i | ||
78 | split(flagstr, flagarray, ",") | ||
79 | flags = "" | ||
80 | for (arg in flagarray) { | ||
81 | if (flagarray[arg] == "NO-OFDM") { | ||
82 | flags = flags "\n\t\t\tNL80211_RRF_NO_OFDM | " | ||
83 | } else if (flagarray[arg] == "NO-CCK") { | ||
84 | flags = flags "\n\t\t\tNL80211_RRF_NO_CCK | " | ||
85 | } else if (flagarray[arg] == "NO-INDOOR") { | ||
86 | flags = flags "\n\t\t\tNL80211_RRF_NO_INDOOR | " | ||
87 | } else if (flagarray[arg] == "NO-OUTDOOR") { | ||
88 | flags = flags "\n\t\t\tNL80211_RRF_NO_OUTDOOR | " | ||
89 | } else if (flagarray[arg] == "DFS") { | ||
90 | flags = flags "\n\t\t\tNL80211_RRF_DFS | " | ||
91 | } else if (flagarray[arg] == "PTP-ONLY") { | ||
92 | flags = flags "\n\t\t\tNL80211_RRF_PTP_ONLY | " | ||
93 | } else if (flagarray[arg] == "PTMP-ONLY") { | ||
94 | flags = flags "\n\t\t\tNL80211_RRF_PTMP_ONLY | " | ||
95 | } else if (flagarray[arg] == "PASSIVE-SCAN") { | ||
96 | flags = flags "\n\t\t\tNL80211_RRF_PASSIVE_SCAN | " | ||
97 | } else if (flagarray[arg] == "NO-IBSS") { | ||
98 | flags = flags "\n\t\t\tNL80211_RRF_NO_IBSS | " | ||
99 | } | ||
100 | } | ||
101 | flags = flags "0" | ||
102 | printf "\t\tREG_RULE(%d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, flags | ||
103 | rules++ | ||
104 | } | ||
105 | |||
106 | active && /^[ \t]*$/ { | ||
107 | active = 0 | ||
108 | printf "\t},\n" | ||
109 | printf "\t.n_reg_rules = %d\n", rules | ||
110 | printf "};\n\n" | ||
111 | rules = 0; | ||
112 | } | ||
113 | |||
114 | END { | ||
115 | print regdb "};" | ||
116 | print "" | ||
117 | print "int reg_regdb_size = ARRAY_SIZE(reg_regdb);" | ||
118 | } | ||
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 82e6002c8d67..94d151f6f73e 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c | |||
@@ -148,22 +148,23 @@ void __cfg80211_send_deauth(struct net_device *dev, | |||
148 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; | 148 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; |
149 | const u8 *bssid = mgmt->bssid; | 149 | const u8 *bssid = mgmt->bssid; |
150 | int i; | 150 | int i; |
151 | bool found = false; | ||
151 | 152 | ||
152 | ASSERT_WDEV_LOCK(wdev); | 153 | ASSERT_WDEV_LOCK(wdev); |
153 | 154 | ||
154 | nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL); | ||
155 | |||
156 | if (wdev->current_bss && | 155 | if (wdev->current_bss && |
157 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { | 156 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { |
158 | cfg80211_unhold_bss(wdev->current_bss); | 157 | cfg80211_unhold_bss(wdev->current_bss); |
159 | cfg80211_put_bss(&wdev->current_bss->pub); | 158 | cfg80211_put_bss(&wdev->current_bss->pub); |
160 | wdev->current_bss = NULL; | 159 | wdev->current_bss = NULL; |
160 | found = true; | ||
161 | } else for (i = 0; i < MAX_AUTH_BSSES; i++) { | 161 | } else for (i = 0; i < MAX_AUTH_BSSES; i++) { |
162 | if (wdev->auth_bsses[i] && | 162 | if (wdev->auth_bsses[i] && |
163 | memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) { | 163 | memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) { |
164 | cfg80211_unhold_bss(wdev->auth_bsses[i]); | 164 | cfg80211_unhold_bss(wdev->auth_bsses[i]); |
165 | cfg80211_put_bss(&wdev->auth_bsses[i]->pub); | 165 | cfg80211_put_bss(&wdev->auth_bsses[i]->pub); |
166 | wdev->auth_bsses[i] = NULL; | 166 | wdev->auth_bsses[i] = NULL; |
167 | found = true; | ||
167 | break; | 168 | break; |
168 | } | 169 | } |
169 | if (wdev->authtry_bsses[i] && | 170 | if (wdev->authtry_bsses[i] && |
@@ -171,10 +172,16 @@ void __cfg80211_send_deauth(struct net_device *dev, | |||
171 | cfg80211_unhold_bss(wdev->authtry_bsses[i]); | 172 | cfg80211_unhold_bss(wdev->authtry_bsses[i]); |
172 | cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); | 173 | cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); |
173 | wdev->authtry_bsses[i] = NULL; | 174 | wdev->authtry_bsses[i] = NULL; |
175 | found = true; | ||
174 | break; | 176 | break; |
175 | } | 177 | } |
176 | } | 178 | } |
177 | 179 | ||
180 | if (!found) | ||
181 | return; | ||
182 | |||
183 | nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL); | ||
184 | |||
178 | if (wdev->sme_state == CFG80211_SME_CONNECTED) { | 185 | if (wdev->sme_state == CFG80211_SME_CONNECTED) { |
179 | u16 reason_code; | 186 | u16 reason_code; |
180 | bool from_ap; | 187 | bool from_ap; |
@@ -684,3 +691,40 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, | |||
684 | } | 691 | } |
685 | } | 692 | } |
686 | } | 693 | } |
694 | |||
695 | void cfg80211_ready_on_channel(struct net_device *dev, u64 cookie, | ||
696 | struct ieee80211_channel *chan, | ||
697 | enum nl80211_channel_type channel_type, | ||
698 | unsigned int duration, gfp_t gfp) | ||
699 | { | ||
700 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | ||
701 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
702 | |||
703 | nl80211_send_remain_on_channel(rdev, dev, cookie, chan, channel_type, | ||
704 | duration, gfp); | ||
705 | } | ||
706 | EXPORT_SYMBOL(cfg80211_ready_on_channel); | ||
707 | |||
708 | void cfg80211_remain_on_channel_expired(struct net_device *dev, | ||
709 | u64 cookie, | ||
710 | struct ieee80211_channel *chan, | ||
711 | enum nl80211_channel_type channel_type, | ||
712 | gfp_t gfp) | ||
713 | { | ||
714 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | ||
715 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
716 | |||
717 | nl80211_send_remain_on_channel_cancel(rdev, dev, cookie, chan, | ||
718 | channel_type, gfp); | ||
719 | } | ||
720 | EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); | ||
721 | |||
722 | void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, | ||
723 | struct station_info *sinfo, gfp_t gfp) | ||
724 | { | ||
725 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | ||
726 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
727 | |||
728 | nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); | ||
729 | } | ||
730 | EXPORT_SYMBOL(cfg80211_new_sta); | ||
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a6028433e3a0..4af7991a9ec8 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -69,6 +69,7 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = { | |||
69 | [NL80211_ATTR_WIPHY_RETRY_LONG] = { .type = NLA_U8 }, | 69 | [NL80211_ATTR_WIPHY_RETRY_LONG] = { .type = NLA_U8 }, |
70 | [NL80211_ATTR_WIPHY_FRAG_THRESHOLD] = { .type = NLA_U32 }, | 70 | [NL80211_ATTR_WIPHY_FRAG_THRESHOLD] = { .type = NLA_U32 }, |
71 | [NL80211_ATTR_WIPHY_RTS_THRESHOLD] = { .type = NLA_U32 }, | 71 | [NL80211_ATTR_WIPHY_RTS_THRESHOLD] = { .type = NLA_U32 }, |
72 | [NL80211_ATTR_WIPHY_COVERAGE_CLASS] = { .type = NLA_U8 }, | ||
72 | 73 | ||
73 | [NL80211_ATTR_IFTYPE] = { .type = NLA_U32 }, | 74 | [NL80211_ATTR_IFTYPE] = { .type = NLA_U32 }, |
74 | [NL80211_ATTR_IFINDEX] = { .type = NLA_U32 }, | 75 | [NL80211_ATTR_IFINDEX] = { .type = NLA_U32 }, |
@@ -141,6 +142,9 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = { | |||
141 | [NL80211_ATTR_4ADDR] = { .type = NLA_U8 }, | 142 | [NL80211_ATTR_4ADDR] = { .type = NLA_U8 }, |
142 | [NL80211_ATTR_PMKID] = { .type = NLA_BINARY, | 143 | [NL80211_ATTR_PMKID] = { .type = NLA_BINARY, |
143 | .len = WLAN_PMKID_LEN }, | 144 | .len = WLAN_PMKID_LEN }, |
145 | [NL80211_ATTR_DURATION] = { .type = NLA_U32 }, | ||
146 | [NL80211_ATTR_COOKIE] = { .type = NLA_U64 }, | ||
147 | [NL80211_ATTR_TX_RATES] = { .type = NLA_NESTED }, | ||
144 | }; | 148 | }; |
145 | 149 | ||
146 | /* policy for the attributes */ | 150 | /* policy for the attributes */ |
@@ -442,6 +446,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
442 | dev->wiphy.frag_threshold); | 446 | dev->wiphy.frag_threshold); |
443 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, | 447 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, |
444 | dev->wiphy.rts_threshold); | 448 | dev->wiphy.rts_threshold); |
449 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, | ||
450 | dev->wiphy.coverage_class); | ||
445 | 451 | ||
446 | NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, | 452 | NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, |
447 | dev->wiphy.max_scan_ssids); | 453 | dev->wiphy.max_scan_ssids); |
@@ -569,6 +575,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
569 | CMD(set_pmksa, SET_PMKSA); | 575 | CMD(set_pmksa, SET_PMKSA); |
570 | CMD(del_pmksa, DEL_PMKSA); | 576 | CMD(del_pmksa, DEL_PMKSA); |
571 | CMD(flush_pmksa, FLUSH_PMKSA); | 577 | CMD(flush_pmksa, FLUSH_PMKSA); |
578 | CMD(remain_on_channel, REMAIN_ON_CHANNEL); | ||
579 | CMD(set_bitrate_mask, SET_TX_BITRATE_MASK); | ||
572 | if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { | 580 | if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { |
573 | i++; | 581 | i++; |
574 | NLA_PUT_U32(msg, i, NL80211_CMD_SET_WIPHY_NETNS); | 582 | NLA_PUT_U32(msg, i, NL80211_CMD_SET_WIPHY_NETNS); |
@@ -681,6 +689,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
681 | u32 changed; | 689 | u32 changed; |
682 | u8 retry_short = 0, retry_long = 0; | 690 | u8 retry_short = 0, retry_long = 0; |
683 | u32 frag_threshold = 0, rts_threshold = 0; | 691 | u32 frag_threshold = 0, rts_threshold = 0; |
692 | u8 coverage_class = 0; | ||
684 | 693 | ||
685 | rtnl_lock(); | 694 | rtnl_lock(); |
686 | 695 | ||
@@ -803,9 +812,16 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
803 | changed |= WIPHY_PARAM_RTS_THRESHOLD; | 812 | changed |= WIPHY_PARAM_RTS_THRESHOLD; |
804 | } | 813 | } |
805 | 814 | ||
815 | if (info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) { | ||
816 | coverage_class = nla_get_u8( | ||
817 | info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]); | ||
818 | changed |= WIPHY_PARAM_COVERAGE_CLASS; | ||
819 | } | ||
820 | |||
806 | if (changed) { | 821 | if (changed) { |
807 | u8 old_retry_short, old_retry_long; | 822 | u8 old_retry_short, old_retry_long; |
808 | u32 old_frag_threshold, old_rts_threshold; | 823 | u32 old_frag_threshold, old_rts_threshold; |
824 | u8 old_coverage_class; | ||
809 | 825 | ||
810 | if (!rdev->ops->set_wiphy_params) { | 826 | if (!rdev->ops->set_wiphy_params) { |
811 | result = -EOPNOTSUPP; | 827 | result = -EOPNOTSUPP; |
@@ -816,6 +832,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
816 | old_retry_long = rdev->wiphy.retry_long; | 832 | old_retry_long = rdev->wiphy.retry_long; |
817 | old_frag_threshold = rdev->wiphy.frag_threshold; | 833 | old_frag_threshold = rdev->wiphy.frag_threshold; |
818 | old_rts_threshold = rdev->wiphy.rts_threshold; | 834 | old_rts_threshold = rdev->wiphy.rts_threshold; |
835 | old_coverage_class = rdev->wiphy.coverage_class; | ||
819 | 836 | ||
820 | if (changed & WIPHY_PARAM_RETRY_SHORT) | 837 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
821 | rdev->wiphy.retry_short = retry_short; | 838 | rdev->wiphy.retry_short = retry_short; |
@@ -825,6 +842,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
825 | rdev->wiphy.frag_threshold = frag_threshold; | 842 | rdev->wiphy.frag_threshold = frag_threshold; |
826 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) | 843 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
827 | rdev->wiphy.rts_threshold = rts_threshold; | 844 | rdev->wiphy.rts_threshold = rts_threshold; |
845 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) | ||
846 | rdev->wiphy.coverage_class = coverage_class; | ||
828 | 847 | ||
829 | result = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); | 848 | result = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); |
830 | if (result) { | 849 | if (result) { |
@@ -832,6 +851,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
832 | rdev->wiphy.retry_long = old_retry_long; | 851 | rdev->wiphy.retry_long = old_retry_long; |
833 | rdev->wiphy.frag_threshold = old_frag_threshold; | 852 | rdev->wiphy.frag_threshold = old_frag_threshold; |
834 | rdev->wiphy.rts_threshold = old_rts_threshold; | 853 | rdev->wiphy.rts_threshold = old_rts_threshold; |
854 | rdev->wiphy.coverage_class = old_coverage_class; | ||
835 | } | 855 | } |
836 | } | 856 | } |
837 | 857 | ||
@@ -1637,42 +1657,9 @@ static int parse_station_flags(struct genl_info *info, | |||
1637 | return 0; | 1657 | return 0; |
1638 | } | 1658 | } |
1639 | 1659 | ||
1640 | static u16 nl80211_calculate_bitrate(struct rate_info *rate) | ||
1641 | { | ||
1642 | int modulation, streams, bitrate; | ||
1643 | |||
1644 | if (!(rate->flags & RATE_INFO_FLAGS_MCS)) | ||
1645 | return rate->legacy; | ||
1646 | |||
1647 | /* the formula below does only work for MCS values smaller than 32 */ | ||
1648 | if (rate->mcs >= 32) | ||
1649 | return 0; | ||
1650 | |||
1651 | modulation = rate->mcs & 7; | ||
1652 | streams = (rate->mcs >> 3) + 1; | ||
1653 | |||
1654 | bitrate = (rate->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) ? | ||
1655 | 13500000 : 6500000; | ||
1656 | |||
1657 | if (modulation < 4) | ||
1658 | bitrate *= (modulation + 1); | ||
1659 | else if (modulation == 4) | ||
1660 | bitrate *= (modulation + 2); | ||
1661 | else | ||
1662 | bitrate *= (modulation + 3); | ||
1663 | |||
1664 | bitrate *= streams; | ||
1665 | |||
1666 | if (rate->flags & RATE_INFO_FLAGS_SHORT_GI) | ||
1667 | bitrate = (bitrate / 9) * 10; | ||
1668 | |||
1669 | /* do NOT round down here */ | ||
1670 | return (bitrate + 50000) / 100000; | ||
1671 | } | ||
1672 | |||
1673 | static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, | 1660 | static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, |
1674 | int flags, struct net_device *dev, | 1661 | int flags, struct net_device *dev, |
1675 | u8 *mac_addr, struct station_info *sinfo) | 1662 | const u8 *mac_addr, struct station_info *sinfo) |
1676 | { | 1663 | { |
1677 | void *hdr; | 1664 | void *hdr; |
1678 | struct nlattr *sinfoattr, *txrate; | 1665 | struct nlattr *sinfoattr, *txrate; |
@@ -1716,8 +1703,8 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, | |||
1716 | if (!txrate) | 1703 | if (!txrate) |
1717 | goto nla_put_failure; | 1704 | goto nla_put_failure; |
1718 | 1705 | ||
1719 | /* nl80211_calculate_bitrate will return 0 for mcs >= 32 */ | 1706 | /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */ |
1720 | bitrate = nl80211_calculate_bitrate(&sinfo->txrate); | 1707 | bitrate = cfg80211_calculate_bitrate(&sinfo->txrate); |
1721 | if (bitrate > 0) | 1708 | if (bitrate > 0) |
1722 | NLA_PUT_U16(msg, NL80211_RATE_INFO_BITRATE, bitrate); | 1709 | NLA_PUT_U16(msg, NL80211_RATE_INFO_BITRATE, bitrate); |
1723 | 1710 | ||
@@ -2583,12 +2570,6 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
2583 | 2570 | ||
2584 | data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); | 2571 | data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); |
2585 | 2572 | ||
2586 | #ifdef CONFIG_WIRELESS_OLD_REGULATORY | ||
2587 | /* We ignore world regdom requests with the old regdom setup */ | ||
2588 | if (is_world_regdom(data)) | ||
2589 | return -EINVAL; | ||
2590 | #endif | ||
2591 | |||
2592 | r = regulatory_hint_user(data); | 2573 | r = regulatory_hint_user(data); |
2593 | 2574 | ||
2594 | return r; | 2575 | return r; |
@@ -3182,6 +3163,10 @@ static int nl80211_send_bss(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
3182 | NLA_PUT(msg, NL80211_BSS_INFORMATION_ELEMENTS, | 3163 | NLA_PUT(msg, NL80211_BSS_INFORMATION_ELEMENTS, |
3183 | res->len_information_elements, | 3164 | res->len_information_elements, |
3184 | res->information_elements); | 3165 | res->information_elements); |
3166 | if (res->beacon_ies && res->len_beacon_ies && | ||
3167 | res->beacon_ies != res->information_elements) | ||
3168 | NLA_PUT(msg, NL80211_BSS_BEACON_IES, | ||
3169 | res->len_beacon_ies, res->beacon_ies); | ||
3185 | if (res->tsf) | 3170 | if (res->tsf) |
3186 | NLA_PUT_U64(msg, NL80211_BSS_TSF, res->tsf); | 3171 | NLA_PUT_U64(msg, NL80211_BSS_TSF, res->tsf); |
3187 | if (res->beacon_interval) | 3172 | if (res->beacon_interval) |
@@ -4322,6 +4307,246 @@ static int nl80211_flush_pmksa(struct sk_buff *skb, struct genl_info *info) | |||
4322 | 4307 | ||
4323 | } | 4308 | } |
4324 | 4309 | ||
4310 | static int nl80211_remain_on_channel(struct sk_buff *skb, | ||
4311 | struct genl_info *info) | ||
4312 | { | ||
4313 | struct cfg80211_registered_device *rdev; | ||
4314 | struct net_device *dev; | ||
4315 | struct ieee80211_channel *chan; | ||
4316 | struct sk_buff *msg; | ||
4317 | void *hdr; | ||
4318 | u64 cookie; | ||
4319 | enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; | ||
4320 | u32 freq, duration; | ||
4321 | int err; | ||
4322 | |||
4323 | if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] || | ||
4324 | !info->attrs[NL80211_ATTR_DURATION]) | ||
4325 | return -EINVAL; | ||
4326 | |||
4327 | duration = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); | ||
4328 | |||
4329 | /* | ||
4330 | * We should be on that channel for at least one jiffie, | ||
4331 | * and more than 5 seconds seems excessive. | ||
4332 | */ | ||
4333 | if (!duration || !msecs_to_jiffies(duration) || duration > 5000) | ||
4334 | return -EINVAL; | ||
4335 | |||
4336 | rtnl_lock(); | ||
4337 | |||
4338 | err = get_rdev_dev_by_info_ifindex(info, &rdev, &dev); | ||
4339 | if (err) | ||
4340 | goto unlock_rtnl; | ||
4341 | |||
4342 | if (!rdev->ops->remain_on_channel) { | ||
4343 | err = -EOPNOTSUPP; | ||
4344 | goto out; | ||
4345 | } | ||
4346 | |||
4347 | if (!netif_running(dev)) { | ||
4348 | err = -ENETDOWN; | ||
4349 | goto out; | ||
4350 | } | ||
4351 | |||
4352 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { | ||
4353 | channel_type = nla_get_u32( | ||
4354 | info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | ||
4355 | if (channel_type != NL80211_CHAN_NO_HT && | ||
4356 | channel_type != NL80211_CHAN_HT20 && | ||
4357 | channel_type != NL80211_CHAN_HT40PLUS && | ||
4358 | channel_type != NL80211_CHAN_HT40MINUS) | ||
4359 | err = -EINVAL; | ||
4360 | goto out; | ||
4361 | } | ||
4362 | |||
4363 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); | ||
4364 | chan = rdev_freq_to_chan(rdev, freq, channel_type); | ||
4365 | if (chan == NULL) { | ||
4366 | err = -EINVAL; | ||
4367 | goto out; | ||
4368 | } | ||
4369 | |||
4370 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
4371 | if (!msg) { | ||
4372 | err = -ENOMEM; | ||
4373 | goto out; | ||
4374 | } | ||
4375 | |||
4376 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, | ||
4377 | NL80211_CMD_REMAIN_ON_CHANNEL); | ||
4378 | |||
4379 | if (IS_ERR(hdr)) { | ||
4380 | err = PTR_ERR(hdr); | ||
4381 | goto free_msg; | ||
4382 | } | ||
4383 | |||
4384 | err = rdev->ops->remain_on_channel(&rdev->wiphy, dev, chan, | ||
4385 | channel_type, duration, &cookie); | ||
4386 | |||
4387 | if (err) | ||
4388 | goto free_msg; | ||
4389 | |||
4390 | NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); | ||
4391 | |||
4392 | genlmsg_end(msg, hdr); | ||
4393 | err = genlmsg_reply(msg, info); | ||
4394 | goto out; | ||
4395 | |||
4396 | nla_put_failure: | ||
4397 | err = -ENOBUFS; | ||
4398 | free_msg: | ||
4399 | nlmsg_free(msg); | ||
4400 | out: | ||
4401 | cfg80211_unlock_rdev(rdev); | ||
4402 | dev_put(dev); | ||
4403 | unlock_rtnl: | ||
4404 | rtnl_unlock(); | ||
4405 | return err; | ||
4406 | } | ||
4407 | |||
4408 | static int nl80211_cancel_remain_on_channel(struct sk_buff *skb, | ||
4409 | struct genl_info *info) | ||
4410 | { | ||
4411 | struct cfg80211_registered_device *rdev; | ||
4412 | struct net_device *dev; | ||
4413 | u64 cookie; | ||
4414 | int err; | ||
4415 | |||
4416 | if (!info->attrs[NL80211_ATTR_COOKIE]) | ||
4417 | return -EINVAL; | ||
4418 | |||
4419 | rtnl_lock(); | ||
4420 | |||
4421 | err = get_rdev_dev_by_info_ifindex(info, &rdev, &dev); | ||
4422 | if (err) | ||
4423 | goto unlock_rtnl; | ||
4424 | |||
4425 | if (!rdev->ops->cancel_remain_on_channel) { | ||
4426 | err = -EOPNOTSUPP; | ||
4427 | goto out; | ||
4428 | } | ||
4429 | |||
4430 | if (!netif_running(dev)) { | ||
4431 | err = -ENETDOWN; | ||
4432 | goto out; | ||
4433 | } | ||
4434 | |||
4435 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); | ||
4436 | |||
4437 | err = rdev->ops->cancel_remain_on_channel(&rdev->wiphy, dev, cookie); | ||
4438 | |||
4439 | out: | ||
4440 | cfg80211_unlock_rdev(rdev); | ||
4441 | dev_put(dev); | ||
4442 | unlock_rtnl: | ||
4443 | rtnl_unlock(); | ||
4444 | return err; | ||
4445 | } | ||
4446 | |||
4447 | static u32 rateset_to_mask(struct ieee80211_supported_band *sband, | ||
4448 | u8 *rates, u8 rates_len) | ||
4449 | { | ||
4450 | u8 i; | ||
4451 | u32 mask = 0; | ||
4452 | |||
4453 | for (i = 0; i < rates_len; i++) { | ||
4454 | int rate = (rates[i] & 0x7f) * 5; | ||
4455 | int ridx; | ||
4456 | for (ridx = 0; ridx < sband->n_bitrates; ridx++) { | ||
4457 | struct ieee80211_rate *srate = | ||
4458 | &sband->bitrates[ridx]; | ||
4459 | if (rate == srate->bitrate) { | ||
4460 | mask |= 1 << ridx; | ||
4461 | break; | ||
4462 | } | ||
4463 | } | ||
4464 | if (ridx == sband->n_bitrates) | ||
4465 | return 0; /* rate not found */ | ||
4466 | } | ||
4467 | |||
4468 | return mask; | ||
4469 | } | ||
4470 | |||
4471 | static struct nla_policy | ||
4472 | nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] __read_mostly = { | ||
4473 | [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY, | ||
4474 | .len = NL80211_MAX_SUPP_RATES }, | ||
4475 | }; | ||
4476 | |||
4477 | static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, | ||
4478 | struct genl_info *info) | ||
4479 | { | ||
4480 | struct nlattr *tb[NL80211_TXRATE_MAX + 1]; | ||
4481 | struct cfg80211_registered_device *rdev; | ||
4482 | struct cfg80211_bitrate_mask mask; | ||
4483 | int err, rem, i; | ||
4484 | struct net_device *dev; | ||
4485 | struct nlattr *tx_rates; | ||
4486 | struct ieee80211_supported_band *sband; | ||
4487 | |||
4488 | if (info->attrs[NL80211_ATTR_TX_RATES] == NULL) | ||
4489 | return -EINVAL; | ||
4490 | |||
4491 | rtnl_lock(); | ||
4492 | |||
4493 | err = get_rdev_dev_by_info_ifindex(info, &rdev, &dev); | ||
4494 | if (err) | ||
4495 | goto unlock_rtnl; | ||
4496 | |||
4497 | if (!rdev->ops->set_bitrate_mask) { | ||
4498 | err = -EOPNOTSUPP; | ||
4499 | goto unlock; | ||
4500 | } | ||
4501 | |||
4502 | memset(&mask, 0, sizeof(mask)); | ||
4503 | /* Default to all rates enabled */ | ||
4504 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) { | ||
4505 | sband = rdev->wiphy.bands[i]; | ||
4506 | mask.control[i].legacy = | ||
4507 | sband ? (1 << sband->n_bitrates) - 1 : 0; | ||
4508 | } | ||
4509 | |||
4510 | /* | ||
4511 | * The nested attribute uses enum nl80211_band as the index. This maps | ||
4512 | * directly to the enum ieee80211_band values used in cfg80211. | ||
4513 | */ | ||
4514 | nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) | ||
4515 | { | ||
4516 | enum ieee80211_band band = nla_type(tx_rates); | ||
4517 | if (band < 0 || band >= IEEE80211_NUM_BANDS) { | ||
4518 | err = -EINVAL; | ||
4519 | goto unlock; | ||
4520 | } | ||
4521 | sband = rdev->wiphy.bands[band]; | ||
4522 | if (sband == NULL) { | ||
4523 | err = -EINVAL; | ||
4524 | goto unlock; | ||
4525 | } | ||
4526 | nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates), | ||
4527 | nla_len(tx_rates), nl80211_txattr_policy); | ||
4528 | if (tb[NL80211_TXRATE_LEGACY]) { | ||
4529 | mask.control[band].legacy = rateset_to_mask( | ||
4530 | sband, | ||
4531 | nla_data(tb[NL80211_TXRATE_LEGACY]), | ||
4532 | nla_len(tb[NL80211_TXRATE_LEGACY])); | ||
4533 | if (mask.control[band].legacy == 0) { | ||
4534 | err = -EINVAL; | ||
4535 | goto unlock; | ||
4536 | } | ||
4537 | } | ||
4538 | } | ||
4539 | |||
4540 | err = rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, NULL, &mask); | ||
4541 | |||
4542 | unlock: | ||
4543 | dev_put(dev); | ||
4544 | cfg80211_unlock_rdev(rdev); | ||
4545 | unlock_rtnl: | ||
4546 | rtnl_unlock(); | ||
4547 | return err; | ||
4548 | } | ||
4549 | |||
4325 | static struct genl_ops nl80211_ops[] = { | 4550 | static struct genl_ops nl80211_ops[] = { |
4326 | { | 4551 | { |
4327 | .cmd = NL80211_CMD_GET_WIPHY, | 4552 | .cmd = NL80211_CMD_GET_WIPHY, |
@@ -4584,8 +4809,26 @@ static struct genl_ops nl80211_ops[] = { | |||
4584 | .policy = nl80211_policy, | 4809 | .policy = nl80211_policy, |
4585 | .flags = GENL_ADMIN_PERM, | 4810 | .flags = GENL_ADMIN_PERM, |
4586 | }, | 4811 | }, |
4587 | 4812 | { | |
4813 | .cmd = NL80211_CMD_REMAIN_ON_CHANNEL, | ||
4814 | .doit = nl80211_remain_on_channel, | ||
4815 | .policy = nl80211_policy, | ||
4816 | .flags = GENL_ADMIN_PERM, | ||
4817 | }, | ||
4818 | { | ||
4819 | .cmd = NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, | ||
4820 | .doit = nl80211_cancel_remain_on_channel, | ||
4821 | .policy = nl80211_policy, | ||
4822 | .flags = GENL_ADMIN_PERM, | ||
4823 | }, | ||
4824 | { | ||
4825 | .cmd = NL80211_CMD_SET_TX_BITRATE_MASK, | ||
4826 | .doit = nl80211_set_tx_bitrate_mask, | ||
4827 | .policy = nl80211_policy, | ||
4828 | .flags = GENL_ADMIN_PERM, | ||
4829 | }, | ||
4588 | }; | 4830 | }; |
4831 | |||
4589 | static struct genl_multicast_group nl80211_mlme_mcgrp = { | 4832 | static struct genl_multicast_group nl80211_mlme_mcgrp = { |
4590 | .name = "mlme", | 4833 | .name = "mlme", |
4591 | }; | 4834 | }; |
@@ -5173,6 +5416,89 @@ nla_put_failure: | |||
5173 | nlmsg_free(msg); | 5416 | nlmsg_free(msg); |
5174 | } | 5417 | } |
5175 | 5418 | ||
5419 | static void nl80211_send_remain_on_chan_event( | ||
5420 | int cmd, struct cfg80211_registered_device *rdev, | ||
5421 | struct net_device *netdev, u64 cookie, | ||
5422 | struct ieee80211_channel *chan, | ||
5423 | enum nl80211_channel_type channel_type, | ||
5424 | unsigned int duration, gfp_t gfp) | ||
5425 | { | ||
5426 | struct sk_buff *msg; | ||
5427 | void *hdr; | ||
5428 | |||
5429 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | ||
5430 | if (!msg) | ||
5431 | return; | ||
5432 | |||
5433 | hdr = nl80211hdr_put(msg, 0, 0, 0, cmd); | ||
5434 | if (!hdr) { | ||
5435 | nlmsg_free(msg); | ||
5436 | return; | ||
5437 | } | ||
5438 | |||
5439 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); | ||
5440 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); | ||
5441 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq); | ||
5442 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, channel_type); | ||
5443 | NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); | ||
5444 | |||
5445 | if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL) | ||
5446 | NLA_PUT_U32(msg, NL80211_ATTR_DURATION, duration); | ||
5447 | |||
5448 | if (genlmsg_end(msg, hdr) < 0) { | ||
5449 | nlmsg_free(msg); | ||
5450 | return; | ||
5451 | } | ||
5452 | |||
5453 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
5454 | nl80211_mlme_mcgrp.id, gfp); | ||
5455 | return; | ||
5456 | |||
5457 | nla_put_failure: | ||
5458 | genlmsg_cancel(msg, hdr); | ||
5459 | nlmsg_free(msg); | ||
5460 | } | ||
5461 | |||
5462 | void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, | ||
5463 | struct net_device *netdev, u64 cookie, | ||
5464 | struct ieee80211_channel *chan, | ||
5465 | enum nl80211_channel_type channel_type, | ||
5466 | unsigned int duration, gfp_t gfp) | ||
5467 | { | ||
5468 | nl80211_send_remain_on_chan_event(NL80211_CMD_REMAIN_ON_CHANNEL, | ||
5469 | rdev, netdev, cookie, chan, | ||
5470 | channel_type, duration, gfp); | ||
5471 | } | ||
5472 | |||
5473 | void nl80211_send_remain_on_channel_cancel( | ||
5474 | struct cfg80211_registered_device *rdev, struct net_device *netdev, | ||
5475 | u64 cookie, struct ieee80211_channel *chan, | ||
5476 | enum nl80211_channel_type channel_type, gfp_t gfp) | ||
5477 | { | ||
5478 | nl80211_send_remain_on_chan_event(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, | ||
5479 | rdev, netdev, cookie, chan, | ||
5480 | channel_type, 0, gfp); | ||
5481 | } | ||
5482 | |||
5483 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, | ||
5484 | struct net_device *dev, const u8 *mac_addr, | ||
5485 | struct station_info *sinfo, gfp_t gfp) | ||
5486 | { | ||
5487 | struct sk_buff *msg; | ||
5488 | |||
5489 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); | ||
5490 | if (!msg) | ||
5491 | return; | ||
5492 | |||
5493 | if (nl80211_send_station(msg, 0, 0, 0, dev, mac_addr, sinfo) < 0) { | ||
5494 | nlmsg_free(msg); | ||
5495 | return; | ||
5496 | } | ||
5497 | |||
5498 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
5499 | nl80211_mlme_mcgrp.id, gfp); | ||
5500 | } | ||
5501 | |||
5176 | /* initialisation/exit functions */ | 5502 | /* initialisation/exit functions */ |
5177 | 5503 | ||
5178 | int nl80211_init(void) | 5504 | int nl80211_init(void) |
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index 44cc2a76a1b0..14855b8fb430 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h | |||
@@ -59,4 +59,19 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev, | |||
59 | struct net_device *netdev, const u8 *bssid, | 59 | struct net_device *netdev, const u8 *bssid, |
60 | gfp_t gfp); | 60 | gfp_t gfp); |
61 | 61 | ||
62 | void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, | ||
63 | struct net_device *netdev, | ||
64 | u64 cookie, | ||
65 | struct ieee80211_channel *chan, | ||
66 | enum nl80211_channel_type channel_type, | ||
67 | unsigned int duration, gfp_t gfp); | ||
68 | void nl80211_send_remain_on_channel_cancel( | ||
69 | struct cfg80211_registered_device *rdev, struct net_device *netdev, | ||
70 | u64 cookie, struct ieee80211_channel *chan, | ||
71 | enum nl80211_channel_type channel_type, gfp_t gfp); | ||
72 | |||
73 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, | ||
74 | struct net_device *dev, const u8 *mac_addr, | ||
75 | struct station_info *sinfo, gfp_t gfp); | ||
76 | |||
62 | #endif /* __NET_WIRELESS_NL80211_H */ | 77 | #endif /* __NET_WIRELESS_NL80211_H */ |
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 7a0754c92df4..5f8071de7950 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -40,8 +40,18 @@ | |||
40 | #include <net/cfg80211.h> | 40 | #include <net/cfg80211.h> |
41 | #include "core.h" | 41 | #include "core.h" |
42 | #include "reg.h" | 42 | #include "reg.h" |
43 | #include "regdb.h" | ||
43 | #include "nl80211.h" | 44 | #include "nl80211.h" |
44 | 45 | ||
46 | #ifdef CONFIG_CFG80211_REG_DEBUG | ||
47 | #define REG_DBG_PRINT(format, args...) \ | ||
48 | do { \ | ||
49 | printk(KERN_DEBUG format , ## args); \ | ||
50 | } while (0) | ||
51 | #else | ||
52 | #define REG_DBG_PRINT(args...) | ||
53 | #endif | ||
54 | |||
45 | /* Receipt of information from last regulatory request */ | 55 | /* Receipt of information from last regulatory request */ |
46 | static struct regulatory_request *last_request; | 56 | static struct regulatory_request *last_request; |
47 | 57 | ||
@@ -128,78 +138,6 @@ static char *ieee80211_regdom = "00"; | |||
128 | module_param(ieee80211_regdom, charp, 0444); | 138 | module_param(ieee80211_regdom, charp, 0444); |
129 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); | 139 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); |
130 | 140 | ||
131 | #ifdef CONFIG_WIRELESS_OLD_REGULATORY | ||
132 | /* | ||
133 | * We assume 40 MHz bandwidth for the old regulatory work. | ||
134 | * We make emphasis we are using the exact same frequencies | ||
135 | * as before | ||
136 | */ | ||
137 | |||
138 | static const struct ieee80211_regdomain us_regdom = { | ||
139 | .n_reg_rules = 6, | ||
140 | .alpha2 = "US", | ||
141 | .reg_rules = { | ||
142 | /* IEEE 802.11b/g, channels 1..11 */ | ||
143 | REG_RULE(2412-10, 2462+10, 40, 6, 27, 0), | ||
144 | /* IEEE 802.11a, channel 36..48 */ | ||
145 | REG_RULE(5180-10, 5240+10, 40, 6, 17, 0), | ||
146 | /* IEEE 802.11a, channels 48..64 */ | ||
147 | REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS), | ||
148 | /* IEEE 802.11a, channels 100..124 */ | ||
149 | REG_RULE(5500-10, 5590+10, 40, 6, 20, NL80211_RRF_DFS), | ||
150 | /* IEEE 802.11a, channels 132..144 */ | ||
151 | REG_RULE(5660-10, 5700+10, 40, 6, 20, NL80211_RRF_DFS), | ||
152 | /* IEEE 802.11a, channels 149..165, outdoor */ | ||
153 | REG_RULE(5745-10, 5825+10, 40, 6, 30, 0), | ||
154 | } | ||
155 | }; | ||
156 | |||
157 | static const struct ieee80211_regdomain jp_regdom = { | ||
158 | .n_reg_rules = 6, | ||
159 | .alpha2 = "JP", | ||
160 | .reg_rules = { | ||
161 | /* IEEE 802.11b/g, channels 1..11 */ | ||
162 | REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), | ||
163 | /* IEEE 802.11b/g, channels 12..13 */ | ||
164 | REG_RULE(2467-10, 2472+10, 20, 6, 20, 0), | ||
165 | /* IEEE 802.11b/g, channel 14 */ | ||
166 | REG_RULE(2484-10, 2484+10, 20, 6, 20, NL80211_RRF_NO_OFDM), | ||
167 | /* IEEE 802.11a, channels 36..48 */ | ||
168 | REG_RULE(5180-10, 5240+10, 40, 6, 20, 0), | ||
169 | /* IEEE 802.11a, channels 52..64 */ | ||
170 | REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS), | ||
171 | /* IEEE 802.11a, channels 100..144 */ | ||
172 | REG_RULE(5500-10, 5700+10, 40, 6, 23, NL80211_RRF_DFS), | ||
173 | } | ||
174 | }; | ||
175 | |||
176 | static const struct ieee80211_regdomain *static_regdom(char *alpha2) | ||
177 | { | ||
178 | if (alpha2[0] == 'U' && alpha2[1] == 'S') | ||
179 | return &us_regdom; | ||
180 | if (alpha2[0] == 'J' && alpha2[1] == 'P') | ||
181 | return &jp_regdom; | ||
182 | /* Use world roaming rules for "EU", since it was a pseudo | ||
183 | domain anyway... */ | ||
184 | if (alpha2[0] == 'E' && alpha2[1] == 'U') | ||
185 | return &world_regdom; | ||
186 | /* Default, world roaming rules */ | ||
187 | return &world_regdom; | ||
188 | } | ||
189 | |||
190 | static bool is_old_static_regdom(const struct ieee80211_regdomain *rd) | ||
191 | { | ||
192 | if (rd == &us_regdom || rd == &jp_regdom || rd == &world_regdom) | ||
193 | return true; | ||
194 | return false; | ||
195 | } | ||
196 | #else | ||
197 | static inline bool is_old_static_regdom(const struct ieee80211_regdomain *rd) | ||
198 | { | ||
199 | return false; | ||
200 | } | ||
201 | #endif | ||
202 | |||
203 | static void reset_regdomains(void) | 141 | static void reset_regdomains(void) |
204 | { | 142 | { |
205 | /* avoid freeing static information or freeing something twice */ | 143 | /* avoid freeing static information or freeing something twice */ |
@@ -209,8 +147,6 @@ static void reset_regdomains(void) | |||
209 | cfg80211_world_regdom = NULL; | 147 | cfg80211_world_regdom = NULL; |
210 | if (cfg80211_regdomain == &world_regdom) | 148 | if (cfg80211_regdomain == &world_regdom) |
211 | cfg80211_regdomain = NULL; | 149 | cfg80211_regdomain = NULL; |
212 | if (is_old_static_regdom(cfg80211_regdomain)) | ||
213 | cfg80211_regdomain = NULL; | ||
214 | 150 | ||
215 | kfree(cfg80211_regdomain); | 151 | kfree(cfg80211_regdomain); |
216 | kfree(cfg80211_world_regdom); | 152 | kfree(cfg80211_world_regdom); |
@@ -335,6 +271,98 @@ static bool country_ie_integrity_changes(u32 checksum) | |||
335 | return false; | 271 | return false; |
336 | } | 272 | } |
337 | 273 | ||
274 | static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd, | ||
275 | const struct ieee80211_regdomain *src_regd) | ||
276 | { | ||
277 | struct ieee80211_regdomain *regd; | ||
278 | int size_of_regd = 0; | ||
279 | unsigned int i; | ||
280 | |||
281 | size_of_regd = sizeof(struct ieee80211_regdomain) + | ||
282 | ((src_regd->n_reg_rules + 1) * sizeof(struct ieee80211_reg_rule)); | ||
283 | |||
284 | regd = kzalloc(size_of_regd, GFP_KERNEL); | ||
285 | if (!regd) | ||
286 | return -ENOMEM; | ||
287 | |||
288 | memcpy(regd, src_regd, sizeof(struct ieee80211_regdomain)); | ||
289 | |||
290 | for (i = 0; i < src_regd->n_reg_rules; i++) | ||
291 | memcpy(®d->reg_rules[i], &src_regd->reg_rules[i], | ||
292 | sizeof(struct ieee80211_reg_rule)); | ||
293 | |||
294 | *dst_regd = regd; | ||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | #ifdef CONFIG_CFG80211_INTERNAL_REGDB | ||
299 | struct reg_regdb_search_request { | ||
300 | char alpha2[2]; | ||
301 | struct list_head list; | ||
302 | }; | ||
303 | |||
304 | static LIST_HEAD(reg_regdb_search_list); | ||
305 | static DEFINE_SPINLOCK(reg_regdb_search_lock); | ||
306 | |||
307 | static void reg_regdb_search(struct work_struct *work) | ||
308 | { | ||
309 | struct reg_regdb_search_request *request; | ||
310 | const struct ieee80211_regdomain *curdom, *regdom; | ||
311 | int i, r; | ||
312 | |||
313 | spin_lock(®_regdb_search_lock); | ||
314 | while (!list_empty(®_regdb_search_list)) { | ||
315 | request = list_first_entry(®_regdb_search_list, | ||
316 | struct reg_regdb_search_request, | ||
317 | list); | ||
318 | list_del(&request->list); | ||
319 | |||
320 | for (i=0; i<reg_regdb_size; i++) { | ||
321 | curdom = reg_regdb[i]; | ||
322 | |||
323 | if (!memcmp(request->alpha2, curdom->alpha2, 2)) { | ||
324 | r = reg_copy_regd(®dom, curdom); | ||
325 | if (r) | ||
326 | break; | ||
327 | spin_unlock(®_regdb_search_lock); | ||
328 | mutex_lock(&cfg80211_mutex); | ||
329 | set_regdom(regdom); | ||
330 | mutex_unlock(&cfg80211_mutex); | ||
331 | spin_lock(®_regdb_search_lock); | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | kfree(request); | ||
337 | } | ||
338 | spin_unlock(®_regdb_search_lock); | ||
339 | } | ||
340 | |||
341 | static DECLARE_WORK(reg_regdb_work, reg_regdb_search); | ||
342 | |||
343 | static void reg_regdb_query(const char *alpha2) | ||
344 | { | ||
345 | struct reg_regdb_search_request *request; | ||
346 | |||
347 | if (!alpha2) | ||
348 | return; | ||
349 | |||
350 | request = kzalloc(sizeof(struct reg_regdb_search_request), GFP_KERNEL); | ||
351 | if (!request) | ||
352 | return; | ||
353 | |||
354 | memcpy(request->alpha2, alpha2, 2); | ||
355 | |||
356 | spin_lock(®_regdb_search_lock); | ||
357 | list_add_tail(&request->list, ®_regdb_search_list); | ||
358 | spin_unlock(®_regdb_search_lock); | ||
359 | |||
360 | schedule_work(®_regdb_work); | ||
361 | } | ||
362 | #else | ||
363 | static inline void reg_regdb_query(const char *alpha2) {} | ||
364 | #endif /* CONFIG_CFG80211_INTERNAL_REGDB */ | ||
365 | |||
338 | /* | 366 | /* |
339 | * This lets us keep regulatory code which is updated on a regulatory | 367 | * This lets us keep regulatory code which is updated on a regulatory |
340 | * basis in userspace. | 368 | * basis in userspace. |
@@ -354,6 +382,9 @@ static int call_crda(const char *alpha2) | |||
354 | printk(KERN_INFO "cfg80211: Calling CRDA to update world " | 382 | printk(KERN_INFO "cfg80211: Calling CRDA to update world " |
355 | "regulatory domain\n"); | 383 | "regulatory domain\n"); |
356 | 384 | ||
385 | /* query internal regulatory database (if it exists) */ | ||
386 | reg_regdb_query(alpha2); | ||
387 | |||
357 | country_env[8] = alpha2[0]; | 388 | country_env[8] = alpha2[0]; |
358 | country_env[9] = alpha2[1]; | 389 | country_env[9] = alpha2[1]; |
359 | 390 | ||
@@ -454,12 +485,212 @@ static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range, | |||
454 | } | 485 | } |
455 | 486 | ||
456 | /* | 487 | /* |
488 | * This is a work around for sanity checking ieee80211_channel_to_frequency()'s | ||
489 | * work. ieee80211_channel_to_frequency() can for example currently provide a | ||
490 | * 2 GHz channel when in fact a 5 GHz channel was desired. An example would be | ||
491 | * an AP providing channel 8 on a country IE triplet when it sent this on the | ||
492 | * 5 GHz band, that channel is designed to be channel 8 on 5 GHz, not a 2 GHz | ||
493 | * channel. | ||
494 | * | ||
495 | * This can be removed once ieee80211_channel_to_frequency() takes in a band. | ||
496 | */ | ||
497 | static bool chan_in_band(int chan, enum ieee80211_band band) | ||
498 | { | ||
499 | int center_freq = ieee80211_channel_to_frequency(chan); | ||
500 | |||
501 | switch (band) { | ||
502 | case IEEE80211_BAND_2GHZ: | ||
503 | if (center_freq <= 2484) | ||
504 | return true; | ||
505 | return false; | ||
506 | case IEEE80211_BAND_5GHZ: | ||
507 | if (center_freq >= 5005) | ||
508 | return true; | ||
509 | return false; | ||
510 | default: | ||
511 | return false; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | /* | ||
516 | * Some APs may send a country IE triplet for each channel they | ||
517 | * support and while this is completely overkill and silly we still | ||
518 | * need to support it. We avoid making a single rule for each channel | ||
519 | * though and to help us with this we use this helper to find the | ||
520 | * actual subband end channel. These type of country IE triplet | ||
521 | * scenerios are handled then, all yielding two regulaotry rules from | ||
522 | * parsing a country IE: | ||
523 | * | ||
524 | * [1] | ||
525 | * [2] | ||
526 | * [36] | ||
527 | * [40] | ||
528 | * | ||
529 | * [1] | ||
530 | * [2-4] | ||
531 | * [5-12] | ||
532 | * [36] | ||
533 | * [40-44] | ||
534 | * | ||
535 | * [1-4] | ||
536 | * [5-7] | ||
537 | * [36-44] | ||
538 | * [48-64] | ||
539 | * | ||
540 | * [36-36] | ||
541 | * [40-40] | ||
542 | * [44-44] | ||
543 | * [48-48] | ||
544 | * [52-52] | ||
545 | * [56-56] | ||
546 | * [60-60] | ||
547 | * [64-64] | ||
548 | * [100-100] | ||
549 | * [104-104] | ||
550 | * [108-108] | ||
551 | * [112-112] | ||
552 | * [116-116] | ||
553 | * [120-120] | ||
554 | * [124-124] | ||
555 | * [128-128] | ||
556 | * [132-132] | ||
557 | * [136-136] | ||
558 | * [140-140] | ||
559 | * | ||
560 | * Returns 0 if the IE has been found to be invalid in the middle | ||
561 | * somewhere. | ||
562 | */ | ||
563 | static int max_subband_chan(enum ieee80211_band band, | ||
564 | int orig_cur_chan, | ||
565 | int orig_end_channel, | ||
566 | s8 orig_max_power, | ||
567 | u8 **country_ie, | ||
568 | u8 *country_ie_len) | ||
569 | { | ||
570 | u8 *triplets_start = *country_ie; | ||
571 | u8 len_at_triplet = *country_ie_len; | ||
572 | int end_subband_chan = orig_end_channel; | ||
573 | |||
574 | /* | ||
575 | * We'll deal with padding for the caller unless | ||
576 | * its not immediate and we don't process any channels | ||
577 | */ | ||
578 | if (*country_ie_len == 1) { | ||
579 | *country_ie += 1; | ||
580 | *country_ie_len -= 1; | ||
581 | return orig_end_channel; | ||
582 | } | ||
583 | |||
584 | /* Move to the next triplet and then start search */ | ||
585 | *country_ie += 3; | ||
586 | *country_ie_len -= 3; | ||
587 | |||
588 | if (!chan_in_band(orig_cur_chan, band)) | ||
589 | return 0; | ||
590 | |||
591 | while (*country_ie_len >= 3) { | ||
592 | int end_channel = 0; | ||
593 | struct ieee80211_country_ie_triplet *triplet = | ||
594 | (struct ieee80211_country_ie_triplet *) *country_ie; | ||
595 | int cur_channel = 0, next_expected_chan; | ||
596 | |||
597 | /* means last triplet is completely unrelated to this one */ | ||
598 | if (triplet->ext.reg_extension_id >= | ||
599 | IEEE80211_COUNTRY_EXTENSION_ID) { | ||
600 | *country_ie -= 3; | ||
601 | *country_ie_len += 3; | ||
602 | break; | ||
603 | } | ||
604 | |||
605 | if (triplet->chans.first_channel == 0) { | ||
606 | *country_ie += 1; | ||
607 | *country_ie_len -= 1; | ||
608 | if (*country_ie_len != 0) | ||
609 | return 0; | ||
610 | break; | ||
611 | } | ||
612 | |||
613 | if (triplet->chans.num_channels == 0) | ||
614 | return 0; | ||
615 | |||
616 | /* Monitonically increasing channel order */ | ||
617 | if (triplet->chans.first_channel <= end_subband_chan) | ||
618 | return 0; | ||
619 | |||
620 | if (!chan_in_band(triplet->chans.first_channel, band)) | ||
621 | return 0; | ||
622 | |||
623 | /* 2 GHz */ | ||
624 | if (triplet->chans.first_channel <= 14) { | ||
625 | end_channel = triplet->chans.first_channel + | ||
626 | triplet->chans.num_channels - 1; | ||
627 | } | ||
628 | else { | ||
629 | end_channel = triplet->chans.first_channel + | ||
630 | (4 * (triplet->chans.num_channels - 1)); | ||
631 | } | ||
632 | |||
633 | if (!chan_in_band(end_channel, band)) | ||
634 | return 0; | ||
635 | |||
636 | if (orig_max_power != triplet->chans.max_power) { | ||
637 | *country_ie -= 3; | ||
638 | *country_ie_len += 3; | ||
639 | break; | ||
640 | } | ||
641 | |||
642 | cur_channel = triplet->chans.first_channel; | ||
643 | |||
644 | /* The key is finding the right next expected channel */ | ||
645 | if (band == IEEE80211_BAND_2GHZ) | ||
646 | next_expected_chan = end_subband_chan + 1; | ||
647 | else | ||
648 | next_expected_chan = end_subband_chan + 4; | ||
649 | |||
650 | if (cur_channel != next_expected_chan) { | ||
651 | *country_ie -= 3; | ||
652 | *country_ie_len += 3; | ||
653 | break; | ||
654 | } | ||
655 | |||
656 | end_subband_chan = end_channel; | ||
657 | |||
658 | /* Move to the next one */ | ||
659 | *country_ie += 3; | ||
660 | *country_ie_len -= 3; | ||
661 | |||
662 | /* | ||
663 | * Padding needs to be dealt with if we processed | ||
664 | * some channels. | ||
665 | */ | ||
666 | if (*country_ie_len == 1) { | ||
667 | *country_ie += 1; | ||
668 | *country_ie_len -= 1; | ||
669 | break; | ||
670 | } | ||
671 | |||
672 | /* If seen, the IE is invalid */ | ||
673 | if (*country_ie_len == 2) | ||
674 | return 0; | ||
675 | } | ||
676 | |||
677 | if (end_subband_chan == orig_end_channel) { | ||
678 | *country_ie = triplets_start; | ||
679 | *country_ie_len = len_at_triplet; | ||
680 | return orig_end_channel; | ||
681 | } | ||
682 | |||
683 | return end_subband_chan; | ||
684 | } | ||
685 | |||
686 | /* | ||
457 | * Converts a country IE to a regulatory domain. A regulatory domain | 687 | * Converts a country IE to a regulatory domain. A regulatory domain |
458 | * structure has a lot of information which the IE doesn't yet have, | 688 | * structure has a lot of information which the IE doesn't yet have, |
459 | * so for the other values we use upper max values as we will intersect | 689 | * so for the other values we use upper max values as we will intersect |
460 | * with our userspace regulatory agent to get lower bounds. | 690 | * with our userspace regulatory agent to get lower bounds. |
461 | */ | 691 | */ |
462 | static struct ieee80211_regdomain *country_ie_2_rd( | 692 | static struct ieee80211_regdomain *country_ie_2_rd( |
693 | enum ieee80211_band band, | ||
463 | u8 *country_ie, | 694 | u8 *country_ie, |
464 | u8 country_ie_len, | 695 | u8 country_ie_len, |
465 | u32 *checksum) | 696 | u32 *checksum) |
@@ -521,10 +752,29 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
521 | continue; | 752 | continue; |
522 | } | 753 | } |
523 | 754 | ||
755 | /* | ||
756 | * APs can add padding to make length divisible | ||
757 | * by two, required by the spec. | ||
758 | */ | ||
759 | if (triplet->chans.first_channel == 0) { | ||
760 | country_ie++; | ||
761 | country_ie_len--; | ||
762 | /* This is expected to be at the very end only */ | ||
763 | if (country_ie_len != 0) | ||
764 | return NULL; | ||
765 | break; | ||
766 | } | ||
767 | |||
768 | if (triplet->chans.num_channels == 0) | ||
769 | return NULL; | ||
770 | |||
771 | if (!chan_in_band(triplet->chans.first_channel, band)) | ||
772 | return NULL; | ||
773 | |||
524 | /* 2 GHz */ | 774 | /* 2 GHz */ |
525 | if (triplet->chans.first_channel <= 14) | 775 | if (band == IEEE80211_BAND_2GHZ) |
526 | end_channel = triplet->chans.first_channel + | 776 | end_channel = triplet->chans.first_channel + |
527 | triplet->chans.num_channels; | 777 | triplet->chans.num_channels - 1; |
528 | else | 778 | else |
529 | /* | 779 | /* |
530 | * 5 GHz -- For example in country IEs if the first | 780 | * 5 GHz -- For example in country IEs if the first |
@@ -539,6 +789,24 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
539 | (4 * (triplet->chans.num_channels - 1)); | 789 | (4 * (triplet->chans.num_channels - 1)); |
540 | 790 | ||
541 | cur_channel = triplet->chans.first_channel; | 791 | cur_channel = triplet->chans.first_channel; |
792 | |||
793 | /* | ||
794 | * Enhancement for APs that send a triplet for every channel | ||
795 | * or for whatever reason sends triplets with multiple channels | ||
796 | * separated when in fact they should be together. | ||
797 | */ | ||
798 | end_channel = max_subband_chan(band, | ||
799 | cur_channel, | ||
800 | end_channel, | ||
801 | triplet->chans.max_power, | ||
802 | &country_ie, | ||
803 | &country_ie_len); | ||
804 | if (!end_channel) | ||
805 | return NULL; | ||
806 | |||
807 | if (!chan_in_band(end_channel, band)) | ||
808 | return NULL; | ||
809 | |||
542 | cur_sub_max_channel = end_channel; | 810 | cur_sub_max_channel = end_channel; |
543 | 811 | ||
544 | /* Basic sanity check */ | 812 | /* Basic sanity check */ |
@@ -569,10 +837,13 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
569 | 837 | ||
570 | last_sub_max_channel = cur_sub_max_channel; | 838 | last_sub_max_channel = cur_sub_max_channel; |
571 | 839 | ||
572 | country_ie += 3; | ||
573 | country_ie_len -= 3; | ||
574 | num_rules++; | 840 | num_rules++; |
575 | 841 | ||
842 | if (country_ie_len >= 3) { | ||
843 | country_ie += 3; | ||
844 | country_ie_len -= 3; | ||
845 | } | ||
846 | |||
576 | /* | 847 | /* |
577 | * Note: this is not a IEEE requirement but | 848 | * Note: this is not a IEEE requirement but |
578 | * simply a memory requirement | 849 | * simply a memory requirement |
@@ -615,6 +886,12 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
615 | continue; | 886 | continue; |
616 | } | 887 | } |
617 | 888 | ||
889 | if (triplet->chans.first_channel == 0) { | ||
890 | country_ie++; | ||
891 | country_ie_len--; | ||
892 | break; | ||
893 | } | ||
894 | |||
618 | reg_rule = &rd->reg_rules[i]; | 895 | reg_rule = &rd->reg_rules[i]; |
619 | freq_range = ®_rule->freq_range; | 896 | freq_range = ®_rule->freq_range; |
620 | power_rule = ®_rule->power_rule; | 897 | power_rule = ®_rule->power_rule; |
@@ -622,13 +899,20 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
622 | reg_rule->flags = flags; | 899 | reg_rule->flags = flags; |
623 | 900 | ||
624 | /* 2 GHz */ | 901 | /* 2 GHz */ |
625 | if (triplet->chans.first_channel <= 14) | 902 | if (band == IEEE80211_BAND_2GHZ) |
626 | end_channel = triplet->chans.first_channel + | 903 | end_channel = triplet->chans.first_channel + |
627 | triplet->chans.num_channels; | 904 | triplet->chans.num_channels -1; |
628 | else | 905 | else |
629 | end_channel = triplet->chans.first_channel + | 906 | end_channel = triplet->chans.first_channel + |
630 | (4 * (triplet->chans.num_channels - 1)); | 907 | (4 * (triplet->chans.num_channels - 1)); |
631 | 908 | ||
909 | end_channel = max_subband_chan(band, | ||
910 | triplet->chans.first_channel, | ||
911 | end_channel, | ||
912 | triplet->chans.max_power, | ||
913 | &country_ie, | ||
914 | &country_ie_len); | ||
915 | |||
632 | /* | 916 | /* |
633 | * The +10 is since the regulatory domain expects | 917 | * The +10 is since the regulatory domain expects |
634 | * the actual band edge, not the center of freq for | 918 | * the actual band edge, not the center of freq for |
@@ -649,12 +933,15 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
649 | */ | 933 | */ |
650 | freq_range->max_bandwidth_khz = MHZ_TO_KHZ(40); | 934 | freq_range->max_bandwidth_khz = MHZ_TO_KHZ(40); |
651 | power_rule->max_antenna_gain = DBI_TO_MBI(100); | 935 | power_rule->max_antenna_gain = DBI_TO_MBI(100); |
652 | power_rule->max_eirp = DBM_TO_MBM(100); | 936 | power_rule->max_eirp = DBM_TO_MBM(triplet->chans.max_power); |
653 | 937 | ||
654 | country_ie += 3; | ||
655 | country_ie_len -= 3; | ||
656 | i++; | 938 | i++; |
657 | 939 | ||
940 | if (country_ie_len >= 3) { | ||
941 | country_ie += 3; | ||
942 | country_ie_len -= 3; | ||
943 | } | ||
944 | |||
658 | BUG_ON(i > NL80211_MAX_SUPP_REG_RULES); | 945 | BUG_ON(i > NL80211_MAX_SUPP_REG_RULES); |
659 | } | 946 | } |
660 | 947 | ||
@@ -950,25 +1237,21 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band, | |||
950 | if (r == -ERANGE && | 1237 | if (r == -ERANGE && |
951 | last_request->initiator == | 1238 | last_request->initiator == |
952 | NL80211_REGDOM_SET_BY_COUNTRY_IE) { | 1239 | NL80211_REGDOM_SET_BY_COUNTRY_IE) { |
953 | #ifdef CONFIG_CFG80211_REG_DEBUG | 1240 | REG_DBG_PRINT("cfg80211: Leaving channel %d MHz " |
954 | printk(KERN_DEBUG "cfg80211: Leaving channel %d MHz " | ||
955 | "intact on %s - no rule found in band on " | 1241 | "intact on %s - no rule found in band on " |
956 | "Country IE\n", | 1242 | "Country IE\n", |
957 | chan->center_freq, wiphy_name(wiphy)); | 1243 | chan->center_freq, wiphy_name(wiphy)); |
958 | #endif | ||
959 | } else { | 1244 | } else { |
960 | /* | 1245 | /* |
961 | * In this case we know the country IE has at least one reg rule | 1246 | * In this case we know the country IE has at least one reg rule |
962 | * for the band so we respect its band definitions | 1247 | * for the band so we respect its band definitions |
963 | */ | 1248 | */ |
964 | #ifdef CONFIG_CFG80211_REG_DEBUG | ||
965 | if (last_request->initiator == | 1249 | if (last_request->initiator == |
966 | NL80211_REGDOM_SET_BY_COUNTRY_IE) | 1250 | NL80211_REGDOM_SET_BY_COUNTRY_IE) |
967 | printk(KERN_DEBUG "cfg80211: Disabling " | 1251 | REG_DBG_PRINT("cfg80211: Disabling " |
968 | "channel %d MHz on %s due to " | 1252 | "channel %d MHz on %s due to " |
969 | "Country IE\n", | 1253 | "Country IE\n", |
970 | chan->center_freq, wiphy_name(wiphy)); | 1254 | chan->center_freq, wiphy_name(wiphy)); |
971 | #endif | ||
972 | flags |= IEEE80211_CHAN_DISABLED; | 1255 | flags |= IEEE80211_CHAN_DISABLED; |
973 | chan->flags = flags; | 1256 | chan->flags = flags; |
974 | } | 1257 | } |
@@ -1342,30 +1625,6 @@ void wiphy_apply_custom_regulatory(struct wiphy *wiphy, | |||
1342 | } | 1625 | } |
1343 | EXPORT_SYMBOL(wiphy_apply_custom_regulatory); | 1626 | EXPORT_SYMBOL(wiphy_apply_custom_regulatory); |
1344 | 1627 | ||
1345 | static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd, | ||
1346 | const struct ieee80211_regdomain *src_regd) | ||
1347 | { | ||
1348 | struct ieee80211_regdomain *regd; | ||
1349 | int size_of_regd = 0; | ||
1350 | unsigned int i; | ||
1351 | |||
1352 | size_of_regd = sizeof(struct ieee80211_regdomain) + | ||
1353 | ((src_regd->n_reg_rules + 1) * sizeof(struct ieee80211_reg_rule)); | ||
1354 | |||
1355 | regd = kzalloc(size_of_regd, GFP_KERNEL); | ||
1356 | if (!regd) | ||
1357 | return -ENOMEM; | ||
1358 | |||
1359 | memcpy(regd, src_regd, sizeof(struct ieee80211_regdomain)); | ||
1360 | |||
1361 | for (i = 0; i < src_regd->n_reg_rules; i++) | ||
1362 | memcpy(®d->reg_rules[i], &src_regd->reg_rules[i], | ||
1363 | sizeof(struct ieee80211_reg_rule)); | ||
1364 | |||
1365 | *dst_regd = regd; | ||
1366 | return 0; | ||
1367 | } | ||
1368 | |||
1369 | /* | 1628 | /* |
1370 | * Return value which can be used by ignore_request() to indicate | 1629 | * Return value which can be used by ignore_request() to indicate |
1371 | * it has been determined we should intersect two regulatory domains | 1630 | * it has been determined we should intersect two regulatory domains |
@@ -1418,8 +1677,6 @@ static int ignore_request(struct wiphy *wiphy, | |||
1418 | return REG_INTERSECT; | 1677 | return REG_INTERSECT; |
1419 | case NL80211_REGDOM_SET_BY_DRIVER: | 1678 | case NL80211_REGDOM_SET_BY_DRIVER: |
1420 | if (last_request->initiator == NL80211_REGDOM_SET_BY_CORE) { | 1679 | if (last_request->initiator == NL80211_REGDOM_SET_BY_CORE) { |
1421 | if (is_old_static_regdom(cfg80211_regdomain)) | ||
1422 | return 0; | ||
1423 | if (regdom_changes(pending_request->alpha2)) | 1680 | if (regdom_changes(pending_request->alpha2)) |
1424 | return 0; | 1681 | return 0; |
1425 | return -EALREADY; | 1682 | return -EALREADY; |
@@ -1456,8 +1713,7 @@ static int ignore_request(struct wiphy *wiphy, | |||
1456 | return -EAGAIN; | 1713 | return -EAGAIN; |
1457 | } | 1714 | } |
1458 | 1715 | ||
1459 | if (!is_old_static_regdom(cfg80211_regdomain) && | 1716 | if (!regdom_changes(pending_request->alpha2)) |
1460 | !regdom_changes(pending_request->alpha2)) | ||
1461 | return -EALREADY; | 1717 | return -EALREADY; |
1462 | 1718 | ||
1463 | return 0; | 1719 | return 0; |
@@ -1758,8 +2014,9 @@ static bool reg_same_country_ie_hint(struct wiphy *wiphy, | |||
1758 | * therefore cannot iterate over the rdev list here. | 2014 | * therefore cannot iterate over the rdev list here. |
1759 | */ | 2015 | */ |
1760 | void regulatory_hint_11d(struct wiphy *wiphy, | 2016 | void regulatory_hint_11d(struct wiphy *wiphy, |
1761 | u8 *country_ie, | 2017 | enum ieee80211_band band, |
1762 | u8 country_ie_len) | 2018 | u8 *country_ie, |
2019 | u8 country_ie_len) | ||
1763 | { | 2020 | { |
1764 | struct ieee80211_regdomain *rd = NULL; | 2021 | struct ieee80211_regdomain *rd = NULL; |
1765 | char alpha2[2]; | 2022 | char alpha2[2]; |
@@ -1805,9 +2062,11 @@ void regulatory_hint_11d(struct wiphy *wiphy, | |||
1805 | wiphy_idx_valid(last_request->wiphy_idx))) | 2062 | wiphy_idx_valid(last_request->wiphy_idx))) |
1806 | goto out; | 2063 | goto out; |
1807 | 2064 | ||
1808 | rd = country_ie_2_rd(country_ie, country_ie_len, &checksum); | 2065 | rd = country_ie_2_rd(band, country_ie, country_ie_len, &checksum); |
1809 | if (!rd) | 2066 | if (!rd) { |
2067 | REG_DBG_PRINT("cfg80211: Ignoring bogus country IE\n"); | ||
1810 | goto out; | 2068 | goto out; |
2069 | } | ||
1811 | 2070 | ||
1812 | /* | 2071 | /* |
1813 | * This will not happen right now but we leave it here for the | 2072 | * This will not happen right now but we leave it here for the |
@@ -1875,13 +2134,12 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy, | |||
1875 | if (!reg_beacon) | 2134 | if (!reg_beacon) |
1876 | return -ENOMEM; | 2135 | return -ENOMEM; |
1877 | 2136 | ||
1878 | #ifdef CONFIG_CFG80211_REG_DEBUG | 2137 | REG_DBG_PRINT("cfg80211: Found new beacon on " |
1879 | printk(KERN_DEBUG "cfg80211: Found new beacon on " | 2138 | "frequency: %d MHz (Ch %d) on %s\n", |
1880 | "frequency: %d MHz (Ch %d) on %s\n", | 2139 | beacon_chan->center_freq, |
1881 | beacon_chan->center_freq, | 2140 | ieee80211_frequency_to_channel(beacon_chan->center_freq), |
1882 | ieee80211_frequency_to_channel(beacon_chan->center_freq), | 2141 | wiphy_name(wiphy)); |
1883 | wiphy_name(wiphy)); | 2142 | |
1884 | #endif | ||
1885 | memcpy(®_beacon->chan, beacon_chan, | 2143 | memcpy(®_beacon->chan, beacon_chan, |
1886 | sizeof(struct ieee80211_channel)); | 2144 | sizeof(struct ieee80211_channel)); |
1887 | 2145 | ||
@@ -2039,8 +2297,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
2039 | * If someone else asked us to change the rd lets only bother | 2297 | * If someone else asked us to change the rd lets only bother |
2040 | * checking if the alpha2 changes if CRDA was already called | 2298 | * checking if the alpha2 changes if CRDA was already called |
2041 | */ | 2299 | */ |
2042 | if (!is_old_static_regdom(cfg80211_regdomain) && | 2300 | if (!regdom_changes(rd->alpha2)) |
2043 | !regdom_changes(rd->alpha2)) | ||
2044 | return -EINVAL; | 2301 | return -EINVAL; |
2045 | } | 2302 | } |
2046 | 2303 | ||
@@ -2239,15 +2496,8 @@ int regulatory_init(void) | |||
2239 | spin_lock_init(®_requests_lock); | 2496 | spin_lock_init(®_requests_lock); |
2240 | spin_lock_init(®_pending_beacons_lock); | 2497 | spin_lock_init(®_pending_beacons_lock); |
2241 | 2498 | ||
2242 | #ifdef CONFIG_WIRELESS_OLD_REGULATORY | ||
2243 | cfg80211_regdomain = static_regdom(ieee80211_regdom); | ||
2244 | |||
2245 | printk(KERN_INFO "cfg80211: Using static regulatory domain info\n"); | ||
2246 | print_regdomain_info(cfg80211_regdomain); | ||
2247 | #else | ||
2248 | cfg80211_regdomain = cfg80211_world_regdom; | 2499 | cfg80211_regdomain = cfg80211_world_regdom; |
2249 | 2500 | ||
2250 | #endif | ||
2251 | /* We always try to get an update for the static regdomain */ | 2501 | /* We always try to get an update for the static regdomain */ |
2252 | err = regulatory_hint_core(cfg80211_regdomain->alpha2); | 2502 | err = regulatory_hint_core(cfg80211_regdomain->alpha2); |
2253 | if (err) { | 2503 | if (err) { |
diff --git a/net/wireless/reg.h b/net/wireless/reg.h index 3362c7c069b2..3018508226ab 100644 --- a/net/wireless/reg.h +++ b/net/wireless/reg.h | |||
@@ -41,14 +41,25 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy, | |||
41 | * regulatory_hint_11d - hints a country IE as a regulatory domain | 41 | * regulatory_hint_11d - hints a country IE as a regulatory domain |
42 | * @wiphy: the wireless device giving the hint (used only for reporting | 42 | * @wiphy: the wireless device giving the hint (used only for reporting |
43 | * conflicts) | 43 | * conflicts) |
44 | * @band: the band on which the country IE was received on. This determines | ||
45 | * the band we'll process the country IE channel triplets for. | ||
44 | * @country_ie: pointer to the country IE | 46 | * @country_ie: pointer to the country IE |
45 | * @country_ie_len: length of the country IE | 47 | * @country_ie_len: length of the country IE |
46 | * | 48 | * |
47 | * We will intersect the rd with the what CRDA tells us should apply | 49 | * We will intersect the rd with the what CRDA tells us should apply |
48 | * for the alpha2 this country IE belongs to, this prevents APs from | 50 | * for the alpha2 this country IE belongs to, this prevents APs from |
49 | * sending us incorrect or outdated information against a country. | 51 | * sending us incorrect or outdated information against a country. |
52 | * | ||
53 | * The AP is expected to provide Country IE channel triplets for the | ||
54 | * band it is on. It is technically possible for APs to send channel | ||
55 | * country IE triplets even for channels outside of the band they are | ||
56 | * in but for that they would have to use the regulatory extension | ||
57 | * in combination with a triplet but this behaviour is currently | ||
58 | * not observed. For this reason if a triplet is seen with channel | ||
59 | * information for a band the BSS is not present in it will be ignored. | ||
50 | */ | 60 | */ |
51 | void regulatory_hint_11d(struct wiphy *wiphy, | 61 | void regulatory_hint_11d(struct wiphy *wiphy, |
62 | enum ieee80211_band band, | ||
52 | u8 *country_ie, | 63 | u8 *country_ie, |
53 | u8 country_ie_len); | 64 | u8 country_ie_len); |
54 | 65 | ||
diff --git a/net/wireless/regdb.h b/net/wireless/regdb.h new file mode 100644 index 000000000000..818222c92513 --- /dev/null +++ b/net/wireless/regdb.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __REGDB_H__ | ||
2 | #define __REGDB_H__ | ||
3 | |||
4 | extern const struct ieee80211_regdomain *reg_regdb[]; | ||
5 | extern int reg_regdb_size; | ||
6 | |||
7 | #endif /* __REGDB_H__ */ | ||
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 0c2cbbebca95..06b0231ee5e3 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -100,8 +100,10 @@ static void bss_release(struct kref *ref) | |||
100 | if (bss->pub.free_priv) | 100 | if (bss->pub.free_priv) |
101 | bss->pub.free_priv(&bss->pub); | 101 | bss->pub.free_priv(&bss->pub); |
102 | 102 | ||
103 | if (bss->ies_allocated) | 103 | if (bss->beacon_ies_allocated) |
104 | kfree(bss->pub.information_elements); | 104 | kfree(bss->pub.beacon_ies); |
105 | if (bss->proberesp_ies_allocated) | ||
106 | kfree(bss->pub.proberesp_ies); | ||
105 | 107 | ||
106 | BUG_ON(atomic_read(&bss->hold)); | 108 | BUG_ON(atomic_read(&bss->hold)); |
107 | 109 | ||
@@ -375,8 +377,7 @@ rb_find_bss(struct cfg80211_registered_device *dev, | |||
375 | 377 | ||
376 | static struct cfg80211_internal_bss * | 378 | static struct cfg80211_internal_bss * |
377 | cfg80211_bss_update(struct cfg80211_registered_device *dev, | 379 | cfg80211_bss_update(struct cfg80211_registered_device *dev, |
378 | struct cfg80211_internal_bss *res, | 380 | struct cfg80211_internal_bss *res) |
379 | bool overwrite) | ||
380 | { | 381 | { |
381 | struct cfg80211_internal_bss *found = NULL; | 382 | struct cfg80211_internal_bss *found = NULL; |
382 | const u8 *meshid, *meshcfg; | 383 | const u8 *meshid, *meshcfg; |
@@ -418,28 +419,64 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev, | |||
418 | found->pub.capability = res->pub.capability; | 419 | found->pub.capability = res->pub.capability; |
419 | found->ts = res->ts; | 420 | found->ts = res->ts; |
420 | 421 | ||
421 | /* overwrite IEs */ | 422 | /* Update IEs */ |
422 | if (overwrite) { | 423 | if (res->pub.proberesp_ies) { |
423 | size_t used = dev->wiphy.bss_priv_size + sizeof(*res); | 424 | size_t used = dev->wiphy.bss_priv_size + sizeof(*res); |
424 | size_t ielen = res->pub.len_information_elements; | 425 | size_t ielen = res->pub.len_proberesp_ies; |
426 | |||
427 | if (found->pub.proberesp_ies && | ||
428 | !found->proberesp_ies_allocated && | ||
429 | ksize(found) >= used + ielen) { | ||
430 | memcpy(found->pub.proberesp_ies, | ||
431 | res->pub.proberesp_ies, ielen); | ||
432 | found->pub.len_proberesp_ies = ielen; | ||
433 | } else { | ||
434 | u8 *ies = found->pub.proberesp_ies; | ||
435 | |||
436 | if (found->proberesp_ies_allocated) | ||
437 | ies = krealloc(ies, ielen, GFP_ATOMIC); | ||
438 | else | ||
439 | ies = kmalloc(ielen, GFP_ATOMIC); | ||
440 | |||
441 | if (ies) { | ||
442 | memcpy(ies, res->pub.proberesp_ies, | ||
443 | ielen); | ||
444 | found->proberesp_ies_allocated = true; | ||
445 | found->pub.proberesp_ies = ies; | ||
446 | found->pub.len_proberesp_ies = ielen; | ||
447 | } | ||
448 | } | ||
425 | 449 | ||
426 | if (!found->ies_allocated && ksize(found) >= used + ielen) { | 450 | /* Override possible earlier Beacon frame IEs */ |
427 | memcpy(found->pub.information_elements, | 451 | found->pub.information_elements = |
428 | res->pub.information_elements, ielen); | 452 | found->pub.proberesp_ies; |
429 | found->pub.len_information_elements = ielen; | 453 | found->pub.len_information_elements = |
454 | found->pub.len_proberesp_ies; | ||
455 | } | ||
456 | if (res->pub.beacon_ies) { | ||
457 | size_t used = dev->wiphy.bss_priv_size + sizeof(*res); | ||
458 | size_t ielen = res->pub.len_beacon_ies; | ||
459 | |||
460 | if (found->pub.beacon_ies && | ||
461 | !found->beacon_ies_allocated && | ||
462 | ksize(found) >= used + ielen) { | ||
463 | memcpy(found->pub.beacon_ies, | ||
464 | res->pub.beacon_ies, ielen); | ||
465 | found->pub.len_beacon_ies = ielen; | ||
430 | } else { | 466 | } else { |
431 | u8 *ies = found->pub.information_elements; | 467 | u8 *ies = found->pub.beacon_ies; |
432 | 468 | ||
433 | if (found->ies_allocated) | 469 | if (found->beacon_ies_allocated) |
434 | ies = krealloc(ies, ielen, GFP_ATOMIC); | 470 | ies = krealloc(ies, ielen, GFP_ATOMIC); |
435 | else | 471 | else |
436 | ies = kmalloc(ielen, GFP_ATOMIC); | 472 | ies = kmalloc(ielen, GFP_ATOMIC); |
437 | 473 | ||
438 | if (ies) { | 474 | if (ies) { |
439 | memcpy(ies, res->pub.information_elements, ielen); | 475 | memcpy(ies, res->pub.beacon_ies, |
440 | found->ies_allocated = true; | 476 | ielen); |
441 | found->pub.information_elements = ies; | 477 | found->beacon_ies_allocated = true; |
442 | found->pub.len_information_elements = ielen; | 478 | found->pub.beacon_ies = ies; |
479 | found->pub.len_beacon_ies = ielen; | ||
443 | } | 480 | } |
444 | } | 481 | } |
445 | } | 482 | } |
@@ -489,14 +526,26 @@ cfg80211_inform_bss(struct wiphy *wiphy, | |||
489 | res->pub.tsf = timestamp; | 526 | res->pub.tsf = timestamp; |
490 | res->pub.beacon_interval = beacon_interval; | 527 | res->pub.beacon_interval = beacon_interval; |
491 | res->pub.capability = capability; | 528 | res->pub.capability = capability; |
492 | /* point to after the private area */ | 529 | /* |
493 | res->pub.information_elements = (u8 *)res + sizeof(*res) + privsz; | 530 | * Since we do not know here whether the IEs are from a Beacon or Probe |
494 | memcpy(res->pub.information_elements, ie, ielen); | 531 | * Response frame, we need to pick one of the options and only use it |
495 | res->pub.len_information_elements = ielen; | 532 | * with the driver that does not provide the full Beacon/Probe Response |
533 | * frame. Use Beacon frame pointer to avoid indicating that this should | ||
534 | * override the information_elements pointer should we have received an | ||
535 | * earlier indication of Probe Response data. | ||
536 | * | ||
537 | * The initial buffer for the IEs is allocated with the BSS entry and | ||
538 | * is located after the private area. | ||
539 | */ | ||
540 | res->pub.beacon_ies = (u8 *)res + sizeof(*res) + privsz; | ||
541 | memcpy(res->pub.beacon_ies, ie, ielen); | ||
542 | res->pub.len_beacon_ies = ielen; | ||
543 | res->pub.information_elements = res->pub.beacon_ies; | ||
544 | res->pub.len_information_elements = res->pub.len_beacon_ies; | ||
496 | 545 | ||
497 | kref_init(&res->ref); | 546 | kref_init(&res->ref); |
498 | 547 | ||
499 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), res, 0); | 548 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), res); |
500 | if (!res) | 549 | if (!res) |
501 | return NULL; | 550 | return NULL; |
502 | 551 | ||
@@ -517,7 +566,6 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
517 | struct cfg80211_internal_bss *res; | 566 | struct cfg80211_internal_bss *res; |
518 | size_t ielen = len - offsetof(struct ieee80211_mgmt, | 567 | size_t ielen = len - offsetof(struct ieee80211_mgmt, |
519 | u.probe_resp.variable); | 568 | u.probe_resp.variable); |
520 | bool overwrite; | ||
521 | size_t privsz = wiphy->bss_priv_size; | 569 | size_t privsz = wiphy->bss_priv_size; |
522 | 570 | ||
523 | if (WARN_ON(wiphy->signal_type == NL80211_BSS_SIGNAL_UNSPEC && | 571 | if (WARN_ON(wiphy->signal_type == NL80211_BSS_SIGNAL_UNSPEC && |
@@ -538,16 +586,28 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
538 | res->pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp); | 586 | res->pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp); |
539 | res->pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); | 587 | res->pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); |
540 | res->pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); | 588 | res->pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); |
541 | /* point to after the private area */ | 589 | /* |
542 | res->pub.information_elements = (u8 *)res + sizeof(*res) + privsz; | 590 | * The initial buffer for the IEs is allocated with the BSS entry and |
543 | memcpy(res->pub.information_elements, mgmt->u.probe_resp.variable, ielen); | 591 | * is located after the private area. |
544 | res->pub.len_information_elements = ielen; | 592 | */ |
593 | if (ieee80211_is_probe_resp(mgmt->frame_control)) { | ||
594 | res->pub.proberesp_ies = (u8 *) res + sizeof(*res) + privsz; | ||
595 | memcpy(res->pub.proberesp_ies, mgmt->u.probe_resp.variable, | ||
596 | ielen); | ||
597 | res->pub.len_proberesp_ies = ielen; | ||
598 | res->pub.information_elements = res->pub.proberesp_ies; | ||
599 | res->pub.len_information_elements = res->pub.len_proberesp_ies; | ||
600 | } else { | ||
601 | res->pub.beacon_ies = (u8 *) res + sizeof(*res) + privsz; | ||
602 | memcpy(res->pub.beacon_ies, mgmt->u.beacon.variable, ielen); | ||
603 | res->pub.len_beacon_ies = ielen; | ||
604 | res->pub.information_elements = res->pub.beacon_ies; | ||
605 | res->pub.len_information_elements = res->pub.len_beacon_ies; | ||
606 | } | ||
545 | 607 | ||
546 | kref_init(&res->ref); | 608 | kref_init(&res->ref); |
547 | 609 | ||
548 | overwrite = ieee80211_is_probe_resp(mgmt->frame_control); | 610 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), res); |
549 | |||
550 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), res, overwrite); | ||
551 | if (!res) | 611 | if (!res) |
552 | return NULL; | 612 | return NULL; |
553 | 613 | ||
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index dc0fc4989d54..745c37e7992e 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -454,6 +454,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
454 | * - and country_ie[1] which is the IE length | 454 | * - and country_ie[1] which is the IE length |
455 | */ | 455 | */ |
456 | regulatory_hint_11d(wdev->wiphy, | 456 | regulatory_hint_11d(wdev->wiphy, |
457 | bss->channel->band, | ||
457 | country_ie + 2, | 458 | country_ie + 2, |
458 | country_ie[1]); | 459 | country_ie[1]); |
459 | } | 460 | } |
diff --git a/net/wireless/util.c b/net/wireless/util.c index 59361fdcb5d0..23557c1d0a9c 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -285,7 +285,7 @@ static int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) | |||
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | int ieee80211_data_to_8023(struct sk_buff *skb, u8 *addr, | 288 | int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, |
289 | enum nl80211_iftype iftype) | 289 | enum nl80211_iftype iftype) |
290 | { | 290 | { |
291 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 291 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
@@ -383,7 +383,7 @@ int ieee80211_data_to_8023(struct sk_buff *skb, u8 *addr, | |||
383 | } | 383 | } |
384 | EXPORT_SYMBOL(ieee80211_data_to_8023); | 384 | EXPORT_SYMBOL(ieee80211_data_to_8023); |
385 | 385 | ||
386 | int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, | 386 | int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, |
387 | enum nl80211_iftype iftype, u8 *bssid, bool qos) | 387 | enum nl80211_iftype iftype, u8 *bssid, bool qos) |
388 | { | 388 | { |
389 | struct ieee80211_hdr hdr; | 389 | struct ieee80211_hdr hdr; |
@@ -497,6 +497,101 @@ int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, | |||
497 | } | 497 | } |
498 | EXPORT_SYMBOL(ieee80211_data_from_8023); | 498 | EXPORT_SYMBOL(ieee80211_data_from_8023); |
499 | 499 | ||
500 | |||
501 | void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, | ||
502 | const u8 *addr, enum nl80211_iftype iftype, | ||
503 | const unsigned int extra_headroom) | ||
504 | { | ||
505 | struct sk_buff *frame = NULL; | ||
506 | u16 ethertype; | ||
507 | u8 *payload; | ||
508 | const struct ethhdr *eth; | ||
509 | int remaining, err; | ||
510 | u8 dst[ETH_ALEN], src[ETH_ALEN]; | ||
511 | |||
512 | err = ieee80211_data_to_8023(skb, addr, iftype); | ||
513 | if (err) | ||
514 | goto out; | ||
515 | |||
516 | /* skip the wrapping header */ | ||
517 | eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr)); | ||
518 | if (!eth) | ||
519 | goto out; | ||
520 | |||
521 | while (skb != frame) { | ||
522 | u8 padding; | ||
523 | __be16 len = eth->h_proto; | ||
524 | unsigned int subframe_len = sizeof(struct ethhdr) + ntohs(len); | ||
525 | |||
526 | remaining = skb->len; | ||
527 | memcpy(dst, eth->h_dest, ETH_ALEN); | ||
528 | memcpy(src, eth->h_source, ETH_ALEN); | ||
529 | |||
530 | padding = (4 - subframe_len) & 0x3; | ||
531 | /* the last MSDU has no padding */ | ||
532 | if (subframe_len > remaining) | ||
533 | goto purge; | ||
534 | |||
535 | skb_pull(skb, sizeof(struct ethhdr)); | ||
536 | /* reuse skb for the last subframe */ | ||
537 | if (remaining <= subframe_len + padding) | ||
538 | frame = skb; | ||
539 | else { | ||
540 | unsigned int hlen = ALIGN(extra_headroom, 4); | ||
541 | /* | ||
542 | * Allocate and reserve two bytes more for payload | ||
543 | * alignment since sizeof(struct ethhdr) is 14. | ||
544 | */ | ||
545 | frame = dev_alloc_skb(hlen + subframe_len + 2); | ||
546 | if (!frame) | ||
547 | goto purge; | ||
548 | |||
549 | skb_reserve(frame, hlen + sizeof(struct ethhdr) + 2); | ||
550 | memcpy(skb_put(frame, ntohs(len)), skb->data, | ||
551 | ntohs(len)); | ||
552 | |||
553 | eth = (struct ethhdr *)skb_pull(skb, ntohs(len) + | ||
554 | padding); | ||
555 | if (!eth) { | ||
556 | dev_kfree_skb(frame); | ||
557 | goto purge; | ||
558 | } | ||
559 | } | ||
560 | |||
561 | skb_reset_network_header(frame); | ||
562 | frame->dev = skb->dev; | ||
563 | frame->priority = skb->priority; | ||
564 | |||
565 | payload = frame->data; | ||
566 | ethertype = (payload[6] << 8) | payload[7]; | ||
567 | |||
568 | if (likely((compare_ether_addr(payload, rfc1042_header) == 0 && | ||
569 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || | ||
570 | compare_ether_addr(payload, | ||
571 | bridge_tunnel_header) == 0)) { | ||
572 | /* remove RFC1042 or Bridge-Tunnel | ||
573 | * encapsulation and replace EtherType */ | ||
574 | skb_pull(frame, 6); | ||
575 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | ||
576 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | ||
577 | } else { | ||
578 | memcpy(skb_push(frame, sizeof(__be16)), &len, | ||
579 | sizeof(__be16)); | ||
580 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | ||
581 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | ||
582 | } | ||
583 | __skb_queue_tail(list, frame); | ||
584 | } | ||
585 | |||
586 | return; | ||
587 | |||
588 | purge: | ||
589 | __skb_queue_purge(list); | ||
590 | out: | ||
591 | dev_kfree_skb(skb); | ||
592 | } | ||
593 | EXPORT_SYMBOL(ieee80211_amsdu_to_8023s); | ||
594 | |||
500 | /* Given a data frame determine the 802.1p/1d tag to use. */ | 595 | /* Given a data frame determine the 802.1p/1d tag to use. */ |
501 | unsigned int cfg80211_classify8021d(struct sk_buff *skb) | 596 | unsigned int cfg80211_classify8021d(struct sk_buff *skb) |
502 | { | 597 | { |
@@ -720,3 +815,36 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
720 | 815 | ||
721 | return err; | 816 | return err; |
722 | } | 817 | } |
818 | |||
819 | u16 cfg80211_calculate_bitrate(struct rate_info *rate) | ||
820 | { | ||
821 | int modulation, streams, bitrate; | ||
822 | |||
823 | if (!(rate->flags & RATE_INFO_FLAGS_MCS)) | ||
824 | return rate->legacy; | ||
825 | |||
826 | /* the formula below does only work for MCS values smaller than 32 */ | ||
827 | if (rate->mcs >= 32) | ||
828 | return 0; | ||
829 | |||
830 | modulation = rate->mcs & 7; | ||
831 | streams = (rate->mcs >> 3) + 1; | ||
832 | |||
833 | bitrate = (rate->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) ? | ||
834 | 13500000 : 6500000; | ||
835 | |||
836 | if (modulation < 4) | ||
837 | bitrate *= (modulation + 1); | ||
838 | else if (modulation == 4) | ||
839 | bitrate *= (modulation + 2); | ||
840 | else | ||
841 | bitrate *= (modulation + 3); | ||
842 | |||
843 | bitrate *= streams; | ||
844 | |||
845 | if (rate->flags & RATE_INFO_FLAGS_SHORT_GI) | ||
846 | bitrate = (bitrate / 9) * 10; | ||
847 | |||
848 | /* do NOT round down here */ | ||
849 | return (bitrate + 50000) / 100000; | ||
850 | } | ||
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 54face3d4424..966d2f01beac 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -1204,21 +1204,47 @@ int cfg80211_wext_siwrate(struct net_device *dev, | |||
1204 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1204 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1205 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 1205 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
1206 | struct cfg80211_bitrate_mask mask; | 1206 | struct cfg80211_bitrate_mask mask; |
1207 | u32 fixed, maxrate; | ||
1208 | struct ieee80211_supported_band *sband; | ||
1209 | int band, ridx; | ||
1210 | bool match = false; | ||
1207 | 1211 | ||
1208 | if (!rdev->ops->set_bitrate_mask) | 1212 | if (!rdev->ops->set_bitrate_mask) |
1209 | return -EOPNOTSUPP; | 1213 | return -EOPNOTSUPP; |
1210 | 1214 | ||
1211 | mask.fixed = 0; | 1215 | memset(&mask, 0, sizeof(mask)); |
1212 | mask.maxrate = 0; | 1216 | fixed = 0; |
1217 | maxrate = 0; | ||
1213 | 1218 | ||
1214 | if (rate->value < 0) { | 1219 | if (rate->value < 0) { |
1215 | /* nothing */ | 1220 | /* nothing */ |
1216 | } else if (rate->fixed) { | 1221 | } else if (rate->fixed) { |
1217 | mask.fixed = rate->value / 1000; /* kbps */ | 1222 | fixed = rate->value / 100000; |
1218 | } else { | 1223 | } else { |
1219 | mask.maxrate = rate->value / 1000; /* kbps */ | 1224 | maxrate = rate->value / 100000; |
1220 | } | 1225 | } |
1221 | 1226 | ||
1227 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
1228 | sband = wdev->wiphy->bands[band]; | ||
1229 | if (sband == NULL) | ||
1230 | continue; | ||
1231 | for (ridx = 0; ridx < sband->n_bitrates; ridx++) { | ||
1232 | struct ieee80211_rate *srate = &sband->bitrates[ridx]; | ||
1233 | if (fixed == srate->bitrate) { | ||
1234 | mask.control[band].legacy = 1 << ridx; | ||
1235 | match = true; | ||
1236 | break; | ||
1237 | } | ||
1238 | if (srate->bitrate <= maxrate) { | ||
1239 | mask.control[band].legacy |= 1 << ridx; | ||
1240 | match = true; | ||
1241 | } | ||
1242 | } | ||
1243 | } | ||
1244 | |||
1245 | if (!match) | ||
1246 | return -EINVAL; | ||
1247 | |||
1222 | return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask); | 1248 | return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask); |
1223 | } | 1249 | } |
1224 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate); | 1250 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate); |
@@ -1257,10 +1283,7 @@ int cfg80211_wext_giwrate(struct net_device *dev, | |||
1257 | if (!(sinfo.filled & STATION_INFO_TX_BITRATE)) | 1283 | if (!(sinfo.filled & STATION_INFO_TX_BITRATE)) |
1258 | return -EOPNOTSUPP; | 1284 | return -EOPNOTSUPP; |
1259 | 1285 | ||
1260 | rate->value = 0; | 1286 | rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); |
1261 | |||
1262 | if (!(sinfo.txrate.flags & RATE_INFO_FLAGS_MCS)) | ||
1263 | rate->value = 100000 * sinfo.txrate.legacy; | ||
1264 | 1287 | ||
1265 | return 0; | 1288 | return 0; |
1266 | } | 1289 | } |
diff --git a/net/wireless/wext-proc.c b/net/wireless/wext-proc.c index 273a7f77c834..8bafa31fa9f8 100644 --- a/net/wireless/wext-proc.c +++ b/net/wireless/wext-proc.c | |||
@@ -140,7 +140,7 @@ static const struct file_operations wireless_seq_fops = { | |||
140 | .release = seq_release_net, | 140 | .release = seq_release_net, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | int wext_proc_init(struct net *net) | 143 | int __net_init wext_proc_init(struct net *net) |
144 | { | 144 | { |
145 | /* Create /proc/net/wireless entry */ | 145 | /* Create /proc/net/wireless entry */ |
146 | if (!proc_net_fops_create(net, "wireless", S_IRUGO, &wireless_seq_fops)) | 146 | if (!proc_net_fops_create(net, "wireless", S_IRUGO, &wireless_seq_fops)) |
@@ -149,7 +149,7 @@ int wext_proc_init(struct net *net) | |||
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
151 | 151 | ||
152 | void wext_proc_exit(struct net *net) | 152 | void __net_exit wext_proc_exit(struct net *net) |
153 | { | 153 | { |
154 | proc_net_remove(net, "wireless"); | 154 | proc_net_remove(net, "wireless"); |
155 | } | 155 | } |
diff --git a/net/xfrm/xfrm_proc.c b/net/xfrm/xfrm_proc.c index fef8db553e8d..c083a4e4e796 100644 --- a/net/xfrm/xfrm_proc.c +++ b/net/xfrm/xfrm_proc.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <net/snmp.h> | 15 | #include <net/snmp.h> |
16 | #include <net/xfrm.h> | 16 | #include <net/xfrm.h> |
17 | 17 | ||
18 | static struct snmp_mib xfrm_mib_list[] = { | 18 | static const struct snmp_mib xfrm_mib_list[] = { |
19 | SNMP_MIB_ITEM("XfrmInError", LINUX_MIB_XFRMINERROR), | 19 | SNMP_MIB_ITEM("XfrmInError", LINUX_MIB_XFRMINERROR), |
20 | SNMP_MIB_ITEM("XfrmInBufferError", LINUX_MIB_XFRMINBUFFERERROR), | 20 | SNMP_MIB_ITEM("XfrmInBufferError", LINUX_MIB_XFRMINBUFFERERROR), |
21 | SNMP_MIB_ITEM("XfrmInHdrError", LINUX_MIB_XFRMINHDRERROR), | 21 | SNMP_MIB_ITEM("XfrmInHdrError", LINUX_MIB_XFRMINHDRERROR), |
diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c index 2e221f2cad7e..2c4d6cdcba49 100644 --- a/net/xfrm/xfrm_sysctl.c +++ b/net/xfrm/xfrm_sysctl.c | |||
@@ -2,7 +2,7 @@ | |||
2 | #include <net/net_namespace.h> | 2 | #include <net/net_namespace.h> |
3 | #include <net/xfrm.h> | 3 | #include <net/xfrm.h> |
4 | 4 | ||
5 | static void __xfrm_sysctl_init(struct net *net) | 5 | static void __net_init __xfrm_sysctl_init(struct net *net) |
6 | { | 6 | { |
7 | net->xfrm.sysctl_aevent_etime = XFRM_AE_ETIME; | 7 | net->xfrm.sysctl_aevent_etime = XFRM_AE_ETIME; |
8 | net->xfrm.sysctl_aevent_rseqth = XFRM_AE_SEQT_SIZE; | 8 | net->xfrm.sysctl_aevent_rseqth = XFRM_AE_SEQT_SIZE; |
@@ -64,7 +64,7 @@ out_kmemdup: | |||
64 | return -ENOMEM; | 64 | return -ENOMEM; |
65 | } | 65 | } |
66 | 66 | ||
67 | void xfrm_sysctl_fini(struct net *net) | 67 | void __net_exit xfrm_sysctl_fini(struct net *net) |
68 | { | 68 | { |
69 | struct ctl_table *table; | 69 | struct ctl_table *table; |
70 | 70 | ||