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.h74
1 files changed, 58 insertions, 16 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4dc65b55812e..66f8819f9568 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -28,6 +28,7 @@
28#include <linux/net.h> 28#include <linux/net.h>
29#include <linux/textsearch.h> 29#include <linux/textsearch.h>
30#include <net/checksum.h> 30#include <net/checksum.h>
31#include <linux/dmaengine.h>
31 32
32#define HAVE_ALLOC_SKB /* For the drivers to know */ 33#define HAVE_ALLOC_SKB /* For the drivers to know */
33#define HAVE_ALIGNABLE_SKB /* Ditto 8) */ 34#define HAVE_ALIGNABLE_SKB /* Ditto 8) */
@@ -208,6 +209,7 @@ enum {
208 * @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
209 * @tc_index: Traffic control index 210 * @tc_index: Traffic control index
210 * @tc_verd: traffic control verdict 211 * @tc_verd: traffic control verdict
212 * @secmark: security marking
211 */ 213 */
212 214
213struct sk_buff { 215struct sk_buff {
@@ -284,6 +286,12 @@ struct sk_buff {
284 __u16 tc_verd; /* traffic control verdict */ 286 __u16 tc_verd; /* traffic control verdict */
285#endif 287#endif
286#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
287 295
288 296
289 /* 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. */
@@ -966,15 +974,16 @@ static inline void skb_reserve(struct sk_buff *skb, int len)
966#define NET_SKB_PAD 16 974#define NET_SKB_PAD 16
967#endif 975#endif
968 976
969extern int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc); 977extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
970 978
971static inline void __skb_trim(struct sk_buff *skb, unsigned int len) 979static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
972{ 980{
973 if (!skb->data_len) { 981 if (unlikely(skb->data_len)) {
974 skb->len = len; 982 WARN_ON(1);
975 skb->tail = skb->data + len; 983 return;
976 } else 984 }
977 ___pskb_trim(skb, len, 0); 985 skb->len = len;
986 skb->tail = skb->data + len;
978} 987}
979 988
980/** 989/**
@@ -984,6 +993,7 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
984 * 993 *
985 * 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
986 * 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.
987 */ 997 */
988static inline void skb_trim(struct sk_buff *skb, unsigned int len) 998static inline void skb_trim(struct sk_buff *skb, unsigned int len)
989{ 999{
@@ -994,12 +1004,10 @@ static inline void skb_trim(struct sk_buff *skb, unsigned int len)
994 1004
995static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) 1005static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
996{ 1006{
997 if (!skb->data_len) { 1007 if (skb->data_len)
998 skb->len = len; 1008 return ___pskb_trim(skb, len);
999 skb->tail = skb->data+len; 1009 __skb_trim(skb, len);
1000 return 0; 1010 return 0;
1001 }
1002 return ___pskb_trim(skb, len, 1);
1003} 1011}
1004 1012
1005static inline int pskb_trim(struct sk_buff *skb, unsigned int len) 1013static inline int pskb_trim(struct sk_buff *skb, unsigned int len)
@@ -1160,18 +1168,34 @@ static inline int skb_can_coalesce(struct sk_buff *skb, int i,
1160 return 0; 1168 return 0;
1161} 1169}
1162 1170
1171static inline int __skb_linearize(struct sk_buff *skb)
1172{
1173 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM;
1174}
1175
1163/** 1176/**
1164 * skb_linearize - convert paged skb to linear one 1177 * skb_linearize - convert paged skb to linear one
1165 * @skb: buffer to linarize 1178 * @skb: buffer to linarize
1166 * @gfp: allocation mode
1167 * 1179 *
1168 * If there is no free memory -ENOMEM is returned, otherwise zero 1180 * If there is no free memory -ENOMEM is returned, otherwise zero
1169 * is returned and the old skb data released. 1181 * is returned and the old skb data released.
1170 */ 1182 */
1171extern int __skb_linearize(struct sk_buff *skb, gfp_t gfp); 1183static inline int skb_linearize(struct sk_buff *skb)
1172static 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 */
1195static inline int skb_linearize_cow(struct sk_buff *skb)
1173{ 1196{
1174 return __skb_linearize(skb, gfp); 1197 return skb_is_nonlinear(skb) || skb_cloned(skb) ?
1198 __skb_linearize(skb) : 0;
1175} 1199}
1176 1200
1177/** 1201/**
@@ -1395,5 +1419,23 @@ static inline void nf_reset(struct sk_buff *skb)
1395static inline void nf_reset(struct sk_buff *skb) {} 1419static inline void nf_reset(struct sk_buff *skb) {}
1396#endif /* CONFIG_NETFILTER */ 1420#endif /* CONFIG_NETFILTER */
1397 1421
1422#ifdef CONFIG_NETWORK_SECMARK
1423static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from)
1424{
1425 to->secmark = from->secmark;
1426}
1427
1428static inline void skb_init_secmark(struct sk_buff *skb)
1429{
1430 skb->secmark = 0;
1431}
1432#else
1433static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from)
1434{ }
1435
1436static inline void skb_init_secmark(struct sk_buff *skb)
1437{ }
1438#endif
1439
1398#endif /* __KERNEL__ */ 1440#endif /* __KERNEL__ */
1399#endif /* _LINUX_SKBUFF_H */ 1441#endif /* _LINUX_SKBUFF_H */