net: Add and use skb_copy_datagram_msg() helper.
[deliverable/linux.git] / include / linux / skbuff.h
index a59d9343c25bdc9575eefa1ac361732599db9ddf..39ec7530ae27984e98b06f5cb2a116c9669662dd 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/time.h>
 #include <linux/bug.h>
 #include <linux/cache.h>
+#include <linux/rbtree.h>
+#include <linux/socket.h>
 
 #include <linux/atomic.h>
 #include <asm/types.h>
@@ -372,6 +374,7 @@ enum {
 
        SKB_GSO_MPLS = 1 << 12,
 
+       SKB_GSO_TUNNEL_REMCSUM = 1 << 13,
 };
 
 #if BITS_PER_LONG > 32
@@ -440,6 +443,7 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
  *     @next: Next buffer in list
  *     @prev: Previous buffer in list
  *     @tstamp: Time we arrived/left
+ *     @rbnode: RB tree node, alternative to next/prev for netem/tcp
  *     @sk: Socket we are owned by
  *     @dev: Device we arrived on/are leaving by
  *     @cb: Control buffer. Free for use by every layer. Put private vars here
@@ -504,15 +508,19 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
  */
 
 struct sk_buff {
-       /* These two members must be first. */
-       struct sk_buff          *next;
-       struct sk_buff          *prev;
-
        union {
-               ktime_t         tstamp;
-               struct skb_mstamp skb_mstamp;
+               struct {
+                       /* These two members must be first. */
+                       struct sk_buff          *next;
+                       struct sk_buff          *prev;
+
+                       union {
+                               ktime_t         tstamp;
+                               struct skb_mstamp skb_mstamp;
+                       };
+               };
+               struct rb_node  rbnode; /* used in netem & tcp stack */
        };
-
        struct sock             *sk;
        struct net_device       *dev;
 
@@ -557,7 +565,9 @@ struct sk_buff {
        /* fields enclosed in headers_start/headers_end are copied
         * using a single memcpy() in __copy_skb_header()
         */
+       /* private: */
        __u32                   headers_start[0];
+       /* public: */
 
 /* if you move pkt_type around you also must adapt those constants */
 #ifdef __BIG_ENDIAN_BITFIELD
@@ -595,7 +605,8 @@ struct sk_buff {
 #endif
        __u8                    ipvs_property:1;
        __u8                    inner_protocol_type:1;
-       /* 4 or 6 bit hole */
+       __u8                    remcsum_offload:1;
+       /* 3 or 5 bit hole */
 
 #ifdef CONFIG_NET_SCHED
        __u16                   tc_index;       /* traffic control index */
@@ -642,7 +653,9 @@ struct sk_buff {
        __u16                   network_header;
        __u16                   mac_header;
 
+       /* private: */
        __u32                   headers_end[0];
+       /* public: */
 
        /* These elements must be at the end, see alloc_skb() for details.  */
        sk_buff_data_t          tail;
@@ -795,15 +808,19 @@ struct sk_buff_fclones {
  *     @skb: buffer
  *
  * Returns true is skb is a fast clone, and its clone is not freed.
+ * Some drivers call skb_orphan() in their ndo_start_xmit(),
+ * so we also check that this didnt happen.
  */
-static inline bool skb_fclone_busy(const struct sk_buff *skb)
+static inline bool skb_fclone_busy(const struct sock *sk,
+                                  const struct sk_buff *skb)
 {
        const struct sk_buff_fclones *fclones;
 
        fclones = container_of(skb, struct sk_buff_fclones, skb1);
 
        return skb->fclone == SKB_FCLONE_ORIG &&
-              fclones->skb2.fclone == SKB_FCLONE_CLONE;
+              fclones->skb2.fclone == SKB_FCLONE_CLONE &&
+              fclones->skb2.sk == sk;
 }
 
 static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
@@ -2623,6 +2640,11 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
                           struct poll_table_struct *wait);
 int skb_copy_datagram_iovec(const struct sk_buff *from, int offset,
                            struct iovec *to, int size);
+static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
+                                       struct msghdr *msg, int size)
+{
+       return skb_copy_datagram_iovec(from, offset, msg->msg_iov, size);
+}
 int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen,
                                     struct iovec *iov);
 int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset,
This page took 0.026645 seconds and 5 git commands to generate.