aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h329
1 files changed, 148 insertions, 181 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c2d89335f637..6f69b3f914fb 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -318,9 +318,13 @@ enum {
318 318
319 SKB_GSO_GRE = 1 << 6, 319 SKB_GSO_GRE = 1 << 6,
320 320
321 SKB_GSO_UDP_TUNNEL = 1 << 7, 321 SKB_GSO_IPIP = 1 << 7,
322 322
323 SKB_GSO_MPLS = 1 << 8, 323 SKB_GSO_SIT = 1 << 8,
324
325 SKB_GSO_UDP_TUNNEL = 1 << 9,
326
327 SKB_GSO_MPLS = 1 << 10,
324}; 328};
325 329
326#if BITS_PER_LONG > 32 330#if BITS_PER_LONG > 32
@@ -333,11 +337,6 @@ typedef unsigned int sk_buff_data_t;
333typedef unsigned char *sk_buff_data_t; 337typedef unsigned char *sk_buff_data_t;
334#endif 338#endif
335 339
336#if defined(CONFIG_NF_DEFRAG_IPV4) || defined(CONFIG_NF_DEFRAG_IPV4_MODULE) || \
337 defined(CONFIG_NF_DEFRAG_IPV6) || defined(CONFIG_NF_DEFRAG_IPV6_MODULE)
338#define NET_SKBUFF_NF_DEFRAG_NEEDED 1
339#endif
340
341/** 340/**
342 * struct sk_buff - socket buffer 341 * struct sk_buff - socket buffer
343 * @next: Next buffer in list 342 * @next: Next buffer in list
@@ -370,7 +369,6 @@ typedef unsigned char *sk_buff_data_t;
370 * @protocol: Packet protocol from driver 369 * @protocol: Packet protocol from driver
371 * @destructor: Destruct function 370 * @destructor: Destruct function
372 * @nfct: Associated connection, if any 371 * @nfct: Associated connection, if any
373 * @nfct_reasm: netfilter conntrack re-assembly pointer
374 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c 372 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
375 * @skb_iif: ifindex of device we arrived on 373 * @skb_iif: ifindex of device we arrived on
376 * @tc_index: Traffic control index 374 * @tc_index: Traffic control index
@@ -459,9 +457,6 @@ struct sk_buff {
459#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 457#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
460 struct nf_conntrack *nfct; 458 struct nf_conntrack *nfct;
461#endif 459#endif
462#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
463 struct sk_buff *nfct_reasm;
464#endif
465#ifdef CONFIG_BRIDGE_NETFILTER 460#ifdef CONFIG_BRIDGE_NETFILTER
466 struct nf_bridge_info *nf_bridge; 461 struct nf_bridge_info *nf_bridge;
467#endif 462#endif
@@ -585,8 +580,8 @@ static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
585 skb->_skb_refdst = (unsigned long)dst; 580 skb->_skb_refdst = (unsigned long)dst;
586} 581}
587 582
588extern void __skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst, 583void __skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst,
589 bool force); 584 bool force);
590 585
591/** 586/**
592 * skb_dst_set_noref - sets skb dst, hopefully, without taking reference 587 * skb_dst_set_noref - sets skb dst, hopefully, without taking reference
@@ -634,20 +629,20 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
634 return (struct rtable *)skb_dst(skb); 629 return (struct rtable *)skb_dst(skb);
635} 630}
636 631
637extern void kfree_skb(struct sk_buff *skb); 632void kfree_skb(struct sk_buff *skb);
638extern void kfree_skb_list(struct sk_buff *segs); 633void kfree_skb_list(struct sk_buff *segs);
639extern void skb_tx_error(struct sk_buff *skb); 634void skb_tx_error(struct sk_buff *skb);
640extern void consume_skb(struct sk_buff *skb); 635void consume_skb(struct sk_buff *skb);
641extern void __kfree_skb(struct sk_buff *skb); 636void __kfree_skb(struct sk_buff *skb);
642extern struct kmem_cache *skbuff_head_cache; 637extern struct kmem_cache *skbuff_head_cache;
643 638
644extern void kfree_skb_partial(struct sk_buff *skb, bool head_stolen); 639void kfree_skb_partial(struct sk_buff *skb, bool head_stolen);
645extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, 640bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
646 bool *fragstolen, int *delta_truesize); 641 bool *fragstolen, int *delta_truesize);
647 642
648extern struct sk_buff *__alloc_skb(unsigned int size, 643struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags,
649 gfp_t priority, int flags, int node); 644 int node);
650extern struct sk_buff *build_skb(void *data, unsigned int frag_size); 645struct sk_buff *build_skb(void *data, unsigned int frag_size);
651static inline struct sk_buff *alloc_skb(unsigned int size, 646static inline struct sk_buff *alloc_skb(unsigned int size,
652 gfp_t priority) 647 gfp_t priority)
653{ 648{
@@ -660,41 +655,33 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
660 return __alloc_skb(size, priority, SKB_ALLOC_FCLONE, NUMA_NO_NODE); 655 return __alloc_skb(size, priority, SKB_ALLOC_FCLONE, NUMA_NO_NODE);
661} 656}
662 657
663extern struct sk_buff *__alloc_skb_head(gfp_t priority, int node); 658struct sk_buff *__alloc_skb_head(gfp_t priority, int node);
664static inline struct sk_buff *alloc_skb_head(gfp_t priority) 659static inline struct sk_buff *alloc_skb_head(gfp_t priority)
665{ 660{
666 return __alloc_skb_head(priority, -1); 661 return __alloc_skb_head(priority, -1);
667} 662}
668 663
669extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src); 664struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src);
670extern int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask); 665int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask);
671extern struct sk_buff *skb_clone(struct sk_buff *skb, 666struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t priority);
672 gfp_t priority); 667struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t priority);
673extern struct sk_buff *skb_copy(const struct sk_buff *skb, 668struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, gfp_t gfp_mask);
674 gfp_t priority); 669
675extern struct sk_buff *__pskb_copy(struct sk_buff *skb, 670int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, gfp_t gfp_mask);
676 int headroom, gfp_t gfp_mask); 671struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
677 672 unsigned int headroom);
678extern int pskb_expand_head(struct sk_buff *skb, 673struct sk_buff *skb_copy_expand(const struct sk_buff *skb, int newheadroom,
679 int nhead, int ntail, 674 int newtailroom, gfp_t priority);
680 gfp_t gfp_mask); 675int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset,
681extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, 676 int len);
682 unsigned int headroom); 677int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
683extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb, 678int skb_pad(struct sk_buff *skb, int pad);
684 int newheadroom, int newtailroom,
685 gfp_t priority);
686extern int skb_to_sgvec(struct sk_buff *skb,
687 struct scatterlist *sg, int offset,
688 int len);
689extern int skb_cow_data(struct sk_buff *skb, int tailbits,
690 struct sk_buff **trailer);
691extern int skb_pad(struct sk_buff *skb, int pad);
692#define dev_kfree_skb(a) consume_skb(a) 679#define dev_kfree_skb(a) consume_skb(a)
693 680
694extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb, 681int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
695 int getfrag(void *from, char *to, int offset, 682 int getfrag(void *from, char *to, int offset,
696 int len,int odd, struct sk_buff *skb), 683 int len, int odd, struct sk_buff *skb),
697 void *from, int length); 684 void *from, int length);
698 685
699struct skb_seq_state { 686struct skb_seq_state {
700 __u32 lower_offset; 687 __u32 lower_offset;
@@ -706,18 +693,17 @@ struct skb_seq_state {
706 __u8 *frag_data; 693 __u8 *frag_data;
707}; 694};
708 695
709extern void skb_prepare_seq_read(struct sk_buff *skb, 696void skb_prepare_seq_read(struct sk_buff *skb, unsigned int from,
710 unsigned int from, unsigned int to, 697 unsigned int to, struct skb_seq_state *st);
711 struct skb_seq_state *st); 698unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
712extern unsigned int skb_seq_read(unsigned int consumed, const u8 **data, 699 struct skb_seq_state *st);
713 struct skb_seq_state *st); 700void skb_abort_seq_read(struct skb_seq_state *st);
714extern void skb_abort_seq_read(struct skb_seq_state *st);
715 701
716extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, 702unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
717 unsigned int to, struct ts_config *config, 703 unsigned int to, struct ts_config *config,
718 struct ts_state *state); 704 struct ts_state *state);
719 705
720extern void __skb_get_rxhash(struct sk_buff *skb); 706void __skb_get_rxhash(struct sk_buff *skb);
721static inline __u32 skb_get_rxhash(struct sk_buff *skb) 707static inline __u32 skb_get_rxhash(struct sk_buff *skb)
722{ 708{
723 if (!skb->l4_rxhash) 709 if (!skb->l4_rxhash)
@@ -1095,7 +1081,8 @@ static inline void skb_queue_head_init_class(struct sk_buff_head *list,
1095 * The "__skb_xxxx()" functions are the non-atomic ones that 1081 * The "__skb_xxxx()" functions are the non-atomic ones that
1096 * can only be called with interrupts disabled. 1082 * can only be called with interrupts disabled.
1097 */ 1083 */
1098extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list); 1084void skb_insert(struct sk_buff *old, struct sk_buff *newsk,
1085 struct sk_buff_head *list);
1099static inline void __skb_insert(struct sk_buff *newsk, 1086static inline void __skb_insert(struct sk_buff *newsk,
1100 struct sk_buff *prev, struct sk_buff *next, 1087 struct sk_buff *prev, struct sk_buff *next,
1101 struct sk_buff_head *list) 1088 struct sk_buff_head *list)
@@ -1201,8 +1188,8 @@ static inline void __skb_queue_after(struct sk_buff_head *list,
1201 __skb_insert(newsk, prev, prev->next, list); 1188 __skb_insert(newsk, prev, prev->next, list);
1202} 1189}
1203 1190
1204extern void skb_append(struct sk_buff *old, struct sk_buff *newsk, 1191void skb_append(struct sk_buff *old, struct sk_buff *newsk,
1205 struct sk_buff_head *list); 1192 struct sk_buff_head *list);
1206 1193
1207static inline void __skb_queue_before(struct sk_buff_head *list, 1194static inline void __skb_queue_before(struct sk_buff_head *list,
1208 struct sk_buff *next, 1195 struct sk_buff *next,
@@ -1221,7 +1208,7 @@ static inline void __skb_queue_before(struct sk_buff_head *list,
1221 * 1208 *
1222 * A buffer cannot be placed on two lists at the same time. 1209 * A buffer cannot be placed on two lists at the same time.
1223 */ 1210 */
1224extern void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk); 1211void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk);
1225static inline void __skb_queue_head(struct sk_buff_head *list, 1212static inline void __skb_queue_head(struct sk_buff_head *list,
1226 struct sk_buff *newsk) 1213 struct sk_buff *newsk)
1227{ 1214{
@@ -1238,7 +1225,7 @@ static inline void __skb_queue_head(struct sk_buff_head *list,
1238 * 1225 *
1239 * A buffer cannot be placed on two lists at the same time. 1226 * A buffer cannot be placed on two lists at the same time.
1240 */ 1227 */
1241extern void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk); 1228void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
1242static inline void __skb_queue_tail(struct sk_buff_head *list, 1229static inline void __skb_queue_tail(struct sk_buff_head *list,
1243 struct sk_buff *newsk) 1230 struct sk_buff *newsk)
1244{ 1231{
@@ -1249,7 +1236,7 @@ static inline void __skb_queue_tail(struct sk_buff_head *list,
1249 * remove sk_buff from list. _Must_ be called atomically, and with 1236 * remove sk_buff from list. _Must_ be called atomically, and with
1250 * the list known.. 1237 * the list known..
1251 */ 1238 */
1252extern void skb_unlink(struct sk_buff *skb, struct sk_buff_head *list); 1239void skb_unlink(struct sk_buff *skb, struct sk_buff_head *list);
1253static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) 1240static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
1254{ 1241{
1255 struct sk_buff *next, *prev; 1242 struct sk_buff *next, *prev;
@@ -1270,7 +1257,7 @@ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
1270 * so must be used with appropriate locks held only. The head item is 1257 * so must be used with appropriate locks held only. The head item is
1271 * returned or %NULL if the list is empty. 1258 * returned or %NULL if the list is empty.
1272 */ 1259 */
1273extern struct sk_buff *skb_dequeue(struct sk_buff_head *list); 1260struct sk_buff *skb_dequeue(struct sk_buff_head *list);
1274static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list) 1261static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
1275{ 1262{
1276 struct sk_buff *skb = skb_peek(list); 1263 struct sk_buff *skb = skb_peek(list);
@@ -1287,7 +1274,7 @@ static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
1287 * so must be used with appropriate locks held only. The tail item is 1274 * so must be used with appropriate locks held only. The tail item is
1288 * returned or %NULL if the list is empty. 1275 * returned or %NULL if the list is empty.
1289 */ 1276 */
1290extern struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list); 1277struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list);
1291static inline struct sk_buff *__skb_dequeue_tail(struct sk_buff_head *list) 1278static inline struct sk_buff *__skb_dequeue_tail(struct sk_buff_head *list)
1292{ 1279{
1293 struct sk_buff *skb = skb_peek_tail(list); 1280 struct sk_buff *skb = skb_peek_tail(list);
@@ -1361,7 +1348,7 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
1361 * @size: the length of the data 1348 * @size: the length of the data
1362 * 1349 *
1363 * As per __skb_fill_page_desc() -- initialises the @i'th fragment of 1350 * As per __skb_fill_page_desc() -- initialises the @i'th fragment of
1364 * @skb to point to &size bytes at offset @off within @page. In 1351 * @skb to point to @size bytes at offset @off within @page. In
1365 * addition updates @skb such that @i is the last fragment. 1352 * addition updates @skb such that @i is the last fragment.
1366 * 1353 *
1367 * Does not take any additional reference on the fragment. 1354 * Does not take any additional reference on the fragment.
@@ -1373,8 +1360,11 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
1373 skb_shinfo(skb)->nr_frags = i + 1; 1360 skb_shinfo(skb)->nr_frags = i + 1;
1374} 1361}
1375 1362
1376extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, 1363void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
1377 int off, int size, unsigned int truesize); 1364 int size, unsigned int truesize);
1365
1366void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size,
1367 unsigned int truesize);
1378 1368
1379#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) 1369#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
1380#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frag_list(skb)) 1370#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frag_list(skb))
@@ -1418,7 +1408,8 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
1418/* 1408/*
1419 * Add data to an sk_buff 1409 * Add data to an sk_buff
1420 */ 1410 */
1421extern unsigned char *skb_put(struct sk_buff *skb, unsigned int len); 1411unsigned char *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
1412unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
1422static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) 1413static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
1423{ 1414{
1424 unsigned char *tmp = skb_tail_pointer(skb); 1415 unsigned char *tmp = skb_tail_pointer(skb);
@@ -1428,7 +1419,7 @@ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
1428 return tmp; 1419 return tmp;
1429} 1420}
1430 1421
1431extern unsigned char *skb_push(struct sk_buff *skb, unsigned int len); 1422unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
1432static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len) 1423static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
1433{ 1424{
1434 skb->data -= len; 1425 skb->data -= len;
@@ -1436,7 +1427,7 @@ static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
1436 return skb->data; 1427 return skb->data;
1437} 1428}
1438 1429
1439extern unsigned char *skb_pull(struct sk_buff *skb, unsigned int len); 1430unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
1440static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len) 1431static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len)
1441{ 1432{
1442 skb->len -= len; 1433 skb->len -= len;
@@ -1449,7 +1440,7 @@ static inline unsigned char *skb_pull_inline(struct sk_buff *skb, unsigned int l
1449 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); 1440 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len);
1450} 1441}
1451 1442
1452extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta); 1443unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta);
1453 1444
1454static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len) 1445static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len)
1455{ 1446{
@@ -1647,6 +1638,11 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1647 skb->mac_header += offset; 1638 skb->mac_header += offset;
1648} 1639}
1649 1640
1641static inline void skb_pop_mac_header(struct sk_buff *skb)
1642{
1643 skb->mac_header = skb->network_header;
1644}
1645
1650static inline void skb_probe_transport_header(struct sk_buff *skb, 1646static inline void skb_probe_transport_header(struct sk_buff *skb,
1651 const int offset_hint) 1647 const int offset_hint)
1652{ 1648{
@@ -1753,7 +1749,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
1753#define NET_SKB_PAD max(32, L1_CACHE_BYTES) 1749#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
1754#endif 1750#endif
1755 1751
1756extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); 1752int ___pskb_trim(struct sk_buff *skb, unsigned int len);
1757 1753
1758static inline void __skb_trim(struct sk_buff *skb, unsigned int len) 1754static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
1759{ 1755{
@@ -1765,7 +1761,7 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
1765 skb_set_tail_pointer(skb, len); 1761 skb_set_tail_pointer(skb, len);
1766} 1762}
1767 1763
1768extern void skb_trim(struct sk_buff *skb, unsigned int len); 1764void skb_trim(struct sk_buff *skb, unsigned int len);
1769 1765
1770static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) 1766static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
1771{ 1767{
@@ -1838,7 +1834,7 @@ static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask)
1838 * the list and one reference dropped. This function does not take the 1834 * the list and one reference dropped. This function does not take the
1839 * list lock and the caller must hold the relevant locks to use it. 1835 * list lock and the caller must hold the relevant locks to use it.
1840 */ 1836 */
1841extern void skb_queue_purge(struct sk_buff_head *list); 1837void skb_queue_purge(struct sk_buff_head *list);
1842static inline void __skb_queue_purge(struct sk_buff_head *list) 1838static inline void __skb_queue_purge(struct sk_buff_head *list)
1843{ 1839{
1844 struct sk_buff *skb; 1840 struct sk_buff *skb;
@@ -1850,11 +1846,10 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
1850#define NETDEV_FRAG_PAGE_MAX_SIZE (PAGE_SIZE << NETDEV_FRAG_PAGE_MAX_ORDER) 1846#define NETDEV_FRAG_PAGE_MAX_SIZE (PAGE_SIZE << NETDEV_FRAG_PAGE_MAX_ORDER)
1851#define NETDEV_PAGECNT_MAX_BIAS NETDEV_FRAG_PAGE_MAX_SIZE 1847#define NETDEV_PAGECNT_MAX_BIAS NETDEV_FRAG_PAGE_MAX_SIZE
1852 1848
1853extern void *netdev_alloc_frag(unsigned int fragsz); 1849void *netdev_alloc_frag(unsigned int fragsz);
1854 1850
1855extern struct sk_buff *__netdev_alloc_skb(struct net_device *dev, 1851struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int length,
1856 unsigned int length, 1852 gfp_t gfp_mask);
1857 gfp_t gfp_mask);
1858 1853
1859/** 1854/**
1860 * netdev_alloc_skb - allocate an skbuff for rx on a specific device 1855 * netdev_alloc_skb - allocate an skbuff for rx on a specific device
@@ -2071,6 +2066,8 @@ static inline void skb_frag_set_page(struct sk_buff *skb, int f,
2071 __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page); 2066 __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page);
2072} 2067}
2073 2068
2069bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t prio);
2070
2074/** 2071/**
2075 * skb_frag_dma_map - maps a paged fragment via the DMA API 2072 * skb_frag_dma_map - maps a paged fragment via the DMA API
2076 * @dev: the device to map the fragment to 2073 * @dev: the device to map the fragment to
@@ -2342,60 +2339,49 @@ static inline void skb_frag_add_head(struct sk_buff *skb, struct sk_buff *frag)
2342#define skb_walk_frags(skb, iter) \ 2339#define skb_walk_frags(skb, iter) \
2343 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next) 2340 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
2344 2341
2345extern struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags, 2342struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
2346 int *peeked, int *off, int *err); 2343 int *peeked, int *off, int *err);
2347extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, 2344struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
2348 int noblock, int *err); 2345 int *err);
2349extern unsigned int datagram_poll(struct file *file, struct socket *sock, 2346unsigned int datagram_poll(struct file *file, struct socket *sock,
2350 struct poll_table_struct *wait); 2347 struct poll_table_struct *wait);
2351extern int skb_copy_datagram_iovec(const struct sk_buff *from, 2348int skb_copy_datagram_iovec(const struct sk_buff *from, int offset,
2352 int offset, struct iovec *to, 2349 struct iovec *to, int size);
2353 int size); 2350int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen,
2354extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, 2351 struct iovec *iov);
2355 int hlen, 2352int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset,
2356 struct iovec *iov); 2353 const struct iovec *from, int from_offset,
2357extern int skb_copy_datagram_from_iovec(struct sk_buff *skb, 2354 int len);
2358 int offset, 2355int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *frm,
2359 const struct iovec *from, 2356 int offset, size_t count);
2360 int from_offset, 2357int skb_copy_datagram_const_iovec(const struct sk_buff *from, int offset,
2361 int len); 2358 const struct iovec *to, int to_offset,
2362extern int zerocopy_sg_from_iovec(struct sk_buff *skb, 2359 int size);
2363 const struct iovec *frm, 2360void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
2364 int offset, 2361void skb_free_datagram_locked(struct sock *sk, struct sk_buff *skb);
2365 size_t count); 2362int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags);
2366extern int skb_copy_datagram_const_iovec(const struct sk_buff *from, 2363int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len);
2367 int offset, 2364int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
2368 const struct iovec *to, 2365__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
2369 int to_offset, 2366 int len, __wsum csum);
2370 int size); 2367int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
2371extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb); 2368 struct pipe_inode_info *pipe, unsigned int len,
2372extern void skb_free_datagram_locked(struct sock *sk, 2369 unsigned int flags);
2373 struct sk_buff *skb); 2370void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
2374extern int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, 2371void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len);
2375 unsigned int flags); 2372int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen);
2376extern __wsum skb_checksum(const struct sk_buff *skb, int offset, 2373void skb_scrub_packet(struct sk_buff *skb, bool xnet);
2377 int len, __wsum csum); 2374struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
2378extern int skb_copy_bits(const struct sk_buff *skb, int offset, 2375
2379 void *to, int len); 2376struct skb_checksum_ops {
2380extern int skb_store_bits(struct sk_buff *skb, int offset, 2377 __wsum (*update)(const void *mem, int len, __wsum wsum);
2381 const void *from, int len); 2378 __wsum (*combine)(__wsum csum, __wsum csum2, int offset, int len);
2382extern __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, 2379};
2383 int offset, u8 *to, int len, 2380
2384 __wsum csum); 2381__wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
2385extern int skb_splice_bits(struct sk_buff *skb, 2382 __wsum csum, const struct skb_checksum_ops *ops);
2386 unsigned int offset, 2383__wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
2387 struct pipe_inode_info *pipe, 2384 __wsum csum);
2388 unsigned int len,
2389 unsigned int flags);
2390extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
2391extern void skb_split(struct sk_buff *skb,
2392 struct sk_buff *skb1, const u32 len);
2393extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
2394 int shiftlen);
2395extern void skb_scrub_packet(struct sk_buff *skb, bool xnet);
2396
2397extern struct sk_buff *skb_segment(struct sk_buff *skb,
2398 netdev_features_t features);
2399 2385
2400static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, 2386static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
2401 int len, void *buffer) 2387 int len, void *buffer)
@@ -2440,7 +2426,7 @@ static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
2440 memcpy(skb->data + offset, from, len); 2426 memcpy(skb->data + offset, from, len);
2441} 2427}
2442 2428
2443extern void skb_init(void); 2429void skb_init(void);
2444 2430
2445static inline ktime_t skb_get_ktime(const struct sk_buff *skb) 2431static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
2446{ 2432{
@@ -2483,12 +2469,12 @@ static inline ktime_t net_invalid_timestamp(void)
2483 return ktime_set(0, 0); 2469 return ktime_set(0, 0);
2484} 2470}
2485 2471
2486extern void skb_timestamping_init(void); 2472void skb_timestamping_init(void);
2487 2473
2488#ifdef CONFIG_NETWORK_PHY_TIMESTAMPING 2474#ifdef CONFIG_NETWORK_PHY_TIMESTAMPING
2489 2475
2490extern void skb_clone_tx_timestamp(struct sk_buff *skb); 2476void skb_clone_tx_timestamp(struct sk_buff *skb);
2491extern bool skb_defer_rx_timestamp(struct sk_buff *skb); 2477bool skb_defer_rx_timestamp(struct sk_buff *skb);
2492 2478
2493#else /* CONFIG_NETWORK_PHY_TIMESTAMPING */ 2479#else /* CONFIG_NETWORK_PHY_TIMESTAMPING */
2494 2480
@@ -2529,8 +2515,8 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
2529 * generates a software time stamp (otherwise), then queues the clone 2515 * generates a software time stamp (otherwise), then queues the clone
2530 * to the error queue of the socket. Errors are silently ignored. 2516 * to the error queue of the socket. Errors are silently ignored.
2531 */ 2517 */
2532extern void skb_tstamp_tx(struct sk_buff *orig_skb, 2518void skb_tstamp_tx(struct sk_buff *orig_skb,
2533 struct skb_shared_hwtstamps *hwtstamps); 2519 struct skb_shared_hwtstamps *hwtstamps);
2534 2520
2535static inline void sw_tx_timestamp(struct sk_buff *skb) 2521static inline void sw_tx_timestamp(struct sk_buff *skb)
2536{ 2522{
@@ -2545,6 +2531,10 @@ static inline void sw_tx_timestamp(struct sk_buff *skb)
2545 * Ethernet MAC Drivers should call this function in their hard_xmit() 2531 * Ethernet MAC Drivers should call this function in their hard_xmit()
2546 * function immediately before giving the sk_buff to the MAC hardware. 2532 * function immediately before giving the sk_buff to the MAC hardware.
2547 * 2533 *
2534 * Specifically, one should make absolutely sure that this function is
2535 * called before TX completion of this packet can trigger. Otherwise
2536 * the packet could potentially already be freed.
2537 *
2548 * @skb: A socket buffer. 2538 * @skb: A socket buffer.
2549 */ 2539 */
2550static inline void skb_tx_timestamp(struct sk_buff *skb) 2540static inline void skb_tx_timestamp(struct sk_buff *skb)
@@ -2562,8 +2552,8 @@ static inline void skb_tx_timestamp(struct sk_buff *skb)
2562 */ 2552 */
2563void skb_complete_wifi_ack(struct sk_buff *skb, bool acked); 2553void skb_complete_wifi_ack(struct sk_buff *skb, bool acked);
2564 2554
2565extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); 2555__sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
2566extern __sum16 __skb_checksum_complete(struct sk_buff *skb); 2556__sum16 __skb_checksum_complete(struct sk_buff *skb);
2567 2557
2568static inline int skb_csum_unnecessary(const struct sk_buff *skb) 2558static inline int skb_csum_unnecessary(const struct sk_buff *skb)
2569{ 2559{
@@ -2593,7 +2583,7 @@ static inline __sum16 skb_checksum_complete(struct sk_buff *skb)
2593} 2583}
2594 2584
2595#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 2585#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
2596extern void nf_conntrack_destroy(struct nf_conntrack *nfct); 2586void nf_conntrack_destroy(struct nf_conntrack *nfct);
2597static inline void nf_conntrack_put(struct nf_conntrack *nfct) 2587static inline void nf_conntrack_put(struct nf_conntrack *nfct)
2598{ 2588{
2599 if (nfct && atomic_dec_and_test(&nfct->use)) 2589 if (nfct && atomic_dec_and_test(&nfct->use))
@@ -2605,18 +2595,6 @@ static inline void nf_conntrack_get(struct nf_conntrack *nfct)
2605 atomic_inc(&nfct->use); 2595 atomic_inc(&nfct->use);
2606} 2596}
2607#endif 2597#endif
2608#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2609static inline void nf_conntrack_get_reasm(struct sk_buff *skb)
2610{
2611 if (skb)
2612 atomic_inc(&skb->users);
2613}
2614static inline void nf_conntrack_put_reasm(struct sk_buff *skb)
2615{
2616 if (skb)
2617 kfree_skb(skb);
2618}
2619#endif
2620#ifdef CONFIG_BRIDGE_NETFILTER 2598#ifdef CONFIG_BRIDGE_NETFILTER
2621static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge) 2599static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge)
2622{ 2600{
@@ -2635,10 +2613,6 @@ static inline void nf_reset(struct sk_buff *skb)
2635 nf_conntrack_put(skb->nfct); 2613 nf_conntrack_put(skb->nfct);
2636 skb->nfct = NULL; 2614 skb->nfct = NULL;
2637#endif 2615#endif
2638#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2639 nf_conntrack_put_reasm(skb->nfct_reasm);
2640 skb->nfct_reasm = NULL;
2641#endif
2642#ifdef CONFIG_BRIDGE_NETFILTER 2616#ifdef CONFIG_BRIDGE_NETFILTER
2643 nf_bridge_put(skb->nf_bridge); 2617 nf_bridge_put(skb->nf_bridge);
2644 skb->nf_bridge = NULL; 2618 skb->nf_bridge = NULL;
@@ -2660,10 +2634,6 @@ static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
2660 nf_conntrack_get(src->nfct); 2634 nf_conntrack_get(src->nfct);
2661 dst->nfctinfo = src->nfctinfo; 2635 dst->nfctinfo = src->nfctinfo;
2662#endif 2636#endif
2663#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2664 dst->nfct_reasm = src->nfct_reasm;
2665 nf_conntrack_get_reasm(src->nfct_reasm);
2666#endif
2667#ifdef CONFIG_BRIDGE_NETFILTER 2637#ifdef CONFIG_BRIDGE_NETFILTER
2668 dst->nf_bridge = src->nf_bridge; 2638 dst->nf_bridge = src->nf_bridge;
2669 nf_bridge_get(src->nf_bridge); 2639 nf_bridge_get(src->nf_bridge);
@@ -2675,9 +2645,6 @@ static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src)
2675#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 2645#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
2676 nf_conntrack_put(dst->nfct); 2646 nf_conntrack_put(dst->nfct);
2677#endif 2647#endif
2678#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2679 nf_conntrack_put_reasm(dst->nfct_reasm);
2680#endif
2681#ifdef CONFIG_BRIDGE_NETFILTER 2648#ifdef CONFIG_BRIDGE_NETFILTER
2682 nf_bridge_put(dst->nf_bridge); 2649 nf_bridge_put(dst->nf_bridge);
2683#endif 2650#endif
@@ -2732,28 +2699,27 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
2732 return skb->queue_mapping != 0; 2699 return skb->queue_mapping != 0;
2733} 2700}
2734 2701
2735extern u16 __skb_tx_hash(const struct net_device *dev, 2702u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
2736 const struct sk_buff *skb, 2703 unsigned int num_tx_queues);
2737 unsigned int num_tx_queues);
2738 2704
2739#ifdef CONFIG_XFRM
2740static inline struct sec_path *skb_sec_path(struct sk_buff *skb) 2705static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
2741{ 2706{
2707#ifdef CONFIG_XFRM
2742 return skb->sp; 2708 return skb->sp;
2743}
2744#else 2709#else
2745static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
2746{
2747 return NULL; 2710 return NULL;
2748}
2749#endif 2711#endif
2712}
2750 2713
2751/* Keeps track of mac header offset relative to skb->head. 2714/* Keeps track of mac header offset relative to skb->head.
2752 * It is useful for TSO of Tunneling protocol. e.g. GRE. 2715 * It is useful for TSO of Tunneling protocol. e.g. GRE.
2753 * For non-tunnel skb it points to skb_mac_header() and for 2716 * For non-tunnel skb it points to skb_mac_header() and for
2754 * tunnel skb it points to outer mac header. */ 2717 * tunnel skb it points to outer mac header.
2718 * Keeps track of level of encapsulation of network headers.
2719 */
2755struct skb_gso_cb { 2720struct skb_gso_cb {
2756 int mac_offset; 2721 int mac_offset;
2722 int encap_level;
2757}; 2723};
2758#define SKB_GSO_CB(skb) ((struct skb_gso_cb *)(skb)->cb) 2724#define SKB_GSO_CB(skb) ((struct skb_gso_cb *)(skb)->cb)
2759 2725
@@ -2783,12 +2749,13 @@ static inline bool skb_is_gso(const struct sk_buff *skb)
2783 return skb_shinfo(skb)->gso_size; 2749 return skb_shinfo(skb)->gso_size;
2784} 2750}
2785 2751
2752/* Note: Should be called only if skb_is_gso(skb) is true */
2786static inline bool skb_is_gso_v6(const struct sk_buff *skb) 2753static inline bool skb_is_gso_v6(const struct sk_buff *skb)
2787{ 2754{
2788 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; 2755 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6;
2789} 2756}
2790 2757
2791extern void __skb_warn_lro_forwarding(const struct sk_buff *skb); 2758void __skb_warn_lro_forwarding(const struct sk_buff *skb);
2792 2759
2793static inline bool skb_warn_if_lro(const struct sk_buff *skb) 2760static inline bool skb_warn_if_lro(const struct sk_buff *skb)
2794{ 2761{