aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-06-09 19:13:38 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-18 00:30:22 -0400
commit3cc0e873986fe594d0e96d07259b11f755325cb2 (patch)
tree5d3e9a57333a2d7088a6a63c09bc97db98f480af /include/linux/skbuff.h
parentb38dfee3d616ffadb58d4215e3ff9d1d7921031e (diff)
[NET]: Warn in __skb_trim if skb is paged
It's better to warn and fail rather than rarely triggering BUG on paths that incorrectly call skb_trim/__skb_trim on a non-linear skb. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 830f58fa03a..93e4db22158 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -975,15 +975,16 @@ static inline void skb_reserve(struct sk_buff *skb, int len)
975#define NET_SKB_PAD 16 975#define NET_SKB_PAD 16
976#endif 976#endif
977 977
978extern int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc); 978extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
979 979
980static inline void __skb_trim(struct sk_buff *skb, unsigned int len) 980static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
981{ 981{
982 if (!skb->data_len) { 982 if (unlikely(skb->data_len)) {
983 skb->len = len; 983 WARN_ON(1);
984 skb->tail = skb->data + len; 984 return;
985 } else 985 }
986 ___pskb_trim(skb, len, 0); 986 skb->len = len;
987 skb->tail = skb->data + len;
987} 988}
988 989
989/** 990/**
@@ -993,6 +994,7 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
993 * 994 *
994 * 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
995 * 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.
996 */ 998 */
997static inline void skb_trim(struct sk_buff *skb, unsigned int len) 999static inline void skb_trim(struct sk_buff *skb, unsigned int len)
998{ 1000{
@@ -1003,12 +1005,10 @@ static inline void skb_trim(struct sk_buff *skb, unsigned int len)
1003 1005
1004static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) 1006static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
1005{ 1007{
1006 if (!skb->data_len) { 1008 if (skb->data_len)
1007 skb->len = len; 1009 return ___pskb_trim(skb, len);
1008 skb->tail = skb->data+len; 1010 __skb_trim(skb, len);
1009 return 0; 1011 return 0;
1010 }
1011 return ___pskb_trim(skb, len, 1);
1012} 1012}
1013 1013
1014static inline int pskb_trim(struct sk_buff *skb, unsigned int len) 1014static inline int pskb_trim(struct sk_buff *skb, unsigned int len)