]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/skbuff.h
[NET] skbuff: Add skb_cow_head
[linux-2.6-omap-h63xx.git] / include / linux / skbuff.h
index 9391e4a4c3447d53b73dba487255cab67ef24b6e..a656cecd373c812eb7057d844f74dd2c0ce189df 100644 (file)
@@ -134,8 +134,8 @@ typedef struct skb_frag_struct skb_frag_t;
 
 struct skb_frag_struct {
        struct page *page;
-       __u16 page_offset;
-       __u16 size;
+       __u32 page_offset;
+       __u32 size;
 };
 
 /* This data is invariant across clones and lives at
@@ -1352,6 +1352,22 @@ static inline int skb_clone_writable(struct sk_buff *skb, int len)
               skb_headroom(skb) + len <= skb->hdr_len;
 }
 
+static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom,
+                           int cloned)
+{
+       int delta = 0;
+
+       if (headroom < NET_SKB_PAD)
+               headroom = NET_SKB_PAD;
+       if (headroom > skb_headroom(skb))
+               delta = headroom - skb_headroom(skb);
+
+       if (delta || cloned)
+               return pskb_expand_head(skb, ALIGN(delta, NET_SKB_PAD), 0,
+                                       GFP_ATOMIC);
+       return 0;
+}
+
 /**
  *     skb_cow - copy header of skb when it is required
  *     @skb: buffer to cow
@@ -1366,16 +1382,22 @@ static inline int skb_clone_writable(struct sk_buff *skb, int len)
  */
 static inline int skb_cow(struct sk_buff *skb, unsigned int headroom)
 {
-       int delta = (headroom > NET_SKB_PAD ? headroom : NET_SKB_PAD) -
-                       skb_headroom(skb);
-
-       if (delta < 0)
-               delta = 0;
+       return __skb_cow(skb, headroom, skb_cloned(skb));
+}
 
-       if (delta || skb_cloned(skb))
-               return pskb_expand_head(skb, (delta + (NET_SKB_PAD-1)) &
-                               ~(NET_SKB_PAD-1), 0, GFP_ATOMIC);
-       return 0;
+/**
+ *     skb_cow_head - skb_cow but only making the head writable
+ *     @skb: buffer to cow
+ *     @headroom: needed headroom
+ *
+ *     This function is identical to skb_cow except that we replace the
+ *     skb_cloned check by skb_header_cloned.  It should be used when
+ *     you only need to push on some header and do not need to modify
+ *     the data.
+ */
+static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
+{
+       return __skb_cow(skb, headroom, skb_header_cloned(skb));
 }
 
 /**
@@ -1639,7 +1661,7 @@ static inline int skb_csum_unnecessary(const struct sk_buff *skb)
  *     if skb->ip_summed is CHECKSUM_UNNECESSARY which indicates that the
  *     hardware has already verified the correctness of the checksum.
  */
-static inline unsigned int skb_checksum_complete(struct sk_buff *skb)
+static inline __sum16 skb_checksum_complete(struct sk_buff *skb)
 {
        return skb_csum_unnecessary(skb) ?
               0 : __skb_checksum_complete(skb);