VirtualBox

Changeset 31705 in vbox


Ignore:
Timestamp:
Aug 16, 2010 3:24:39 PM (15 years ago)
Author:
vboxsync
Message:

vboxnetflt: indentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r31703 r31705  
    195195#ifdef VBOXNETFLT_WITH_QDISC
    196196//#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 #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) */
     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) */
    232232
    233233struct VBoxNetQDiscPriv
     
    252252    int                 rc;
    253253
    254 #ifdef VBOXNETFLT_QDISC_ENQUEUE
     254# ifdef VBOXNETFLT_QDISC_ENQUEUE
    255255    if (VALID_PTR(pPriv->pVBoxNetFlt))
    256256    {
     
    281281        }
    282282    }
    283 #endif /* VBOXNETFLT_QDISC_ENQUEUE */
     283# endif /* VBOXNETFLT_QDISC_ENQUEUE */
    284284    rc = pPriv->pChild->enqueue(skb, pPriv->pChild);
    285285    if (rc == NET_XMIT_SUCCESS)
     
    297297{
    298298    PVBOXNETQDISCPRIV    pPriv = qdisc_priv(sch);
    299 #ifdef VBOXNETFLT_QDISC_ENQUEUE
     299# ifdef VBOXNETFLT_QDISC_ENQUEUE
    300300    --sch->q.qlen;
    301301    return pPriv->pChild->dequeue(pPriv->pChild);
    302 #else /*  VBOXNETFLT_QDISC_ENQUEUE */
     302# else /*  VBOXNETFLT_QDISC_ENQUEUE */
    303303    uint8_t              abHdrBuf[sizeof(RTNETETHERHDR) + sizeof(uint32_t) + RTNETIPV4_MIN_LEN];
    304304    PCRTNETETHERHDR      pEtherHdr;
     
    344344
    345345    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)
    350350static int vboxNetFltQdiscRequeue(struct sk_buff *skb, struct Qdisc *sch)
    351351{
     
    357357    {
    358358        sch->q.qlen++;
    359 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
     359#  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
    360360        sch->qstats.requeues++;
    361 #endif
     361#  endif
    362362    }
    363363
    364364    return rc;
    365365}
    366 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     366# endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
    367367
    368368static unsigned int vboxNetFltQdiscDrop(struct Qdisc *sch)
     
    385385}
    386386
    387 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
     387# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
    388388static 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) */
    390390static 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) */
    392392{
    393393    PVBOXNETQDISCPRIV pPriv = qdisc_priv(sch);
     
    454454    *ppOld = pPriv->pChild;
    455455    pPriv->pChild = pNew;
    456 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
     456# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
    457457    sch->q.qlen = 0;
    458 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) */
     458# else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) */
    459459    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) */
    461461    qdisc_reset(*ppOld);
    462462    sch_tree_unlock(sch);
     
    480480}
    481481
    482 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
     482# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
    483483static int vboxNetFltClassChange(struct Qdisc *sch, u32 classid, u32 parentid,
    484484                                 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) */
    486486static int vboxNetFltClassChange(struct Qdisc *sch, u32 classid, u32 parentid,
    487487                                 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) */
    489489{
    490490    return -ENOSYS;
     
    548548    .enqueue   = vboxNetFltQdiscEnqueue,
    549549    .dequeue   = vboxNetFltQdiscDequeue,
    550 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     550# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
    551551    .requeue   = vboxNetFltQdiscRequeue,
    552 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     552# else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
    553553    .peek      = qdisc_peek_dequeued,
    554 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     554# endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
    555555    .drop      = vboxNetFltQdiscDrop,
    556556    .init      = vboxNetFltQdiscInit,
     
    572572static void vboxNetFltLinuxQdiscInstall(PVBOXNETFLTINS pThis, struct net_device *pDev)
    573573{
    574 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     574# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
    575575    int i;
    576 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     576# endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
    577577    PVBOXNETQDISCPRIV pPriv;
    578578
     
    609609         * qdisc is already 1.
    610610         */
    611 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
     611# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
    612612        pPriv->ppSaved[0] = pDev->qdisc_sleeping;
    613613        ASMAtomicWritePtr(&pDev->qdisc_sleeping, pNew);
    614614        ASMAtomicWritePtr(&pDev->qdisc, pNew);
    615 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     615# else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
    616616        for (i = 0; i < pDev->num_tx_queues; i++)
    617617        {
     
    625625        }
    626626        /* 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)
    628628        pPriv->ppSaved[pDev->num_tx_queues] = pDev->qdisc;
    629629        ASMAtomicWritePtr(&pDev->qdisc, pNew);
    630630        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) */
    633633        /* Synch the queue len with our child */
    634634        pNew->q.qlen = pPriv->pChild->q.qlen;
     
    645645static void vboxNetFltLinuxQdiscRemove(PVBOXNETFLTINS pThis, struct net_device *pDev)
    646646{
    647 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     647# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
    648648    int i;
    649 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     649# endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
    650650    PVBOXNETQDISCPRIV pPriv;
    651651    struct Qdisc *pQdisc, *pChild;
     
    677677    QDISC_LOG(("vboxNetFltLinuxQdiscRemove: refcnt=%d num_tx_queues=%d\n",
    678678               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)
    680680    /* Play it safe, make sure the qdisc is not being used. */
    681681    if (pPriv->ppSaved[0])
     
    688688        qdisc_destroy(pQdisc); /* Destroy reference */
    689689    }
    690 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     690# else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
    691691    for (i = 0; i < pDev->num_tx_queues; i++)
    692692    {
     
    704704    }
    705705    /* 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)
    707707    ASMAtomicWritePtr(&pDev->qdisc, pPriv->ppSaved[pDev->num_tx_queues]);
    708708    pPriv->ppSaved[pDev->num_tx_queues] = NULL;
     
    710710        yield();
    711711    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) */
    714714
    715715    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette