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