OSDN Git Service

Merge branch 'master' into ysato-h8300
[uclinux-h8/linux.git] / include / linux / skbuff.h
index 85ab7d7..06793b5 100644 (file)
  *
  * CHECKSUM_PARTIAL:
  *
- *   This is identical to the case for output below. This may occur on a packet
+ *   A checksum is set up to be offloaded to a device as described in the
+ *   output description for CHECKSUM_PARTIAL. This may occur on a packet
  *   received directly from another Linux OS, e.g., a virtualized Linux kernel
- *   on the same host. The packet can be treated in the same way as
- *   CHECKSUM_UNNECESSARY, except that on output (i.e., forwarding) the
- *   checksum must be filled in by the OS or the hardware.
+ *   on the same host, or it may be set in the input path in GRO or remote
+ *   checksum offload. For the purposes of checksum verification, the checksum
+ *   referred to by skb->csum_start + skb->csum_offset and any preceding
+ *   checksums in the packet are considered verified. Any checksums in the
+ *   packet that are after the checksum being offloaded are not considered to
+ *   be verified.
  *
  * B. Checksumming on output.
  *
@@ -162,10 +166,16 @@ struct nf_conntrack {
 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
 struct nf_bridge_info {
        atomic_t                use;
+       enum {
+               BRNF_PROTO_UNCHANGED,
+               BRNF_PROTO_8021Q,
+               BRNF_PROTO_PPPOE
+       } orig_proto;
+       bool                    pkt_otherhost;
        unsigned int            mask;
        struct net_device       *physindev;
        struct net_device       *physoutdev;
-       unsigned long           data[32 / sizeof(unsigned long)];
+       char                    neigh_header[8];
 };
 #endif
 
@@ -488,7 +498,6 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
   *    @napi_id: id of the NAPI struct this skb came from
  *     @secmark: security marking
  *     @mark: Generic packet mark
- *     @dropcount: total number of sk_receive_queue overflows
  *     @vlan_proto: vlan encapsulation protocol
  *     @vlan_tci: vlan tag control information
  *     @inner_protocol: Protocol (encapsulation)
@@ -626,15 +635,17 @@ struct sk_buff {
        __u32                   hash;
        __be16                  vlan_proto;
        __u16                   vlan_tci;
-#ifdef CONFIG_NET_RX_BUSY_POLL
-       unsigned int    napi_id;
+#if defined(CONFIG_NET_RX_BUSY_POLL) || defined(CONFIG_XPS)
+       union {
+               unsigned int    napi_id;
+               unsigned int    sender_cpu;
+       };
 #endif
 #ifdef CONFIG_NETWORK_SECMARK
        __u32                   secmark;
 #endif
        union {
                __u32           mark;
-               __u32           dropcount;
                __u32           reserved_tailroom;
        };
 
@@ -863,8 +874,7 @@ unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
 void skb_abort_seq_read(struct skb_seq_state *st);
 
 unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
-                          unsigned int to, struct ts_config *config,
-                          struct ts_state *state);
+                          unsigned int to, struct ts_config *config);
 
 /*
  * Packet hash types specify the type of hash in skb_set_hash.
@@ -941,6 +951,13 @@ static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)
        to->l4_hash = from->l4_hash;
 };
 
+static inline void skb_sender_cpu_clear(struct sk_buff *skb)
+{
+#ifdef CONFIG_XPS
+       skb->sender_cpu = 0;
+#endif
+}
+
 #ifdef NET_SKBUFF_DATA_USES_OFFSET
 static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
 {
@@ -2484,19 +2501,18 @@ static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
 }
 
 static inline int skb_add_data(struct sk_buff *skb,
-                              char __user *from, int copy)
+                              struct iov_iter *from, int copy)
 {
        const int off = skb->len;
 
        if (skb->ip_summed == CHECKSUM_NONE) {
-               int err = 0;
-               __wsum csum = csum_and_copy_from_user(from, skb_put(skb, copy),
-                                                           copy, 0, &err);
-               if (!err) {
+               __wsum csum = 0;
+               if (csum_and_copy_from_iter(skb_put(skb, copy), copy,
+                                           &csum, from) == copy) {
                        skb->csum = csum_block_add(skb->csum, csum, off);
                        return 0;
                }
-       } else if (!copy_from_user(skb_put(skb, copy), from, copy))
+       } else if (copy_from_iter(skb_put(skb, copy), copy, from) == copy)
                return 0;
 
        __skb_trim(skb, off);
@@ -2693,8 +2709,7 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
 
 static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len)
 {
-       /* XXX: stripping const */
-       return memcpy_fromiovec(data, (struct iovec *)msg->msg_iter.iov, len);
+       return copy_from_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT;
 }
 
 static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
@@ -2914,7 +2929,10 @@ __sum16 __skb_checksum_complete(struct sk_buff *skb);
 
 static inline int skb_csum_unnecessary(const struct sk_buff *skb)
 {
-       return ((skb->ip_summed & CHECKSUM_UNNECESSARY) || skb->csum_valid);
+       return ((skb->ip_summed == CHECKSUM_UNNECESSARY) ||
+               skb->csum_valid ||
+               (skb->ip_summed == CHECKSUM_PARTIAL &&
+                skb_checksum_start_offset(skb) >= 0));
 }
 
 /**
@@ -2998,6 +3016,18 @@ static inline bool __skb_checksum_validate_needed(struct sk_buff *skb,
  */
 #define CHECKSUM_BREAK 76
 
+/* Unset checksum-complete
+ *
+ * Unset checksum complete can be done when packet is being modified
+ * (uncompressed for instance) and checksum-complete value is
+ * invalidated.
+ */
+static inline void skb_checksum_complete_unset(struct sk_buff *skb)
+{
+       if (skb->ip_summed == CHECKSUM_COMPLETE)
+               skb->ip_summed = CHECKSUM_NONE;
+}
+
 /* Validate (init) checksum based on checksum complete.
  *
  * Return values:
@@ -3071,7 +3101,7 @@ static inline __wsum null_compute_pseudo(struct sk_buff *skb, int proto)
 
 #define skb_checksum_validate_zero_check(skb, proto, check,            \
                                         compute_pseudo)                \
-       __skb_checksum_validate_(skb, proto, true, true, check, compute_pseudo)
+       __skb_checksum_validate(skb, proto, true, true, check, compute_pseudo)
 
 #define skb_checksum_simple_validate(skb)                              \
        __skb_checksum_validate(skb, 0, true, false, 0, null_compute_pseudo)
@@ -3096,6 +3126,40 @@ do {                                                                     \
                                       compute_pseudo(skb, proto));     \
 } while (0)
 
+static inline void skb_remcsum_adjust_partial(struct sk_buff *skb, void *ptr,
+                                             u16 start, u16 offset)
+{
+       skb->ip_summed = CHECKSUM_PARTIAL;
+       skb->csum_start = ((unsigned char *)ptr + start) - skb->head;
+       skb->csum_offset = offset - start;
+}
+
+/* Update skbuf and packet to reflect the remote checksum offload operation.
+ * When called, ptr indicates the starting point for skb->csum when
+ * ip_summed is CHECKSUM_COMPLETE. If we need create checksum complete
+ * here, skb_postpull_rcsum is done so skb->csum start is ptr.
+ */
+static inline void skb_remcsum_process(struct sk_buff *skb, void *ptr,
+                                      int start, int offset, bool nopartial)
+{
+       __wsum delta;
+
+       if (!nopartial) {
+               skb_remcsum_adjust_partial(skb, ptr, start, offset);
+               return;
+       }
+
+        if (unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) {
+               __skb_checksum_complete(skb);
+               skb_postpull_rcsum(skb, skb->data, ptr - (void *)skb->data);
+       }
+
+       delta = remcsum_adjust(ptr, skb->csum, start, offset);
+
+       /* Adjust skb->csum since we changed the packet */
+       skb->csum = csum_add(skb->csum, delta);
+}
+
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 void nf_conntrack_destroy(struct nf_conntrack *nfct);
 static inline void nf_conntrack_put(struct nf_conntrack *nfct)