diff options
author | David S. Miller <davem@davemloft.net> | 2008-09-22 01:36:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-22 01:36:24 -0400 |
commit | 67fed45930fa31e92c11beb3a3dbf83a1a92a58d (patch) | |
tree | 7c7aa03a8cc730b109193a8fd127b83f69187e85 /include | |
parent | ceade961c4c8d8bc033dc7907047818c9525c326 (diff) |
net: Add new interfaces for SKB list light-weight init and splicing.
This will be used by subsequent changesets.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/skbuff.h | 96 |
1 files changed, 94 insertions, 2 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index aa80ad9cbc88..027b06170b40 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -660,6 +660,22 @@ static inline __u32 skb_queue_len(const struct sk_buff_head *list_) | |||
660 | return list_->qlen; | 660 | return list_->qlen; |
661 | } | 661 | } |
662 | 662 | ||
663 | /** | ||
664 | * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head | ||
665 | * @list: queue to initialize | ||
666 | * | ||
667 | * This initializes only the list and queue length aspects of | ||
668 | * an sk_buff_head object. This allows to initialize the list | ||
669 | * aspects of an sk_buff_head without reinitializing things like | ||
670 | * the spinlock. It can also be used for on-stack sk_buff_head | ||
671 | * objects where the spinlock is known to not be used. | ||
672 | */ | ||
673 | static inline void __skb_queue_head_init(struct sk_buff_head *list) | ||
674 | { | ||
675 | list->prev = list->next = (struct sk_buff *)list; | ||
676 | list->qlen = 0; | ||
677 | } | ||
678 | |||
663 | /* | 679 | /* |
664 | * This function creates a split out lock class for each invocation; | 680 | * This function creates a split out lock class for each invocation; |
665 | * this is needed for now since a whole lot of users of the skb-queue | 681 | * this is needed for now since a whole lot of users of the skb-queue |
@@ -671,8 +687,7 @@ static inline __u32 skb_queue_len(const struct sk_buff_head *list_) | |||
671 | static inline void skb_queue_head_init(struct sk_buff_head *list) | 687 | static inline void skb_queue_head_init(struct sk_buff_head *list) |
672 | { | 688 | { |
673 | spin_lock_init(&list->lock); | 689 | spin_lock_init(&list->lock); |
674 | list->prev = list->next = (struct sk_buff *)list; | 690 | __skb_queue_head_init(list); |
675 | list->qlen = 0; | ||
676 | } | 691 | } |
677 | 692 | ||
678 | static inline void skb_queue_head_init_class(struct sk_buff_head *list, | 693 | static inline void skb_queue_head_init_class(struct sk_buff_head *list, |
@@ -699,6 +714,83 @@ static inline void __skb_insert(struct sk_buff *newsk, | |||
699 | list->qlen++; | 714 | list->qlen++; |
700 | } | 715 | } |
701 | 716 | ||
717 | static inline void __skb_queue_splice(const struct sk_buff_head *list, | ||
718 | struct sk_buff *prev, | ||
719 | struct sk_buff *next) | ||
720 | { | ||
721 | struct sk_buff *first = list->next; | ||
722 | struct sk_buff *last = list->prev; | ||
723 | |||
724 | first->prev = prev; | ||
725 | prev->next = first; | ||
726 | |||
727 | last->next = next; | ||
728 | next->prev = last; | ||
729 | } | ||
730 | |||
731 | /** | ||
732 | * skb_queue_splice - join two skb lists, this is designed for stacks | ||
733 | * @list: the new list to add | ||
734 | * @head: the place to add it in the first list | ||
735 | */ | ||
736 | static inline void skb_queue_splice(const struct sk_buff_head *list, | ||
737 | struct sk_buff_head *head) | ||
738 | { | ||
739 | if (!skb_queue_empty(list)) { | ||
740 | __skb_queue_splice(list, (struct sk_buff *) head, head->next); | ||
741 | head->qlen = list->qlen; | ||
742 | } | ||
743 | } | ||
744 | |||
745 | /** | ||
746 | * skb_queue_splice - join two skb lists and reinitialise the emptied list | ||
747 | * @list: the new list to add | ||
748 | * @head: the place to add it in the first list | ||
749 | * | ||
750 | * The list at @list is reinitialised | ||
751 | */ | ||
752 | static inline void skb_queue_splice_init(struct sk_buff_head *list, | ||
753 | struct sk_buff_head *head) | ||
754 | { | ||
755 | if (!skb_queue_empty(list)) { | ||
756 | __skb_queue_splice(list, (struct sk_buff *) head, head->next); | ||
757 | head->qlen = list->qlen; | ||
758 | __skb_queue_head_init(list); | ||
759 | } | ||
760 | } | ||
761 | |||
762 | /** | ||
763 | * skb_queue_splice_tail - join two skb lists, each list being a queue | ||
764 | * @list: the new list to add | ||
765 | * @head: the place to add it in the first list | ||
766 | */ | ||
767 | static inline void skb_queue_splice_tail(const struct sk_buff_head *list, | ||
768 | struct sk_buff_head *head) | ||
769 | { | ||
770 | if (!skb_queue_empty(list)) { | ||
771 | __skb_queue_splice(list, head->prev, (struct sk_buff *) head); | ||
772 | head->qlen = list->qlen; | ||
773 | } | ||
774 | } | ||
775 | |||
776 | /** | ||
777 | * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list | ||
778 | * @list: the new list to add | ||
779 | * @head: the place to add it in the first list | ||
780 | * | ||
781 | * Each of the lists is a queue. | ||
782 | * The list at @list is reinitialised | ||
783 | */ | ||
784 | static inline void skb_queue_splice_tail_init(struct sk_buff_head *list, | ||
785 | struct sk_buff_head *head) | ||
786 | { | ||
787 | if (!skb_queue_empty(list)) { | ||
788 | __skb_queue_splice(list, head->prev, (struct sk_buff *) head); | ||
789 | head->qlen = list->qlen; | ||
790 | __skb_queue_head_init(list); | ||
791 | } | ||
792 | } | ||
793 | |||
702 | /** | 794 | /** |
703 | * __skb_queue_after - queue a buffer at the list head | 795 | * __skb_queue_after - queue a buffer at the list head |
704 | * @list: list to use | 796 | * @list: list to use |