summaryrefslogtreecommitdiff
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2005-02-23 03:18:34 -0800
committerDavid S. Miller <davem@nuts.davemloft.net>2005-02-23 03:18:34 -0800
commit0fcc652d6fdaebdb0ceb3899af4ab8903542f49c (patch)
tree5a5a6c24ad898d9f0ba0827c0919b82d471a5a38 /include/linux/skbuff.h
parent99a54de720dcd9902cd51a77d5275fa91850036c (diff)
[NET]: Add skb_header_cloned and use it in e1000/tg3
This patch adds skb_header_cloned which tells us whether we need to copy the data before we can modify the header part of the skb. Again, what constitutes the header is left up to the users of the skb to define. This patch then uses this function in e1000/tg3 to copy the data before the TCP/IP header is modified. 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.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a8b55c4f4d2f..ca05008ba5b5 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -391,6 +391,25 @@ static inline int skb_cloned(const struct sk_buff *skb)
}
/**
+ * skb_header_cloned - is the header a clone
+ * @skb: buffer to check
+ *
+ * Returns true if modifying the header part of the buffer requires
+ * the data to be copied.
+ */
+static inline int skb_header_cloned(const struct sk_buff *skb)
+{
+ int dataref;
+
+ if (!skb->cloned)
+ return 0;
+
+ dataref = atomic_read(&skb_shinfo(skb)->dataref);
+ dataref = (dataref & SKB_DATAREF_MASK) - (dataref >> SKB_DATAREF_SHIFT);
+ return dataref != 1;
+}
+
+/**
* skb_header_release - release reference to header
* @skb: buffer to operate on
*