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