]> err.no Git - linux-2.6/blobdiff - include/linux/skbuff.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched
[linux-2.6] / include / linux / skbuff.h
index 625d73b07ab79c7925865a36e0d7fbcf3abb7805..a656cecd373c812eb7057d844f74dd2c0ce189df 100644 (file)
  *         is able to produce some skb->csum, it MUST use COMPLETE,
  *         not UNNECESSARY.
  *
+ *     PARTIAL: identical to the case for output below.  This may occur
+ *         on a packet received directly from another Linux OS, e.g.,
+ *         a virtualised Linux kernel on the same host.  The packet can
+ *         be treated in the same way as UNNECESSARY except that on
+ *         output (i.e., forwarding) the checksum must be filled in
+ *         by the OS or the hardware.
+ *
  * B. Checksumming on output.
  *
  *     NONE: skb is checksummed by protocol or csum is not required.
  *
  *     PARTIAL: device is required to csum packet as seen by hard_start_xmit
- *     from skb->transport_header to the end and to record the checksum
- *     at skb->transport_header + skb->csum.
+ *     from skb->csum_start to the end and to record the checksum
+ *     at skb->csum_start + skb->csum_offset.
  *
  *     Device must show its capabilities in dev->features, set
  *     at device setup time.
@@ -82,6 +89,7 @@
  *                       TCP/UDP over IPv4. Sigh. Vendors like this
  *                       way by an unknown reason. Though, see comment above
  *                       about CHECKSUM_UNNECESSARY. 8)
+ *     NETIF_F_IPV6_CSUM about as dumb as the last one but does IPv6 instead.
  *
  *     Any questions? No questions, good.              --ANK
  */
@@ -126,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
@@ -1344,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
@@ -1358,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));
 }
 
 /**
@@ -1631,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);