]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Definitions for the 'struct sk_buff' memory handlers. | |
3 | * | |
4 | * Authors: | |
5 | * Alan Cox, <gw4pts@gw4pts.ampr.org> | |
6 | * Florian La Roche, <rzsfl@rz.uni-sb.de> | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License | |
10 | * as published by the Free Software Foundation; either version | |
11 | * 2 of the License, or (at your option) any later version. | |
12 | */ | |
13 | ||
14 | #ifndef _LINUX_SKBUFF_H | |
15 | #define _LINUX_SKBUFF_H | |
16 | ||
1da177e4 | 17 | #include <linux/kernel.h> |
fe55f6d5 | 18 | #include <linux/kmemcheck.h> |
1da177e4 LT |
19 | #include <linux/compiler.h> |
20 | #include <linux/time.h> | |
187f1882 | 21 | #include <linux/bug.h> |
1da177e4 LT |
22 | #include <linux/cache.h> |
23 | ||
60063497 | 24 | #include <linux/atomic.h> |
1da177e4 LT |
25 | #include <asm/types.h> |
26 | #include <linux/spinlock.h> | |
1da177e4 | 27 | #include <linux/net.h> |
3fc7e8a6 | 28 | #include <linux/textsearch.h> |
1da177e4 | 29 | #include <net/checksum.h> |
a80958f4 | 30 | #include <linux/rcupdate.h> |
97fc2f08 | 31 | #include <linux/dmaengine.h> |
b7aa0bf7 | 32 | #include <linux/hrtimer.h> |
131ea667 | 33 | #include <linux/dma-mapping.h> |
c8f44aff | 34 | #include <linux/netdev_features.h> |
1da177e4 | 35 | |
60476372 | 36 | /* Don't change this without changing skb_csum_unnecessary! */ |
1da177e4 | 37 | #define CHECKSUM_NONE 0 |
60476372 HX |
38 | #define CHECKSUM_UNNECESSARY 1 |
39 | #define CHECKSUM_COMPLETE 2 | |
40 | #define CHECKSUM_PARTIAL 3 | |
1da177e4 LT |
41 | |
42 | #define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ | |
43 | ~(SMP_CACHE_BYTES - 1)) | |
fc910a27 | 44 | #define SKB_WITH_OVERHEAD(X) \ |
deea84b0 | 45 | ((X) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) |
fc910a27 DM |
46 | #define SKB_MAX_ORDER(X, ORDER) \ |
47 | SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X)) | |
1da177e4 LT |
48 | #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0)) |
49 | #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) | |
50 | ||
87fb4b7b ED |
51 | /* return minimum truesize of one skb containing X bytes of data */ |
52 | #define SKB_TRUESIZE(X) ((X) + \ | |
53 | SKB_DATA_ALIGN(sizeof(struct sk_buff)) + \ | |
54 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) | |
55 | ||
1da177e4 LT |
56 | /* A. Checksumming of received packets by device. |
57 | * | |
58 | * NONE: device failed to checksum this packet. | |
59 | * skb->csum is undefined. | |
60 | * | |
61 | * UNNECESSARY: device parsed packet and wouldbe verified checksum. | |
62 | * skb->csum is undefined. | |
63 | * It is bad option, but, unfortunately, many of vendors do this. | |
64 | * Apparently with secret goal to sell you new device, when you | |
65 | * will add new protocol to your host. F.e. IPv6. 8) | |
66 | * | |
84fa7933 | 67 | * COMPLETE: the most generic way. Device supplied checksum of _all_ |
1da177e4 LT |
68 | * the packet as seen by netif_rx in skb->csum. |
69 | * NOTE: Even if device supports only some protocols, but | |
84fa7933 | 70 | * is able to produce some skb->csum, it MUST use COMPLETE, |
1da177e4 LT |
71 | * not UNNECESSARY. |
72 | * | |
c6c6e3e0 HX |
73 | * PARTIAL: identical to the case for output below. This may occur |
74 | * on a packet received directly from another Linux OS, e.g., | |
75 | * a virtualised Linux kernel on the same host. The packet can | |
76 | * be treated in the same way as UNNECESSARY except that on | |
77 | * output (i.e., forwarding) the checksum must be filled in | |
78 | * by the OS or the hardware. | |
79 | * | |
1da177e4 LT |
80 | * B. Checksumming on output. |
81 | * | |
82 | * NONE: skb is checksummed by protocol or csum is not required. | |
83 | * | |
84fa7933 | 84 | * PARTIAL: device is required to csum packet as seen by hard_start_xmit |
c6c6e3e0 HX |
85 | * from skb->csum_start to the end and to record the checksum |
86 | * at skb->csum_start + skb->csum_offset. | |
1da177e4 LT |
87 | * |
88 | * Device must show its capabilities in dev->features, set | |
89 | * at device setup time. | |
90 | * NETIF_F_HW_CSUM - it is clever device, it is able to checksum | |
91 | * everything. | |
1da177e4 LT |
92 | * NETIF_F_IP_CSUM - device is dumb. It is able to csum only |
93 | * TCP/UDP over IPv4. Sigh. Vendors like this | |
94 | * way by an unknown reason. Though, see comment above | |
95 | * about CHECKSUM_UNNECESSARY. 8) | |
c6c6e3e0 | 96 | * NETIF_F_IPV6_CSUM about as dumb as the last one but does IPv6 instead. |
1da177e4 | 97 | * |
3af79302 YZ |
98 | * UNNECESSARY: device will do per protocol specific csum. Protocol drivers |
99 | * that do not want net to perform the checksum calculation should use | |
100 | * this flag in their outgoing skbs. | |
101 | * NETIF_F_FCOE_CRC this indicates the device can do FCoE FC CRC | |
102 | * offload. Correspondingly, the FCoE protocol driver | |
103 | * stack should use CHECKSUM_UNNECESSARY. | |
104 | * | |
1da177e4 LT |
105 | * Any questions? No questions, good. --ANK |
106 | */ | |
107 | ||
1da177e4 | 108 | struct net_device; |
716ea3a7 | 109 | struct scatterlist; |
9c55e01c | 110 | struct pipe_inode_info; |
1da177e4 | 111 | |
5f79e0f9 | 112 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
1da177e4 LT |
113 | struct nf_conntrack { |
114 | atomic_t use; | |
1da177e4 | 115 | }; |
5f79e0f9 | 116 | #endif |
1da177e4 LT |
117 | |
118 | #ifdef CONFIG_BRIDGE_NETFILTER | |
119 | struct nf_bridge_info { | |
bf1ac5ca ED |
120 | atomic_t use; |
121 | unsigned int mask; | |
122 | struct net_device *physindev; | |
123 | struct net_device *physoutdev; | |
124 | unsigned long data[32 / sizeof(unsigned long)]; | |
1da177e4 LT |
125 | }; |
126 | #endif | |
127 | ||
1da177e4 LT |
128 | struct sk_buff_head { |
129 | /* These two members must be first. */ | |
130 | struct sk_buff *next; | |
131 | struct sk_buff *prev; | |
132 | ||
133 | __u32 qlen; | |
134 | spinlock_t lock; | |
135 | }; | |
136 | ||
137 | struct sk_buff; | |
138 | ||
9d4dde52 IC |
139 | /* To allow 64K frame to be packed as single skb without frag_list we |
140 | * require 64K/PAGE_SIZE pages plus 1 additional page to allow for | |
141 | * buffers which do not start on a page boundary. | |
142 | * | |
143 | * Since GRO uses frags we allocate at least 16 regardless of page | |
144 | * size. | |
a715dea3 | 145 | */ |
9d4dde52 | 146 | #if (65536/PAGE_SIZE + 1) < 16 |
eec00954 | 147 | #define MAX_SKB_FRAGS 16UL |
a715dea3 | 148 | #else |
9d4dde52 | 149 | #define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1) |
a715dea3 | 150 | #endif |
1da177e4 LT |
151 | |
152 | typedef struct skb_frag_struct skb_frag_t; | |
153 | ||
154 | struct skb_frag_struct { | |
a8605c60 IC |
155 | struct { |
156 | struct page *p; | |
157 | } page; | |
cb4dfe56 | 158 | #if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536) |
a309bb07 DM |
159 | __u32 page_offset; |
160 | __u32 size; | |
cb4dfe56 ED |
161 | #else |
162 | __u16 page_offset; | |
163 | __u16 size; | |
164 | #endif | |
1da177e4 LT |
165 | }; |
166 | ||
9e903e08 ED |
167 | static inline unsigned int skb_frag_size(const skb_frag_t *frag) |
168 | { | |
169 | return frag->size; | |
170 | } | |
171 | ||
172 | static inline void skb_frag_size_set(skb_frag_t *frag, unsigned int size) | |
173 | { | |
174 | frag->size = size; | |
175 | } | |
176 | ||
177 | static inline void skb_frag_size_add(skb_frag_t *frag, int delta) | |
178 | { | |
179 | frag->size += delta; | |
180 | } | |
181 | ||
182 | static inline void skb_frag_size_sub(skb_frag_t *frag, int delta) | |
183 | { | |
184 | frag->size -= delta; | |
185 | } | |
186 | ||
ac45f602 PO |
187 | #define HAVE_HW_TIME_STAMP |
188 | ||
189 | /** | |
d3a21be8 | 190 | * struct skb_shared_hwtstamps - hardware time stamps |
ac45f602 PO |
191 | * @hwtstamp: hardware time stamp transformed into duration |
192 | * since arbitrary point in time | |
193 | * @syststamp: hwtstamp transformed to system time base | |
194 | * | |
195 | * Software time stamps generated by ktime_get_real() are stored in | |
196 | * skb->tstamp. The relation between the different kinds of time | |
197 | * stamps is as follows: | |
198 | * | |
199 | * syststamp and tstamp can be compared against each other in | |
200 | * arbitrary combinations. The accuracy of a | |
201 | * syststamp/tstamp/"syststamp from other device" comparison is | |
202 | * limited by the accuracy of the transformation into system time | |
203 | * base. This depends on the device driver and its underlying | |
204 | * hardware. | |
205 | * | |
206 | * hwtstamps can only be compared against other hwtstamps from | |
207 | * the same device. | |
208 | * | |
209 | * This structure is attached to packets as part of the | |
210 | * &skb_shared_info. Use skb_hwtstamps() to get a pointer. | |
211 | */ | |
212 | struct skb_shared_hwtstamps { | |
213 | ktime_t hwtstamp; | |
214 | ktime_t syststamp; | |
215 | }; | |
216 | ||
2244d07b OH |
217 | /* Definitions for tx_flags in struct skb_shared_info */ |
218 | enum { | |
219 | /* generate hardware time stamp */ | |
220 | SKBTX_HW_TSTAMP = 1 << 0, | |
221 | ||
222 | /* generate software time stamp */ | |
223 | SKBTX_SW_TSTAMP = 1 << 1, | |
224 | ||
225 | /* device driver is going to provide hardware time stamp */ | |
226 | SKBTX_IN_PROGRESS = 1 << 2, | |
227 | ||
a6686f2f | 228 | /* device driver supports TX zero-copy buffers */ |
62b1a8ab | 229 | SKBTX_DEV_ZEROCOPY = 1 << 3, |
6e3e939f JB |
230 | |
231 | /* generate wifi status information (where possible) */ | |
62b1a8ab | 232 | SKBTX_WIFI_STATUS = 1 << 4, |
a6686f2f SM |
233 | }; |
234 | ||
235 | /* | |
236 | * The callback notifies userspace to release buffers when skb DMA is done in | |
237 | * lower device, the skb last reference should be 0 when calling this. | |
ca8f4fb2 MT |
238 | * The ctx field is used to track device context. |
239 | * The desc field is used to track userspace buffer index. | |
a6686f2f SM |
240 | */ |
241 | struct ubuf_info { | |
ca8f4fb2 MT |
242 | void (*callback)(struct ubuf_info *); |
243 | void *ctx; | |
a6686f2f | 244 | unsigned long desc; |
ac45f602 PO |
245 | }; |
246 | ||
1da177e4 LT |
247 | /* This data is invariant across clones and lives at |
248 | * the end of the header data, ie. at skb->end. | |
249 | */ | |
250 | struct skb_shared_info { | |
9f42f126 IC |
251 | unsigned char nr_frags; |
252 | __u8 tx_flags; | |
7967168c HX |
253 | unsigned short gso_size; |
254 | /* Warning: this field is not always filled in (UFO)! */ | |
255 | unsigned short gso_segs; | |
256 | unsigned short gso_type; | |
1da177e4 | 257 | struct sk_buff *frag_list; |
ac45f602 | 258 | struct skb_shared_hwtstamps hwtstamps; |
9f42f126 | 259 | __be32 ip6_frag_id; |
ec7d2f2c ED |
260 | |
261 | /* | |
262 | * Warning : all fields before dataref are cleared in __alloc_skb() | |
263 | */ | |
264 | atomic_t dataref; | |
265 | ||
69e3c75f JB |
266 | /* Intermediate layers must ensure that destructor_arg |
267 | * remains valid until skb destructor */ | |
268 | void * destructor_arg; | |
a6686f2f | 269 | |
fed66381 ED |
270 | /* must be last field, see pskb_expand_head() */ |
271 | skb_frag_t frags[MAX_SKB_FRAGS]; | |
1da177e4 LT |
272 | }; |
273 | ||
274 | /* We divide dataref into two halves. The higher 16 bits hold references | |
275 | * to the payload part of skb->data. The lower 16 bits hold references to | |
334a8132 PM |
276 | * the entire skb->data. A clone of a headerless skb holds the length of |
277 | * the header in skb->hdr_len. | |
1da177e4 LT |
278 | * |
279 | * All users must obey the rule that the skb->data reference count must be | |
280 | * greater than or equal to the payload reference count. | |
281 | * | |
282 | * Holding a reference to the payload part means that the user does not | |
283 | * care about modifications to the header part of skb->data. | |
284 | */ | |
285 | #define SKB_DATAREF_SHIFT 16 | |
286 | #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) | |
287 | ||
d179cd12 DM |
288 | |
289 | enum { | |
290 | SKB_FCLONE_UNAVAILABLE, | |
291 | SKB_FCLONE_ORIG, | |
292 | SKB_FCLONE_CLONE, | |
293 | }; | |
294 | ||
7967168c HX |
295 | enum { |
296 | SKB_GSO_TCPV4 = 1 << 0, | |
f83ef8c0 | 297 | SKB_GSO_UDP = 1 << 1, |
576a30eb HX |
298 | |
299 | /* This indicates the skb is from an untrusted source. */ | |
300 | SKB_GSO_DODGY = 1 << 2, | |
b0da8537 MC |
301 | |
302 | /* This indicates the tcp segment has CWR set. */ | |
f83ef8c0 HX |
303 | SKB_GSO_TCP_ECN = 1 << 3, |
304 | ||
305 | SKB_GSO_TCPV6 = 1 << 4, | |
01d5b2fc CL |
306 | |
307 | SKB_GSO_FCOE = 1 << 5, | |
7967168c HX |
308 | }; |
309 | ||
2e07fa9c ACM |
310 | #if BITS_PER_LONG > 32 |
311 | #define NET_SKBUFF_DATA_USES_OFFSET 1 | |
312 | #endif | |
313 | ||
314 | #ifdef NET_SKBUFF_DATA_USES_OFFSET | |
315 | typedef unsigned int sk_buff_data_t; | |
316 | #else | |
317 | typedef unsigned char *sk_buff_data_t; | |
318 | #endif | |
319 | ||
2fc72c7b KK |
320 | #if defined(CONFIG_NF_DEFRAG_IPV4) || defined(CONFIG_NF_DEFRAG_IPV4_MODULE) || \ |
321 | defined(CONFIG_NF_DEFRAG_IPV6) || defined(CONFIG_NF_DEFRAG_IPV6_MODULE) | |
322 | #define NET_SKBUFF_NF_DEFRAG_NEEDED 1 | |
323 | #endif | |
324 | ||
1da177e4 LT |
325 | /** |
326 | * struct sk_buff - socket buffer | |
327 | * @next: Next buffer in list | |
328 | * @prev: Previous buffer in list | |
325ed823 | 329 | * @tstamp: Time we arrived |
d84e0bd7 | 330 | * @sk: Socket we are owned by |
1da177e4 | 331 | * @dev: Device we arrived on/are leaving by |
d84e0bd7 | 332 | * @cb: Control buffer. Free for use by every layer. Put private vars here |
7fee226a | 333 | * @_skb_refdst: destination entry (with norefcount bit) |
67be2dd1 | 334 | * @sp: the security path, used for xfrm |
1da177e4 LT |
335 | * @len: Length of actual data |
336 | * @data_len: Data length | |
337 | * @mac_len: Length of link layer header | |
334a8132 | 338 | * @hdr_len: writable header length of cloned skb |
663ead3b HX |
339 | * @csum: Checksum (must include start/offset pair) |
340 | * @csum_start: Offset from skb->head where checksumming should start | |
341 | * @csum_offset: Offset from csum_start where checksum should be stored | |
d84e0bd7 | 342 | * @priority: Packet queueing priority |
67be2dd1 | 343 | * @local_df: allow local fragmentation |
1da177e4 | 344 | * @cloned: Head may be cloned (check refcnt to be sure) |
d84e0bd7 | 345 | * @ip_summed: Driver fed us an IP checksum |
1da177e4 | 346 | * @nohdr: Payload reference only, must not modify header |
d84e0bd7 | 347 | * @nfctinfo: Relationship of this skb to the connection |
1da177e4 | 348 | * @pkt_type: Packet class |
c83c2486 | 349 | * @fclone: skbuff clone status |
c83c2486 | 350 | * @ipvs_property: skbuff is owned by ipvs |
31729363 RD |
351 | * @peeked: this packet has been seen already, so stats have been |
352 | * done for it, don't do them again | |
ba9dda3a | 353 | * @nf_trace: netfilter packet trace flag |
d84e0bd7 DB |
354 | * @protocol: Packet protocol from driver |
355 | * @destructor: Destruct function | |
356 | * @nfct: Associated connection, if any | |
461ddf3b | 357 | * @nfct_reasm: netfilter conntrack re-assembly pointer |
1da177e4 | 358 | * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c |
8964be4a | 359 | * @skb_iif: ifindex of device we arrived on |
1da177e4 LT |
360 | * @tc_index: Traffic control index |
361 | * @tc_verd: traffic control verdict | |
d84e0bd7 DB |
362 | * @rxhash: the packet hash computed on receive |
363 | * @queue_mapping: Queue mapping for multiqueue devices | |
553a5672 | 364 | * @ndisc_nodetype: router type (from link layer) |
d84e0bd7 | 365 | * @ooo_okay: allow the mapping of a socket to a queue to be changed |
4ca2462e CG |
366 | * @l4_rxhash: indicate rxhash is a canonical 4-tuple hash over transport |
367 | * ports. | |
6e3e939f JB |
368 | * @wifi_acked_valid: wifi_acked was set |
369 | * @wifi_acked: whether frame was acked on wifi or not | |
3bdc0eba | 370 | * @no_fcs: Request NIC to treat last 4 bytes as Ethernet FCS |
f4b8ea78 RD |
371 | * @dma_cookie: a cookie to one of several possible DMA operations |
372 | * done by skb DMA functions | |
984bc16c | 373 | * @secmark: security marking |
d84e0bd7 DB |
374 | * @mark: Generic packet mark |
375 | * @dropcount: total number of sk_receive_queue overflows | |
6aa895b0 | 376 | * @vlan_tci: vlan tag control information |
d84e0bd7 DB |
377 | * @transport_header: Transport layer header |
378 | * @network_header: Network layer header | |
379 | * @mac_header: Link layer header | |
380 | * @tail: Tail pointer | |
381 | * @end: End pointer | |
382 | * @head: Head of buffer | |
383 | * @data: Data head pointer | |
384 | * @truesize: Buffer size | |
385 | * @users: User count - see {datagram,tcp}.c | |
1da177e4 LT |
386 | */ |
387 | ||
388 | struct sk_buff { | |
389 | /* These two members must be first. */ | |
390 | struct sk_buff *next; | |
391 | struct sk_buff *prev; | |
392 | ||
b7aa0bf7 | 393 | ktime_t tstamp; |
da3f5cf1 FF |
394 | |
395 | struct sock *sk; | |
1da177e4 | 396 | struct net_device *dev; |
1da177e4 | 397 | |
1da177e4 LT |
398 | /* |
399 | * This is the control buffer. It is free to use for every | |
400 | * layer. Please put your private variables there. If you | |
401 | * want to keep them across layers you have to do a skb_clone() | |
402 | * first. This is owned by whoever has the skb queued ATM. | |
403 | */ | |
da3f5cf1 | 404 | char cb[48] __aligned(8); |
1da177e4 | 405 | |
7fee226a | 406 | unsigned long _skb_refdst; |
da3f5cf1 FF |
407 | #ifdef CONFIG_XFRM |
408 | struct sec_path *sp; | |
409 | #endif | |
1da177e4 | 410 | unsigned int len, |
334a8132 PM |
411 | data_len; |
412 | __u16 mac_len, | |
413 | hdr_len; | |
ff1dcadb AV |
414 | union { |
415 | __wsum csum; | |
663ead3b HX |
416 | struct { |
417 | __u16 csum_start; | |
418 | __u16 csum_offset; | |
419 | }; | |
ff1dcadb | 420 | }; |
1da177e4 | 421 | __u32 priority; |
fe55f6d5 | 422 | kmemcheck_bitfield_begin(flags1); |
1cbb3380 TG |
423 | __u8 local_df:1, |
424 | cloned:1, | |
425 | ip_summed:2, | |
6869c4d8 HW |
426 | nohdr:1, |
427 | nfctinfo:3; | |
d179cd12 | 428 | __u8 pkt_type:3, |
b84f4cc9 | 429 | fclone:2, |
ba9dda3a | 430 | ipvs_property:1, |
a59322be | 431 | peeked:1, |
ba9dda3a | 432 | nf_trace:1; |
fe55f6d5 | 433 | kmemcheck_bitfield_end(flags1); |
4ab408de | 434 | __be16 protocol; |
1da177e4 LT |
435 | |
436 | void (*destructor)(struct sk_buff *skb); | |
9fb9cbb1 | 437 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
5f79e0f9 | 438 | struct nf_conntrack *nfct; |
2fc72c7b KK |
439 | #endif |
440 | #ifdef NET_SKBUFF_NF_DEFRAG_NEEDED | |
9fb9cbb1 YK |
441 | struct sk_buff *nfct_reasm; |
442 | #endif | |
1da177e4 LT |
443 | #ifdef CONFIG_BRIDGE_NETFILTER |
444 | struct nf_bridge_info *nf_bridge; | |
445 | #endif | |
f25f4e44 | 446 | |
8964be4a | 447 | int skb_iif; |
4031ae6e AD |
448 | |
449 | __u32 rxhash; | |
450 | ||
451 | __u16 vlan_tci; | |
452 | ||
1da177e4 | 453 | #ifdef CONFIG_NET_SCHED |
b6b99eb5 | 454 | __u16 tc_index; /* traffic control index */ |
1da177e4 | 455 | #ifdef CONFIG_NET_CLS_ACT |
b6b99eb5 | 456 | __u16 tc_verd; /* traffic control verdict */ |
1da177e4 | 457 | #endif |
1da177e4 | 458 | #endif |
fe55f6d5 | 459 | |
0a14842f | 460 | __u16 queue_mapping; |
fe55f6d5 | 461 | kmemcheck_bitfield_begin(flags2); |
de357cc0 | 462 | #ifdef CONFIG_IPV6_NDISC_NODETYPE |
8a4eb573 | 463 | __u8 ndisc_nodetype:2; |
d0f09804 | 464 | #endif |
c93bdd0e | 465 | __u8 pfmemalloc:1; |
3853b584 | 466 | __u8 ooo_okay:1; |
bdeab991 | 467 | __u8 l4_rxhash:1; |
6e3e939f JB |
468 | __u8 wifi_acked_valid:1; |
469 | __u8 wifi_acked:1; | |
3bdc0eba | 470 | __u8 no_fcs:1; |
d3836f21 ED |
471 | __u8 head_frag:1; |
472 | /* 8/10 bit hole (depending on ndisc_nodetype presence) */ | |
fe55f6d5 VN |
473 | kmemcheck_bitfield_end(flags2); |
474 | ||
97fc2f08 CL |
475 | #ifdef CONFIG_NET_DMA |
476 | dma_cookie_t dma_cookie; | |
477 | #endif | |
984bc16c JM |
478 | #ifdef CONFIG_NETWORK_SECMARK |
479 | __u32 secmark; | |
480 | #endif | |
3b885787 NH |
481 | union { |
482 | __u32 mark; | |
483 | __u32 dropcount; | |
a21d4572 | 484 | __u32 avail_size; |
3b885787 | 485 | }; |
1da177e4 | 486 | |
27a884dc ACM |
487 | sk_buff_data_t transport_header; |
488 | sk_buff_data_t network_header; | |
489 | sk_buff_data_t mac_header; | |
1da177e4 | 490 | /* These elements must be at the end, see alloc_skb() for details. */ |
27a884dc | 491 | sk_buff_data_t tail; |
4305b541 | 492 | sk_buff_data_t end; |
1da177e4 | 493 | unsigned char *head, |
4305b541 | 494 | *data; |
27a884dc ACM |
495 | unsigned int truesize; |
496 | atomic_t users; | |
1da177e4 LT |
497 | }; |
498 | ||
499 | #ifdef __KERNEL__ | |
500 | /* | |
501 | * Handling routines are only of interest to the kernel | |
502 | */ | |
503 | #include <linux/slab.h> | |
504 | ||
1da177e4 | 505 | |
c93bdd0e MG |
506 | #define SKB_ALLOC_FCLONE 0x01 |
507 | #define SKB_ALLOC_RX 0x02 | |
508 | ||
509 | /* Returns true if the skb was allocated from PFMEMALLOC reserves */ | |
510 | static inline bool skb_pfmemalloc(const struct sk_buff *skb) | |
511 | { | |
512 | return unlikely(skb->pfmemalloc); | |
513 | } | |
514 | ||
7fee226a ED |
515 | /* |
516 | * skb might have a dst pointer attached, refcounted or not. | |
517 | * _skb_refdst low order bit is set if refcount was _not_ taken | |
518 | */ | |
519 | #define SKB_DST_NOREF 1UL | |
520 | #define SKB_DST_PTRMASK ~(SKB_DST_NOREF) | |
521 | ||
522 | /** | |
523 | * skb_dst - returns skb dst_entry | |
524 | * @skb: buffer | |
525 | * | |
526 | * Returns skb dst_entry, regardless of reference taken or not. | |
527 | */ | |
adf30907 ED |
528 | static inline struct dst_entry *skb_dst(const struct sk_buff *skb) |
529 | { | |
7fee226a ED |
530 | /* If refdst was not refcounted, check we still are in a |
531 | * rcu_read_lock section | |
532 | */ | |
533 | WARN_ON((skb->_skb_refdst & SKB_DST_NOREF) && | |
534 | !rcu_read_lock_held() && | |
535 | !rcu_read_lock_bh_held()); | |
536 | return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK); | |
adf30907 ED |
537 | } |
538 | ||
7fee226a ED |
539 | /** |
540 | * skb_dst_set - sets skb dst | |
541 | * @skb: buffer | |
542 | * @dst: dst entry | |
543 | * | |
544 | * Sets skb dst, assuming a reference was taken on dst and should | |
545 | * be released by skb_dst_drop() | |
546 | */ | |
adf30907 ED |
547 | static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) |
548 | { | |
7fee226a ED |
549 | skb->_skb_refdst = (unsigned long)dst; |
550 | } | |
551 | ||
27b75c95 | 552 | extern void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst); |
7fee226a ED |
553 | |
554 | /** | |
25985edc | 555 | * skb_dst_is_noref - Test if skb dst isn't refcounted |
7fee226a ED |
556 | * @skb: buffer |
557 | */ | |
558 | static inline bool skb_dst_is_noref(const struct sk_buff *skb) | |
559 | { | |
560 | return (skb->_skb_refdst & SKB_DST_NOREF) && skb_dst(skb); | |
adf30907 ED |
561 | } |
562 | ||
511c3f92 ED |
563 | static inline struct rtable *skb_rtable(const struct sk_buff *skb) |
564 | { | |
adf30907 | 565 | return (struct rtable *)skb_dst(skb); |
511c3f92 ED |
566 | } |
567 | ||