__skb_dequeue()

_skb_dequeue() -- 将sk_buff链表的第一个节点从队列中摘除,并返回该节点

process_backlog()  --> __skb_dequeue() 

/usr/src/linux-2.6.19/include/linux/skbuff.h

static inline struct  sk_buff  *__skb_dequeue(struct  sk_buff_head  *list)
{
    struct sk_buff *next, *prev, *result;

    prev = (struct sk_buff *) list;
    next = prev->next;
    result = NULL;
    if (next != prev) {
        result       = next;                //(1)
        next         = next->next;
        list->qlen--;
        next->prev   = prev;                //(2)
        prev->next   = next;
        result->next = result->prev = NULL; //(3)
    }
    return result;
}


(1)
------------------------------------------------------------------
                         result --+
                                  |
prev -+                    next --+                             
      |                           |                          
      |    struct sk_buff_head    |     struct sk_buff            struct sk_buff 
list -+-->|--------------------| -| -|--------------------|    |--------------------|
          |struct sk_buff *next|--+->|struct sk_buff *next|--->|struct sk_buff *next|
          |--------------------|     |--------------------|    |--------------------|
          |struct sk_buff *prev|<----|struct sk_buff *prev|<---|struct sk_buff *prev|
          |--------------------|     |--------------------|    |--------------------|
          |__u32          qlen |     |                    |    |                    |
          |--------------------|     |--------------------|    |--------------------|
                                                             
                                                                 

(2)
------------------------------------------------------------------
                         result --+
                                  |
prev -+                           |                  next --+
      |                           |                         |
      |    struct sk_buff_head    |     struct sk_buff      |     struct sk_buff 
list -+-->|--------------------| -| -|--------------------| | -|--------------------|
          |struct sk_buff *next|--+->|struct sk_buff *next|-+->|struct sk_buff *next|
          |--------------------|     |--------------------|    |--------------------|
          |struct sk_buff *prev|<-+--|struct sk_buff *prev| +--|struct sk_buff *prev|
          |--------------------| -| -|--------------------| | -|--------------------|
          |__u32          qlen | -| -|                    | | -|                    |
          |--------------------| -| -|--------------------| | -|--------------------|
                                  |                         |
                                  +-------------------------+



(3)
------------------------------------------------------------------                                  
prev -+                                              next --+
      |                                                     |
      |    struct sk_buff_head                              |     struct sk_buff
list -+-->|--------------------|                            | -|--------------------|
          |struct sk_buff *next|----------------------------+->|struct sk_buff *next|
          |--------------------|                               |--------------------|
          |struct sk_buff *prev|<-+                         +--|struct sk_buff *prev|
          |--------------------| -|                         | -|--------------------|
          |__u32          qlen | -|                         | -|                    |
          |--------------------| -|                         | -|--------------------|
                                  |                         |
                                  +-------------------------+


                        result ---+
                                  |
                                  |     struct sk_buff
                                  | -|--------------------|
                                  +->|struct sk_buff *next|NULL
                                     |--------------------|
                                     |struct sk_buff *prev|NULL
                                     |--------------------|
                                     |                    |
                                     |--------------------|


你可能感兴趣的:(网络,linux,c)