1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef _LINUX_SKBUFF_H
15#define _LINUX_SKBUFF_H
16
17#include <linux/kernel.h>
18#include <linux/kmemcheck.h>
19#include <linux/compiler.h>
20#include <linux/time.h>
21#include <linux/cache.h>
22
23#include <asm/atomic.h>
24#include <asm/types.h>
25#include <linux/spinlock.h>
26#include <linux/net.h>
27#include <linux/textsearch.h>
28#include <net/checksum.h>
29#include <linux/rcupdate.h>
30#include <linux/dmaengine.h>
31#include <linux/hrtimer.h>
32
33
34#define CHECKSUM_NONE 0
35#define CHECKSUM_UNNECESSARY 1
36#define CHECKSUM_COMPLETE 2
37#define CHECKSUM_PARTIAL 3
38
39#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \
40 ~(SMP_CACHE_BYTES - 1))
41#define SKB_WITH_OVERHEAD(X) \
42 ((X) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
43#define SKB_MAX_ORDER(X, ORDER) \
44 SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
45#define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0))
46#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2))
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94struct net_device;
95struct scatterlist;
96struct pipe_inode_info;
97
98#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
99struct nf_conntrack {
100 atomic_t use;
101};
102#endif
103
104#ifdef CONFIG_BRIDGE_NETFILTER
105struct nf_bridge_info {
106 atomic_t use;
107 struct net_device *physindev;
108 struct net_device *physoutdev;
109 unsigned int mask;
110 unsigned long data[32 / sizeof(unsigned long)];
111};
112#endif
113
114struct sk_buff_head {
115
116 struct sk_buff *next;
117 struct sk_buff *prev;
118
119 __u32 qlen;
120 spinlock_t lock;
121};
122
123struct sk_buff;
124
125
126#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 2)
127
128typedef struct skb_frag_struct skb_frag_t;
129
130struct skb_frag_struct {
131 struct page *page;
132 __u32 page_offset;
133 __u32 size;
134};
135
136#define HAVE_HW_TIME_STAMP
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161struct skb_shared_hwtstamps {
162 ktime_t hwtstamp;
163 ktime_t syststamp;
164};
165
166
167
168
169
170
171
172
173
174
175
176
177union skb_shared_tx {
178 struct {
179 __u8 hardware:1,
180 software:1,
181 in_progress:1;
182 };
183 __u8 flags;
184};
185
186
187
188
189struct skb_shared_info {
190 atomic_t dataref;
191 unsigned short nr_frags;
192 unsigned short gso_size;
193#ifdef CONFIG_HAS_DMA
194 dma_addr_t dma_head;
195#endif
196
197 unsigned short gso_segs;
198 unsigned short gso_type;
199 __be32 ip6_frag_id;
200 union skb_shared_tx tx_flags;
201 struct sk_buff *frag_list;
202 struct skb_shared_hwtstamps hwtstamps;
203 skb_frag_t frags[MAX_SKB_FRAGS];
204#ifdef CONFIG_HAS_DMA
205 dma_addr_t dma_maps[MAX_SKB_FRAGS];
206#endif
207
208
209 void * destructor_arg;
210};
211
212
213
214
215
216
217
218
219
220
221
222
223#define SKB_DATAREF_SHIFT 16
224#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
225
226
227enum {
228 SKB_FCLONE_UNAVAILABLE,
229 SKB_FCLONE_ORIG,
230 SKB_FCLONE_CLONE,
231};
232
233enum {
234 SKB_GSO_TCPV4 = 1 << 0,
235 SKB_GSO_UDP = 1 << 1,
236
237
238 SKB_GSO_DODGY = 1 << 2,
239
240
241 SKB_GSO_TCP_ECN = 1 << 3,
242
243 SKB_GSO_TCPV6 = 1 << 4,
244
245 SKB_GSO_FCOE = 1 << 5,
246};
247
248#if BITS_PER_LONG > 32
249#define NET_SKBUFF_DATA_USES_OFFSET 1
250#endif
251
252#ifdef NET_SKBUFF_DATA_USES_OFFSET
253typedef unsigned int sk_buff_data_t;
254#else
255typedef unsigned char *sk_buff_data_t;
256#endif
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314struct sk_buff {
315
316 struct sk_buff *next;
317 struct sk_buff *prev;
318
319 struct sock *sk;
320 ktime_t tstamp;
321 struct net_device *dev;
322
323 unsigned long _skb_dst;
324#ifdef CONFIG_XFRM
325 struct sec_path *sp;
326#endif
327
328
329
330
331
332
333 char cb[48];
334
335 unsigned int len,
336 data_len;
337 __u16 mac_len,
338 hdr_len;
339 union {
340 __wsum csum;
341 struct {
342 __u16 csum_start;
343 __u16 csum_offset;
344 };
345 };
346 __u32 priority;
347 kmemcheck_bitfield_begin(flags1);
348 __u8 local_df:1,
349 cloned:1,
350 ip_summed:2,
351 nohdr:1,
352 nfctinfo:3;
353 __u8 pkt_type:3,
354 fclone:2,
355 ipvs_property:1,
356 peeked:1,
357 nf_trace:1;
358 kmemcheck_bitfield_end(flags1);
359 __be16 protocol;
360
361 void (*destructor)(struct sk_buff *skb);
362#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
363 struct nf_conntrack *nfct;
364 struct sk_buff *nfct_reasm;
365#endif
366#ifdef CONFIG_BRIDGE_NETFILTER
367 struct nf_bridge_info *nf_bridge;
368#endif
369
370 int iif;
371 __u16 queue_mapping;
372#ifdef CONFIG_NET_SCHED
373 __u16 tc_index;
374#ifdef CONFIG_NET_CLS_ACT
375 __u16 tc_verd;
376#endif
377#endif
378
379 kmemcheck_bitfield_begin(flags2);
380#ifdef CONFIG_IPV6_NDISC_NODETYPE
381 __u8 ndisc_nodetype:2;
382#endif
383#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE)
384 __u8 do_not_encrypt:1;
385#endif
386 kmemcheck_bitfield_end(flags2);
387
388
389
390#ifdef CONFIG_NET_DMA
391 dma_cookie_t dma_cookie;
392#endif
393#ifdef CONFIG_NETWORK_SECMARK
394 __u32 secmark;
395#endif
396
397 __u32 mark;
398
399 __u16 vlan_tci;
400
401 sk_buff_data_t transport_header;
402 sk_buff_data_t network_header;
403 sk_buff_data_t mac_header;
404
405 sk_buff_data_t tail;
406 sk_buff_data_t end;
407 unsigned char *head,
408 *data;
409 unsigned int truesize;
410 atomic_t users;
411};
412
413#ifdef __KERNEL__
414
415
416
417#include <linux/slab.h>
418
419#include <asm/system.h>
420
421#ifdef CONFIG_HAS_DMA
422#include <linux/dma-mapping.h>
423extern int skb_dma_map(struct device *dev, struct sk_buff *skb,
424 enum dma_data_direction dir);
425extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
426 enum dma_data_direction dir);
427#endif
428
429static inline struct dst_entry *skb_dst(const struct sk_buff *skb)
430{
431 return (struct dst_entry *)skb->_skb_dst;
432}
433
434static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
435{
436 skb->_skb_dst = (unsigned long)dst;
437}
438
439static inline struct rtable *skb_rtable(const struct sk_buff *skb)
440{
441 return (struct rtable *)skb_dst(skb);
442}
443
444extern void kfree_skb(struct sk_buff *skb);
445extern void consume_skb(struct sk_buff *skb);
446extern void __kfree_skb(struct sk_buff *skb);
447extern struct sk_buff *__alloc_skb(unsigned int size,
448 gfp_t priority, int fclone, int node);
449static inline struct sk_buff *alloc_skb(unsigned int size,
450 gfp_t priority)
451{
452 return __alloc_skb(size, priority, 0, -1);
453}
454
455static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
456 gfp_t priority)
457{
458 return __alloc_skb(size, priority, 1, -1);
459}
460
461extern int skb_recycle_check(struct sk_buff *skb, int skb_size);
462
463extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src);
464extern struct sk_buff *skb_clone(struct sk_buff *skb,
465 gfp_t priority);
466extern struct sk_buff *skb_copy(const struct sk_buff *skb,
467 gfp_t priority);
468extern struct sk_buff *pskb_copy(struct sk_buff *skb,
469 gfp_t gfp_mask);
470extern int pskb_expand_head(struct sk_buff *skb,
471 int nhead, int ntail,
472 gfp_t gfp_mask);
473extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
474 unsigned int headroom);
475extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
476 int newheadroom, int newtailroom,
477 gfp_t priority);
478extern int skb_to_sgvec(struct sk_buff *skb,
479 struct scatterlist *sg, int offset,
480 int len);
481extern int skb_cow_data(struct sk_buff *skb, int tailbits,
482 struct sk_buff **trailer);
483extern int skb_pad(struct sk_buff *skb, int pad);
484#define dev_kfree_skb(a) consume_skb(a)
485#define dev_consume_skb(a) kfree_skb_clean(a)
486extern void skb_over_panic(struct sk_buff *skb, int len,
487 void *here);
488extern void skb_under_panic(struct sk_buff *skb, int len,
489 void *here);
490
491extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
492 int getfrag(void *from, char *to, int offset,
493 int len,int odd, struct sk_buff *skb),
494 void *from, int length);
495
496struct skb_seq_state
497{
498 __u32 lower_offset;
499 __u32 upper_offset;
500 __u32 frag_idx;
501 __u32 stepped_offset;
502 struct sk_buff *root_skb;
503 struct sk_buff *cur_skb;
504 __u8 *frag_data;
505};
506
507extern void skb_prepare_seq_read(struct sk_buff *skb,
508 unsigned int from, unsigned int to,
509 struct skb_seq_state *st);
510extern unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
511 struct skb_seq_state *st);
512extern void skb_abort_seq_read(struct skb_seq_state *st);
513
514extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
515 unsigned int to, struct ts_config *config,
516 struct ts_state *state);
517
518#ifdef NET_SKBUFF_DATA_USES_OFFSET
519static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
520{
521 return skb->head + skb->end;
522}
523#else
524static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
525{
526 return skb->end;
527}
528#endif
529
530
531#define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB)))
532
533static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
534{
535 return &skb_shinfo(skb)->hwtstamps;
536}
537
538static inline union skb_shared_tx *skb_tx(struct sk_buff *skb)
539{
540 return &skb_shinfo(skb)->tx_flags;
541}
542
543
544
545
546
547
548
549static inline int skb_queue_empty(const struct sk_buff_head *list)
550{
551 return list->next == (struct sk_buff *)list;
552}
553
554
555
556
557
558
559
560
561static inline bool skb_queue_is_last(const struct sk_buff_head *list,
562 const struct sk_buff *skb)
563{
564 return (skb->next == (struct sk_buff *) list);
565}
566
567
568
569
570
571
572
573
574static inline bool skb_queue_is_first(const struct sk_buff_head *list,
575 const struct sk_buff *skb)
576{
577 return (skb->prev == (struct sk_buff *) list);
578}
579
580
581
582
583
584
585
586
587
588static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list,
589 const struct sk_buff *skb)
590{
591
592
593
594 BUG_ON(skb_queue_is_last(list, skb));
595 return skb->next;
596}
597
598
599
600
601
602
603
604
605
606static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list,
607 const struct sk_buff *skb)
608{
609
610
611
612 BUG_ON(skb_queue_is_first(list, skb));
613 return skb->prev;
614}
615
616
617
618
619
620
621
622
623static inline struct sk_buff *skb_get(struct sk_buff *skb)
624{
625 atomic_inc(&skb->users);
626 return skb;
627}
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642static inline int skb_cloned(const struct sk_buff *skb)
643{
644 return skb->cloned &&
645 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1;
646}
647
648
649
650
651
652
653
654
655static inline int skb_header_cloned(const struct sk_buff *skb)
656{
657 int dataref;
658
659 if (!skb->cloned)
660 return 0;
661
662 dataref = atomic_read(&skb_shinfo(skb)->dataref);
663 dataref = (dataref & SKB_DATAREF_MASK) - (dataref >> SKB_DATAREF_SHIFT);
664 return dataref != 1;
665}
666
667
668
669
670
671
672
673
674
675static inline void skb_header_release(struct sk_buff *skb)
676{
677 BUG_ON(skb->nohdr);
678 skb->nohdr = 1;
679 atomic_add(1 << SKB_DATAREF_SHIFT, &skb_shinfo(skb)->dataref);
680}
681
682
683
684
685
686
687
688
689static inline int skb_shared(const struct sk_buff *skb)
690{
691 return atomic_read(&skb->users) != 1;
692}
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707static inline struct sk_buff *skb_share_check(struct sk_buff *skb,
708 gfp_t pri)
709{
710 might_sleep_if(pri & __GFP_WAIT);
711 if (skb_shared(skb)) {
712 struct sk_buff *nskb = skb_clone(skb, pri);
713 kfree_skb(skb);
714 skb = nskb;
715 }
716 return skb;
717}
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739static inline struct sk_buff *skb_unshare(struct sk_buff *skb,
740 gfp_t pri)
741{
742 might_sleep_if(pri & __GFP_WAIT);
743 if (skb_cloned(skb)) {
744 struct sk_buff *nskb = skb_copy(skb, pri);
745 kfree_skb(skb);
746 skb = nskb;
747 }
748 return skb;
749}
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764static inline struct sk_buff *skb_peek(struct sk_buff_head *list_)
765{
766 struct sk_buff *list = ((struct sk_buff *)list_)->next;
767 if (list == (struct sk_buff *)list_)
768 list = NULL;
769 return list;
770}
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785static inline struct sk_buff *skb_peek_tail(struct sk_buff_head *list_)
786{
787 struct sk_buff *list = ((struct sk_buff *)list_)->prev;
788 if (list == (struct sk_buff *)list_)
789 list = NULL;
790 return list;
791}
792
793
794
795
796
797
798
799static inline __u32 skb_queue_len(const struct sk_buff_head *list_)
800{
801 return list_->qlen;
802}
803
804
805
806
807
808
809
810
811
812
813
814static inline void __skb_queue_head_init(struct sk_buff_head *list)
815{
816 list->prev = list->next = (struct sk_buff *)list;
817 list->qlen = 0;
818}
819
820
821
822
823
824
825
826
827
828static inline void skb_queue_head_init(struct sk_buff_head *list)
829{
830 spin_lock_init(&list->lock);
831 __skb_queue_head_init(list);
832}
833
834static inline void skb_queue_head_init_class(struct sk_buff_head *list,
835 struct lock_class_key *class)
836{
837 skb_queue_head_init(list);
838 lockdep_set_class(&list->lock, class);
839}
840
841
842
843
844
845
846
847extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
848static inline void __skb_insert(struct sk_buff *newsk,
849 struct sk_buff *prev, struct sk_buff *next,
850 struct sk_buff_head *list)
851{
852 newsk->next = next;
853 newsk->prev = prev;
854 next->prev = prev->next = newsk;
855 list->qlen++;
856}
857
858static inline void __skb_queue_splice(const struct sk_buff_head *list,
859 struct sk_buff *prev,
860 struct sk_buff *next)
861{
862 struct sk_buff *first = list->next;
863 struct sk_buff *last = list->prev;
864
865 first->prev = prev;
866 prev->next = first;
867
868 last->next = next;
869 next->prev = last;
870}
871
872
873
874
875
876
877static inline void skb_queue_splice(const struct sk_buff_head *list,
878 struct sk_buff_head *head)
879{
880 if (!skb_queue_empty(list)) {
881 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
882 head->qlen += list->qlen;
883 }
884}
885
886
887
888
889
890
891
892
893static inline void skb_queue_splice_init(struct sk_buff_head *list,
894 struct sk_buff_head *head)
895{
896 if (!skb_queue_empty(list)) {
897 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
898 head->qlen += list->qlen;
899 __skb_queue_head_init(list);
900 }
901}
902
903
904
905
906
907
908static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
909 struct sk_buff_head *head)
910{
911 if (!skb_queue_empty(list)) {
912 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
913 head->qlen += list->qlen;
914 }
915}
916
917
918
919
920
921
922
923
924
925static inline void skb_queue_splice_tail_init(struct sk_buff_head *list,
926 struct sk_buff_head *head)
927{
928 if (!skb_queue_empty(list)) {
929 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
930 head->qlen += list->qlen;
931 __skb_queue_head_init(list);
932 }
933}
934
935
936
937
938
939
940
941
942
943
944
945
946static inline void __skb_queue_after(struct sk_buff_head *list,
947 struct sk_buff *prev,
948 struct sk_buff *newsk)
949{
950 __skb_insert(newsk, prev, prev->next, list);
951}
952
953extern void skb_append(struct sk_buff *old, struct sk_buff *newsk,
954 struct sk_buff_head *list);
955
956static inline void __skb_queue_before(struct sk_buff_head *list,
957 struct sk_buff *next,
958 struct sk_buff *newsk)
959{
960 __skb_insert(newsk, next->prev, next, list);
961}
962
963
964
965
966
967
968
969
970
971
972
973extern void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk);
974static inline void __skb_queue_head(struct sk_buff_head *list,
975 struct sk_buff *newsk)
976{
977 __skb_queue_after(list, (struct sk_buff *)list, newsk);
978}
979
980
981
982
983
984
985
986
987
988
989
990extern void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
991static inline void __skb_queue_tail(struct sk_buff_head *list,
992 struct sk_buff *newsk)
993{
994 __skb_queue_before(list, (struct sk_buff *)list, newsk);
995}
996
997
998
999
1000
1001extern void skb_unlink(struct sk_buff *skb, struct sk_buff_head *list);
1002static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
1003{
1004 struct sk_buff *next, *prev;
1005
1006 list->qlen--;
1007 next = skb->next;
1008 prev = skb->prev;
1009 skb->next = skb->prev = NULL;
1010 next->prev = prev;
1011 prev->next = next;
1012}
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022extern struct sk_buff *skb_dequeue(struct sk_buff_head *list);
1023static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
1024{
1025 struct sk_buff *skb = skb_peek(list);
1026 if (skb)
1027 __skb_unlink(skb, list);
1028 return skb;
1029}
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039extern struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list);
1040static inline struct sk_buff *__skb_dequeue_tail(struct sk_buff_head *list)
1041{
1042 struct sk_buff *skb = skb_peek_tail(list);
1043 if (skb)
1044 __skb_unlink(skb, list);
1045 return skb;
1046}
1047
1048
1049static inline int skb_is_nonlinear(const struct sk_buff *skb)
1050{
1051 return skb->data_len;
1052}
1053
1054static inline unsigned int skb_headlen(const struct sk_buff *skb)
1055{
1056 return skb->len - skb->data_len;
1057}
1058
1059static inline int skb_pagelen(const struct sk_buff *skb)
1060{
1061 int i, len = 0;
1062
1063 for (i = (int)skb_shinfo(skb)->nr_frags - 1; i >= 0; i--)
1064 len += skb_shinfo(skb)->frags[i].size;
1065 return len + skb_headlen(skb);
1066}
1067
1068static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
1069 struct page *page, int off, int size)
1070{
1071 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1072
1073 frag->page = page;
1074 frag->page_offset = off;
1075 frag->size = size;
1076 skb_shinfo(skb)->nr_frags = i + 1;
1077}
1078
1079extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
1080 int off, int size);
1081
1082#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
1083#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frags(skb))
1084#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
1085
1086#ifdef NET_SKBUFF_DATA_USES_OFFSET
1087static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
1088{
1089 return skb->head + skb->tail;
1090}
1091
1092static inline void skb_reset_tail_pointer(struct sk_buff *skb)
1093{
1094 skb->tail = skb->data - skb->head;
1095}
1096
1097static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
1098{
1099 skb_reset_tail_pointer(skb);
1100 skb->tail += offset;
1101}
1102#else
1103static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
1104{
1105 return skb->tail;
1106}
1107
1108static inline void skb_reset_tail_pointer(struct sk_buff *skb)
1109{
1110 skb->tail = skb->data;
1111}
1112
1113static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
1114{
1115 skb->tail = skb->data + offset;
1116}
1117
1118#endif
1119
1120
1121
1122
1123extern unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
1124static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
1125{
1126 unsigned char *tmp = skb_tail_pointer(skb);
1127 SKB_LINEAR_ASSERT(skb);
1128 skb->tail += len;
1129 skb->len += len;
1130 return tmp;
1131}
1132
1133extern unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
1134static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
1135{
1136 skb->data -= len;
1137 skb->len += len;
1138 return skb->data;
1139}
1140
1141extern unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
1142static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len)
1143{
1144 skb->len -= len;
1145 BUG_ON(skb->len < skb->data_len);
1146 return skb->data += len;
1147}
1148
1149extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta);
1150
1151static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len)
1152{
1153 if (len > skb_headlen(skb) &&
1154 !__pskb_pull_tail(skb, len - skb_headlen(skb)))
1155 return NULL;
1156 skb->len -= len;
1157 return skb->data += len;
1158}
1159
1160static inline unsigned char *pskb_pull(struct sk_buff *skb, unsigned int len)
1161{
1162 return unlikely(len > skb->len) ? NULL : __pskb_pull(skb, len);
1163}
1164
1165static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len)
1166{
1167 if (likely(len <= skb_headlen(skb)))
1168 return 1;
1169 if (unlikely(len > skb->len))
1170 return 0;
1171 return __pskb_pull_tail(skb, len - skb_headlen(skb)) != NULL;
1172}
1173
1174
1175
1176
1177
1178
1179
1180static inline unsigned int skb_headroom(const struct sk_buff *skb)
1181{
1182 return skb->data - skb->head;
1183}
1184
1185
1186
1187
1188
1189
1190
1191static inline int skb_tailroom(const struct sk_buff *skb)
1192{
1193 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail;
1194}
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204static inline void skb_reserve(struct sk_buff *skb, int len)
1205{
1206 skb->data += len;
1207 skb->tail += len;
1208}
1209
1210#ifdef NET_SKBUFF_DATA_USES_OFFSET
1211static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
1212{
1213 return skb->head + skb->transport_header;
1214}
1215
1216static inline void skb_reset_transport_header(struct sk_buff *skb)
1217{
1218 skb->transport_header = skb->data - skb->head;
1219}
1220
1221static inline void skb_set_transport_header(struct sk_buff *skb,
1222 const int offset)
1223{
1224 skb_reset_transport_header(skb);
1225 skb->transport_header += offset;
1226}
1227
1228static inline unsigned char *skb_network_header(const struct sk_buff *skb)
1229{
1230 return skb->head + skb->network_header;
1231}
1232
1233static inline void skb_reset_network_header(struct sk_buff *skb)
1234{
1235 skb->network_header = skb->data - skb->head;
1236}
1237
1238static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
1239{
1240 skb_reset_network_header(skb);
1241 skb->network_header += offset;
1242}
1243
1244static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
1245{
1246 return skb->head + skb->mac_header;
1247}
1248
1249static inline int skb_mac_header_was_set(const struct sk_buff *skb)
1250{
1251 return skb->mac_header != ~0U;
1252}
1253
1254static inline void skb_reset_mac_header(struct sk_buff *skb)
1255{
1256 skb->mac_header = skb->data - skb->head;
1257}
1258
1259static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1260{
1261 skb_reset_mac_header(skb);
1262 skb->mac_header += offset;
1263}
1264
1265#else
1266
1267static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
1268{
1269 return skb->transport_header;
1270}
1271
1272static inline void skb_reset_transport_header(struct sk_buff *skb)
1273{
1274 skb->transport_header = skb->data;
1275}
1276
1277static inline void skb_set_transport_header(struct sk_buff *skb,
1278 const int offset)
1279{
1280 skb->transport_header = skb->data + offset;
1281}
1282
1283static inline unsigned char *skb_network_header(const struct sk_buff *skb)
1284{
1285 return skb->network_header;
1286}
1287
1288static inline void skb_reset_network_header(struct sk_buff *skb)
1289{
1290 skb->network_header = skb->data;
1291}
1292
1293static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
1294{
1295 skb->network_header = skb->data + offset;
1296}
1297
1298static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
1299{
1300 return skb->mac_header;
1301}
1302
1303static inline int skb_mac_header_was_set(const struct sk_buff *skb)
1304{
1305 return skb->mac_header != NULL;
1306}
1307
1308static inline void skb_reset_mac_header(struct sk_buff *skb)
1309{
1310 skb->mac_header = skb->data;
1311}
1312
1313static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1314{
1315 skb->mac_header = skb->data + offset;
1316}
1317#endif
1318
1319static inline int skb_transport_offset(const struct sk_buff *skb)
1320{
1321 return skb_transport_header(skb) - skb->data;
1322}
1323
1324static inline u32 skb_network_header_len(const struct sk_buff *skb)
1325{
1326 return skb->transport_header - skb->network_header;
1327}
1328
1329static inline int skb_network_offset(const struct sk_buff *skb)
1330{
1331 return skb_network_header(skb) - skb->data;
1332}
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354#ifndef NET_IP_ALIGN
1355#define NET_IP_ALIGN 2
1356#endif
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373#ifndef NET_SKB_PAD
1374#define NET_SKB_PAD 32
1375#endif
1376
1377extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
1378
1379static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
1380{
1381 if (unlikely(skb->data_len)) {
1382 WARN_ON(1);
1383 return;
1384 }
1385 skb->len = len;
1386 skb_set_tail_pointer(skb, len);
1387}
1388
1389extern void skb_trim(struct sk_buff *skb, unsigned int len);
1390
1391static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
1392{
1393 if (skb->data_len)
1394 return ___pskb_trim(skb, len);
1395 __skb_trim(skb, len);
1396 return 0;
1397}
1398
1399static inline int pskb_trim(struct sk_buff *skb, unsigned int len)
1400{
1401 return (len < skb->len) ? __pskb_trim(skb, len) : 0;
1402}
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413static inline void pskb_trim_unique(struct sk_buff *skb, unsigned int len)
1414{
1415 int err = pskb_trim(skb, len);
1416 BUG_ON(err);
1417}
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427static inline void skb_orphan(struct sk_buff *skb)
1428{
1429 if (skb->destructor)
1430 skb->destructor(skb);
1431 skb->destructor = NULL;
1432 skb->sk = NULL;
1433}
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443extern void skb_queue_purge(struct sk_buff_head *list);
1444static inline void __skb_queue_purge(struct sk_buff_head *list)
1445{
1446 struct sk_buff *skb;
1447 while ((skb = __skb_dequeue(list)) != NULL)
1448 kfree_skb(skb);
1449}
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
1464 gfp_t gfp_mask)
1465{
1466 struct sk_buff *skb = alloc_skb(length + NET_SKB_PAD, gfp_mask);
1467 if (likely(skb))
1468 skb_reserve(skb, NET_SKB_PAD);
1469 return skb;
1470}
1471
1472extern struct sk_buff *dev_alloc_skb(unsigned int length);
1473
1474extern struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
1475 unsigned int length, gfp_t gfp_mask);
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev,
1491 unsigned int length)
1492{
1493 return __netdev_alloc_skb(dev, length, GFP_ATOMIC);
1494}
1495
1496extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask);
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506static inline struct page *netdev_alloc_page(struct net_device *dev)
1507{
1508 return __netdev_alloc_page(dev, GFP_ATOMIC);
1509}
1510
1511static inline void netdev_free_page(struct net_device *dev, struct page *page)
1512{
1513 __free_page(page);
1514}
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524static inline int skb_clone_writable(struct sk_buff *skb, unsigned int len)
1525{
1526 return !skb_header_cloned(skb) &&
1527 skb_headroom(skb) + len <= skb->hdr_len;
1528}
1529
1530static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom,
1531 int cloned)
1532{
1533 int delta = 0;
1534
1535 if (headroom < NET_SKB_PAD)
1536 headroom = NET_SKB_PAD;
1537 if (headroom > skb_headroom(skb))
1538 delta = headroom - skb_headroom(skb);
1539
1540 if (delta || cloned)
1541 return pskb_expand_head(skb, ALIGN(delta, NET_SKB_PAD), 0,
1542 GFP_ATOMIC);
1543 return 0;
1544}
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558static inline int skb_cow(struct sk_buff *skb, unsigned int headroom)
1559{
1560 return __skb_cow(skb, headroom, skb_cloned(skb));
1561}
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
1574{
1575 return __skb_cow(skb, headroom, skb_header_cloned(skb));
1576}
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589static inline int skb_padto(struct sk_buff *skb, unsigned int len)
1590{
1591 unsigned int size = skb->len;
1592 if (likely(size >= len))
1593 return 0;
1594 return skb_pad(skb, len - size);
1595}
1596
1597static inline int skb_add_data(struct sk_buff *skb,
1598 char __user *from, int copy)
1599{
1600 const int off = skb->len;
1601
1602 if (skb->ip_summed == CHECKSUM_NONE) {
1603 int err = 0;
1604 __wsum csum = csum_and_copy_from_user(from, skb_put(skb, copy),
1605 copy, 0, &err);
1606 if (!err) {
1607 skb->csum = csum_block_add(skb->csum, csum, off);
1608 return 0;
1609 }
1610 } else if (!copy_from_user(skb_put(skb, copy), from, copy))
1611 return 0;
1612
1613 __skb_trim(skb, off);
1614 return -EFAULT;
1615}
1616
1617static inline int skb_can_coalesce(struct sk_buff *skb, int i,
1618 struct page *page, int off)
1619{
1620 if (i) {
1621 struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
1622
1623 return page == frag->page &&
1624 off == frag->page_offset + frag->size;
1625 }
1626 return 0;
1627}
1628
1629static inline int __skb_linearize(struct sk_buff *skb)
1630{
1631 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM;
1632}
1633
1634
1635
1636
1637
1638
1639
1640
1641static inline int skb_linearize(struct sk_buff *skb)
1642{
1643 return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0;
1644}
1645
1646
1647
1648
1649
1650
1651
1652
1653static inline int skb_linearize_cow(struct sk_buff *skb)
1654{
1655 return skb_is_nonlinear(skb) || skb_cloned(skb) ?
1656 __skb_linearize(skb) : 0;
1657}
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670static inline void skb_postpull_rcsum(struct sk_buff *skb,
1671 const void *start, unsigned int len)
1672{
1673 if (skb->ip_summed == CHECKSUM_COMPLETE)
1674 skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0));
1675}
1676
1677unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
1689{
1690 if (likely(len >= skb->len))
1691 return 0;
1692 if (skb->ip_summed == CHECKSUM_COMPLETE)
1693 skb->ip_summed = CHECKSUM_NONE;
1694 return __pskb_trim(skb, len);
1695}
1696
1697#define skb_queue_walk(queue, skb) \
1698 for (skb = (queue)->next; \
1699 prefetch(skb->next), (skb != (struct sk_buff *)(queue)); \
1700 skb = skb->next)
1701
1702#define skb_queue_walk_safe(queue, skb, tmp) \
1703 for (skb = (queue)->next, tmp = skb->next; \
1704 skb != (struct sk_buff *)(queue); \
1705 skb = tmp, tmp = skb->next)
1706
1707#define skb_queue_walk_from(queue, skb) \
1708 for (; prefetch(skb->next), (skb != (struct sk_buff *)(queue)); \
1709 skb = skb->next)
1710
1711#define skb_queue_walk_from_safe(queue, skb, tmp) \
1712 for (tmp = skb->next; \
1713 skb != (struct sk_buff *)(queue); \
1714 skb = tmp, tmp = skb->next)
1715
1716#define skb_queue_reverse_walk(queue, skb) \
1717 for (skb = (queue)->prev; \
1718 prefetch(skb->prev), (skb != (struct sk_buff *)(queue)); \
1719 skb = skb->prev)
1720
1721
1722static inline bool skb_has_frags(const struct sk_buff *skb)
1723{
1724 return skb_shinfo(skb)->frag_list != NULL;
1725}
1726
1727static inline void skb_frag_list_init(struct sk_buff *skb)
1728{
1729 skb_shinfo(skb)->frag_list = NULL;
1730}
1731
1732static inline void skb_frag_add_head(struct sk_buff *skb, struct sk_buff *frag)
1733{
1734 frag->next = skb_shinfo(skb)->frag_list;
1735 skb_shinfo(skb)->frag_list = frag;
1736}
1737
1738#define skb_walk_frags(skb, iter) \
1739 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
1740
1741extern struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
1742 int *peeked, int *err);
1743extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
1744 int noblock, int *err);
1745extern unsigned int datagram_poll(struct file *file, struct socket *sock,
1746 struct poll_table_struct *wait);
1747extern int skb_copy_datagram_iovec(const struct sk_buff *from,
1748 int offset, struct iovec *to,
1749 int size);
1750extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
1751 int hlen,
1752 struct iovec *iov);
1753extern int skb_copy_datagram_from_iovec(struct sk_buff *skb,
1754 int offset,
1755 const struct iovec *from,
1756 int from_offset,
1757 int len);
1758extern int skb_copy_datagram_const_iovec(const struct sk_buff *from,
1759 int offset,
1760 const struct iovec *to,
1761 int to_offset,
1762 int size);
1763extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
1764extern int skb_kill_datagram(struct sock *sk, struct sk_buff *skb,
1765 unsigned int flags);
1766extern __wsum skb_checksum(const struct sk_buff *skb, int offset,
1767 int len, __wsum csum);
1768extern int skb_copy_bits(const struct sk_buff *skb, int offset,
1769 void *to, int len);
1770extern int skb_store_bits(struct sk_buff *skb, int offset,
1771 const void *from, int len);
1772extern __wsum skb_copy_and_csum_bits(const struct sk_buff *skb,
1773 int offset, u8 *to, int len,
1774 __wsum csum);
1775extern int skb_splice_bits(struct sk_buff *skb,
1776 unsigned int offset,
1777 struct pipe_inode_info *pipe,
1778 unsigned int len,
1779 unsigned int flags);
1780extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
1781extern void skb_split(struct sk_buff *skb,
1782 struct sk_buff *skb1, const u32 len);
1783extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
1784 int shiftlen);
1785
1786extern struct sk_buff *skb_segment(struct sk_buff *skb, int features);
1787
1788static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
1789 int len, void *buffer)
1790{
1791 int hlen = skb_headlen(skb);
1792
1793 if (hlen - offset >= len)
1794 return skb->data + offset;
1795
1796 if (skb_copy_bits(skb, offset, buffer, len) < 0)
1797 return NULL;
1798
1799 return buffer;
1800}
1801
1802static inline void skb_copy_from_linear_data(const struct sk_buff *skb,
1803 void *to,
1804 const unsigned int len)
1805{
1806 memcpy(to, skb->data, len);
1807}
1808
1809static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
1810 const int offset, void *to,
1811 const unsigned int len)
1812{
1813 memcpy(to, skb->data + offset, len);
1814}
1815
1816static inline void skb_copy_to_linear_data(struct sk_buff *skb,
1817 const void *from,
1818 const unsigned int len)
1819{
1820 memcpy(skb->data, from, len);
1821}
1822
1823static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
1824 const int offset,
1825 const void *from,
1826 const unsigned int len)
1827{
1828 memcpy(skb->data + offset, from, len);
1829}
1830
1831extern void skb_init(void);
1832
1833static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
1834{
1835 return skb->tstamp;
1836}
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847static inline void skb_get_timestamp(const struct sk_buff *skb,
1848 struct timeval *stamp)
1849{
1850 *stamp = ktime_to_timeval(skb->tstamp);
1851}
1852
1853static inline void skb_get_timestampns(const struct sk_buff *skb,
1854 struct timespec *stamp)
1855{
1856 *stamp = ktime_to_timespec(skb->tstamp);
1857}
1858
1859static inline void __net_timestamp(struct sk_buff *skb)
1860{
1861 skb->tstamp = ktime_get_real();
1862}
1863
1864static inline ktime_t net_timedelta(ktime_t t)
1865{
1866 return ktime_sub(ktime_get_real(), t);
1867}
1868
1869static inline ktime_t net_invalid_timestamp(void)
1870{
1871 return ktime_set(0, 0);
1872}
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885extern void skb_tstamp_tx(struct sk_buff *orig_skb,
1886 struct skb_shared_hwtstamps *hwtstamps);
1887
1888extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
1889extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
1890
1891static inline int skb_csum_unnecessary(const struct sk_buff *skb)
1892{
1893 return skb->ip_summed & CHECKSUM_UNNECESSARY;
1894}
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912static inline __sum16 skb_checksum_complete(struct sk_buff *skb)
1913{
1914 return skb_csum_unnecessary(skb) ?
1915 0 : __skb_checksum_complete(skb);
1916}
1917
1918#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
1919extern void nf_conntrack_destroy(struct nf_conntrack *nfct);
1920static inline void nf_conntrack_put(struct nf_conntrack *nfct)
1921{
1922 if (nfct && atomic_dec_and_test(&nfct->use))
1923 nf_conntrack_destroy(nfct);
1924}
1925static inline void nf_conntrack_get(struct nf_conntrack *nfct)
1926{
1927 if (nfct)
1928 atomic_inc(&nfct->use);
1929}
1930static inline void nf_conntrack_get_reasm(struct sk_buff *skb)
1931{
1932 if (skb)
1933 atomic_inc(&skb->users);
1934}
1935static inline void nf_conntrack_put_reasm(struct sk_buff *skb)
1936{
1937 if (skb)
1938 kfree_skb(skb);
1939}
1940#endif
1941#ifdef CONFIG_BRIDGE_NETFILTER
1942static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge)
1943{
1944 if (nf_bridge && atomic_dec_and_test(&nf_bridge->use))
1945 kfree(nf_bridge);
1946}
1947static inline void nf_bridge_get(struct nf_bridge_info *nf_bridge)
1948{
1949 if (nf_bridge)
1950 atomic_inc(&nf_bridge->use);
1951}
1952#endif
1953static inline void nf_reset(struct sk_buff *skb)
1954{
1955#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
1956 nf_conntrack_put(skb->nfct);
1957 skb->nfct = NULL;
1958 nf_conntrack_put_reasm(skb->nfct_reasm);
1959 skb->nfct_reasm = NULL;
1960#endif
1961#ifdef CONFIG_BRIDGE_NETFILTER
1962 nf_bridge_put(skb->nf_bridge);
1963 skb->nf_bridge = NULL;
1964#endif
1965}
1966
1967
1968static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
1969{
1970#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
1971 dst->nfct = src->nfct;
1972 nf_conntrack_get(src->nfct);
1973 dst->nfctinfo = src->nfctinfo;
1974 dst->nfct_reasm = src->nfct_reasm;
1975 nf_conntrack_get_reasm(src->nfct_reasm);
1976#endif
1977#ifdef CONFIG_BRIDGE_NETFILTER
1978 dst->nf_bridge = src->nf_bridge;
1979 nf_bridge_get(src->nf_bridge);
1980#endif
1981}
1982
1983static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src)
1984{
1985#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
1986 nf_conntrack_put(dst->nfct);
1987 nf_conntrack_put_reasm(dst->nfct_reasm);
1988#endif
1989#ifdef CONFIG_BRIDGE_NETFILTER
1990 nf_bridge_put(dst->nf_bridge);
1991#endif
1992 __nf_copy(dst, src);
1993}
1994
1995#ifdef CONFIG_NETWORK_SECMARK
1996static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from)
1997{
1998 to->secmark = from->secmark;
1999}
2000
2001static inline void skb_init_secmark(struct sk_buff *skb)
2002{
2003 skb->secmark = 0;
2004}
2005#else
2006static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from)
2007{ }
2008
2009static inline void skb_init_secmark(struct sk_buff *skb)
2010{ }
2011#endif
2012
2013static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
2014{
2015 skb->queue_mapping = queue_mapping;
2016}
2017
2018static inline u16 skb_get_queue_mapping(const struct sk_buff *skb)
2019{
2020 return skb->queue_mapping;
2021}
2022
2023static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_buff *from)
2024{
2025 to->queue_mapping = from->queue_mapping;
2026}
2027
2028static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue)
2029{
2030 skb->queue_mapping = rx_queue + 1;
2031}
2032
2033static inline u16 skb_get_rx_queue(const struct sk_buff *skb)
2034{
2035 return skb->queue_mapping - 1;
2036}
2037
2038static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
2039{
2040 return (skb->queue_mapping != 0);
2041}
2042
2043extern u16 skb_tx_hash(const struct net_device *dev,
2044 const struct sk_buff *skb);
2045
2046#ifdef CONFIG_XFRM
2047static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
2048{
2049 return skb->sp;
2050}
2051#else
2052static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
2053{
2054 return NULL;
2055}
2056#endif
2057
2058static inline int skb_is_gso(const struct sk_buff *skb)
2059{
2060 return skb_shinfo(skb)->gso_size;
2061}
2062
2063static inline int skb_is_gso_v6(const struct sk_buff *skb)
2064{
2065 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6;
2066}
2067
2068extern void __skb_warn_lro_forwarding(const struct sk_buff *skb);
2069
2070static inline bool skb_warn_if_lro(const struct sk_buff *skb)
2071{
2072
2073
2074 struct skb_shared_info *shinfo = skb_shinfo(skb);
2075 if (shinfo->gso_size != 0 && unlikely(shinfo->gso_type == 0)) {
2076 __skb_warn_lro_forwarding(skb);
2077 return true;
2078 }
2079 return false;
2080}
2081
2082static inline void skb_forward_csum(struct sk_buff *skb)
2083{
2084
2085 if (skb->ip_summed == CHECKSUM_COMPLETE)
2086 skb->ip_summed = CHECKSUM_NONE;
2087}
2088
2089bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
2090#endif
2091#endif
2092