diff options
Diffstat (limited to 'net/atm')
-rw-r--r-- | net/atm/addr.c | 2 | ||||
-rw-r--r-- | net/atm/atm_misc.c | 40 | ||||
-rw-r--r-- | net/atm/atm_sysfs.c | 27 | ||||
-rw-r--r-- | net/atm/br2684.c | 90 | ||||
-rw-r--r-- | net/atm/clip.c | 86 | ||||
-rw-r--r-- | net/atm/common.c | 386 | ||||
-rw-r--r-- | net/atm/ioctl.c | 196 | ||||
-rw-r--r-- | net/atm/lec.c | 599 | ||||
-rw-r--r-- | net/atm/mpc.c | 540 | ||||
-rw-r--r-- | net/atm/mpoa_caches.c | 190 | ||||
-rw-r--r-- | net/atm/mpoa_proc.c | 89 | ||||
-rw-r--r-- | net/atm/pppoatm.c | 28 | ||||
-rw-r--r-- | net/atm/proc.c | 83 | ||||
-rw-r--r-- | net/atm/pvc.c | 43 | ||||
-rw-r--r-- | net/atm/raw.c | 26 | ||||
-rw-r--r-- | net/atm/resources.c | 418 | ||||
-rw-r--r-- | net/atm/signaling.c | 219 | ||||
-rw-r--r-- | net/atm/svc.c | 258 |
18 files changed, 1677 insertions, 1643 deletions
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..7a96b2376bd7 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) |
@@ -236,7 +238,7 @@ static int atm_dev_seq_show(struct seq_file *seq, void *v) | |||
236 | "Itf Type ESI/\"MAC\"addr " | 238 | "Itf Type ESI/\"MAC\"addr " |
237 | "AAL(TX,err,RX,err,drop) ... [refcnt]\n"; | 239 | "AAL(TX,err,RX,err,drop) ... [refcnt]\n"; |
238 | 240 | ||
239 | if (v == SEQ_START_TOKEN) | 241 | if (v == &atm_devs) |
240 | seq_puts(seq, atm_dev_banner); | 242 | seq_puts(seq, atm_dev_banner); |
241 | else { | 243 | else { |
242 | struct atm_dev *dev = list_entry(v, struct atm_dev, dev_list); | 244 | struct atm_dev *dev = list_entry(v, struct atm_dev, dev_list); |
@@ -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..90082904f20d 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); | 230 | mutex_unlock(&atm_dev_mutex); |
240 | if (!tmp_buf) { | 231 | return -E2BIG; |
241 | mutex_unlock(&atm_dev_mutex); | 232 | } |
242 | return -ENOMEM; | 233 | tmp_buf = kmalloc(size, GFP_ATOMIC); |
243 | } | 234 | if (!tmp_buf) { |
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); | 235 | mutex_unlock(&atm_dev_mutex); |
250 | error = ((copy_to_user(buf, tmp_buf, size)) || | 236 | return -ENOMEM; |
251 | put_user(size, iobuf_len)) | 237 | } |
252 | ? -EFAULT : 0; | 238 | tmp_p = tmp_buf; |
253 | kfree(tmp_buf); | 239 | list_for_each(p, &atm_devs) { |
254 | return error; | 240 | dev = list_entry(p, struct atm_dev, dev_list); |
255 | default: | 241 | *tmp_p++ = dev->number; |
256 | break; | 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; | ||
403 | goto done; | ||
404 | } | ||
405 | /* fall through */ | ||
406 | case ATM_SETCIRANGE: | ||
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; | ||
401 | goto done; | 413 | goto done; |
402 | case ATM_SETLOOP: | 414 | } |
403 | if (__ATM_LM_XTRMT((int) (unsigned long) buf) && | 415 | /* fall through */ |
404 | __ATM_LM_XTLOC((int) (unsigned long) buf) > | 416 | default: |
405 | __ATM_LM_XTRMT((int) (unsigned long) buf)) { | 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,21 +444,10 @@ done: | |||
449 | return error; | 444 | return error; |
450 | } | 445 | } |
451 | 446 | ||
452 | static __inline__ void *dev_get_idx(loff_t left) | ||
453 | { | ||
454 | struct list_head *p; | ||
455 | |||
456 | list_for_each(p, &atm_devs) { | ||
457 | if (!--left) | ||
458 | break; | ||
459 | } | ||
460 | return (p != &atm_devs) ? p : NULL; | ||
461 | } | ||
462 | |||
463 | void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos) | 447 | void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos) |
464 | { | 448 | { |
465 | mutex_lock(&atm_dev_mutex); | 449 | mutex_lock(&atm_dev_mutex); |
466 | return *pos ? dev_get_idx(*pos) : SEQ_START_TOKEN; | 450 | return seq_list_start_head(&atm_devs, *pos); |
467 | } | 451 | } |
468 | 452 | ||
469 | void atm_dev_seq_stop(struct seq_file *seq, void *v) | 453 | void atm_dev_seq_stop(struct seq_file *seq, void *v) |
@@ -473,13 +457,5 @@ void atm_dev_seq_stop(struct seq_file *seq, void *v) | |||
473 | 457 | ||
474 | void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 458 | void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
475 | { | 459 | { |
476 | ++*pos; | 460 | return seq_list_next(v, &atm_devs, pos); |
477 | v = (v == SEQ_START_TOKEN) | ||
478 | ? atm_devs.next : ((struct list_head *)v)->next; | ||
479 | return (v == &atm_devs) ? NULL : v; | ||
480 | } | 461 | } |
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, |