diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 12:26:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 12:26:46 -0400 |
commit | 15c54033964a943de7b0763efd3bd0ede7326395 (patch) | |
tree | 840b292612d1b5396d5bab5bde537a9013db3ceb /include/linux/skbuff.h | |
parent | ad5da3cf39a5b11a198929be1f2644e17ecd767e (diff) | |
parent | 912a41a4ab935ce8c4308428ec13fc7f8b1f18f4 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (448 commits)
[IPV4] nl_fib_lookup: Initialise res.r before fib_res_put(&res)
[IPV6]: Fix thinko in ipv6_rthdr_rcv() changes.
[IPV4]: Add multipath cached to feature-removal-schedule.txt
[WIRELESS] cfg80211: Clarify locking comment.
[WIRELESS] cfg80211: Fix locking in wiphy_new.
[WEXT] net_device: Don't include wext bits if not required.
[WEXT]: Misc code cleanups.
[WEXT]: Reduce inline abuse.
[WEXT]: Move EXPORT_SYMBOL statements where they belong.
[WEXT]: Cleanup early ioctl call path.
[WEXT]: Remove options.
[WEXT]: Remove dead debug code.
[WEXT]: Clean up how wext is called.
[WEXT]: Move to net/wireless
[AFS]: Eliminate cmpxchg() usage in vlocation code.
[RXRPC]: Fix pointers passed to bitops.
[RXRPC]: Remove bogus atomic_* overrides.
[AFS]: Fix u64 printing in debug logging.
[AFS]: Add "directory write" support.
[AFS]: Implement the CB.InitCallBackState3 operation.
...
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 392 |
1 files changed, 309 insertions, 83 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 5992f65b4184..2694cb3ca763 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -27,20 +27,24 @@ | |||
27 | #include <net/checksum.h> | 27 | #include <net/checksum.h> |
28 | #include <linux/rcupdate.h> | 28 | #include <linux/rcupdate.h> |
29 | #include <linux/dmaengine.h> | 29 | #include <linux/dmaengine.h> |
30 | #include <linux/hrtimer.h> | ||
30 | 31 | ||
31 | #define HAVE_ALLOC_SKB /* For the drivers to know */ | 32 | #define HAVE_ALLOC_SKB /* For the drivers to know */ |
32 | #define HAVE_ALIGNABLE_SKB /* Ditto 8) */ | 33 | #define HAVE_ALIGNABLE_SKB /* Ditto 8) */ |
33 | 34 | ||
35 | /* Don't change this without changing skb_csum_unnecessary! */ | ||
34 | #define CHECKSUM_NONE 0 | 36 | #define CHECKSUM_NONE 0 |
35 | #define CHECKSUM_PARTIAL 1 | 37 | #define CHECKSUM_UNNECESSARY 1 |
36 | #define CHECKSUM_UNNECESSARY 2 | 38 | #define CHECKSUM_COMPLETE 2 |
37 | #define CHECKSUM_COMPLETE 3 | 39 | #define CHECKSUM_PARTIAL 3 |
38 | 40 | ||
39 | #define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ | 41 | #define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ |
40 | ~(SMP_CACHE_BYTES - 1)) | 42 | ~(SMP_CACHE_BYTES - 1)) |
41 | #define SKB_MAX_ORDER(X, ORDER) (((PAGE_SIZE << (ORDER)) - (X) - \ | 43 | #define SKB_WITH_OVERHEAD(X) \ |
42 | sizeof(struct skb_shared_info)) & \ | 44 | (((X) - sizeof(struct skb_shared_info)) & \ |
43 | ~(SMP_CACHE_BYTES - 1)) | 45 | ~(SMP_CACHE_BYTES - 1)) |
46 | #define SKB_MAX_ORDER(X, ORDER) \ | ||
47 | SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X)) | ||
44 | #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0)) | 48 | #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0)) |
45 | #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) | 49 | #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) |
46 | 50 | ||
@@ -66,8 +70,8 @@ | |||
66 | * NONE: skb is checksummed by protocol or csum is not required. | 70 | * NONE: skb is checksummed by protocol or csum is not required. |
67 | * | 71 | * |
68 | * PARTIAL: device is required to csum packet as seen by hard_start_xmit | 72 | * PARTIAL: device is required to csum packet as seen by hard_start_xmit |
69 | * from skb->h.raw to the end and to record the checksum | 73 | * from skb->transport_header to the end and to record the checksum |
70 | * at skb->h.raw+skb->csum. | 74 | * at skb->transport_header + skb->csum. |
71 | * | 75 | * |
72 | * Device must show its capabilities in dev->features, set | 76 | * Device must show its capabilities in dev->features, set |
73 | * at device setup time. | 77 | * at device setup time. |
@@ -83,12 +87,13 @@ | |||
83 | */ | 87 | */ |
84 | 88 | ||
85 | struct net_device; | 89 | struct net_device; |
90 | struct scatterlist; | ||
86 | 91 | ||
87 | #ifdef CONFIG_NETFILTER | 92 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
88 | struct nf_conntrack { | 93 | struct nf_conntrack { |
89 | atomic_t use; | 94 | atomic_t use; |
90 | void (*destroy)(struct nf_conntrack *); | ||
91 | }; | 95 | }; |
96 | #endif | ||
92 | 97 | ||
93 | #ifdef CONFIG_BRIDGE_NETFILTER | 98 | #ifdef CONFIG_BRIDGE_NETFILTER |
94 | struct nf_bridge_info { | 99 | struct nf_bridge_info { |
@@ -103,8 +108,6 @@ struct nf_bridge_info { | |||
103 | }; | 108 | }; |
104 | #endif | 109 | #endif |
105 | 110 | ||
106 | #endif | ||
107 | |||
108 | struct sk_buff_head { | 111 | struct sk_buff_head { |
109 | /* These two members must be first. */ | 112 | /* These two members must be first. */ |
110 | struct sk_buff *next; | 113 | struct sk_buff *next; |
@@ -156,11 +159,6 @@ struct skb_shared_info { | |||
156 | #define SKB_DATAREF_SHIFT 16 | 159 | #define SKB_DATAREF_SHIFT 16 |
157 | #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) | 160 | #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) |
158 | 161 | ||
159 | struct skb_timeval { | ||
160 | u32 off_sec; | ||
161 | u32 off_usec; | ||
162 | }; | ||
163 | |||
164 | 162 | ||
165 | enum { | 163 | enum { |
166 | SKB_FCLONE_UNAVAILABLE, | 164 | SKB_FCLONE_UNAVAILABLE, |
@@ -181,6 +179,16 @@ enum { | |||
181 | SKB_GSO_TCPV6 = 1 << 4, | 179 | SKB_GSO_TCPV6 = 1 << 4, |
182 | }; | 180 | }; |
183 | 181 | ||
182 | #if BITS_PER_LONG > 32 | ||
183 | #define NET_SKBUFF_DATA_USES_OFFSET 1 | ||
184 | #endif | ||
185 | |||
186 | #ifdef NET_SKBUFF_DATA_USES_OFFSET | ||
187 | typedef unsigned int sk_buff_data_t; | ||
188 | #else | ||
189 | typedef unsigned char *sk_buff_data_t; | ||
190 | #endif | ||
191 | |||
184 | /** | 192 | /** |
185 | * struct sk_buff - socket buffer | 193 | * struct sk_buff - socket buffer |
186 | * @next: Next buffer in list | 194 | * @next: Next buffer in list |
@@ -190,15 +198,17 @@ enum { | |||
190 | * @dev: Device we arrived on/are leaving by | 198 | * @dev: Device we arrived on/are leaving by |
191 | * @iif: ifindex of device we arrived on | 199 | * @iif: ifindex of device we arrived on |
192 | * @h: Transport layer header | 200 | * @h: Transport layer header |
193 | * @nh: Network layer header | 201 | * @network_header: Network layer header |
194 | * @mac: Link layer header | 202 | * @mac_header: Link layer header |
195 | * @dst: destination entry | 203 | * @dst: destination entry |
196 | * @sp: the security path, used for xfrm | 204 | * @sp: the security path, used for xfrm |
197 | * @cb: Control buffer. Free for use by every layer. Put private vars here | 205 | * @cb: Control buffer. Free for use by every layer. Put private vars here |
198 | * @len: Length of actual data | 206 | * @len: Length of actual data |
199 | * @data_len: Data length | 207 | * @data_len: Data length |
200 | * @mac_len: Length of link layer header | 208 | * @mac_len: Length of link layer header |
201 | * @csum: Checksum | 209 | * @csum: Checksum (must include start/offset pair) |
210 | * @csum_start: Offset from skb->head where checksumming should start | ||
211 | * @csum_offset: Offset from csum_start where checksum should be stored | ||
202 | * @local_df: allow local fragmentation | 212 | * @local_df: allow local fragmentation |
203 | * @cloned: Head may be cloned (check refcnt to be sure) | 213 | * @cloned: Head may be cloned (check refcnt to be sure) |
204 | * @nohdr: Payload reference only, must not modify header | 214 | * @nohdr: Payload reference only, must not modify header |
@@ -233,32 +243,11 @@ struct sk_buff { | |||
233 | struct sk_buff *prev; | 243 | struct sk_buff *prev; |
234 | 244 | ||
235 | struct sock *sk; | 245 | struct sock *sk; |
236 | struct skb_timeval tstamp; | 246 | ktime_t tstamp; |
237 | struct net_device *dev; | 247 | struct net_device *dev; |
238 | int iif; | 248 | int iif; |
239 | /* 4 byte hole on 64 bit*/ | 249 | /* 4 byte hole on 64 bit*/ |
240 | 250 | ||
241 | union { | ||
242 | struct tcphdr *th; | ||
243 | struct udphdr *uh; | ||
244 | struct icmphdr *icmph; | ||
245 | struct igmphdr *igmph; | ||
246 | struct iphdr *ipiph; | ||
247 | struct ipv6hdr *ipv6h; | ||
248 | unsigned char *raw; | ||
249 | } h; | ||
250 | |||
251 | union { | ||
252 | struct iphdr *iph; | ||
253 | struct ipv6hdr *ipv6h; | ||
254 | struct arphdr *arph; | ||
255 | unsigned char *raw; | ||
256 | } nh; | ||
257 | |||
258 | union { | ||
259 | unsigned char *raw; | ||
260 | } mac; | ||
261 | |||
262 | struct dst_entry *dst; | 251 | struct dst_entry *dst; |
263 | struct sec_path *sp; | 252 | struct sec_path *sp; |
264 | 253 | ||
@@ -275,7 +264,10 @@ struct sk_buff { | |||
275 | mac_len; | 264 | mac_len; |
276 | union { | 265 | union { |
277 | __wsum csum; | 266 | __wsum csum; |
278 | __u32 csum_offset; | 267 | struct { |
268 | __u16 csum_start; | ||
269 | __u16 csum_offset; | ||
270 | }; | ||
279 | }; | 271 | }; |
280 | __u32 priority; | 272 | __u32 priority; |
281 | __u8 local_df:1, | 273 | __u8 local_df:1, |
@@ -289,15 +281,13 @@ struct sk_buff { | |||
289 | __be16 protocol; | 281 | __be16 protocol; |
290 | 282 | ||
291 | void (*destructor)(struct sk_buff *skb); | 283 | void (*destructor)(struct sk_buff *skb); |
292 | #ifdef CONFIG_NETFILTER | ||
293 | struct nf_conntrack *nfct; | ||
294 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 284 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
285 | struct nf_conntrack *nfct; | ||
295 | struct sk_buff *nfct_reasm; | 286 | struct sk_buff *nfct_reasm; |
296 | #endif | 287 | #endif |
297 | #ifdef CONFIG_BRIDGE_NETFILTER | 288 | #ifdef CONFIG_BRIDGE_NETFILTER |
298 | struct nf_bridge_info *nf_bridge; | 289 | struct nf_bridge_info *nf_bridge; |
299 | #endif | 290 | #endif |
300 | #endif /* CONFIG_NETFILTER */ | ||
301 | #ifdef CONFIG_NET_SCHED | 291 | #ifdef CONFIG_NET_SCHED |
302 | __u16 tc_index; /* traffic control index */ | 292 | __u16 tc_index; /* traffic control index */ |
303 | #ifdef CONFIG_NET_CLS_ACT | 293 | #ifdef CONFIG_NET_CLS_ACT |
@@ -313,13 +303,16 @@ struct sk_buff { | |||
313 | 303 | ||
314 | __u32 mark; | 304 | __u32 mark; |
315 | 305 | ||
306 | sk_buff_data_t transport_header; | ||
307 | sk_buff_data_t network_header; | ||
308 | sk_buff_data_t mac_header; | ||
316 | /* These elements must be at the end, see alloc_skb() for details. */ | 309 | /* These elements must be at the end, see alloc_skb() for details. */ |
310 | sk_buff_data_t tail; | ||
311 | sk_buff_data_t end; | ||
312 | unsigned char *head, | ||
313 | *data; | ||
317 | unsigned int truesize; | 314 | unsigned int truesize; |
318 | atomic_t users; | 315 | atomic_t users; |
319 | unsigned char *head, | ||
320 | *data, | ||
321 | *tail, | ||
322 | *end; | ||
323 | }; | 316 | }; |
324 | 317 | ||
325 | #ifdef __KERNEL__ | 318 | #ifdef __KERNEL__ |
@@ -361,6 +354,11 @@ extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, | |||
361 | extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb, | 354 | extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb, |
362 | int newheadroom, int newtailroom, | 355 | int newheadroom, int newtailroom, |
363 | gfp_t priority); | 356 | gfp_t priority); |
357 | extern int skb_to_sgvec(struct sk_buff *skb, | ||
358 | struct scatterlist *sg, int offset, | ||
359 | int len); | ||
360 | extern int skb_cow_data(struct sk_buff *skb, int tailbits, | ||
361 | struct sk_buff **trailer); | ||
364 | extern int skb_pad(struct sk_buff *skb, int pad); | 362 | extern int skb_pad(struct sk_buff *skb, int pad); |
365 | #define dev_kfree_skb(a) kfree_skb(a) | 363 | #define dev_kfree_skb(a) kfree_skb(a) |
366 | extern void skb_over_panic(struct sk_buff *skb, int len, | 364 | extern void skb_over_panic(struct sk_buff *skb, int len, |
@@ -402,8 +400,20 @@ extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, | |||
402 | unsigned int to, struct ts_config *config, | 400 | unsigned int to, struct ts_config *config, |
403 | struct ts_state *state); | 401 | struct ts_state *state); |
404 | 402 | ||
403 | #ifdef NET_SKBUFF_DATA_USES_OFFSET | ||
404 | static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) | ||
405 | { | ||
406 | return skb->head + skb->end; | ||
407 | } | ||
408 | #else | ||
409 | static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) | ||
410 | { | ||
411 | return skb->end; | ||
412 | } | ||
413 | #endif | ||
414 | |||
405 | /* Internal */ | 415 | /* Internal */ |
406 | #define skb_shinfo(SKB) ((struct skb_shared_info *)((SKB)->end)) | 416 | #define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB))) |
407 | 417 | ||
408 | /** | 418 | /** |
409 | * skb_queue_empty - check if a queue is empty | 419 | * skb_queue_empty - check if a queue is empty |
@@ -822,12 +832,46 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i, | |||
822 | #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list) | 832 | #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list) |
823 | #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) | 833 | #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) |
824 | 834 | ||
835 | #ifdef NET_SKBUFF_DATA_USES_OFFSET | ||
836 | static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) | ||
837 | { | ||
838 | return skb->head + skb->tail; | ||
839 | } | ||
840 | |||
841 | static inline void skb_reset_tail_pointer(struct sk_buff *skb) | ||
842 | { | ||
843 | skb->tail = skb->data - skb->head; | ||
844 | } | ||
845 | |||
846 | static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset) | ||
847 | { | ||
848 | skb_reset_tail_pointer(skb); | ||
849 | skb->tail += offset; | ||
850 | } | ||
851 | #else /* NET_SKBUFF_DATA_USES_OFFSET */ | ||
852 | static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) | ||
853 | { | ||
854 | return skb->tail; | ||
855 | } | ||
856 | |||
857 | static inline void skb_reset_tail_pointer(struct sk_buff *skb) | ||
858 | { | ||
859 | skb->tail = skb->data; | ||
860 | } | ||
861 | |||
862 | static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset) | ||
863 | { | ||
864 | skb->tail = skb->data + offset; | ||
865 | } | ||
866 | |||
867 | #endif /* NET_SKBUFF_DATA_USES_OFFSET */ | ||
868 | |||
825 | /* | 869 | /* |
826 | * Add data to an sk_buff | 870 | * Add data to an sk_buff |
827 | */ | 871 | */ |
828 | static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) | 872 | static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) |
829 | { | 873 | { |
830 | unsigned char *tmp = skb->tail; | 874 | unsigned char *tmp = skb_tail_pointer(skb); |
831 | SKB_LINEAR_ASSERT(skb); | 875 | SKB_LINEAR_ASSERT(skb); |
832 | skb->tail += len; | 876 | skb->tail += len; |
833 | skb->len += len; | 877 | skb->len += len; |
@@ -845,11 +889,11 @@ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) | |||
845 | */ | 889 | */ |
846 | static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len) | 890 | static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len) |
847 | { | 891 | { |
848 | unsigned char *tmp = skb->tail; | 892 | unsigned char *tmp = skb_tail_pointer(skb); |
849 | SKB_LINEAR_ASSERT(skb); | 893 | SKB_LINEAR_ASSERT(skb); |
850 | skb->tail += len; | 894 | skb->tail += len; |
851 | skb->len += len; | 895 | skb->len += len; |
852 | if (unlikely(skb->tail>skb->end)) | 896 | if (unlikely(skb->tail > skb->end)) |
853 | skb_over_panic(skb, len, current_text_addr()); | 897 | skb_over_panic(skb, len, current_text_addr()); |
854 | return tmp; | 898 | return tmp; |
855 | } | 899 | } |
@@ -962,6 +1006,130 @@ static inline void skb_reserve(struct sk_buff *skb, int len) | |||
962 | skb->tail += len; | 1006 | skb->tail += len; |
963 | } | 1007 | } |
964 | 1008 | ||
1009 | #ifdef NET_SKBUFF_DATA_USES_OFFSET | ||
1010 | static inline unsigned char *skb_transport_header(const struct sk_buff *skb) | ||
1011 | { | ||
1012 | return skb->head + skb->transport_header; | ||
1013 | } | ||
1014 | |||
1015 | static inline void skb_reset_transport_header(struct sk_buff *skb) | ||
1016 | { | ||
1017 | skb->transport_header = skb->data - skb->head; | ||
1018 | } | ||
1019 | |||
1020 | static inline void skb_set_transport_header(struct sk_buff *skb, | ||
1021 | const int offset) | ||
1022 | { | ||
1023 | skb_reset_transport_header(skb); | ||
1024 | skb->transport_header += offset; | ||
1025 | } | ||
1026 | |||
1027 | static inline unsigned char *skb_network_header(const struct sk_buff *skb) | ||
1028 | { | ||
1029 | return skb->head + skb->network_header; | ||
1030 | } | ||
1031 | |||
1032 | static inline void skb_reset_network_header(struct sk_buff *skb) | ||
1033 | { | ||
1034 | skb->network_header = skb->data - skb->head; | ||
1035 | } | ||
1036 | |||
1037 | static inline void skb_set_network_header(struct sk_buff *skb, const int offset) | ||
1038 | { | ||
1039 | skb_reset_network_header(skb); | ||
1040 | skb->network_header += offset; | ||
1041 | } | ||
1042 | |||
1043 | static inline unsigned char *skb_mac_header(const struct sk_buff *skb) | ||
1044 | { | ||
1045 | return skb->head + skb->mac_header; | ||
1046 | } | ||
1047 | |||
1048 | static inline int skb_mac_header_was_set(const struct sk_buff *skb) | ||
1049 | { | ||
1050 | return skb->mac_header != ~0U; | ||
1051 | } | ||
1052 | |||
1053 | static inline void skb_reset_mac_header(struct sk_buff *skb) | ||
1054 | { | ||
1055 | skb->mac_header = skb->data - skb->head; | ||
1056 | } | ||
1057 | |||
1058 | static inline void skb_set_mac_header(struct sk_buff *skb, const int offset) | ||
1059 | { | ||
1060 | skb_reset_mac_header(skb); | ||
1061 | skb->mac_header += offset; | ||
1062 | } | ||
1063 | |||
1064 | #else /* NET_SKBUFF_DATA_USES_OFFSET */ | ||
1065 | |||
1066 | static inline unsigned char *skb_transport_header(const struct sk_buff *skb) | ||
1067 | { | ||
1068 | return skb->transport_header; | ||
1069 | } | ||
1070 | |||
1071 | static inline void skb_reset_transport_header(struct sk_buff *skb) | ||
1072 | { | ||
1073 | skb->transport_header = skb->data; | ||
1074 | } | ||
1075 | |||
1076 | static inline void skb_set_transport_header(struct sk_buff *skb, | ||
1077 | const int offset) | ||
1078 | { | ||
1079 | skb->transport_header = skb->data + offset; | ||
1080 | } | ||
1081 | |||
1082 | static inline unsigned char *skb_network_header(const struct sk_buff *skb) | ||
1083 | { | ||
1084 | return skb->network_header; | ||
1085 | } | ||
1086 | |||
1087 | static inline void skb_reset_network_header(struct sk_buff *skb) | ||
1088 | { | ||
1089 | skb->network_header = skb->data; | ||
1090 | } | ||
1091 | |||
1092 | static inline void skb_set_network_header(struct sk_buff *skb, const int offset) | ||
1093 | { | ||
1094 | skb->network_header = skb->data + offset; | ||
1095 | } | ||
1096 | |||
1097 | static inline unsigned char *skb_mac_header(const struct sk_buff *skb) | ||
1098 | { | ||
1099 | return skb->mac_header; | ||
1100 | } | ||
1101 | |||
1102 | static inline int skb_mac_header_was_set(const struct sk_buff *skb) | ||
1103 | { | ||
1104 | return skb->mac_header != NULL; | ||
1105 | } | ||
1106 | |||
1107 | static inline void skb_reset_mac_header(struct sk_buff *skb) | ||
1108 | { | ||
1109 | skb->mac_header = skb->data; | ||
1110 | } | ||
1111 | |||
1112 | static inline void skb_set_mac_header(struct sk_buff *skb, const int offset) | ||
1113 | { | ||
1114 | skb->mac_header = skb->data + offset; | ||
1115 | } | ||
1116 | #endif /* NET_SKBUFF_DATA_USES_OFFSET */ | ||
1117 | |||
1118 | static inline int skb_transport_offset(const struct sk_buff *skb) | ||
1119 | { | ||
1120 | return skb_transport_header(skb) - skb->data; | ||
1121 | } | ||
1122 | |||
1123 | static inline u32 skb_network_header_len(const struct sk_buff *skb) | ||
1124 | { | ||
1125 | return skb->transport_header - skb->network_header; | ||
1126 | } | ||
1127 | |||
1128 | static inline int skb_network_offset(const struct sk_buff *skb) | ||
1129 | { | ||
1130 | return skb_network_header(skb) - skb->data; | ||
1131 | } | ||
1132 | |||
965 | /* | 1133 | /* |
966 | * CPUs often take a performance hit when accessing unaligned memory | 1134 | * CPUs often take a performance hit when accessing unaligned memory |
967 | * locations. The actual performance hit varies, it can be small if the | 1135 | * locations. The actual performance hit varies, it can be small if the |
@@ -1013,8 +1181,8 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len) | |||
1013 | WARN_ON(1); | 1181 | WARN_ON(1); |
1014 | return; | 1182 | return; |
1015 | } | 1183 | } |
1016 | skb->len = len; | 1184 | skb->len = len; |
1017 | skb->tail = skb->data + len; | 1185 | skb_set_tail_pointer(skb, len); |
1018 | } | 1186 | } |
1019 | 1187 | ||
1020 | /** | 1188 | /** |
@@ -1326,8 +1494,8 @@ extern __wsum skb_checksum(const struct sk_buff *skb, int offset, | |||
1326 | int len, __wsum csum); | 1494 | int len, __wsum csum); |
1327 | extern int skb_copy_bits(const struct sk_buff *skb, int offset, | 1495 | extern int skb_copy_bits(const struct sk_buff *skb, int offset, |
1328 | void *to, int len); | 1496 | void *to, int len); |
1329 | extern int skb_store_bits(const struct sk_buff *skb, int offset, | 1497 | extern int skb_store_bits(struct sk_buff *skb, int offset, |
1330 | void *from, int len); | 1498 | const void *from, int len); |
1331 | extern __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, | 1499 | extern __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, |
1332 | int offset, u8 *to, int len, | 1500 | int offset, u8 *to, int len, |
1333 | __wsum csum); | 1501 | __wsum csum); |
@@ -1351,8 +1519,36 @@ static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, | |||
1351 | return buffer; | 1519 | return buffer; |
1352 | } | 1520 | } |
1353 | 1521 | ||
1522 | static inline void skb_copy_from_linear_data(const struct sk_buff *skb, | ||
1523 | void *to, | ||
1524 | const unsigned int len) | ||
1525 | { | ||
1526 | memcpy(to, skb->data, len); | ||
1527 | } | ||
1528 | |||
1529 | static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb, | ||
1530 | const int offset, void *to, | ||
1531 | const unsigned int len) | ||
1532 | { | ||
1533 | memcpy(to, skb->data + offset, len); | ||
1534 | } | ||
1535 | |||
1536 | static inline void skb_copy_to_linear_data(struct sk_buff *skb, | ||
1537 | const void *from, | ||
1538 | const unsigned int len) | ||
1539 | { | ||
1540 | memcpy(skb->data, from, len); | ||
1541 | } | ||
1542 | |||
1543 | static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb, | ||
1544 | const int offset, | ||
1545 | const void *from, | ||
1546 | const unsigned int len) | ||
1547 | { | ||
1548 | memcpy(skb->data + offset, from, len); | ||
1549 | } | ||
1550 | |||
1354 | extern void skb_init(void); | 1551 | extern void skb_init(void); |
1355 | extern void skb_add_mtu(int mtu); | ||
1356 | 1552 | ||
1357 | /** | 1553 | /** |
1358 | * skb_get_timestamp - get timestamp from a skb | 1554 | * skb_get_timestamp - get timestamp from a skb |
@@ -1365,29 +1561,28 @@ extern void skb_add_mtu(int mtu); | |||
1365 | */ | 1561 | */ |
1366 | static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp) | 1562 | static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp) |
1367 | { | 1563 | { |
1368 | stamp->tv_sec = skb->tstamp.off_sec; | 1564 | *stamp = ktime_to_timeval(skb->tstamp); |
1369 | stamp->tv_usec = skb->tstamp.off_usec; | ||
1370 | } | 1565 | } |
1371 | 1566 | ||
1372 | /** | 1567 | static inline void __net_timestamp(struct sk_buff *skb) |
1373 | * skb_set_timestamp - set timestamp of a skb | 1568 | { |
1374 | * @skb: skb to set stamp of | 1569 | skb->tstamp = ktime_get_real(); |
1375 | * @stamp: pointer to struct timeval to get stamp from | 1570 | } |
1376 | * | 1571 | |
1377 | * Timestamps are stored in the skb as offsets to a base timestamp. | 1572 | static inline ktime_t net_timedelta(ktime_t t) |
1378 | * This function converts a struct timeval to an offset and stores | ||
1379 | * it in the skb. | ||
1380 | */ | ||
1381 | static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *stamp) | ||
1382 | { | 1573 | { |
1383 | skb->tstamp.off_sec = stamp->tv_sec; | 1574 | return ktime_sub(ktime_get_real(), t); |
1384 | skb->tstamp.off_usec = stamp->tv_usec; | ||
1385 | } | 1575 | } |
1386 | 1576 | ||
1387 | extern void __net_timestamp(struct sk_buff *skb); | ||
1388 | 1577 | ||
1578 | extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); | ||
1389 | extern __sum16 __skb_checksum_complete(struct sk_buff *skb); | 1579 | extern __sum16 __skb_checksum_complete(struct sk_buff *skb); |
1390 | 1580 | ||
1581 | static inline int skb_csum_unnecessary(const struct sk_buff *skb) | ||
1582 | { | ||
1583 | return skb->ip_summed & CHECKSUM_UNNECESSARY; | ||
1584 | } | ||
1585 | |||
1391 | /** | 1586 | /** |
1392 | * skb_checksum_complete - Calculate checksum of an entire packet | 1587 | * skb_checksum_complete - Calculate checksum of an entire packet |
1393 | * @skb: packet to process | 1588 | * @skb: packet to process |
@@ -1406,22 +1601,22 @@ extern __sum16 __skb_checksum_complete(struct sk_buff *skb); | |||
1406 | */ | 1601 | */ |
1407 | static inline unsigned int skb_checksum_complete(struct sk_buff *skb) | 1602 | static inline unsigned int skb_checksum_complete(struct sk_buff *skb) |
1408 | { | 1603 | { |
1409 | return skb->ip_summed != CHECKSUM_UNNECESSARY && | 1604 | return skb_csum_unnecessary(skb) ? |
1410 | __skb_checksum_complete(skb); | 1605 | 0 : __skb_checksum_complete(skb); |
1411 | } | 1606 | } |
1412 | 1607 | ||
1413 | #ifdef CONFIG_NETFILTER | 1608 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
1609 | extern void nf_conntrack_destroy(struct nf_conntrack *nfct); | ||
1414 | static inline void nf_conntrack_put(struct nf_conntrack *nfct) | 1610 | static inline void nf_conntrack_put(struct nf_conntrack *nfct) |
1415 | { | 1611 | { |
1416 | if (nfct && atomic_dec_and_test(&nfct->use)) | 1612 | if (nfct && atomic_dec_and_test(&nfct->use)) |
1417 | nfct->destroy(nfct); | 1613 | nf_conntrack_destroy(nfct); |
1418 | } | 1614 | } |
1419 | static inline void nf_conntrack_get(struct nf_conntrack *nfct) | 1615 | static inline void nf_conntrack_get(struct nf_conntrack *nfct) |
1420 | { | 1616 | { |
1421 | if (nfct) | 1617 | if (nfct) |
1422 | atomic_inc(&nfct->use); | 1618 | atomic_inc(&nfct->use); |
1423 | } | 1619 | } |
1424 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
1425 | static inline void nf_conntrack_get_reasm(struct sk_buff *skb) | 1620 | static inline void nf_conntrack_get_reasm(struct sk_buff *skb) |
1426 | { | 1621 | { |
1427 | if (skb) | 1622 | if (skb) |
@@ -1447,9 +1642,9 @@ static inline void nf_bridge_get(struct nf_bridge_info *nf_bridge) | |||
1447 | #endif /* CONFIG_BRIDGE_NETFILTER */ | 1642 | #endif /* CONFIG_BRIDGE_NETFILTER */ |
1448 | static inline void nf_reset(struct sk_buff *skb) | 1643 | static inline void nf_reset(struct sk_buff *skb) |
1449 | { | 1644 | { |
1645 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
1450 | nf_conntrack_put(skb->nfct); | 1646 | nf_conntrack_put(skb->nfct); |
1451 | skb->nfct = NULL; | 1647 | skb->nfct = NULL; |
1452 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
1453 | nf_conntrack_put_reasm(skb->nfct_reasm); | 1648 | nf_conntrack_put_reasm(skb->nfct_reasm); |
1454 | skb->nfct_reasm = NULL; | 1649 | skb->nfct_reasm = NULL; |
1455 | #endif | 1650 | #endif |
@@ -1459,9 +1654,33 @@ static inline void nf_reset(struct sk_buff *skb) | |||
1459 | #endif | 1654 | #endif |
1460 | } | 1655 | } |
1461 | 1656 | ||
1462 | #else /* CONFIG_NETFILTER */ | 1657 | /* Note: This doesn't put any conntrack and bridge info in dst. */ |
1463 | static inline void nf_reset(struct sk_buff *skb) {} | 1658 | static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src) |
1464 | #endif /* CONFIG_NETFILTER */ | 1659 | { |
1660 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
1661 | dst->nfct = src->nfct; | ||
1662 | nf_conntrack_get(src->nfct); | ||
1663 | dst->nfctinfo = src->nfctinfo; | ||
1664 | dst->nfct_reasm = src->nfct_reasm; | ||
1665 | nf_conntrack_get_reasm(src->nfct_reasm); | ||
1666 | #endif | ||
1667 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
1668 | dst->nf_bridge = src->nf_bridge; | ||
1669 | nf_bridge_get(src->nf_bridge); | ||
1670 | #endif | ||
1671 | } | ||
1672 | |||
1673 | static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) | ||
1674 | { | ||
1675 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
1676 | nf_conntrack_put(dst->nfct); | ||
1677 | nf_conntrack_put_reasm(dst->nfct_reasm); | ||
1678 | #endif | ||
1679 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
1680 | nf_bridge_put(dst->nf_bridge); | ||
1681 | #endif | ||
1682 | __nf_copy(dst, src); | ||
1683 | } | ||
1465 | 1684 | ||
1466 | #ifdef CONFIG_NETWORK_SECMARK | 1685 | #ifdef CONFIG_NETWORK_SECMARK |
1467 | static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from) | 1686 | static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from) |
@@ -1486,5 +1705,12 @@ static inline int skb_is_gso(const struct sk_buff *skb) | |||
1486 | return skb_shinfo(skb)->gso_size; | 1705 | return skb_shinfo(skb)->gso_size; |
1487 | } | 1706 | } |
1488 | 1707 | ||
1708 | static inline void skb_forward_csum(struct sk_buff *skb) | ||
1709 | { | ||
1710 | /* Unfortunately we don't support this one. Any brave souls? */ | ||
1711 | if (skb->ip_summed == CHECKSUM_COMPLETE) | ||
1712 | skb->ip_summed = CHECKSUM_NONE; | ||
1713 | } | ||
1714 | |||
1489 | #endif /* __KERNEL__ */ | 1715 | #endif /* __KERNEL__ */ |
1490 | #endif /* _LINUX_SKBUFF_H */ | 1716 | #endif /* _LINUX_SKBUFF_H */ |