/* Does 'skb' fits after 'here' in the queue 'head' ? * If yes, we queue it and return 1 */ static int mptcp_ofo_queue_after(struct sk_buff_head *head, struct sk_buff *skb, struct sk_buff *here) { u32 seq = TCP_SKB_CB(skb)->seq; u32 end_seq = TCP_SKB_CB(skb)->end_seq; /* We want to queue skb after here, thus seq >= end_seq */ if (before(seq, TCP_SKB_CB(here)->end_seq)) return 0; /* If here is the last one, we can always queue it */ if (skb_queue_is_last(head, here)) { __skb_queue_after(head, here, skb); return 1; } else { struct sk_buff *skb1 = skb_queue_next(head, here); /* It's not the last one, but does it fits between 'here' and * the one after 'here' ? Thus, does end_seq <= after_here->seq */ if (!after(end_seq, TCP_SKB_CB(skb1)->seq)) { __skb_queue_after(head, here, skb); return 1; } } return 0; }
static void tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch) { struct sk_buff_head *list = &sch->q; psched_time_t tnext = netem_skb_cb(nskb)->time_to_send; struct sk_buff *skb = skb_peek_tail(list); /* Optimize for add at tail */ if (likely(!skb || tnext >= netem_skb_cb(skb)->time_to_send)) return __skb_queue_tail(list, nskb); skb_queue_reverse_walk(list, skb) { if (tnext >= netem_skb_cb(skb)->time_to_send) break; } __skb_queue_after(list, skb, nskb); }
static int tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch) { struct sk_buff_head *list = &sch->q; psched_time_t tnext = netem_skb_cb(nskb)->time_to_send; struct sk_buff *skb; if (likely(skb_queue_len(list) < sch->limit)) { skb = skb_peek_tail(list); /* Optimize for add at tail */ if (likely(!skb || tnext >= netem_skb_cb(skb)->time_to_send)) return qdisc_enqueue_tail(nskb, sch); skb_queue_reverse_walk(list, skb) { if (tnext >= netem_skb_cb(skb)->time_to_send) break; } __skb_queue_after(list, skb, nskb); sch->qstats.backlog += qdisc_pkt_len(nskb); return NET_XMIT_SUCCESS; }