Changeset 31705 in vbox
- Timestamp:
- Aug 16, 2010 3:24:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r31703 r31705 195 195 #ifdef VBOXNETFLT_WITH_QDISC 196 196 //#define QDISC_LOG(x) printk x 197 # define QDISC_LOG(x) do { } while (0)198 199 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)200 # define QDISC_CREATE(dev, queue, ops, parent) qdisc_create_dflt(dev, ops)201 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)202 # define QDISC_CREATE(dev, queue, ops, parent) qdisc_create_dflt(dev, ops, parent)203 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */204 # define QDISC_CREATE(dev, queue, ops, parent) qdisc_create_dflt(dev, queue, ops, parent)205 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */206 207 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)208 # define qdisc_dev(qdisc) (qdisc->dev)209 # define qdisc_pkt_len(skb) (skb->len)210 # define QDISC_GET(dev) (dev->qdisc_sleeping)211 # else212 # define QDISC_GET(dev) (netdev_get_tx_queue(dev, 0)->qdisc_sleeping)213 # endif214 215 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)216 # define QDISC_SAVED_NUM(dev) 1217 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)218 # define QDISC_SAVED_NUM(dev) dev->num_tx_queues219 # else220 # define QDISC_SAVED_NUM(dev) dev->num_tx_queues+1221 # endif222 223 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)224 # define QDISC_IS_BUSY(dev, qdisc) test_bit(__LINK_STATE_SCHED, &dev->state)225 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)226 # define QDISC_IS_BUSY(dev, qdisc) (test_bit(__QDISC_STATE_RUNNING, &qdisc->state) || \227 test_bit(__QDISC_STATE_SCHED, &qdisc->state))228 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */229 # define QDISC_IS_BUSY(dev, qdisc) (qdisc_is_running(qdisc) || \230 test_bit(__QDISC_STATE_SCHED, &qdisc->state))231 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */197 # define QDISC_LOG(x) do { } while (0) 198 199 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) 200 # define QDISC_CREATE(dev, queue, ops, parent) qdisc_create_dflt(dev, ops) 201 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 202 # define QDISC_CREATE(dev, queue, ops, parent) qdisc_create_dflt(dev, ops, parent) 203 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 204 # define QDISC_CREATE(dev, queue, ops, parent) qdisc_create_dflt(dev, queue, ops, parent) 205 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 206 207 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 208 # define qdisc_dev(qdisc) (qdisc->dev) 209 # define qdisc_pkt_len(skb) (skb->len) 210 # define QDISC_GET(dev) (dev->qdisc_sleeping) 211 # else 212 # define QDISC_GET(dev) (netdev_get_tx_queue(dev, 0)->qdisc_sleeping) 213 # endif 214 215 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 216 # define QDISC_SAVED_NUM(dev) 1 217 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) 218 # define QDISC_SAVED_NUM(dev) dev->num_tx_queues 219 # else 220 # define QDISC_SAVED_NUM(dev) dev->num_tx_queues+1 221 # endif 222 223 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 224 # define QDISC_IS_BUSY(dev, qdisc) test_bit(__LINK_STATE_SCHED, &dev->state) 225 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) 226 # define QDISC_IS_BUSY(dev, qdisc) (test_bit(__QDISC_STATE_RUNNING, &qdisc->state) || \ 227 test_bit(__QDISC_STATE_SCHED, &qdisc->state)) 228 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */ 229 # define QDISC_IS_BUSY(dev, qdisc) (qdisc_is_running(qdisc) || \ 230 test_bit(__QDISC_STATE_SCHED, &qdisc->state)) 231 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */ 232 232 233 233 struct VBoxNetQDiscPriv … … 252 252 int rc; 253 253 254 # ifdef VBOXNETFLT_QDISC_ENQUEUE254 # ifdef VBOXNETFLT_QDISC_ENQUEUE 255 255 if (VALID_PTR(pPriv->pVBoxNetFlt)) 256 256 { … … 281 281 } 282 282 } 283 # endif /* VBOXNETFLT_QDISC_ENQUEUE */283 # endif /* VBOXNETFLT_QDISC_ENQUEUE */ 284 284 rc = pPriv->pChild->enqueue(skb, pPriv->pChild); 285 285 if (rc == NET_XMIT_SUCCESS) … … 297 297 { 298 298 PVBOXNETQDISCPRIV pPriv = qdisc_priv(sch); 299 # ifdef VBOXNETFLT_QDISC_ENQUEUE299 # ifdef VBOXNETFLT_QDISC_ENQUEUE 300 300 --sch->q.qlen; 301 301 return pPriv->pChild->dequeue(pPriv->pChild); 302 # else /* VBOXNETFLT_QDISC_ENQUEUE */302 # else /* VBOXNETFLT_QDISC_ENQUEUE */ 303 303 uint8_t abHdrBuf[sizeof(RTNETETHERHDR) + sizeof(uint32_t) + RTNETIPV4_MIN_LEN]; 304 304 PCRTNETETHERHDR pEtherHdr; … … 344 344 345 345 return pSkb; 346 # endif /* VBOXNETFLT_QDISC_ENQUEUE */347 } 348 349 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)346 # endif /* VBOXNETFLT_QDISC_ENQUEUE */ 347 } 348 349 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 350 350 static int vboxNetFltQdiscRequeue(struct sk_buff *skb, struct Qdisc *sch) 351 351 { … … 357 357 { 358 358 sch->q.qlen++; 359 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)359 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) 360 360 sch->qstats.requeues++; 361 # endif361 # endif 362 362 } 363 363 364 364 return rc; 365 365 } 366 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */366 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */ 367 367 368 368 static unsigned int vboxNetFltQdiscDrop(struct Qdisc *sch) … … 385 385 } 386 386 387 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)387 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) 388 388 static int vboxNetFltQdiscInit(struct Qdisc *sch, struct rtattr *opt) 389 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */389 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */ 390 390 static int vboxNetFltQdiscInit(struct Qdisc *sch, struct nlattr *opt) 391 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */391 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */ 392 392 { 393 393 PVBOXNETQDISCPRIV pPriv = qdisc_priv(sch); … … 454 454 *ppOld = pPriv->pChild; 455 455 pPriv->pChild = pNew; 456 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)456 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) 457 457 sch->q.qlen = 0; 458 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) */458 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) */ 459 459 qdisc_tree_decrease_qlen(*ppOld, (*ppOld)->q.qlen); 460 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) */460 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) */ 461 461 qdisc_reset(*ppOld); 462 462 sch_tree_unlock(sch); … … 480 480 } 481 481 482 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)482 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) 483 483 static int vboxNetFltClassChange(struct Qdisc *sch, u32 classid, u32 parentid, 484 484 struct rtattr **tca, unsigned long *arg) 485 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */485 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */ 486 486 static int vboxNetFltClassChange(struct Qdisc *sch, u32 classid, u32 parentid, 487 487 struct nlattr **tca, unsigned long *arg) 488 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */488 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) */ 489 489 { 490 490 return -ENOSYS; … … 548 548 .enqueue = vboxNetFltQdiscEnqueue, 549 549 .dequeue = vboxNetFltQdiscDequeue, 550 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)550 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 551 551 .requeue = vboxNetFltQdiscRequeue, 552 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */552 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */ 553 553 .peek = qdisc_peek_dequeued, 554 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */554 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */ 555 555 .drop = vboxNetFltQdiscDrop, 556 556 .init = vboxNetFltQdiscInit, … … 572 572 static void vboxNetFltLinuxQdiscInstall(PVBOXNETFLTINS pThis, struct net_device *pDev) 573 573 { 574 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)574 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 575 575 int i; 576 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */576 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 577 577 PVBOXNETQDISCPRIV pPriv; 578 578 … … 609 609 * qdisc is already 1. 610 610 */ 611 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)611 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 612 612 pPriv->ppSaved[0] = pDev->qdisc_sleeping; 613 613 ASMAtomicWritePtr(&pDev->qdisc_sleeping, pNew); 614 614 ASMAtomicWritePtr(&pDev->qdisc, pNew); 615 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */615 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 616 616 for (i = 0; i < pDev->num_tx_queues; i++) 617 617 { … … 625 625 } 626 626 /* Newer kernels store root qdisc in netdev structure as well. */ 627 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)627 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) 628 628 pPriv->ppSaved[pDev->num_tx_queues] = pDev->qdisc; 629 629 ASMAtomicWritePtr(&pDev->qdisc, pNew); 630 630 atomic_inc(&pNew->refcnt); 631 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) */632 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */631 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) */ 632 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 633 633 /* Synch the queue len with our child */ 634 634 pNew->q.qlen = pPriv->pChild->q.qlen; … … 645 645 static void vboxNetFltLinuxQdiscRemove(PVBOXNETFLTINS pThis, struct net_device *pDev) 646 646 { 647 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)647 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 648 648 int i; 649 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */649 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 650 650 PVBOXNETQDISCPRIV pPriv; 651 651 struct Qdisc *pQdisc, *pChild; … … 677 677 QDISC_LOG(("vboxNetFltLinuxQdiscRemove: refcnt=%d num_tx_queues=%d\n", 678 678 atomic_read(&pQdisc->refcnt), pDev->num_tx_queues)); 679 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)679 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 680 680 /* Play it safe, make sure the qdisc is not being used. */ 681 681 if (pPriv->ppSaved[0]) … … 688 688 qdisc_destroy(pQdisc); /* Destroy reference */ 689 689 } 690 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */690 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 691 691 for (i = 0; i < pDev->num_tx_queues; i++) 692 692 { … … 704 704 } 705 705 /* Newer kernels store root qdisc in netdev structure as well. */ 706 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)706 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) 707 707 ASMAtomicWritePtr(&pDev->qdisc, pPriv->ppSaved[pDev->num_tx_queues]); 708 708 pPriv->ppSaved[pDev->num_tx_queues] = NULL; … … 710 710 yield(); 711 711 qdisc_destroy(pQdisc); /* Destroy reference */ 712 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) */713 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */712 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) */ 713 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 714 714 715 715 /*
Note:
See TracChangeset
for help on using the changeset viewer.