diff options
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f8f234708b98..66f8819f9568 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -14,7 +14,6 @@ | |||
14 | #ifndef _LINUX_SKBUFF_H | 14 | #ifndef _LINUX_SKBUFF_H |
15 | #define _LINUX_SKBUFF_H | 15 | #define _LINUX_SKBUFF_H |
16 | 16 | ||
17 | #include <linux/config.h> | ||
18 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
19 | #include <linux/compiler.h> | 18 | #include <linux/compiler.h> |
20 | #include <linux/time.h> | 19 | #include <linux/time.h> |
@@ -29,6 +28,7 @@ | |||
29 | #include <linux/net.h> | 28 | #include <linux/net.h> |
30 | #include <linux/textsearch.h> | 29 | #include <linux/textsearch.h> |
31 | #include <net/checksum.h> | 30 | #include <net/checksum.h> |
31 | #include <linux/dmaengine.h> | ||
32 | 32 | ||
33 | #define HAVE_ALLOC_SKB /* For the drivers to know */ | 33 | #define HAVE_ALLOC_SKB /* For the drivers to know */ |
34 | #define HAVE_ALIGNABLE_SKB /* Ditto 8) */ | 34 | #define HAVE_ALIGNABLE_SKB /* Ditto 8) */ |
@@ -209,6 +209,7 @@ enum { | |||
209 | * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c | 209 | * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c |
210 | * @tc_index: Traffic control index | 210 | * @tc_index: Traffic control index |
211 | * @tc_verd: traffic control verdict | 211 | * @tc_verd: traffic control verdict |
212 | * @secmark: security marking | ||
212 | */ | 213 | */ |
213 | 214 | ||
214 | struct sk_buff { | 215 | struct sk_buff { |
@@ -285,6 +286,12 @@ struct sk_buff { | |||
285 | __u16 tc_verd; /* traffic control verdict */ | 286 | __u16 tc_verd; /* traffic control verdict */ |
286 | #endif | 287 | #endif |
287 | #endif | 288 | #endif |
289 | #ifdef CONFIG_NET_DMA | ||
290 | dma_cookie_t dma_cookie; | ||
291 | #endif | ||
292 | #ifdef CONFIG_NETWORK_SECMARK | ||
293 | __u32 secmark; | ||
294 | #endif | ||
288 | 295 | ||
289 | 296 | ||
290 | /* These elements must be at the end, see alloc_skb() for details. */ | 297 | /* These elements must be at the end, see alloc_skb() for details. */ |
@@ -967,15 +974,16 @@ static inline void skb_reserve(struct sk_buff *skb, int len) | |||
967 | #define NET_SKB_PAD 16 | 974 | #define NET_SKB_PAD 16 |
968 | #endif | 975 | #endif |
969 | 976 | ||
970 | extern int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc); | 977 | extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); |
971 | 978 | ||
972 | static inline void __skb_trim(struct sk_buff *skb, unsigned int len) | 979 | static inline void __skb_trim(struct sk_buff *skb, unsigned int len) |
973 | { | 980 | { |
974 | if (!skb->data_len) { | 981 | if (unlikely(skb->data_len)) { |
975 | skb->len = len; | 982 | WARN_ON(1); |
976 | skb->tail = skb->data + len; | 983 | return; |
977 | } else | 984 | } |
978 | ___pskb_trim(skb, len, 0); | 985 | skb->len = len; |
986 | skb->tail = skb->data + len; | ||
979 | } | 987 | } |
980 | 988 | ||
981 | /** | 989 | /** |
@@ -985,6 +993,7 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len) | |||
985 | * | 993 | * |
986 | * Cut the length of a buffer down by removing data from the tail. If | 994 | * Cut the length of a buffer down by removing data from the tail. If |
987 | * the buffer is already under the length specified it is not modified. | 995 | * the buffer is already under the length specified it is not modified. |
996 | * The skb must be linear. | ||
988 | */ | 997 | */ |
989 | static inline void skb_trim(struct sk_buff *skb, unsigned int len) | 998 | static inline void skb_trim(struct sk_buff *skb, unsigned int len) |
990 | { | 999 | { |
@@ -995,12 +1004,10 @@ static inline void skb_trim(struct sk_buff *skb, unsigned int len) | |||
995 | 1004 | ||
996 | static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) | 1005 | static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) |
997 | { | 1006 | { |
998 | if (!skb->data_len) { | 1007 | if (skb->data_len) |
999 | skb->len = len; | 1008 | return ___pskb_trim(skb, len); |
1000 | skb->tail = skb->data+len; | 1009 | __skb_trim(skb, len); |
1001 | return 0; | 1010 | return 0; |
1002 | } | ||
1003 | return ___pskb_trim(skb, len, 1); | ||
1004 | } | 1011 | } |
1005 | 1012 | ||
1006 | static inline int pskb_trim(struct sk_buff *skb, unsigned int len) | 1013 | static inline int pskb_trim(struct sk_buff *skb, unsigned int len) |
@@ -1161,18 +1168,34 @@ static inline int skb_can_coalesce(struct sk_buff *skb, int i, | |||
1161 | return 0; | 1168 | return 0; |
1162 | } | 1169 | } |
1163 | 1170 | ||
1171 | static inline int __skb_linearize(struct sk_buff *skb) | ||
1172 | { | ||
1173 | return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM; | ||
1174 | } | ||
1175 | |||
1164 | /** | 1176 | /** |
1165 | * skb_linearize - convert paged skb to linear one | 1177 | * skb_linearize - convert paged skb to linear one |
1166 | * @skb: buffer to linarize | 1178 | * @skb: buffer to linarize |
1167 | * @gfp: allocation mode | ||
1168 | * | 1179 | * |
1169 | * If there is no free memory -ENOMEM is returned, otherwise zero | 1180 | * If there is no free memory -ENOMEM is returned, otherwise zero |
1170 | * is returned and the old skb data released. | 1181 | * is returned and the old skb data released. |
1171 | */ | 1182 | */ |
1172 | extern int __skb_linearize(struct sk_buff *skb, gfp_t gfp); | 1183 | static inline int skb_linearize(struct sk_buff *skb) |
1173 | static inline int skb_linearize(struct sk_buff *skb, gfp_t gfp) | 1184 | { |
1185 | return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0; | ||
1186 | } | ||
1187 | |||
1188 | /** | ||
1189 | * skb_linearize_cow - make sure skb is linear and writable | ||
1190 | * @skb: buffer to process | ||
1191 | * | ||
1192 | * If there is no free memory -ENOMEM is returned, otherwise zero | ||
1193 | * is returned and the old skb data released. | ||
1194 | */ | ||
1195 | static inline int skb_linearize_cow(struct sk_buff *skb) | ||
1174 | { | 1196 | { |
1175 | return __skb_linearize(skb, gfp); | 1197 | return skb_is_nonlinear(skb) || skb_cloned(skb) ? |
1198 | __skb_linearize(skb) : 0; | ||
1176 | } | 1199 | } |
1177 | 1200 | ||
1178 | /** | 1201 | /** |
@@ -1396,5 +1419,23 @@ static inline void nf_reset(struct sk_buff *skb) | |||
1396 | static inline void nf_reset(struct sk_buff *skb) {} | 1419 | static inline void nf_reset(struct sk_buff *skb) {} |
1397 | #endif /* CONFIG_NETFILTER */ | 1420 | #endif /* CONFIG_NETFILTER */ |
1398 | 1421 | ||
1422 | #ifdef CONFIG_NETWORK_SECMARK | ||
1423 | static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from) | ||
1424 | { | ||
1425 | to->secmark = from->secmark; | ||
1426 | } | ||
1427 | |||
1428 | static inline void skb_init_secmark(struct sk_buff *skb) | ||
1429 | { | ||
1430 | skb->secmark = 0; | ||
1431 | } | ||
1432 | #else | ||
1433 | static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from) | ||
1434 | { } | ||
1435 | |||
1436 | static inline void skb_init_secmark(struct sk_buff *skb) | ||
1437 | { } | ||
1438 | #endif | ||
1439 | |||
1399 | #endif /* __KERNEL__ */ | 1440 | #endif /* __KERNEL__ */ |
1400 | #endif /* _LINUX_SKBUFF_H */ | 1441 | #endif /* _LINUX_SKBUFF_H */ |