Changeset 34443
- Timestamp:
- 2012-12-02T14:04:04+01:00 (5 years ago)
- Location:
- trunk/target/linux/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/target/linux/generic/patches-3.3/131-atm-fixes.patch
r34410 r34443 1 commit 86768086727a60335b08c34b2966c784029a24cf 1 commit d7d3d8f1ee4435e32bc6c93187798b7e2e3170a9 2 Author: David Woodhouse <David.Woodhouse@intel.com> 3 Date: Thu Nov 29 23:28:30 2012 +0000 4 5 solos-pci: remove list_vccs() debugging function 6 7 No idea why we've gone so long dumping a list of VCCs with vci==0 on 8 every ->open() call... 9 10 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 11 12 commit c93967bfd3a3dffa759a3f28370167bf3cdbc3d0 13 Author: David Woodhouse <David.Woodhouse@intel.com> 14 Date: Thu Nov 29 23:27:20 2012 +0000 15 16 solos-pci: use GFP_KERNEL where possible, not GFP_ATOMIC 17 18 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 19 20 commit ad6999e17ae4f7b99f6d28f425ae970acb115347 21 Author: David Woodhouse <David.Woodhouse@intel.com> 22 Date: Thu Nov 29 23:15:30 2012 +0000 23 24 solos-pci: clean up pclose() function 25 26 - Flush pending TX skbs from the queue rather than waiting for them all to 27 complete (suggested by Krzysztof Mazur <krzysiek@podlesie.net>). 28 - Clear ATM_VF_ADDR only when the PKT_PCLOSE packet has been submitted. 29 - Don't clear ATM_VF_READY at all â vcc_destroy_socket() does that for us. 30 31 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 32 33 commit 2547e97f29d6d69d567947d5ef90b6b4fbcaf565 2 34 Author: David Woodhouse <David.Woodhouse@intel.com> 3 35 Date: Wed Nov 28 10:15:05 2012 +0000 … … 11 43 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 12 44 13 commit a009aa5fde926350f7a7e558a3ac0180e10eb24a45 commit 990b0884a2e9668c08e9daa4d70a54d65329cb6f 14 46 Author: Krzysztof Mazur <krzysiek@podlesie.net> 15 47 Date: Wed Nov 28 09:08:04 2012 +0100 … … 27 59 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 28 60 29 commit ae2169bcb6375fb214cadd0ea50ac54bcf39b0d661 commit f49b6da01f0abebb17f6241473d53018d923f6b0 30 62 Author: Nathan Williams <nathan@traverse.com.au> 31 63 Date: Tue Nov 27 17:34:09 2012 +1100 … … 38 70 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 39 71 40 commit 6227612becaebe2f9f4ad7d0cdf27e298bb5668772 commit a61d37ff4a555886c4ebe31d2c6d893afb6f4d3c 41 73 Author: David Woodhouse <David.Woodhouse@intel.com> 42 74 Date: Wed Nov 28 00:46:45 2012 +0000 … … 53 85 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 54 86 55 commit 44abbb464896dc2270716d25e12fe47e57eeb1d387 commit c52f40629884ddc62c7af445fd5d620fdb466fb2 56 88 Author: David Woodhouse <David.Woodhouse@intel.com> 57 89 Date: Wed Nov 28 00:05:52 2012 +0000 … … 70 102 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 71 103 72 commit c93eeac2ebee497dbc9b6ad39c235ff3061be141 104 commit 35826e7372fe39b7db7930eda0267c82d68d1a4c 105 Author: David Woodhouse <dwmw2@infradead.org> 106 Date: Tue Nov 27 23:28:36 2012 +0000 107 108 br2684: don't send frames on not-ready vcc 109 110 Avoid submitting packets to a vcc which is being closed. Things go badly 111 wrong when the ->pop method gets later called after everything's been 112 torn down. 113 114 Use the ATM socket lock for synchronisation with vcc_destroy_socket(), 115 which clears the ATM_VF_READY bit under the same lock. Otherwise, we 116 could end up submitting a packet to the device driver even after its 117 ->ops->close method has been called. And it could call the vcc's ->pop 118 method after the protocol has been shut down. Which leads to a panic. 119 120 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 121 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 122 123 commit 7f940dde65de4a707f3dd723bb6ce9de90ca1eab 73 124 Author: David Woodhouse <David.Woodhouse@intel.com> 74 125 Date: Wed Nov 28 00:03:11 2012 +0000 75 126 76 atm: Add release_cb() callback to vcc127 atm: add release_cb() callback to vcc 77 128 78 129 The immediate use case for this is that it will allow us to ensure that a … … 87 138 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 88 139 89 commit 9b3e2e224cc4326d8897243b24d778abf9098a8d 90 Author: David Woodhouse <dwmw2@infradead.org> 91 Date: Tue Nov 27 23:28:36 2012 +0000 92 93 br2684: don't send frames on not-ready vcc 94 95 Avoid submitting packets to a vcc which is being closed. Things go badly 96 wrong when the ->pop method gets later called after everything's been 97 torn down. 98 99 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 100 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 101 102 commit 26c7c53318cf56a690ae553104f4a60181734fb5 140 commit def1b2f9083f84d0a77730e537c76429914d17c1 103 141 Author: David Woodhouse <David.Woodhouse@intel.com> 104 142 Date: Tue Nov 27 23:49:24 2012 +0000 105 143 106 solos-pci: Wait for pending TX to complete when releasing vcc144 solos-pci: wait for pending TX to complete when releasing vcc 107 145 108 146 We should no longer be calling the old pop routine for the vcc, after … … 112 150 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 113 151 114 commit 1a3304e89b9ba168340a37926014be11c3ad110e152 commit 397ff16dce53888ec693b3718640be2560204751 115 153 Author: Krzysztof Mazur <krzysiek@podlesie.net> 116 154 Date: Tue Nov 6 23:17:02 2012 +0100 … … 130 168 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 131 169 132 commit 294398bcd0fe26335059a185b59cfb5de1fc4c71170 commit 071d93931a75dc1f82f0baa9959613af81c5a032 133 171 Author: Krzysztof Mazur <krzysiek@podlesie.net> 134 172 Date: Sat Nov 10 23:33:19 2012 +0100 … … 136 174 pppoatm: drop frames to not-ready vcc 137 175 138 Patches "atm: detach protocol before closing vcc" 139 and "pppoatm: allow assign only on a connected socket" fixed 140 common cases where the pppoatm_send() crashes while sending 141 frame to not-ready vcc. However there are still some other cases 142 where we can send frames to vcc, which is flagged as ATM_VF_CLOSE 143 (for instance after vcc_release_async()) or it's opened but not 144 ready yet. 176 The vcc_destroy_socket() closes vcc before the protocol is detached 177 from vcc by calling vcc->push() with NULL skb. This leaves some time 178 window, where the protocol may call vcc->send() on closed vcc 179 and crash. 145 180 146 181 Now pppoatm_send(), like vcc_sendmsg(), checks for vcc flags that … … 278 313 Signed-off-by: David S. Miller <davem@davemloft.net> 279 314 280 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c281 index 9851093..6258961 100644282 315 --- a/drivers/atm/solos-pci.c 283 316 +++ b/drivers/atm/solos-pci.c … … 290 323 uint32_t dma_addr; 291 324 }; 292 @@ -710,7 +711,8 @@ void solos_bh(unsigned long card_arg) 325 @@ -164,7 +165,6 @@ static void fpga_queue(struct solos_card 326 static uint32_t fpga_tx(struct solos_card *); 327 static irqreturn_t solos_irq(int irq, void *dev_id); 328 static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci); 329 -static int list_vccs(int vci); 330 static int atm_init(struct solos_card *, struct device *); 331 static void atm_remove(struct solos_card *); 332 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size); 333 @@ -710,7 +710,8 @@ void solos_bh(unsigned long card_arg) 293 334 dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n", 294 335 le16_to_cpu(header->vpi), le16_to_cpu(header->vci), … … 300 341 atm_charge(vcc, skb->truesize); 301 342 vcc->push(vcc, skb); 302 @@ -881,11 +883,18 @@ static void pclose(struct atm_vcc *vcc) 343 @@ -790,44 +791,6 @@ static struct atm_vcc *find_vcc(struct a 344 return vcc; 345 } 346 347 -static int list_vccs(int vci) 348 -{ 349 - struct hlist_head *head; 350 - struct atm_vcc *vcc; 351 - struct hlist_node *node; 352 - struct sock *s; 353 - int num_found = 0; 354 - int i; 355 - 356 - read_lock(&vcc_sklist_lock); 357 - if (vci != 0){ 358 - head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)]; 359 - sk_for_each(s, node, head) { 360 - num_found ++; 361 - vcc = atm_sk(s); 362 - printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", 363 - vcc->dev->number, 364 - vcc->vpi, 365 - vcc->vci); 366 - } 367 - } else { 368 - for(i = 0; i < VCC_HTABLE_SIZE; i++){ 369 - head = &vcc_hash[i]; 370 - sk_for_each(s, node, head) { 371 - num_found ++; 372 - vcc = atm_sk(s); 373 - printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", 374 - vcc->dev->number, 375 - vcc->vpi, 376 - vcc->vci); 377 - } 378 - } 379 - } 380 - read_unlock(&vcc_sklist_lock); 381 - return num_found; 382 -} 383 - 384 - 385 static int popen(struct atm_vcc *vcc) 386 { 387 struct solos_card *card = vcc->dev->dev_data; 388 @@ -840,7 +803,7 @@ static int popen(struct atm_vcc *vcc) 389 return -EINVAL; 390 } 391 392 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 393 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 394 if (!skb) { 395 if (net_ratelimit()) 396 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n"); 397 @@ -857,8 +820,6 @@ static int popen(struct atm_vcc *vcc) 398 399 set_bit(ATM_VF_ADDR, &vcc->flags); 400 set_bit(ATM_VF_READY, &vcc->flags); 401 - list_vccs(0); 402 - 403 404 return 0; 405 } 406 @@ -866,10 +827,21 @@ static int popen(struct atm_vcc *vcc) 407 static void pclose(struct atm_vcc *vcc) 408 { 409 struct solos_card *card = vcc->dev->dev_data; 410 - struct sk_buff *skb; 411 + unsigned char port = SOLOS_CHAN(vcc->dev); 412 + struct sk_buff *skb, *tmpskb; 413 struct pkt_hdr *header; 414 415 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 416 + /* Remove any yet-to-be-transmitted packets from the pending queue */ 417 + spin_lock(&card->tx_queue_lock); 418 + skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) { 419 + if (SKB_CB(skb)->vcc == vcc) { 420 + skb_unlink(skb, &card->tx_queue[port]); 421 + solos_pop(vcc, skb); 422 + } 423 + } 424 + spin_unlock(&card->tx_queue_lock); 425 + 426 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 427 if (!skb) { 428 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n"); 429 return; 430 @@ -881,15 +853,21 @@ static void pclose(struct atm_vcc *vcc) 303 431 header->vci = cpu_to_le16(vcc->vci); 304 432 header->type = cpu_to_le16(PKT_PCLOSE); 305 433 434 - fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); 306 435 + init_completion(&SKB_CB(skb)->c); 307 + 308 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); 309 310 clear_bit(ATM_VF_ADDR, &vcc->flags); 311 clear_bit(ATM_VF_READY, &vcc->flags); 312 313 + if (!wait_for_completion_timeout(&SKB_CB(skb)->c, 314 + msecs_to_jiffies(5000))) 436 437 - clear_bit(ATM_VF_ADDR, &vcc->flags); 438 - clear_bit(ATM_VF_READY, &vcc->flags); 439 + fpga_queue(card, port, skb, NULL); 440 + 441 + if (!wait_for_completion_timeout(&SKB_CB(skb)->c, 5 * HZ)) 315 442 + dev_warn(&card->dev->dev, "Timeout waiting for VCC close on port %d\n", 316 + SOLOS_CHAN(vcc->dev));317 + 443 + port); 444 318 445 /* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the 319 446 tasklet has finished processing any incoming packets (and, more to 320 447 the point, using the vcc pointer). */ 321 @@ -1011,9 +1020,12 @@ static uint32_t fpga_tx(struct solos_card *card) 448 tasklet_unlock_wait(&card->tlet); 449 + 450 + clear_bit(ATM_VF_ADDR, &vcc->flags); 451 + 452 return; 453 } 454 455 @@ -1010,9 +988,12 @@ static uint32_t fpga_tx(struct solos_car 322 456 if (vcc) { 323 457 atomic_inc(&vcc->stats->tx); … … 334 468 } 335 469 /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */ 336 @@ -1345,6 +1357,8 @@ static struct pci_driver fpga_driver = { 470 @@ -1246,7 +1227,7 @@ static int atm_init(struct solos_card *c 471 card->atmdev[i]->phy_data = (void *)(unsigned long)i; 472 atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND); 473 474 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 475 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 476 if (!skb) { 477 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n"); 478 continue; 479 @@ -1343,6 +1324,8 @@ static struct pci_driver fpga_driver = { 337 480 338 481 static int __init solos_pci_init(void) … … 343 486 return pci_register_driver(&fpga_driver); 344 487 } 345 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h346 index 22ef21c..c1da539 100644347 488 --- a/include/linux/atmdev.h 348 489 +++ b/include/linux/atmdev.h 349 @@ - 99,6 +99,7 @@ struct atm_vcc {490 @@ -307,6 +307,7 @@ struct atm_vcc { 350 491 struct atm_dev *dev; /* device back pointer */ 351 492 struct atm_qos qos; /* QOS */ … … 355 496 void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */ 356 497 int (*push_oam)(struct atm_vcc *vcc,void *cell); 357 @@ - 106,6 +107,7 @@ struct atm_vcc {498 @@ -314,6 +315,7 @@ struct atm_vcc { 358 499 void *dev_data; /* per-device data */ 359 500 void *proto_data; /* per-protocol data */ … … 363 504 short itf; /* interface number */ 364 505 struct sockaddr_atmsvc local; 365 diff --git a/net/atm/br2684.c b/net/atm/br2684.c366 index 4819d315..a4ee4ad 100644367 506 --- a/net/atm/br2684.c 368 507 +++ b/net/atm/br2684.c 369 @@ -68,12 +68,1 4@@ struct br2684_vcc {508 @@ -68,12 +68,15 @@ struct br2684_vcc { 370 509 /* keep old push, pop functions for chaining */ 371 510 void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb); 372 511 void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); 512 + void (*old_release_cb)(struct atm_vcc *vcc); 373 513 + struct module *old_owner; 374 514 enum br2684_encaps encaps; … … 382 522 383 523 struct br2684_dev { 384 @@ -181,18 +18 3,15 @@ static struct notifier_block atm_dev_notifier = {524 @@ -181,18 +184,15 @@ static struct notifier_block atm_dev_not 385 525 static void br2684_pop(struct atm_vcc *vcc, struct sk_buff *skb) 386 526 { … … 406 546 * Send a packet out a particular vcc. Not to useful right now, but paves 407 547 * the way for multiple vcc's per itf. Returns true if we can send, 408 @@ -251,21 +250,30 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct net_device *dev, 409 skb_debug(skb); 410 411 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; 412 + if (test_bit(ATM_VF_RELEASED, &atmvcc->flags) || 413 + test_bit(ATM_VF_CLOSE, &atmvcc->flags) || 414 + !test_bit(ATM_VF_READY, &atmvcc->flags)) { 415 + dev_kfree_skb(skb); 416 + return 0; 417 + } 418 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); 419 atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); 548 @@ -256,16 +256,30 @@ static int br2684_xmit_vcc(struct sk_buf 420 549 ATM_SKB(skb)->atm_options = atmvcc->atm_options; 421 550 dev->stats.tx_packets++; … … 440 569 + the stats are updated correctly */ 441 570 + return !atmvcc->send(atmvcc, skb); 571 +} 572 + 573 +static void br2684_release_cb(struct atm_vcc *atmvcc) 574 +{ 575 + struct br2684_vcc *brvcc = BR2684_VCC(atmvcc); 576 + 577 + if (atomic_read(&brvcc->qspace) > 0) 578 + netif_wake_queue(brvcc->device); 579 + 580 + if (brvcc->old_release_cb) 581 + brvcc->old_release_cb(atmvcc); 442 582 } 443 583 444 584 static inline struct br2684_vcc *pick_outgoing_vcc(const struct sk_buff *skb, 445 @@ -378,8 +386,8 @@ static void br2684_close_vcc(struct br2684_vcc *brvcc) 585 @@ -279,6 +293,8 @@ static netdev_tx_t br2684_start_xmit(str 586 { 587 struct br2684_dev *brdev = BRPRIV(dev); 588 struct br2684_vcc *brvcc; 589 + struct atm_vcc *atmvcc; 590 + netdev_tx_t ret = NETDEV_TX_OK; 591 592 pr_debug("skb_dst(skb)=%p\n", skb_dst(skb)); 593 read_lock(&devs_lock); 594 @@ -289,9 +305,26 @@ static netdev_tx_t br2684_start_xmit(str 595 dev->stats.tx_carrier_errors++; 596 /* netif_stop_queue(dev); */ 597 dev_kfree_skb(skb); 598 - read_unlock(&devs_lock); 599 - return NETDEV_TX_OK; 600 + goto out_devs; 601 } 602 + atmvcc = brvcc->atmvcc; 603 + 604 + bh_lock_sock(sk_atm(atmvcc)); 605 + 606 + if (test_bit(ATM_VF_RELEASED, &atmvcc->flags) || 607 + test_bit(ATM_VF_CLOSE, &atmvcc->flags) || 608 + !test_bit(ATM_VF_READY, &atmvcc->flags)) { 609 + dev->stats.tx_dropped++; 610 + dev_kfree_skb(skb); 611 + goto out; 612 + } 613 + 614 + if (sock_owned_by_user(sk_atm(atmvcc))) { 615 + netif_stop_queue(brvcc->device); 616 + ret = NETDEV_TX_BUSY; 617 + goto out; 618 + } 619 + 620 if (!br2684_xmit_vcc(skb, dev, brvcc)) { 621 /* 622 * We should probably use netif_*_queue() here, but that 623 @@ -303,8 +336,11 @@ static netdev_tx_t br2684_start_xmit(str 624 dev->stats.tx_errors++; 625 dev->stats.tx_fifo_errors++; 626 } 627 + out: 628 + bh_unlock_sock(sk_atm(atmvcc)); 629 + out_devs: 630 read_unlock(&devs_lock); 631 - return NETDEV_TX_OK; 632 + return ret; 633 } 634 635 /* 636 @@ -377,9 +413,10 @@ static void br2684_close_vcc(struct br26 637 list_del(&brvcc->brvccs); 446 638 write_unlock_irq(&devs_lock); 447 639 brvcc->atmvcc->user_back = NULL; /* what about vcc->recvq ??? */ 640 + brvcc->atmvcc->release_cb = brvcc->old_release_cb; 448 641 brvcc->old_push(brvcc->atmvcc, NULL); /* pass on the bad news */ 449 642 + module_put(brvcc->old_owner); … … 453 646 454 647 /* when AAL5 PDU comes in: */ 455 @@ -504,6 +5 12,13 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)648 @@ -504,6 +541,13 @@ static int br2684_regvcc(struct atm_vcc 456 649 brvcc = kzalloc(sizeof(struct br2684_vcc), GFP_KERNEL); 457 650 if (!brvcc) … … 467 660 net_dev = br2684_find_dev(&be.ifspec); 468 661 if (net_dev == NULL) { 469 @@ -546,9 +5 61,11 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)662 @@ -546,9 +590,13 @@ static int br2684_regvcc(struct atm_vcc 470 663 brvcc->encaps = (enum br2684_encaps)be.encaps; 471 664 brvcc->old_push = atmvcc->push; 472 665 brvcc->old_pop = atmvcc->pop; 666 + brvcc->old_release_cb = atmvcc->release_cb; 473 667 + brvcc->old_owner = atmvcc->owner; 474 668 barrier(); 475 669 atmvcc->push = br2684_push; 476 670 atmvcc->pop = br2684_pop; 671 + atmvcc->release_cb = br2684_release_cb; 477 672 + atmvcc->owner = THIS_MODULE; 478 673 479 674 /* initialize netdev carrier state */ 480 675 if (atmvcc->dev->signal == ATM_PHY_SIG_LOST) 481 @@ -687,10 +7 04,13 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,676 @@ -687,10 +735,13 @@ static int br2684_ioctl(struct socket *s 482 677 return -ENOIOCTLCMD; 483 678 if (!capable(CAP_NET_ADMIN)) … … 495 690 case BR2684_SETFILT: 496 691 if (atmvcc->push != br2684_push) 497 diff --git a/net/atm/common.c b/net/atm/common.c498 index 0c0ad93..806fc0a 100644499 692 --- a/net/atm/common.c 500 693 +++ b/net/atm/common.c 501 @@ -126,10 +126,19 @@ static void vcc_write_space(struct sock *sk)694 @@ -126,10 +126,19 @@ static void vcc_write_space(struct sock 502 695 rcu_read_unlock(); 503 696 } … … 519 712 520 713 int vcc_create(struct net *net, struct socket *sock, int protocol, int family) 521 @@ -156,7 +165,9 @@ int vcc_create(struct net *net, struct s ocket *sock, int protocol, int family)714 @@ -156,7 +165,9 @@ int vcc_create(struct net *net, struct s 522 715 atomic_set(&sk->sk_rmem_alloc, 0); 523 716 vcc->push = NULL; … … 529 722 vcc->atm_options = vcc->aal_options = 0; 530 723 sk->sk_destruct = vcc_sock_destruct; 531 @@ -175,6 +186,7 @@ static void vcc_destroy_socket(struct so ck *sk)724 @@ -175,6 +186,7 @@ static void vcc_destroy_socket(struct so 532 725 vcc->dev->ops->close(vcc); 533 726 if (vcc->push) … … 537 730 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 538 731 atm_return(vcc, skb->truesize); 539 diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c540 index 226dca9..8c93267 100644541 732 --- a/net/atm/pppoatm.c 542 733 +++ b/net/atm/pppoatm.c … … 550 741 enum pppoatm_encaps encaps; 551 742 atomic_t inflight; 552 @@ -107,6 +109,24 @@ static void pppoatm_wakeup_sender(unsign ed long arg)743 @@ -107,6 +109,24 @@ static void pppoatm_wakeup_sender(unsign 553 744 ppp_output_wakeup((struct ppp_channel *) arg); 554 745 } … … 575 766 * This gets called every time the ATM card has finished sending our 576 767 * skb. The ->old_pop will take care up normal atm flow control, 577 @@ -151,12 +171,11 @@ static void pppoatm_unassign_vcc(struct atm_vcc *atmvcc)768 @@ -151,12 +171,11 @@ static void pppoatm_unassign_vcc(struct 578 769 pvcc = atmvcc_to_pvcc(atmvcc); 579 770 atmvcc->push = pvcc->old_push; … … 589 780 590 781 /* Called when an AAL5 PDU comes in */ 591 @@ -165,9 +184,13 @@ static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb)782 @@ -165,9 +184,13 @@ static void pppoatm_push(struct atm_vcc 592 783 struct pppoatm_vcc *pvcc = atmvcc_to_pvcc(atmvcc); 593 784 pr_debug("\n"); … … 612 803 /* 613 804 * It's not clear that we need to bother with using atm_may_send() 614 @@ -269,10 +292,33 @@ static inline int pppoatm_may_send(struc t pppoatm_vcc *pvcc, int size)805 @@ -269,10 +292,33 @@ static inline int pppoatm_may_send(struc 615 806 static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) 616 807 { … … 646 837 case e_llc: 647 838 if (skb_headroom(skb) < LLC_LEN) { 648 @@ -285,8 +331,10 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)839 @@ -285,8 +331,10 @@ static int pppoatm_send(struct ppp_chann 649 840 } 650 consume_skb(skb);841 kfree_skb(skb); 651 842 skb = n; 652 843 - if (skb == NULL) … … 658 849 goto nospace; 659 850 memcpy(skb_push(skb, LLC_LEN), pppllc, LLC_LEN); 660 @@ -296,6 +344,7 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)851 @@ -296,6 +344,7 @@ static int pppoatm_send(struct ppp_chann 661 852 goto nospace; 662 853 break; … … 666 857 kfree_skb(skb); 667 858 return 1; 668 @@ -305,9 +354,12 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)859 @@ -305,9 +354,12 @@ static int pppoatm_send(struct ppp_chann 669 860 ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options; 670 861 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", … … 680 871 * We don't have space to send this SKB now, but we might have 681 872 * already applied SC_COMP_PROT compression, so may need to undo 682 @@ -362,6 +414,8 @@ static int pppoatm_assign_vcc(struct atm _vcc *atmvcc, void __user *arg)873 @@ -362,6 +414,8 @@ static int pppoatm_assign_vcc(struct atm 683 874 atomic_set(&pvcc->inflight, NONE_INFLIGHT); 684 875 pvcc->old_push = atmvcc->push; … … 689 880 pvcc->chan.private = pvcc; 690 881 pvcc->chan.ops = &pppoatm_ops; 691 @@ -377,7 +431,9 @@ static int pppoatm_assign_vcc(struct atm _vcc *atmvcc, void __user *arg)882 @@ -377,7 +431,9 @@ static int pppoatm_assign_vcc(struct atm 692 883 atmvcc->user_back = pvcc; 693 884 atmvcc->push = pppoatm_push; … … 699 890 /* re-process everything received between connection setup and 700 891 backend setup */ 701 @@ -406,6 +462,8 @@ static int pppoatm_ioctl(struct socket * sock, unsigned int cmd,892 @@ -406,6 +462,8 @@ static int pppoatm_ioctl(struct socket * 702 893 return -ENOIOCTLCMD; 703 894 if (!capable(CAP_NET_ADMIN)) -
trunk/target/linux/generic/patches-3.6/131-atm-fixes.patch
r34410 r34443 1 commit 86768086727a60335b08c34b2966c784029a24cf 1 commit d7d3d8f1ee4435e32bc6c93187798b7e2e3170a9 2 Author: David Woodhouse <David.Woodhouse@intel.com> 3 Date: Thu Nov 29 23:28:30 2012 +0000 4 5 solos-pci: remove list_vccs() debugging function 6 7 No idea why we've gone so long dumping a list of VCCs with vci==0 on 8 every ->open() call... 9 10 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 11 12 commit c93967bfd3a3dffa759a3f28370167bf3cdbc3d0 13 Author: David Woodhouse <David.Woodhouse@intel.com> 14 Date: Thu Nov 29 23:27:20 2012 +0000 15 16 solos-pci: use GFP_KERNEL where possible, not GFP_ATOMIC 17 18 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 19 20 commit ad6999e17ae4f7b99f6d28f425ae970acb115347 21 Author: David Woodhouse <David.Woodhouse@intel.com> 22 Date: Thu Nov 29 23:15:30 2012 +0000 23 24 solos-pci: clean up pclose() function 25 26 - Flush pending TX skbs from the queue rather than waiting for them all to 27 complete (suggested by Krzysztof Mazur <krzysiek@podlesie.net>). 28 - Clear ATM_VF_ADDR only when the PKT_PCLOSE packet has been submitted. 29 - Don't clear ATM_VF_READY at all â vcc_destroy_socket() does that for us. 30 31 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 32 33 commit 2547e97f29d6d69d567947d5ef90b6b4fbcaf565 2 34 Author: David Woodhouse <David.Woodhouse@intel.com> 3 35 Date: Wed Nov 28 10:15:05 2012 +0000 … … 11 43 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 12 44 13 commit a009aa5fde926350f7a7e558a3ac0180e10eb24a45 commit 990b0884a2e9668c08e9daa4d70a54d65329cb6f 14 46 Author: Krzysztof Mazur <krzysiek@podlesie.net> 15 47 Date: Wed Nov 28 09:08:04 2012 +0100 … … 27 59 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 28 60 29 commit ae2169bcb6375fb214cadd0ea50ac54bcf39b0d661 commit f49b6da01f0abebb17f6241473d53018d923f6b0 30 62 Author: Nathan Williams <nathan@traverse.com.au> 31 63 Date: Tue Nov 27 17:34:09 2012 +1100 … … 38 70 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 39 71 40 commit 6227612becaebe2f9f4ad7d0cdf27e298bb5668772 commit a61d37ff4a555886c4ebe31d2c6d893afb6f4d3c 41 73 Author: David Woodhouse <David.Woodhouse@intel.com> 42 74 Date: Wed Nov 28 00:46:45 2012 +0000 … … 53 85 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 54 86 55 commit 44abbb464896dc2270716d25e12fe47e57eeb1d387 commit c52f40629884ddc62c7af445fd5d620fdb466fb2 56 88 Author: David Woodhouse <David.Woodhouse@intel.com> 57 89 Date: Wed Nov 28 00:05:52 2012 +0000 … … 70 102 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 71 103 72 commit c93eeac2ebee497dbc9b6ad39c235ff3061be141 104 commit 35826e7372fe39b7db7930eda0267c82d68d1a4c 105 Author: David Woodhouse <dwmw2@infradead.org> 106 Date: Tue Nov 27 23:28:36 2012 +0000 107 108 br2684: don't send frames on not-ready vcc 109 110 Avoid submitting packets to a vcc which is being closed. Things go badly 111 wrong when the ->pop method gets later called after everything's been 112 torn down. 113 114 Use the ATM socket lock for synchronisation with vcc_destroy_socket(), 115 which clears the ATM_VF_READY bit under the same lock. Otherwise, we 116 could end up submitting a packet to the device driver even after its 117 ->ops->close method has been called. And it could call the vcc's ->pop 118 method after the protocol has been shut down. Which leads to a panic. 119 120 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 121 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 122 123 commit 7f940dde65de4a707f3dd723bb6ce9de90ca1eab 73 124 Author: David Woodhouse <David.Woodhouse@intel.com> 74 125 Date: Wed Nov 28 00:03:11 2012 +0000 75 126 76 atm: Add release_cb() callback to vcc127 atm: add release_cb() callback to vcc 77 128 78 129 The immediate use case for this is that it will allow us to ensure that a … … 87 138 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 88 139 89 commit 9b3e2e224cc4326d8897243b24d778abf9098a8d 90 Author: David Woodhouse <dwmw2@infradead.org> 91 Date: Tue Nov 27 23:28:36 2012 +0000 92 93 br2684: don't send frames on not-ready vcc 94 95 Avoid submitting packets to a vcc which is being closed. Things go badly 96 wrong when the ->pop method gets later called after everything's been 97 torn down. 98 99 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 100 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 101 102 commit 26c7c53318cf56a690ae553104f4a60181734fb5 140 commit def1b2f9083f84d0a77730e537c76429914d17c1 103 141 Author: David Woodhouse <David.Woodhouse@intel.com> 104 142 Date: Tue Nov 27 23:49:24 2012 +0000 105 143 106 solos-pci: Wait for pending TX to complete when releasing vcc144 solos-pci: wait for pending TX to complete when releasing vcc 107 145 108 146 We should no longer be calling the old pop routine for the vcc, after … … 112 150 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 113 151 114 commit 1a3304e89b9ba168340a37926014be11c3ad110e152 commit 397ff16dce53888ec693b3718640be2560204751 115 153 Author: Krzysztof Mazur <krzysiek@podlesie.net> 116 154 Date: Tue Nov 6 23:17:02 2012 +0100 … … 130 168 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 131 169 132 commit 294398bcd0fe26335059a185b59cfb5de1fc4c71170 commit 071d93931a75dc1f82f0baa9959613af81c5a032 133 171 Author: Krzysztof Mazur <krzysiek@podlesie.net> 134 172 Date: Sat Nov 10 23:33:19 2012 +0100 … … 136 174 pppoatm: drop frames to not-ready vcc 137 175 138 Patches "atm: detach protocol before closing vcc" 139 and "pppoatm: allow assign only on a connected socket" fixed 140 common cases where the pppoatm_send() crashes while sending 141 frame to not-ready vcc. However there are still some other cases 142 where we can send frames to vcc, which is flagged as ATM_VF_CLOSE 143 (for instance after vcc_release_async()) or it's opened but not 144 ready yet. 176 The vcc_destroy_socket() closes vcc before the protocol is detached 177 from vcc by calling vcc->push() with NULL skb. This leaves some time 178 window, where the protocol may call vcc->send() on closed vcc 179 and crash. 145 180 146 181 Now pppoatm_send(), like vcc_sendmsg(), checks for vcc flags that … … 278 313 Signed-off-by: David S. Miller <davem@davemloft.net> 279 314 280 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c281 index 9851093..6258961 100644282 315 --- a/drivers/atm/solos-pci.c 283 316 +++ b/drivers/atm/solos-pci.c … … 290 323 uint32_t dma_addr; 291 324 }; 292 @@ -710,7 +711,8 @@ void solos_bh(unsigned long card_arg) 325 @@ -164,7 +165,6 @@ static void fpga_queue(struct solos_card 326 static uint32_t fpga_tx(struct solos_card *); 327 static irqreturn_t solos_irq(int irq, void *dev_id); 328 static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci); 329 -static int list_vccs(int vci); 330 static int atm_init(struct solos_card *, struct device *); 331 static void atm_remove(struct solos_card *); 332 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size); 333 @@ -710,7 +710,8 @@ void solos_bh(unsigned long card_arg) 293 334 dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n", 294 335 le16_to_cpu(header->vpi), le16_to_cpu(header->vci), … … 300 341 atm_charge(vcc, skb->truesize); 301 342 vcc->push(vcc, skb); 302 @@ -881,11 +883,18 @@ static void pclose(struct atm_vcc *vcc) 343 @@ -790,44 +791,6 @@ static struct atm_vcc *find_vcc(struct a 344 return vcc; 345 } 346 347 -static int list_vccs(int vci) 348 -{ 349 - struct hlist_head *head; 350 - struct atm_vcc *vcc; 351 - struct hlist_node *node; 352 - struct sock *s; 353 - int num_found = 0; 354 - int i; 355 - 356 - read_lock(&vcc_sklist_lock); 357 - if (vci != 0){ 358 - head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)]; 359 - sk_for_each(s, node, head) { 360 - num_found ++; 361 - vcc = atm_sk(s); 362 - printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", 363 - vcc->dev->number, 364 - vcc->vpi, 365 - vcc->vci); 366 - } 367 - } else { 368 - for(i = 0; i < VCC_HTABLE_SIZE; i++){ 369 - head = &vcc_hash[i]; 370 - sk_for_each(s, node, head) { 371 - num_found ++; 372 - vcc = atm_sk(s); 373 - printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", 374 - vcc->dev->number, 375 - vcc->vpi, 376 - vcc->vci); 377 - } 378 - } 379 - } 380 - read_unlock(&vcc_sklist_lock); 381 - return num_found; 382 -} 383 - 384 - 385 static int popen(struct atm_vcc *vcc) 386 { 387 struct solos_card *card = vcc->dev->dev_data; 388 @@ -840,7 +803,7 @@ static int popen(struct atm_vcc *vcc) 389 return -EINVAL; 390 } 391 392 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 393 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 394 if (!skb) { 395 if (net_ratelimit()) 396 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n"); 397 @@ -857,8 +820,6 @@ static int popen(struct atm_vcc *vcc) 398 399 set_bit(ATM_VF_ADDR, &vcc->flags); 400 set_bit(ATM_VF_READY, &vcc->flags); 401 - list_vccs(0); 402 - 403 404 return 0; 405 } 406 @@ -866,10 +827,21 @@ static int popen(struct atm_vcc *vcc) 407 static void pclose(struct atm_vcc *vcc) 408 { 409 struct solos_card *card = vcc->dev->dev_data; 410 - struct sk_buff *skb; 411 + unsigned char port = SOLOS_CHAN(vcc->dev); 412 + struct sk_buff *skb, *tmpskb; 413 struct pkt_hdr *header; 414 415 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 416 + /* Remove any yet-to-be-transmitted packets from the pending queue */ 417 + spin_lock(&card->tx_queue_lock); 418 + skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) { 419 + if (SKB_CB(skb)->vcc == vcc) { 420 + skb_unlink(skb, &card->tx_queue[port]); 421 + solos_pop(vcc, skb); 422 + } 423 + } 424 + spin_unlock(&card->tx_queue_lock); 425 + 426 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 427 if (!skb) { 428 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n"); 429 return; 430 @@ -881,15 +853,21 @@ static void pclose(struct atm_vcc *vcc) 303 431 header->vci = cpu_to_le16(vcc->vci); 304 432 header->type = cpu_to_le16(PKT_PCLOSE); 305 433 434 - fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); 306 435 + init_completion(&SKB_CB(skb)->c); 307 + 308 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); 309 310 clear_bit(ATM_VF_ADDR, &vcc->flags); 311 clear_bit(ATM_VF_READY, &vcc->flags); 312 313 + if (!wait_for_completion_timeout(&SKB_CB(skb)->c, 314 + msecs_to_jiffies(5000))) 436 437 - clear_bit(ATM_VF_ADDR, &vcc->flags); 438 - clear_bit(ATM_VF_READY, &vcc->flags); 439 + fpga_queue(card, port, skb, NULL); 440 + 441 + if (!wait_for_completion_timeout(&SKB_CB(skb)->c, 5 * HZ)) 315 442 + dev_warn(&card->dev->dev, "Timeout waiting for VCC close on port %d\n", 316 + SOLOS_CHAN(vcc->dev));317 + 443 + port); 444 318 445 /* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the 319 446 tasklet has finished processing any incoming packets (and, more to 320 447 the point, using the vcc pointer). */ 321 @@ -1011,9 +1020,12 @@ static uint32_t fpga_tx(struct solos_card *card) 448 tasklet_unlock_wait(&card->tlet); 449 + 450 + clear_bit(ATM_VF_ADDR, &vcc->flags); 451 + 452 return; 453 } 454 455 @@ -1011,9 +989,12 @@ static uint32_t fpga_tx(struct solos_car 322 456 if (vcc) { 323 457 atomic_inc(&vcc->stats->tx); … … 334 468 } 335 469 /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */ 336 @@ -1345,6 +1357,8 @@ static struct pci_driver fpga_driver = { 470 @@ -1248,7 +1229,7 @@ static int atm_init(struct solos_card *c 471 card->atmdev[i]->phy_data = (void *)(unsigned long)i; 472 atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND); 473 474 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 475 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 476 if (!skb) { 477 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n"); 478 continue; 479 @@ -1345,6 +1326,8 @@ static struct pci_driver fpga_driver = { 337 480 338 481 static int __init solos_pci_init(void) … … 343 486 return pci_register_driver(&fpga_driver); 344 487 } 345 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h346 index 22ef21c..c1da539 100644347 488 --- a/include/linux/atmdev.h 348 489 +++ b/include/linux/atmdev.h 349 @@ - 99,6 +99,7 @@ struct atm_vcc {490 @@ -308,6 +308,7 @@ struct atm_vcc { 350 491 struct atm_dev *dev; /* device back pointer */ 351 492 struct atm_qos qos; /* QOS */ … … 355 496 void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */ 356 497 int (*push_oam)(struct atm_vcc *vcc,void *cell); 357 @@ - 106,6 +107,7 @@ struct atm_vcc {498 @@ -315,6 +316,7 @@ struct atm_vcc { 358 499 void *dev_data; /* per-device data */ 359 500 void *proto_data; /* per-protocol data */ … … 363 504 short itf; /* interface number */ 364 505 struct sockaddr_atmsvc local; 365 diff --git a/net/atm/br2684.c b/net/atm/br2684.c366 index 4819d315..a4ee4ad 100644367 506 --- a/net/atm/br2684.c 368 507 +++ b/net/atm/br2684.c 369 @@ -68,12 +68,1 4@@ struct br2684_vcc {508 @@ -68,12 +68,15 @@ struct br2684_vcc { 370 509 /* keep old push, pop functions for chaining */ 371 510 void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb); 372 511 void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); 512 + void (*old_release_cb)(struct atm_vcc *vcc); 373 513 + struct module *old_owner; 374 514 enum br2684_encaps encaps; … … 382 522 383 523 struct br2684_dev { 384 @@ -181,18 +18 3,15 @@ static struct notifier_block atm_dev_notifier = {524 @@ -181,18 +184,15 @@ static struct notifier_block atm_dev_not 385 525 static void br2684_pop(struct atm_vcc *vcc, struct sk_buff *skb) 386 526 { … … 406 546 * Send a packet out a particular vcc. Not to useful right now, but paves 407 547 * the way for multiple vcc's per itf. Returns true if we can send, 408 @@ -251,21 +250,30 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct net_device *dev, 409 skb_debug(skb); 410 411 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; 412 + if (test_bit(ATM_VF_RELEASED, &atmvcc->flags) || 413 + test_bit(ATM_VF_CLOSE, &atmvcc->flags) || 414 + !test_bit(ATM_VF_READY, &atmvcc->flags)) { 415 + dev_kfree_skb(skb); 416 + return 0; 417 + } 418 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); 419 atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); 548 @@ -256,16 +256,30 @@ static int br2684_xmit_vcc(struct sk_buf 420 549 ATM_SKB(skb)->atm_options = atmvcc->atm_options; 421 550 dev->stats.tx_packets++; … … 440 569 + the stats are updated correctly */ 441 570 + return !atmvcc->send(atmvcc, skb); 571 +} 572 + 573 +static void br2684_release_cb(struct atm_vcc *atmvcc) 574 +{ 575 + struct br2684_vcc *brvcc = BR2684_VCC(atmvcc); 576 + 577 + if (atomic_read(&brvcc->qspace) > 0) 578 + netif_wake_queue(brvcc->device); 579 + 580 + if (brvcc->old_release_cb) 581 + brvcc->old_release_cb(atmvcc); 442 582 } 443 583 444 584 static inline struct br2684_vcc *pick_outgoing_vcc(const struct sk_buff *skb, 445 @@ -378,8 +386,8 @@ static void br2684_close_vcc(struct br2684_vcc *brvcc) 585 @@ -279,6 +293,8 @@ static netdev_tx_t br2684_start_xmit(str 586 { 587 struct br2684_dev *brdev = BRPRIV(dev); 588 struct br2684_vcc *brvcc; 589 + struct atm_vcc *atmvcc; 590 + netdev_tx_t ret = NETDEV_TX_OK; 591 592 pr_debug("skb_dst(skb)=%p\n", skb_dst(skb)); 593 read_lock(&devs_lock); 594 @@ -289,9 +305,26 @@ static netdev_tx_t br2684_start_xmit(str 595 dev->stats.tx_carrier_errors++; 596 /* netif_stop_queue(dev); */ 597 dev_kfree_skb(skb); 598 - read_unlock(&devs_lock); 599 - return NETDEV_TX_OK; 600 + goto out_devs; 601 } 602 + atmvcc = brvcc->atmvcc; 603 + 604 + bh_lock_sock(sk_atm(atmvcc)); 605 + 606 + if (test_bit(ATM_VF_RELEASED, &atmvcc->flags) || 607 + test_bit(ATM_VF_CLOSE, &atmvcc->flags) || 608 + !test_bit(ATM_VF_READY, &atmvcc->flags)) { 609 + dev->stats.tx_dropped++; 610 + dev_kfree_skb(skb); 611 + goto out; 612 + } 613 + 614 + if (sock_owned_by_user(sk_atm(atmvcc))) { 615 + netif_stop_queue(brvcc->device); 616 + ret = NETDEV_TX_BUSY; 617 + goto out; 618 + } 619 + 620 if (!br2684_xmit_vcc(skb, dev, brvcc)) { 621 /* 622 * We should probably use netif_*_queue() here, but that 623 @@ -303,8 +336,11 @@ static netdev_tx_t br2684_start_xmit(str 624 dev->stats.tx_errors++; 625 dev->stats.tx_fifo_errors++; 626 } 627 + out: 628 + bh_unlock_sock(sk_atm(atmvcc)); 629 + out_devs: 630 read_unlock(&devs_lock); 631 - return NETDEV_TX_OK; 632 + return ret; 633 } 634 635 /* 636 @@ -377,9 +413,10 @@ static void br2684_close_vcc(struct br26 637 list_del(&brvcc->brvccs); 446 638 write_unlock_irq(&devs_lock); 447 639 brvcc->atmvcc->user_back = NULL; /* what about vcc->recvq ??? */ 640 + brvcc->atmvcc->release_cb = brvcc->old_release_cb; 448 641 brvcc->old_push(brvcc->atmvcc, NULL); /* pass on the bad news */ 449 642 + module_put(brvcc->old_owner); … … 453 646 454 647 /* when AAL5 PDU comes in: */ 455 @@ -504,6 +5 12,13 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)648 @@ -504,6 +541,13 @@ static int br2684_regvcc(struct atm_vcc 456 649 brvcc = kzalloc(sizeof(struct br2684_vcc), GFP_KERNEL); 457 650 if (!brvcc) … … 467 660 net_dev = br2684_find_dev(&be.ifspec); 468 661 if (net_dev == NULL) { 469 @@ -546,9 +5 61,11 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)662 @@ -546,9 +590,13 @@ static int br2684_regvcc(struct atm_vcc 470 663 brvcc->encaps = (enum br2684_encaps)be.encaps; 471 664 brvcc->old_push = atmvcc->push; 472 665 brvcc->old_pop = atmvcc->pop; 666 + brvcc->old_release_cb = atmvcc->release_cb; 473 667 + brvcc->old_owner = atmvcc->owner; 474 668 barrier(); 475 669 atmvcc->push = br2684_push; 476 670 atmvcc->pop = br2684_pop; 671 + atmvcc->release_cb = br2684_release_cb; 477 672 + atmvcc->owner = THIS_MODULE; 478 673 479 674 /* initialize netdev carrier state */ 480 675 if (atmvcc->dev->signal == ATM_PHY_SIG_LOST) 481 @@ -687,10 +7 04,13 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,676 @@ -687,10 +735,13 @@ static int br2684_ioctl(struct socket *s 482 677 return -ENOIOCTLCMD; 483 678 if (!capable(CAP_NET_ADMIN)) … … 495 690 case BR2684_SETFILT: 496 691 if (atmvcc->push != br2684_push) 497 diff --git a/net/atm/common.c b/net/atm/common.c498 index 0c0ad93..806fc0a 100644499 692 --- a/net/atm/common.c 500 693 +++ b/net/atm/common.c 501 @@ -126,10 +126,19 @@ static void vcc_write_space(struct sock *sk)694 @@ -126,10 +126,19 @@ static void vcc_write_space(struct sock 502 695 rcu_read_unlock(); 503 696 } … … 519 712 520 713 int vcc_create(struct net *net, struct socket *sock, int protocol, int family) 521 @@ -156,7 +165,9 @@ int vcc_create(struct net *net, struct s ocket *sock, int protocol, int family)714 @@ -156,7 +165,9 @@ int vcc_create(struct net *net, struct s 522 715 atomic_set(&sk->sk_rmem_alloc, 0); 523 716 vcc->push = NULL; … … 529 722 vcc->atm_options = vcc->aal_options = 0; 530 723 sk->sk_destruct = vcc_sock_destruct; 531 @@ -175,6 +186,7 @@ static void vcc_destroy_socket(struct so ck *sk)724 @@ -175,6 +186,7 @@ static void vcc_destroy_socket(struct so 532 725 vcc->dev->ops->close(vcc); 533 726 if (vcc->push) … … 537 730 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 538 731 atm_return(vcc, skb->truesize); 539 diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c540 index 226dca9..8c93267 100644541 732 --- a/net/atm/pppoatm.c 542 733 +++ b/net/atm/pppoatm.c … … 550 741 enum pppoatm_encaps encaps; 551 742 atomic_t inflight; 552 @@ -107,6 +109,24 @@ static void pppoatm_wakeup_sender(unsign ed long arg)743 @@ -107,6 +109,24 @@ static void pppoatm_wakeup_sender(unsign 553 744 ppp_output_wakeup((struct ppp_channel *) arg); 554 745 } … … 575 766 * This gets called every time the ATM card has finished sending our 576 767 * skb. The ->old_pop will take care up normal atm flow control, 577 @@ -151,12 +171,11 @@ static void pppoatm_unassign_vcc(struct atm_vcc *atmvcc)768 @@ -151,12 +171,11 @@ static void pppoatm_unassign_vcc(struct 578 769 pvcc = atmvcc_to_pvcc(atmvcc); 579 770 atmvcc->push = pvcc->old_push; … … 589 780 590 781 /* Called when an AAL5 PDU comes in */ 591 @@ -165,9 +184,13 @@ static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb)782 @@ -165,9 +184,13 @@ static void pppoatm_push(struct atm_vcc 592 783 struct pppoatm_vcc *pvcc = atmvcc_to_pvcc(atmvcc); 593 784 pr_debug("\n"); … … 612 803 /* 613 804 * It's not clear that we need to bother with using atm_may_send() 614 @@ -269,10 +292,33 @@ static inline int pppoatm_may_send(struc t pppoatm_vcc *pvcc, int size)805 @@ -269,10 +292,33 @@ static inline int pppoatm_may_send(struc 615 806 static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) 616 807 { … … 646 837 case e_llc: 647 838 if (skb_headroom(skb) < LLC_LEN) { 648 @@ -285,8 +331,10 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)839 @@ -285,8 +331,10 @@ static int pppoatm_send(struct ppp_chann 649 840 } 650 841 consume_skb(skb); … … 658 849 goto nospace; 659 850 memcpy(skb_push(skb, LLC_LEN), pppllc, LLC_LEN); 660 @@ -296,6 +344,7 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)851 @@ -296,6 +344,7 @@ static int pppoatm_send(struct ppp_chann 661 852 goto nospace; 662 853 break; … … 666 857 kfree_skb(skb); 667 858 return 1; 668 @@ -305,9 +354,12 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)859 @@ -305,9 +354,12 @@ static int pppoatm_send(struct ppp_chann 669 860 ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options; 670 861 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", … … 680 871 * We don't have space to send this SKB now, but we might have 681 872 * already applied SC_COMP_PROT compression, so may need to undo 682 @@ -362,6 +414,8 @@ static int pppoatm_assign_vcc(struct atm _vcc *atmvcc, void __user *arg)873 @@ -362,6 +414,8 @@ static int pppoatm_assign_vcc(struct atm 683 874 atomic_set(&pvcc->inflight, NONE_INFLIGHT); 684 875 pvcc->old_push = atmvcc->push; … … 689 880 pvcc->chan.private = pvcc; 690 881 pvcc->chan.ops = &pppoatm_ops; 691 @@ -377,7 +431,9 @@ static int pppoatm_assign_vcc(struct atm _vcc *atmvcc, void __user *arg)882 @@ -377,7 +431,9 @@ static int pppoatm_assign_vcc(struct atm 692 883 atmvcc->user_back = pvcc; 693 884 atmvcc->push = pppoatm_push; … … 699 890 /* re-process everything received between connection setup and 700 891 backend setup */ 701 @@ -406,6 +462,8 @@ static int pppoatm_ioctl(struct socket * sock, unsigned int cmd,892 @@ -406,6 +462,8 @@ static int pppoatm_ioctl(struct socket * 702 893 return -ENOIOCTLCMD; 703 894 if (!capable(CAP_NET_ADMIN)) -
trunk/target/linux/generic/patches-3.7/131-atm-fixes.patch
r34410 r34443 1 commit 86768086727a60335b08c34b2966c784029a24cf 1 commit d7d3d8f1ee4435e32bc6c93187798b7e2e3170a9 2 Author: David Woodhouse <David.Woodhouse@intel.com> 3 Date: Thu Nov 29 23:28:30 2012 +0000 4 5 solos-pci: remove list_vccs() debugging function 6 7 No idea why we've gone so long dumping a list of VCCs with vci==0 on 8 every ->open() call... 9 10 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 11 12 commit c93967bfd3a3dffa759a3f28370167bf3cdbc3d0 13 Author: David Woodhouse <David.Woodhouse@intel.com> 14 Date: Thu Nov 29 23:27:20 2012 +0000 15 16 solos-pci: use GFP_KERNEL where possible, not GFP_ATOMIC 17 18 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 19 20 commit ad6999e17ae4f7b99f6d28f425ae970acb115347 21 Author: David Woodhouse <David.Woodhouse@intel.com> 22 Date: Thu Nov 29 23:15:30 2012 +0000 23 24 solos-pci: clean up pclose() function 25 26 - Flush pending TX skbs from the queue rather than waiting for them all to 27 complete (suggested by Krzysztof Mazur <krzysiek@podlesie.net>). 28 - Clear ATM_VF_ADDR only when the PKT_PCLOSE packet has been submitted. 29 - Don't clear ATM_VF_READY at all â vcc_destroy_socket() does that for us. 30 31 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 32 33 commit 2547e97f29d6d69d567947d5ef90b6b4fbcaf565 2 34 Author: David Woodhouse <David.Woodhouse@intel.com> 3 35 Date: Wed Nov 28 10:15:05 2012 +0000 … … 11 43 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 12 44 13 commit a009aa5fde926350f7a7e558a3ac0180e10eb24a45 commit 990b0884a2e9668c08e9daa4d70a54d65329cb6f 14 46 Author: Krzysztof Mazur <krzysiek@podlesie.net> 15 47 Date: Wed Nov 28 09:08:04 2012 +0100 … … 27 59 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 28 60 29 commit ae2169bcb6375fb214cadd0ea50ac54bcf39b0d661 commit f49b6da01f0abebb17f6241473d53018d923f6b0 30 62 Author: Nathan Williams <nathan@traverse.com.au> 31 63 Date: Tue Nov 27 17:34:09 2012 +1100 … … 38 70 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 39 71 40 commit 6227612becaebe2f9f4ad7d0cdf27e298bb5668772 commit a61d37ff4a555886c4ebe31d2c6d893afb6f4d3c 41 73 Author: David Woodhouse <David.Woodhouse@intel.com> 42 74 Date: Wed Nov 28 00:46:45 2012 +0000 … … 53 85 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 54 86 55 commit 44abbb464896dc2270716d25e12fe47e57eeb1d387 commit c52f40629884ddc62c7af445fd5d620fdb466fb2 56 88 Author: David Woodhouse <David.Woodhouse@intel.com> 57 89 Date: Wed Nov 28 00:05:52 2012 +0000 … … 70 102 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 71 103 72 commit c93eeac2ebee497dbc9b6ad39c235ff3061be141 104 commit 35826e7372fe39b7db7930eda0267c82d68d1a4c 105 Author: David Woodhouse <dwmw2@infradead.org> 106 Date: Tue Nov 27 23:28:36 2012 +0000 107 108 br2684: don't send frames on not-ready vcc 109 110 Avoid submitting packets to a vcc which is being closed. Things go badly 111 wrong when the ->pop method gets later called after everything's been 112 torn down. 113 114 Use the ATM socket lock for synchronisation with vcc_destroy_socket(), 115 which clears the ATM_VF_READY bit under the same lock. Otherwise, we 116 could end up submitting a packet to the device driver even after its 117 ->ops->close method has been called. And it could call the vcc's ->pop 118 method after the protocol has been shut down. Which leads to a panic. 119 120 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 121 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 122 123 commit 7f940dde65de4a707f3dd723bb6ce9de90ca1eab 73 124 Author: David Woodhouse <David.Woodhouse@intel.com> 74 125 Date: Wed Nov 28 00:03:11 2012 +0000 75 126 76 atm: Add release_cb() callback to vcc127 atm: add release_cb() callback to vcc 77 128 78 129 The immediate use case for this is that it will allow us to ensure that a … … 87 138 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 88 139 89 commit 9b3e2e224cc4326d8897243b24d778abf9098a8d 90 Author: David Woodhouse <dwmw2@infradead.org> 91 Date: Tue Nov 27 23:28:36 2012 +0000 92 93 br2684: don't send frames on not-ready vcc 94 95 Avoid submitting packets to a vcc which is being closed. Things go badly 96 wrong when the ->pop method gets later called after everything's been 97 torn down. 98 99 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 100 Acked-by: Krzysztof Mazur <krzysiek@podlesie.net> 101 102 commit 26c7c53318cf56a690ae553104f4a60181734fb5 140 commit def1b2f9083f84d0a77730e537c76429914d17c1 103 141 Author: David Woodhouse <David.Woodhouse@intel.com> 104 142 Date: Tue Nov 27 23:49:24 2012 +0000 105 143 106 solos-pci: Wait for pending TX to complete when releasing vcc144 solos-pci: wait for pending TX to complete when releasing vcc 107 145 108 146 We should no longer be calling the old pop routine for the vcc, after … … 112 150 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 113 151 114 commit 1a3304e89b9ba168340a37926014be11c3ad110e152 commit 397ff16dce53888ec693b3718640be2560204751 115 153 Author: Krzysztof Mazur <krzysiek@podlesie.net> 116 154 Date: Tue Nov 6 23:17:02 2012 +0100 … … 130 168 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> 131 169 132 commit 294398bcd0fe26335059a185b59cfb5de1fc4c71170 commit 071d93931a75dc1f82f0baa9959613af81c5a032 133 171 Author: Krzysztof Mazur <krzysiek@podlesie.net> 134 172 Date: Sat Nov 10 23:33:19 2012 +0100 … … 136 174 pppoatm: drop frames to not-ready vcc 137 175 138 Patches "atm: detach protocol before closing vcc" 139 and "pppoatm: allow assign only on a connected socket" fixed 140 common cases where the pppoatm_send() crashes while sending 141 frame to not-ready vcc. However there are still some other cases 142 where we can send frames to vcc, which is flagged as ATM_VF_CLOSE 143 (for instance after vcc_release_async()) or it's opened but not 144 ready yet. 176 The vcc_destroy_socket() closes vcc before the protocol is detached 177 from vcc by calling vcc->push() with NULL skb. This leaves some time 178 window, where the protocol may call vcc->send() on closed vcc 179 and crash. 145 180 146 181 Now pppoatm_send(), like vcc_sendmsg(), checks for vcc flags that … … 278 313 Signed-off-by: David S. Miller <davem@davemloft.net> 279 314 280 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c281 index 9851093..6258961 100644282 315 --- a/drivers/atm/solos-pci.c 283 316 +++ b/drivers/atm/solos-pci.c … … 290 323 uint32_t dma_addr; 291 324 }; 292 @@ -710,7 +711,8 @@ void solos_bh(unsigned long card_arg) 325 @@ -164,7 +165,6 @@ static void fpga_queue(struct solos_card 326 static uint32_t fpga_tx(struct solos_card *); 327 static irqreturn_t solos_irq(int irq, void *dev_id); 328 static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci); 329 -static int list_vccs(int vci); 330 static int atm_init(struct solos_card *, struct device *); 331 static void atm_remove(struct solos_card *); 332 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size); 333 @@ -710,7 +710,8 @@ void solos_bh(unsigned long card_arg) 293 334 dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n", 294 335 le16_to_cpu(header->vpi), le16_to_cpu(header->vci), … … 300 341 atm_charge(vcc, skb->truesize); 301 342 vcc->push(vcc, skb); 302 @@ -881,11 +883,18 @@ static void pclose(struct atm_vcc *vcc) 343 @@ -790,44 +791,6 @@ static struct atm_vcc *find_vcc(struct a 344 return vcc; 345 } 346 347 -static int list_vccs(int vci) 348 -{ 349 - struct hlist_head *head; 350 - struct atm_vcc *vcc; 351 - struct hlist_node *node; 352 - struct sock *s; 353 - int num_found = 0; 354 - int i; 355 - 356 - read_lock(&vcc_sklist_lock); 357 - if (vci != 0){ 358 - head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)]; 359 - sk_for_each(s, node, head) { 360 - num_found ++; 361 - vcc = atm_sk(s); 362 - printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", 363 - vcc->dev->number, 364 - vcc->vpi, 365 - vcc->vci); 366 - } 367 - } else { 368 - for(i = 0; i < VCC_HTABLE_SIZE; i++){ 369 - head = &vcc_hash[i]; 370 - sk_for_each(s, node, head) { 371 - num_found ++; 372 - vcc = atm_sk(s); 373 - printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", 374 - vcc->dev->number, 375 - vcc->vpi, 376 - vcc->vci); 377 - } 378 - } 379 - } 380 - read_unlock(&vcc_sklist_lock); 381 - return num_found; 382 -} 383 - 384 - 385 static int popen(struct atm_vcc *vcc) 386 { 387 struct solos_card *card = vcc->dev->dev_data; 388 @@ -840,7 +803,7 @@ static int popen(struct atm_vcc *vcc) 389 return -EINVAL; 390 } 391 392 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 393 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 394 if (!skb) { 395 if (net_ratelimit()) 396 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n"); 397 @@ -857,8 +820,6 @@ static int popen(struct atm_vcc *vcc) 398 399 set_bit(ATM_VF_ADDR, &vcc->flags); 400 set_bit(ATM_VF_READY, &vcc->flags); 401 - list_vccs(0); 402 - 403 404 return 0; 405 } 406 @@ -866,10 +827,21 @@ static int popen(struct atm_vcc *vcc) 407 static void pclose(struct atm_vcc *vcc) 408 { 409 struct solos_card *card = vcc->dev->dev_data; 410 - struct sk_buff *skb; 411 + unsigned char port = SOLOS_CHAN(vcc->dev); 412 + struct sk_buff *skb, *tmpskb; 413 struct pkt_hdr *header; 414 415 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 416 + /* Remove any yet-to-be-transmitted packets from the pending queue */ 417 + spin_lock(&card->tx_queue_lock); 418 + skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) { 419 + if (SKB_CB(skb)->vcc == vcc) { 420 + skb_unlink(skb, &card->tx_queue[port]); 421 + solos_pop(vcc, skb); 422 + } 423 + } 424 + spin_unlock(&card->tx_queue_lock); 425 + 426 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 427 if (!skb) { 428 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n"); 429 return; 430 @@ -881,15 +853,21 @@ static void pclose(struct atm_vcc *vcc) 303 431 header->vci = cpu_to_le16(vcc->vci); 304 432 header->type = cpu_to_le16(PKT_PCLOSE); 305 433 434 - fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); 306 435 + init_completion(&SKB_CB(skb)->c); 307 + 308 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); 309 310 clear_bit(ATM_VF_ADDR, &vcc->flags); 311 clear_bit(ATM_VF_READY, &vcc->flags); 312 313 + if (!wait_for_completion_timeout(&SKB_CB(skb)->c, 314 + msecs_to_jiffies(5000))) 436 437 - clear_bit(ATM_VF_ADDR, &vcc->flags); 438 - clear_bit(ATM_VF_READY, &vcc->flags); 439 + fpga_queue(card, port, skb, NULL); 440 + 441 + if (!wait_for_completion_timeout(&SKB_CB(skb)->c, 5 * HZ)) 315 442 + dev_warn(&card->dev->dev, "Timeout waiting for VCC close on port %d\n", 316 + SOLOS_CHAN(vcc->dev));317 + 443 + port); 444 318 445 /* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the 319 446 tasklet has finished processing any incoming packets (and, more to 320 447 the point, using the vcc pointer). */ 321 @@ -1011,9 +1020,12 @@ static uint32_t fpga_tx(struct solos_card *card) 448 tasklet_unlock_wait(&card->tlet); 449 + 450 + clear_bit(ATM_VF_ADDR, &vcc->flags); 451 + 452 return; 453 } 454 455 @@ -1011,9 +989,12 @@ static uint32_t fpga_tx(struct solos_car 322 456 if (vcc) { 323 457 atomic_inc(&vcc->stats->tx); … … 334 468 } 335 469 /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */ 336 @@ -1345,6 +1357,8 @@ static struct pci_driver fpga_driver = { 470 @@ -1248,7 +1229,7 @@ static int atm_init(struct solos_card *c 471 card->atmdev[i]->phy_data = (void *)(unsigned long)i; 472 atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND); 473 474 - skb = alloc_skb(sizeof(*header), GFP_ATOMIC); 475 + skb = alloc_skb(sizeof(*header), GFP_KERNEL); 476 if (!skb) { 477 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n"); 478 continue; 479 @@ -1345,6 +1326,8 @@ static struct pci_driver fpga_driver = { 337 480 338 481 static int __init solos_pci_init(void) … … 343 486 return pci_register_driver(&fpga_driver); 344 487 } 345 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h346 index 22ef21c..c1da539 100644347 488 --- a/include/linux/atmdev.h 348 489 +++ b/include/linux/atmdev.h … … 363 504 short itf; /* interface number */ 364 505 struct sockaddr_atmsvc local; 365 diff --git a/net/atm/br2684.c b/net/atm/br2684.c366 index 4819d315..a4ee4ad 100644367 506 --- a/net/atm/br2684.c 368 507 +++ b/net/atm/br2684.c 369 @@ -68,12 +68,1 4@@ struct br2684_vcc {508 @@ -68,12 +68,15 @@ struct br2684_vcc { 370 509 /* keep old push, pop functions for chaining */ 371 510 void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb); 372 511 void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); 512 + void (*old_release_cb)(struct atm_vcc *vcc); 373 513 + struct module *old_owner; 374 514 enum br2684_encaps encaps; … … 382 522 383 523 struct br2684_dev { 384 @@ -181,18 +18 3,15 @@ static struct notifier_block atm_dev_notifier = {524 @@ -181,18 +184,15 @@ static struct notifier_block atm_dev_not 385 525 static void br2684_pop(struct atm_vcc *vcc, struct sk_buff *skb) 386 526 { … … 406 546 * Send a packet out a particular vcc. Not to useful right now, but paves 407 547 * the way for multiple vcc's per itf. Returns true if we can send, 408 @@ -251,21 +250,30 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct net_device *dev, 409 skb_debug(skb); 410 411 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; 412 + if (test_bit(ATM_VF_RELEASED, &atmvcc->flags) || 413 + test_bit(ATM_VF_CLOSE, &atmvcc->flags) || 414 + !test_bit(ATM_VF_READY, &atmvcc->flags)) { 415 + dev_kfree_skb(skb); 416 + return 0; 417 + } 418 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); 419 atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); 548 @@ -256,16 +256,30 @@ static int br2684_xmit_vcc(struct sk_buf 420 549 ATM_SKB(skb)->atm_options = atmvcc->atm_options; 421 550 dev->stats.tx_packets++; … … 440 569 + the stats are updated correctly */ 441 570 + return !atmvcc->send(atmvcc, skb); 571 +} 572 + 573 +static void br2684_release_cb(struct atm_vcc *atmvcc) 574 +{ 575 + struct br2684_vcc *brvcc = BR2684_VCC(atmvcc); 576 + 577 + if (atomic_read(&brvcc->qspace) > 0) 578 + netif_wake_queue(brvcc->device); 579 + 580 + if (brvcc->old_release_cb) 581 + brvcc->old_release_cb(atmvcc); 442 582 } 443 583 444 584 static inline struct br2684_vcc *pick_outgoing_vcc(const struct sk_buff *skb, 445 @@ -378,8 +386,8 @@ static void br2684_close_vcc(struct br2684_vcc *brvcc) 585 @@ -279,6 +293,8 @@ static netdev_tx_t br2684_start_xmit(str 586 { 587 struct br2684_dev *brdev = BRPRIV(dev); 588 struct br2684_vcc *brvcc; 589 + struct atm_vcc *atmvcc; 590 + netdev_tx_t ret = NETDEV_TX_OK; 591 592 pr_debug("skb_dst(skb)=%p\n", skb_dst(skb)); 593 read_lock(&devs_lock); 594 @@ -289,9 +305,26 @@ static netdev_tx_t br2684_start_xmit(str 595 dev->stats.tx_carrier_errors++; 596 /* netif_stop_queue(dev); */ 597 dev_kfree_skb(skb); 598 - read_unlock(&devs_lock); 599 - return NETDEV_TX_OK; 600 + goto out_devs; 601 } 602 + atmvcc = brvcc->atmvcc; 603 + 604 + bh_lock_sock(sk_atm(atmvcc)); 605 + 606 + if (test_bit(ATM_VF_RELEASED, &atmvcc->flags) || 607 + test_bit(ATM_VF_CLOSE, &atmvcc->flags) || 608 + !test_bit(ATM_VF_READY, &atmvcc->flags)) { 609 + dev->stats.tx_dropped++; 610 + dev_kfree_skb(skb); 611 + goto out; 612 + } 613 + 614 + if (sock_owned_by_user(sk_atm(atmvcc))) { 615 + netif_stop_queue(brvcc->device); 616 + ret = NETDEV_TX_BUSY; 617 + goto out; 618 + } 619 + 620 if (!br2684_xmit_vcc(skb, dev, brvcc)) { 621 /* 622 * We should probably use netif_*_queue() here, but that 623 @@ -303,8 +336,11 @@ static netdev_tx_t br2684_start_xmit(str 624 dev->stats.tx_errors++; 625 dev->stats.tx_fifo_errors++; 626 } 627 + out: 628 + bh_unlock_sock(sk_atm(atmvcc)); 629 + out_devs: 630 read_unlock(&devs_lock); 631 - return NETDEV_TX_OK; 632 + return ret; 633 } 634 635 /* 636 @@ -377,9 +413,10 @@ static void br2684_close_vcc(struct br26 637 list_del(&brvcc->brvccs); 446 638 write_unlock_irq(&devs_lock); 447 639 brvcc->atmvcc->user_back = NULL; /* what about vcc->recvq ??? */ 640 + brvcc->atmvcc->release_cb = brvcc->old_release_cb; 448 641 brvcc->old_push(brvcc->atmvcc, NULL); /* pass on the bad news */ 449 642 + module_put(brvcc->old_owner); … … 453 646 454 647 /* when AAL5 PDU comes in: */ 455 @@ -504,6 +5 12,13 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)648 @@ -504,6 +541,13 @@ static int br2684_regvcc(struct atm_vcc 456 649 brvcc = kzalloc(sizeof(struct br2684_vcc), GFP_KERNEL); 457 650 if (!brvcc) … … 467 660 net_dev = br2684_find_dev(&be.ifspec); 468 661 if (net_dev == NULL) { 469 @@ -546,9 +5 61,11 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)662 @@ -546,9 +590,13 @@ static int br2684_regvcc(struct atm_vcc 470 663 brvcc->encaps = (enum br2684_encaps)be.encaps; 471 664 brvcc->old_push = atmvcc->push; 472 665 brvcc->old_pop = atmvcc->pop; 666 + brvcc->old_release_cb = atmvcc->release_cb; 473 667 + brvcc->old_owner = atmvcc->owner; 474 668 barrier(); 475 669 atmvcc->push = br2684_push; 476 670 atmvcc->pop = br2684_pop; 671 + atmvcc->release_cb = br2684_release_cb; 477 672 + atmvcc->owner = THIS_MODULE; 478 673 479 674 /* initialize netdev carrier state */ 480 675 if (atmvcc->dev->signal == ATM_PHY_SIG_LOST) 481 @@ -687,10 +7 04,13 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,676 @@ -687,10 +735,13 @@ static int br2684_ioctl(struct socket *s 482 677 return -ENOIOCTLCMD; 483 678 if (!capable(CAP_NET_ADMIN)) … … 495 690 case BR2684_SETFILT: 496 691 if (atmvcc->push != br2684_push) 497 diff --git a/net/atm/common.c b/net/atm/common.c498 index 0c0ad93..806fc0a 100644499 692 --- a/net/atm/common.c 500 693 +++ b/net/atm/common.c 501 @@ -126,10 +126,19 @@ static void vcc_write_space(struct sock *sk)694 @@ -126,10 +126,19 @@ static void vcc_write_space(struct sock 502 695 rcu_read_unlock(); 503 696 } … … 519 712 520 713 int vcc_create(struct net *net, struct socket *sock, int protocol, int family) 521 @@ -156,7 +165,9 @@ int vcc_create(struct net *net, struct s ocket *sock, int protocol, int family)714 @@ -156,7 +165,9 @@ int vcc_create(struct net *net, struct s 522 715 atomic_set(&sk->sk_rmem_alloc, 0); 523 716 vcc->push = NULL; … … 529 722 vcc->atm_options = vcc->aal_options = 0; 530 723 sk->sk_destruct = vcc_sock_destruct; 531 @@ -175,6 +186,7 @@ static void vcc_destroy_socket(struct so ck *sk)724 @@ -175,6 +186,7 @@ static void vcc_destroy_socket(struct so 532 725 vcc->dev->ops->close(vcc); 533 726 if (vcc->push) … … 537 730 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 538 731 atm_return(vcc, skb->truesize); 539 diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c540 index 226dca9..8c93267 100644541 732 --- a/net/atm/pppoatm.c 542 733 +++ b/net/atm/pppoatm.c … … 550 741 enum pppoatm_encaps encaps; 551 742 atomic_t inflight; 552 @@ -107,6 +109,24 @@ static void pppoatm_wakeup_sender(unsign ed long arg)743 @@ -107,6 +109,24 @@ static void pppoatm_wakeup_sender(unsign 553 744 ppp_output_wakeup((struct ppp_channel *) arg); 554 745 } … … 575 766 * This gets called every time the ATM card has finished sending our 576 767 * skb. The ->old_pop will take care up normal atm flow control, 577 @@ -151,12 +171,11 @@ static void pppoatm_unassign_vcc(struct atm_vcc *atmvcc)768 @@ -151,12 +171,11 @@ static void pppoatm_unassign_vcc(struct 578 769 pvcc = atmvcc_to_pvcc(atmvcc); 579 770 atmvcc->push = pvcc->old_push; … … 589 780 590 781 /* Called when an AAL5 PDU comes in */ 591 @@ -165,9 +184,13 @@ static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb)782 @@ -165,9 +184,13 @@ static void pppoatm_push(struct atm_vcc 592 783 struct pppoatm_vcc *pvcc = atmvcc_to_pvcc(atmvcc); 593 784 pr_debug("\n"); … … 612 803 /* 613 804 * It's not clear that we need to bother with using atm_may_send() 614 @@ -269,10 +292,33 @@ static inline int pppoatm_may_send(struc t pppoatm_vcc *pvcc, int size)805 @@ -269,10 +292,33 @@ static inline int pppoatm_may_send(struc 615 806 static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) 616 807 { … … 646 837 case e_llc: 647 838 if (skb_headroom(skb) < LLC_LEN) { 648 @@ -285,8 +331,10 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)839 @@ -285,8 +331,10 @@ static int pppoatm_send(struct ppp_chann 649 840 } 650 841 consume_skb(skb); … … 658 849 goto nospace; 659 850 memcpy(skb_push(skb, LLC_LEN), pppllc, LLC_LEN); 660 @@ -296,6 +344,7 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)851 @@ -296,6 +344,7 @@ static int pppoatm_send(struct ppp_chann 661 852 goto nospace; 662 853 break; … … 666 857 kfree_skb(skb); 667 858 return 1; 668 @@ -305,9 +354,12 @@ static int pppoatm_send(struct ppp_chann el *chan, struct sk_buff *skb)859 @@ -305,9 +354,12 @@ static int pppoatm_send(struct ppp_chann 669 860 ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options; 670 861 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", … … 680 871 * We don't have space to send this SKB now, but we might have 681 872 * already applied SC_COMP_PROT compression, so may need to undo 682 @@ -362,6 +414,8 @@ static int pppoatm_assign_vcc(struct atm _vcc *atmvcc, void __user *arg)873 @@ -362,6 +414,8 @@ static int pppoatm_assign_vcc(struct atm 683 874 atomic_set(&pvcc->inflight, NONE_INFLIGHT); 684 875 pvcc->old_push = atmvcc->push; … … 689 880 pvcc->chan.private = pvcc; 690 881 pvcc->chan.ops = &pppoatm_ops; 691 @@ -377,7 +431,9 @@ static int pppoatm_assign_vcc(struct atm _vcc *atmvcc, void __user *arg)882 @@ -377,7 +431,9 @@ static int pppoatm_assign_vcc(struct atm 692 883 atmvcc->user_back = pvcc; 693 884 atmvcc->push = pppoatm_push; … … 699 890 /* re-process everything received between connection setup and 700 891 backend setup */ 701 @@ -406,6 +462,8 @@ static int pppoatm_ioctl(struct socket * sock, unsigned int cmd,892 @@ -406,6 +462,8 @@ static int pppoatm_ioctl(struct socket * 702 893 return -ENOIOCTLCMD; 703 894 if (!capable(CAP_NET_ADMIN))
Note: See TracChangeset
for help on using the changeset viewer.