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.h113
1 files changed, 86 insertions, 27 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index ae836fded530..f89e7fd59a4c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -187,12 +187,8 @@ union skb_shared_tx {
187 * the end of the header data, ie. at skb->end. 187 * the end of the header data, ie. at skb->end.
188 */ 188 */
189struct skb_shared_info { 189struct skb_shared_info {
190 atomic_t dataref;
191 unsigned short nr_frags; 190 unsigned short nr_frags;
192 unsigned short gso_size; 191 unsigned short gso_size;
193#ifdef CONFIG_HAS_DMA
194 dma_addr_t dma_head;
195#endif
196 /* Warning: this field is not always filled in (UFO)! */ 192 /* Warning: this field is not always filled in (UFO)! */
197 unsigned short gso_segs; 193 unsigned short gso_segs;
198 unsigned short gso_type; 194 unsigned short gso_type;
@@ -200,10 +196,13 @@ struct skb_shared_info {
200 union skb_shared_tx tx_flags; 196 union skb_shared_tx tx_flags;
201 struct sk_buff *frag_list; 197 struct sk_buff *frag_list;
202 struct skb_shared_hwtstamps hwtstamps; 198 struct skb_shared_hwtstamps hwtstamps;
199
200 /*
201 * Warning : all fields before dataref are cleared in __alloc_skb()
202 */
203 atomic_t dataref;
204
203 skb_frag_t frags[MAX_SKB_FRAGS]; 205 skb_frag_t frags[MAX_SKB_FRAGS];
204#ifdef CONFIG_HAS_DMA
205 dma_addr_t dma_maps[MAX_SKB_FRAGS];
206#endif
207 /* Intermediate layers must ensure that destructor_arg 206 /* Intermediate layers must ensure that destructor_arg
208 * remains valid until skb destructor */ 207 * remains valid until skb destructor */
209 void * destructor_arg; 208 void * destructor_arg;
@@ -265,7 +264,7 @@ typedef unsigned char *sk_buff_data_t;
265 * @transport_header: Transport layer header 264 * @transport_header: Transport layer header
266 * @network_header: Network layer header 265 * @network_header: Network layer header
267 * @mac_header: Link layer header 266 * @mac_header: Link layer header
268 * @_skb_dst: destination entry 267 * @_skb_refdst: destination entry (with norefcount bit)
269 * @sp: the security path, used for xfrm 268 * @sp: the security path, used for xfrm
270 * @cb: Control buffer. Free for use by every layer. Put private vars here 269 * @cb: Control buffer. Free for use by every layer. Put private vars here
271 * @len: Length of actual data 270 * @len: Length of actual data
@@ -300,6 +299,7 @@ typedef unsigned char *sk_buff_data_t;
300 * @nfct_reasm: netfilter conntrack re-assembly pointer 299 * @nfct_reasm: netfilter conntrack re-assembly pointer
301 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c 300 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
302 * @skb_iif: ifindex of device we arrived on 301 * @skb_iif: ifindex of device we arrived on
302 * @rxhash: the packet hash computed on receive
303 * @queue_mapping: Queue mapping for multiqueue devices 303 * @queue_mapping: Queue mapping for multiqueue devices
304 * @tc_index: Traffic control index 304 * @tc_index: Traffic control index
305 * @tc_verd: traffic control verdict 305 * @tc_verd: traffic control verdict
@@ -315,22 +315,23 @@ struct sk_buff {
315 struct sk_buff *next; 315 struct sk_buff *next;
316 struct sk_buff *prev; 316 struct sk_buff *prev;
317 317
318 struct sock *sk;
319 ktime_t tstamp; 318 ktime_t tstamp;
319
320 struct sock *sk;
320 struct net_device *dev; 321 struct net_device *dev;
321 322
322 unsigned long _skb_dst;
323#ifdef CONFIG_XFRM
324 struct sec_path *sp;
325#endif
326 /* 323 /*
327 * This is the control buffer. It is free to use for every 324 * This is the control buffer. It is free to use for every
328 * layer. Please put your private variables there. If you 325 * layer. Please put your private variables there. If you
329 * want to keep them across layers you have to do a skb_clone() 326 * want to keep them across layers you have to do a skb_clone()
330 * first. This is owned by whoever has the skb queued ATM. 327 * first. This is owned by whoever has the skb queued ATM.
331 */ 328 */
332 char cb[48]; 329 char cb[48] __aligned(8);
333 330
331 unsigned long _skb_refdst;
332#ifdef CONFIG_XFRM
333 struct sec_path *sp;
334#endif
334 unsigned int len, 335 unsigned int len,
335 data_len; 336 data_len;
336 __u16 mac_len, 337 __u16 mac_len,
@@ -354,8 +355,8 @@ struct sk_buff {
354 ipvs_property:1, 355 ipvs_property:1,
355 peeked:1, 356 peeked:1,
356 nf_trace:1; 357 nf_trace:1;
357 __be16 protocol:16;
358 kmemcheck_bitfield_end(flags1); 358 kmemcheck_bitfield_end(flags1);
359 __be16 protocol;
359 360
360 void (*destructor)(struct sk_buff *skb); 361 void (*destructor)(struct sk_buff *skb);
361#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 362#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
@@ -374,10 +375,15 @@ struct sk_buff {
374#endif 375#endif
375#endif 376#endif
376 377
378 __u32 rxhash;
379
377 kmemcheck_bitfield_begin(flags2); 380 kmemcheck_bitfield_begin(flags2);
378 __u16 queue_mapping:16; 381 __u16 queue_mapping:16;
379#ifdef CONFIG_IPV6_NDISC_NODETYPE 382#ifdef CONFIG_IPV6_NDISC_NODETYPE
380 __u8 ndisc_nodetype:2; 383 __u8 ndisc_nodetype:2,
384 deliver_no_wcard:1;
385#else
386 __u8 deliver_no_wcard:1;
381#endif 387#endif
382 kmemcheck_bitfield_end(flags2); 388 kmemcheck_bitfield_end(flags2);
383 389
@@ -416,14 +422,64 @@ struct sk_buff {
416 422
417#include <asm/system.h> 423#include <asm/system.h>
418 424
425/*
426 * skb might have a dst pointer attached, refcounted or not.
427 * _skb_refdst low order bit is set if refcount was _not_ taken
428 */
429#define SKB_DST_NOREF 1UL
430#define SKB_DST_PTRMASK ~(SKB_DST_NOREF)
431
432/**
433 * skb_dst - returns skb dst_entry
434 * @skb: buffer
435 *
436 * Returns skb dst_entry, regardless of reference taken or not.
437 */
419static inline struct dst_entry *skb_dst(const struct sk_buff *skb) 438static inline struct dst_entry *skb_dst(const struct sk_buff *skb)
420{ 439{
421 return (struct dst_entry *)skb->_skb_dst; 440 /* If refdst was not refcounted, check we still are in a
441 * rcu_read_lock section
442 */
443 WARN_ON((skb->_skb_refdst & SKB_DST_NOREF) &&
444 !rcu_read_lock_held() &&
445 !rcu_read_lock_bh_held());
446 return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK);
422} 447}
423 448
449/**
450 * skb_dst_set - sets skb dst
451 * @skb: buffer
452 * @dst: dst entry
453 *
454 * Sets skb dst, assuming a reference was taken on dst and should
455 * be released by skb_dst_drop()
456 */
424static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) 457static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
425{ 458{
426 skb->_skb_dst = (unsigned long)dst; 459 skb->_skb_refdst = (unsigned long)dst;
460}
461
462/**
463 * skb_dst_set_noref - sets skb dst, without a reference
464 * @skb: buffer
465 * @dst: dst entry
466 *
467 * Sets skb dst, assuming a reference was not taken on dst
468 * skb_dst_drop() should not dst_release() this dst
469 */
470static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst)
471{
472 WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held());
473 skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF;
474}
475
476/**
477 * skb_dst_is_noref - Test if skb dst isnt refcounted
478 * @skb: buffer
479 */
480static inline bool skb_dst_is_noref(const struct sk_buff *skb)
481{
482 return (skb->_skb_refdst & SKB_DST_NOREF) && skb_dst(skb);
427} 483}
428 484
429static inline struct rtable *skb_rtable(const struct sk_buff *skb) 485static inline struct rtable *skb_rtable(const struct sk_buff *skb)
@@ -448,7 +504,7 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
448 return __alloc_skb(size, priority, 1, -1); 504 return __alloc_skb(size, priority, 1, -1);
449} 505}
450 506
451extern int skb_recycle_check(struct sk_buff *skb, int skb_size); 507extern bool skb_recycle_check(struct sk_buff *skb, int skb_size);
452 508
453extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src); 509extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src);
454extern struct sk_buff *skb_clone(struct sk_buff *skb, 510extern struct sk_buff *skb_clone(struct sk_buff *skb,
@@ -472,11 +528,6 @@ extern int skb_cow_data(struct sk_buff *skb, int tailbits,
472 struct sk_buff **trailer); 528 struct sk_buff **trailer);
473extern int skb_pad(struct sk_buff *skb, int pad); 529extern int skb_pad(struct sk_buff *skb, int pad);
474#define dev_kfree_skb(a) consume_skb(a) 530#define dev_kfree_skb(a) consume_skb(a)
475#define dev_consume_skb(a) kfree_skb_clean(a)
476extern void skb_over_panic(struct sk_buff *skb, int len,
477 void *here);
478extern void skb_under_panic(struct sk_buff *skb, int len,
479 void *here);
480 531
481extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb, 532extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
482 int getfrag(void *from, char *to, int offset, 533 int getfrag(void *from, char *to, int offset,
@@ -738,7 +789,7 @@ static inline struct sk_buff *skb_unshare(struct sk_buff *skb,
738} 789}
739 790
740/** 791/**
741 * skb_peek 792 * skb_peek - peek at the head of an &sk_buff_head
742 * @list_: list to peek at 793 * @list_: list to peek at
743 * 794 *
744 * Peek an &sk_buff. Unlike most other operations you _MUST_ 795 * Peek an &sk_buff. Unlike most other operations you _MUST_
@@ -759,7 +810,7 @@ static inline struct sk_buff *skb_peek(struct sk_buff_head *list_)
759} 810}
760 811
761/** 812/**
762 * skb_peek_tail 813 * skb_peek_tail - peek at the tail of an &sk_buff_head
763 * @list_: list to peek at 814 * @list_: list to peek at
764 * 815 *
765 * Peek an &sk_buff. Unlike most other operations you _MUST_ 816 * Peek an &sk_buff. Unlike most other operations you _MUST_
@@ -1135,6 +1186,11 @@ static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len)
1135 return skb->data += len; 1186 return skb->data += len;
1136} 1187}
1137 1188
1189static inline unsigned char *skb_pull_inline(struct sk_buff *skb, unsigned int len)
1190{
1191 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len);
1192}
1193
1138extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta); 1194extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta);
1139 1195
1140static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len) 1196static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len)
@@ -1358,9 +1414,12 @@ static inline int skb_network_offset(const struct sk_buff *skb)
1358 * 1414 *
1359 * Various parts of the networking layer expect at least 32 bytes of 1415 * Various parts of the networking layer expect at least 32 bytes of
1360 * headroom, you should not reduce this. 1416 * headroom, you should not reduce this.
1417 * With RPS, we raised NET_SKB_PAD to 64 so that get_rps_cpus() fetches span
1418 * a 64 bytes aligned block to fit modern (>= 64 bytes) cache line sizes
1419 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
1361 */ 1420 */
1362#ifndef NET_SKB_PAD 1421#ifndef NET_SKB_PAD
1363#define NET_SKB_PAD 32 1422#define NET_SKB_PAD 64
1364#endif 1423#endif
1365 1424
1366extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); 1425extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);