Lines Matching refs:skb
44 * DOC: skb checksums
105 * not in skb->csum. Thus, skb->csum is undefined in this case.
133 * checksum is bad, skb->csum_level would be set to zero (TCP checksum is
145 * skb->csum, it MUST use CHECKSUM_COMPLETE, not CHECKSUM_UNNECESSARY.
155 * referred to by skb->csum_start + skb->csum_offset and any preceding
194 * The skb was already checksummed by the protocol, or a checksum is not
253 /* Maximum value in skb->csum_level */
260 /* For X bytes available in skb->head, what is the minimal
272 /* return minimum truesize of one skb containing X bytes of data */
310 * skb is out in neigh layer.
356 /* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
368 * skb_frag_size() - Returns the size of a skb fragment
369 * @frag: skb fragment
377 * skb_frag_size_set() - Sets the size of a skb fragment
378 * @frag: skb fragment
387 * skb_frag_size_add() - Increments the size of a skb fragment by @delta
388 * @frag: skb fragment
397 * skb_frag_size_sub() - Decrements the size of a skb fragment by @delta
398 * @frag: skb fragment
422 * @f: skb frag to operate on
454 * skb->tstamp.
535 int (*link_skb)(struct sk_buff *skb, struct ubuf_info *uarg);
539 * The callback notifies userspace to release buffers when skb DMA is done in
540 * lower device, the skb last reference should be 0 when calling this.
591 * the end of the header data, ie. at skb->end.
622 * remains valid until skb destructor.
639 * skb_header_cloned() checks if skb is allowed to add / write the headers.
641 * The creator of the skb (e.g. TCP) marks its skb as &sk_buff.nohdr
642 * (via __skb_header_release()). Any clone created from marked skb will get
647 * <alloc skb>
654 * doing the right thing. In practice there's usually only one payload-only skb.
663 SKB_FCLONE_UNAVAILABLE, /* skb has no fclone (from head_cache) */
664 SKB_FCLONE_ORIG, /* orig skb (from fclone_cache) */
665 SKB_FCLONE_CLONE, /* companion fclone skb (from fclone_cache) */
671 /* This indicates the skb is from an untrusted source. */
745 * this is the part of the skb operated on by the common helpers
750 * Optionally &skb_shared_info.frag_list may point to another skb.
793 * @hdr_len: writable header length of cloned skb
795 * @csum_start: Offset from skb->head where checksumming should start
827 * @head_frag: skb was allocated from page fragments,
849 * @unreadable: indicates that at least 1 of the fragments in this skb is
854 * @tstamp_type: When set, skb->tstamp has the
855 * delivery_time clock base of skb->tstamp.
856 * @napi_id: id of the NAPI struct this skb came from
858 * @alloc_cpu: CPU which did the skb allocation.
868 * skb->inner_protocol_type == ENCAP_TYPE_IPPROTO;
916 * first. This is owned by whoever has the skb queued ATM.
923 void (*destructor)(struct sk_buff *skb);
1136 * skb_pfmemalloc - Test if the skb was allocated from PFMEMALLOC reserves
1137 * @skb: buffer
1139 static inline bool skb_pfmemalloc(const struct sk_buff *skb)
1141 return unlikely(skb->pfmemalloc);
1145 * skb might have a dst pointer attached, refcounted or not.
1152 * skb_dst - returns skb dst_entry
1153 * @skb: buffer
1155 * Returns: skb dst_entry, regardless of reference taken or not.
1157 static inline struct dst_entry *skb_dst(const struct sk_buff *skb)
1162 WARN_ON((skb->_skb_refdst & SKB_DST_NOREF) &&
1165 return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK);
1168 static inline void skb_dst_check_unset(struct sk_buff *skb)
1170 DEBUG_NET_WARN_ON_ONCE((skb->_skb_refdst & SKB_DST_PTRMASK) &&
1171 !(skb->_skb_refdst & SKB_DST_NOREF));
1176 * @skb: buffer
1178 * Resets skb dst_entry without adjusting its reference count. Useful in
1186 * Returns: original skb dst_entry.
1188 static inline unsigned long skb_dstref_steal(struct sk_buff *skb)
1190 unsigned long refdst = skb->_skb_refdst;
1192 skb->_skb_refdst = 0;
1197 * skb_dstref_restore() - restore skb dst_entry removed via skb_dstref_steal()
1198 * @skb: buffer
1201 static inline void skb_dstref_restore(struct sk_buff *skb, unsigned long refdst)
1203 skb_dst_check_unset(skb);
1204 skb->_skb_refdst = refdst;
1208 * skb_dst_set - sets skb dst
1209 * @skb: buffer
1212 * Sets skb dst, assuming a reference was taken on dst and should
1215 static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
1217 skb_dst_check_unset(skb);
1218 skb->slow_gro |= !!dst;
1219 skb->_skb_refdst = (unsigned long)dst;
1223 * skb_dst_set_noref - sets skb dst, hopefully, without taking reference
1224 * @skb: buffer
1227 * Sets skb dst, assuming a reference was not taken on dst.
1232 static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst)
1234 skb_dst_check_unset(skb);
1236 skb->slow_gro |= !!dst;
1237 skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF;
1241 * skb_dst_is_noref - Test if skb dst isn't refcounted
1242 * @skb: buffer
1244 static inline bool skb_dst_is_noref(const struct sk_buff *skb)
1246 return (skb->_skb_refdst & SKB_DST_NOREF) && skb_dst(skb);
1249 /* For mangling skb->pkt_type from user space side from applications
1259 * skb_napi_id - Returns the skb's NAPI id
1260 * @skb: buffer
1262 static inline unsigned int skb_napi_id(const struct sk_buff *skb)
1265 return skb->napi_id;
1271 static inline bool skb_wifi_acked_valid(const struct sk_buff *skb)
1274 return skb->wifi_acked_valid;
1281 * skb_unref - decrement the skb's reference count
1282 * @skb: buffer
1284 * Returns: true if we can free the skb.
1286 static inline bool skb_unref(struct sk_buff *skb)
1288 if (unlikely(!skb))
1290 if (!IS_ENABLED(CONFIG_DEBUG_NET) && likely(refcount_read(&skb->users) == 1))
1292 else if (likely(!refcount_dec_and_test(&skb->users)))
1298 static inline bool skb_data_unref(const struct sk_buff *skb,
1303 if (!skb->cloned)
1306 bias = skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1;
1316 void __fix_address sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb,
1320 kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason)
1322 sk_skb_reason_drop(NULL, skb, reason);
1327 * @skb: buffer to free
1329 static inline void kfree_skb(struct sk_buff *skb)
1331 kfree_skb_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
1334 void skb_release_head_state(struct sk_buff *skb);
1337 void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt);
1338 void skb_tx_error(struct sk_buff *skb);
1346 void consume_skb(struct sk_buff *skb);
1348 static inline void consume_skb(struct sk_buff *skb)
1350 return kfree_skb(skb);
1354 void __consume_stateless_skb(struct sk_buff *skb);
1355 void __kfree_skb(struct sk_buff *skb);
1357 void kfree_skb_partial(struct sk_buff *skb, bool head_stolen);
1365 struct sk_buff *build_skb_around(struct sk_buff *skb,
1367 void skb_attempt_defer_free(struct sk_buff *skb);
1405 * @skb: buffer
1407 * Returns: true if skb is a fast clone, and its clone is not freed.
1412 const struct sk_buff *skb)
1416 fclones = container_of(skb, struct sk_buff_fclones, skb1);
1418 return skb->fclone == SKB_FCLONE_ORIG &&
1437 void skb_headers_offset_update(struct sk_buff *skb, int off);
1438 int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask);
1439 struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t priority);
1441 struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t priority);
1442 struct sk_buff *__pskb_copy_fclone(struct sk_buff *skb, int headroom,
1444 static inline struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom,
1447 return __pskb_copy_fclone(skb, headroom, gfp_mask, false);
1450 int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, gfp_t gfp_mask);
1451 struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
1453 struct sk_buff *skb_expand_head(struct sk_buff *skb, unsigned int headroom);
1454 struct sk_buff *skb_copy_expand(const struct sk_buff *skb, int newheadroom,
1456 int __must_check skb_to_sgvec_nomark(struct sk_buff *skb, struct scatterlist *sg,
1458 int __must_check skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg,
1460 int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
1461 int __skb_pad(struct sk_buff *skb, int pad, bool free_on_error);
1464 * skb_pad - zero pad the tail of an skb
1465 * @skb: buffer to pad
1472 * May return error in out of memory cases. The skb is freed on error.
1474 static inline int skb_pad(struct sk_buff *skb, int pad)
1476 return __skb_pad(skb, pad, true);
1480 int skb_append_pagefrags(struct sk_buff *skb, struct page *page,
1494 void skb_prepare_seq_read(struct sk_buff *skb, unsigned int from,
1501 unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
1537 static inline void skb_clear_hash(struct sk_buff *skb)
1539 skb->hash = 0;
1540 skb->sw_hash = 0;
1541 skb->l4_hash = 0;
1544 static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb)
1546 if (!skb->l4_hash)
1547 skb_clear_hash(skb);
1551 __skb_set_hash(struct sk_buff *skb, __u32 hash, bool is_sw, bool is_l4)
1553 skb->l4_hash = is_l4;
1554 skb->sw_hash = is_sw;
1555 skb->hash = hash;
1559 skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type)
1562 __skb_set_hash(skb, hash, false, type == PKT_HASH_TYPE_L4);
1566 __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
1568 __skb_set_hash(skb, hash, true, is_l4);
1571 u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb);
1573 static inline u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
1575 return __skb_get_hash_symmetric_net(NULL, skb);
1578 void __skb_get_hash_net(const struct net *net, struct sk_buff *skb);
1579 u32 skb_get_poff(const struct sk_buff *skb);
1580 u32 __skb_get_poff(const struct sk_buff *skb, const void *data,
1582 __be32 skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
1594 const struct sk_buff *skb,
1599 static inline bool skb_flow_dissect(const struct sk_buff *skb,
1603 return __skb_flow_dissect(NULL, skb, flow_dissector,
1607 static inline bool skb_flow_dissect_flow_keys(const struct sk_buff *skb,
1612 return __skb_flow_dissect(NULL, skb, &flow_keys_dissector,
1618 const struct sk_buff *skb,
1624 return __skb_flow_dissect(net, skb, &flow_keys_basic_dissector, flow,
1628 void skb_flow_dissect_meta(const struct sk_buff *skb,
1632 /* Gets a skb connection tracking info, ctinfo map should be a
1637 skb_flow_dissect_ct(const struct sk_buff *skb,
1643 skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
1647 void skb_flow_dissect_hash(const struct sk_buff *skb,
1651 static inline __u32 skb_get_hash_net(const struct net *net, struct sk_buff *skb)
1653 if (!skb->l4_hash && !skb->sw_hash)
1654 __skb_get_hash_net(net, skb);
1656 return skb->hash;
1659 static inline __u32 skb_get_hash(struct sk_buff *skb)
1661 if (!skb->l4_hash && !skb->sw_hash)
1662 __skb_get_hash_net(NULL, skb);
1664 return skb->hash;
1667 static inline __u32 skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6 *fl6)
1669 if (!skb->l4_hash && !skb->sw_hash) {
1673 __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys));
1676 return skb->hash;
1679 __u32 skb_get_hash_perturb(const struct sk_buff *skb,
1682 static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
1684 return skb->hash;
1704 static inline bool skb_is_decrypted(const struct sk_buff *skb)
1707 return skb->decrypted;
1722 static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
1724 return skb->head + skb->end;
1727 static inline unsigned int skb_end_offset(const struct sk_buff *skb)
1729 return skb->end;
1732 static inline void skb_set_end_offset(struct sk_buff *skb, unsigned int offset)
1734 skb->end = offset;
1737 static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
1739 return skb->end;
1742 static inline unsigned int skb_end_offset(const struct sk_buff *skb)
1744 return skb->end - skb->head;
1747 static inline void skb_set_end_offset(struct sk_buff *skb, unsigned int offset)
1749 skb->end = skb->head + offset;
1763 struct sk_buff *skb, struct iov_iter *from,
1767 int zerocopy_fill_skb_from_iter(struct sk_buff *skb,
1770 static inline int skb_zerocopy_iter_dgram(struct sk_buff *skb,
1773 return __zerocopy_sg_from_iter(msg, skb->sk, skb, &msg->msg_iter, len,
1777 int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
1785 static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
1787 return &skb_shinfo(skb)->hwtstamps;
1790 static inline struct ubuf_info *skb_zcopy(struct sk_buff *skb)
1792 bool is_zcopy = skb && skb_shinfo(skb)->flags & SKBFL_ZEROCOPY_ENABLE;
1794 return is_zcopy ? skb_uarg(skb) : NULL;
1797 static inline bool skb_zcopy_pure(const struct sk_buff *skb)
1799 return skb_shinfo(skb)->flags & SKBFL_PURE_ZEROCOPY;
1802 static inline bool skb_zcopy_managed(const struct sk_buff *skb)
1804 return skb_shinfo(skb)->flags & SKBFL_MANAGED_FRAG_REFS;
1818 static inline void skb_zcopy_init(struct sk_buff *skb, struct ubuf_info *uarg)
1820 skb_shinfo(skb)->destructor_arg = uarg;
1821 skb_shinfo(skb)->flags |= uarg->flags;
1824 static inline void skb_zcopy_set(struct sk_buff *skb, struct ubuf_info *uarg,
1827 if (skb && uarg && !skb_zcopy(skb)) {
1832 skb_zcopy_init(skb, uarg);
1836 static inline void skb_zcopy_set_nouarg(struct sk_buff *skb, void *val)
1838 skb_shinfo(skb)->destructor_arg = (void *)((uintptr_t) val | 0x1UL);
1839 skb_shinfo(skb)->flags |= SKBFL_ZEROCOPY_FRAG;
1842 static inline bool skb_zcopy_is_nouarg(struct sk_buff *skb)
1844 return (uintptr_t) skb_shinfo(skb)->destructor_arg & 0x1UL;
1847 static inline void *skb_zcopy_get_nouarg(struct sk_buff *skb)
1849 return (void *)((uintptr_t) skb_shinfo(skb)->destructor_arg & ~0x1UL);
1869 static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy_success)
1871 struct ubuf_info *uarg = skb_zcopy(skb);
1874 if (!skb_zcopy_is_nouarg(skb))
1875 uarg->ops->complete(skb, uarg, zerocopy_success);
1877 skb_shinfo(skb)->flags &= ~SKBFL_ALL_ZEROCOPY;
1881 void __skb_zcopy_downgrade_managed(struct sk_buff *skb);
1883 static inline void skb_zcopy_downgrade_managed(struct sk_buff *skb)
1885 if (unlikely(skb_zcopy_managed(skb)))
1886 __skb_zcopy_downgrade_managed(skb);
1889 /* Return true if frags in this skb are readable by the host. */
1890 static inline bool skb_frags_readable(const struct sk_buff *skb)
1892 return !skb->unreadable;
1895 static inline void skb_mark_not_on_list(struct sk_buff *skb)
1897 skb->next = NULL;
1900 static inline void skb_poison_list(struct sk_buff *skb)
1903 skb->next = SKB_LIST_POISON_NEXT;
1907 /* Iterate through singly-linked GSO fragments of an skb. */
1908 #define skb_list_walk_safe(first, skb, next_skb) \
1909 for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \
1910 (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)
1912 static inline void skb_list_del_init(struct sk_buff *skb)
1914 __list_del_entry(&skb->list);
1915 skb_mark_not_on_list(skb);
1943 * skb_queue_is_last - check if skb is the last entry in the queue
1945 * @skb: buffer
1947 * Returns true if @skb is the last buffer on the list.
1950 const struct sk_buff *skb)
1952 return skb->next == (const struct sk_buff *) list;
1956 * skb_queue_is_first - check if skb is the first entry in the queue
1958 * @skb: buffer
1960 * Returns true if @skb is the first buffer on the list.
1963 const struct sk_buff *skb)
1965 return skb->prev == (const struct sk_buff *) list;
1971 * @skb: current buffer
1973 * Return the next packet in @list after @skb. It is only valid to
1977 const struct sk_buff *skb)
1982 BUG_ON(skb_queue_is_last(list, skb));
1983 return skb->next;
1989 * @skb: current buffer
1991 * Return the prev packet in @list before @skb. It is only valid to
1995 const struct sk_buff *skb)
2000 BUG_ON(skb_queue_is_first(list, skb));
2001 return skb->prev;
2006 * @skb: buffer to reference
2011 static inline struct sk_buff *skb_get(struct sk_buff *skb)
2013 refcount_inc(&skb->users);
2014 return skb;
2023 * @skb: buffer to check
2029 static inline int skb_cloned(const struct sk_buff *skb)
2031 return skb->cloned &&
2032 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1;
2035 static inline int skb_unclone(struct sk_buff *skb, gfp_t pri)
2039 if (skb_cloned(skb))
2040 return pskb_expand_head(skb, 0, 0, pri);
2045 /* This variant of skb_unclone() makes sure skb->truesize
2046 * and skb_end_offset() are not changed, whenever a new skb->head is needed.
2051 int __skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri);
2052 static inline int skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri)
2056 if (skb_cloned(skb))
2057 return __skb_unclone_keeptruesize(skb, pri);
2063 * @skb: buffer to check
2068 static inline int skb_header_cloned(const struct sk_buff *skb)
2072 if (!skb->cloned)
2075 dataref = atomic_read(&skb_shinfo(skb)->dataref);
2080 static inline int skb_header_unclone(struct sk_buff *skb, gfp_t pri)
2084 if (skb_header_cloned(skb))
2085 return pskb_expand_head(skb, 0, 0, pri);
2092 * @skb: buffer to operate on
2096 static inline void __skb_header_release(struct sk_buff *skb)
2098 skb->nohdr = 1;
2099 atomic_set(&skb_shinfo(skb)->dataref, 1 + (1 << SKB_DATAREF_SHIFT));
2105 * @skb: buffer to check
2110 static inline int skb_shared(const struct sk_buff *skb)
2112 return refcount_read(&skb->users) != 1;
2117 * @skb: buffer to check
2128 static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri)
2131 if (skb_shared(skb)) {
2132 struct sk_buff *nskb = skb_clone(skb, pri);
2135 consume_skb(skb);
2137 kfree_skb(skb);
2138 skb = nskb;
2140 return skb;
2152 * @skb: buffer to check
2163 static inline struct sk_buff *skb_unshare(struct sk_buff *skb,
2167 if (skb_cloned(skb)) {
2168 struct sk_buff *nskb = skb_copy(skb, pri);
2172 consume_skb(skb);
2174 kfree_skb(skb);
2175 skb = nskb;
2177 return skb;
2195 struct sk_buff *skb = list_->next;
2197 if (skb == (struct sk_buff *)list_)
2198 skb = NULL;
2199 return skb;
2214 * skb_peek_next - peek skb following the given one from a queue
2215 * @skb: skb to start from
2222 static inline struct sk_buff *skb_peek_next(struct sk_buff *skb,
2225 struct sk_buff *next = skb->next;
2247 struct sk_buff *skb = READ_ONCE(list_->prev);
2249 if (skb == (struct sk_buff *)list_)
2250 skb = NULL;
2251 return skb;
2296 * this is needed for now since a whole lot of users of the skb-queue
2350 * skb_queue_splice - join two skb lists, this is designed for stacks
2364 * skb_queue_splice_init - join two skb lists and reinitialise the emptied list
2381 * skb_queue_splice_tail - join two skb lists, each list being a queue
2395 * skb_queue_splice_tail_init - join two skb lists and reinitialise the emptied list
2478 void skb_unlink(struct sk_buff *skb, struct sk_buff_head *list);
2479 static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
2484 next = skb->next;
2485 prev = skb->prev;
2486 skb->next = skb->prev = NULL;
2501 struct sk_buff *skb = skb_peek(list);
2502 if (skb)
2503 __skb_unlink(skb, list);
2504 return skb;
2518 struct sk_buff *skb = skb_peek_tail(list);
2519 if (skb)
2520 __skb_unlink(skb, list);
2521 return skb;
2526 static inline bool skb_is_nonlinear(const struct sk_buff *skb)
2528 return skb->data_len;
2531 static inline unsigned int skb_headlen(const struct sk_buff *skb)
2533 return skb->len - skb->data_len;
2536 static inline unsigned int __skb_pagelen(const struct sk_buff *skb)
2540 for (i = skb_shinfo(skb)->nr_frags - 1; (int)i >= 0; i--)
2541 len += skb_frag_size(&skb_shinfo(skb)->frags[i]);
2545 static inline unsigned int skb_pagelen(const struct sk_buff *skb)
2547 return skb_headlen(skb) + __skb_pagelen(skb);
2584 * skb_len_add - adds a number to len fields of skb
2585 * @skb: buffer to add len to
2588 static inline void skb_len_add(struct sk_buff *skb, int delta)
2590 skb->len += delta;
2591 skb->data_len += delta;
2592 skb->truesize += delta;
2596 * __skb_fill_netmem_desc - initialise a fragment in an skb
2597 * @skb: buffer containing fragment to be initialised
2603 * Initialises the @i'th fragment of @skb to point to &size bytes at
2608 static inline void __skb_fill_netmem_desc(struct sk_buff *skb, int i,
2613 __skb_fill_netmem_desc_noacc(skb_shinfo(skb), i, netmem, off, size);
2616 skb->unreadable = true;
2622 /* Propagate page pfmemalloc to the skb if we can. The problem is
2628 skb->pfmemalloc = true;
2631 static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
2634 __skb_fill_netmem_desc(skb, i, page_to_netmem(page), off, size);
2637 static inline void skb_fill_netmem_desc(struct sk_buff *skb, int i,
2640 __skb_fill_netmem_desc(skb, i, netmem, off, size);
2641 skb_shinfo(skb)->nr_frags = i + 1;
2645 * skb_fill_page_desc - initialise a paged fragment in an skb
2646 * @skb: buffer containing fragment to be initialised
2653 * @skb to point to @size bytes at offset @off within @page. In
2654 * addition updates @skb such that @i is the last fragment.
2658 static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
2661 skb_fill_netmem_desc(skb, i, page_to_netmem(page), off, size);
2665 * skb_fill_page_desc_noacc - initialise a paged fragment in an skb
2666 * @skb: buffer containing fragment to be initialised
2675 static inline void skb_fill_page_desc_noacc(struct sk_buff *skb, int i,
2679 struct skb_shared_info *shinfo = skb_shinfo(skb);
2685 void skb_add_rx_frag_netmem(struct sk_buff *skb, int i, netmem_ref netmem,
2688 static inline void skb_add_rx_frag(struct sk_buff *skb, int i,
2692 skb_add_rx_frag_netmem(skb, i, page_to_netmem(page), off, size,
2696 void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size,
2699 #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
2702 static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
2704 return skb->head + skb->tail;
2707 static inline void skb_reset_tail_pointer(struct sk_buff *skb)
2709 skb->tail = skb->data - skb->head;
2712 static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
2714 skb_reset_tail_pointer(skb);
2715 skb->tail += offset;
2719 static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
2721 return skb->tail;
2724 static inline void skb_reset_tail_pointer(struct sk_buff *skb)
2726 skb->tail = skb->data;
2729 static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
2731 skb->tail = skb->data + offset;
2736 static inline void skb_assert_len(struct sk_buff *skb)
2739 if (WARN_ONCE(!skb->len, "%s\n", __func__))
2740 DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
2745 void skb_might_realloc(struct sk_buff *skb);
2747 static inline void skb_might_realloc(struct sk_buff *skb) {}
2753 void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
2754 void *skb_put(struct sk_buff *skb, unsigned int len);
2755 static inline void *__skb_put(struct sk_buff *skb, unsigned int len)
2757 void *tmp = skb_tail_pointer(skb);
2758 SKB_LINEAR_ASSERT(skb);
2759 skb->tail += len;
2760 skb->len += len;
2764 static inline void *__skb_put_zero(struct sk_buff *skb, unsigned int len)
2766 void *tmp = __skb_put(skb, len);
2772 static inline void *__skb_put_data(struct sk_buff *skb, const void *data,
2775 void *tmp = __skb_put(skb, len);
2781 static inline void __skb_put_u8(struct sk_buff *skb, u8 val)
2783 *(u8 *)__skb_put(skb, 1) = val;
2786 static inline void *skb_put_zero(struct sk_buff *skb, unsigned int len)
2788 void *tmp = skb_put(skb, len);
2795 static inline void *skb_put_data(struct sk_buff *skb, const void *data,
2798 void *tmp = skb_put(skb, len);
2805 static inline void skb_put_u8(struct sk_buff *skb, u8 val)
2807 *(u8 *)skb_put(skb, 1) = val;
2810 void *skb_push(struct sk_buff *skb, unsigned int len);
2811 static inline void *__skb_push(struct sk_buff *skb, unsigned int len)
2815 skb->data -= len;
2816 DEBUG_NET_WARN_ON_ONCE(skb->data < skb->head);
2817 skb->len += len;
2818 return skb->data;
2821 void *skb_pull(struct sk_buff *skb, unsigned int len);
2822 static inline void *__skb_pull(struct sk_buff *skb, unsigned int len)
2826 skb->len -= len;
2827 if (unlikely(skb->len < skb->data_len)) {
2829 skb->len += len;
2831 skb_dump(KERN_ERR, skb, false);
2835 return skb->data += len;
2838 static inline void *skb_pull_inline(struct sk_buff *skb, unsigned int len)
2840 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len);
2843 void *skb_pull_data(struct sk_buff *skb, size_t len);
2845 void *__pskb_pull_tail(struct sk_buff *skb, int delta);
2848 pskb_may_pull_reason(struct sk_buff *skb, unsigned int len)
2851 skb_might_realloc(skb);
2853 if (likely(len <= skb_headlen(skb)))
2856 if (unlikely(len > skb->len))
2859 if (unlikely(!__pskb_pull_tail(skb, len - skb_headlen(skb))))
2865 static inline bool pskb_may_pull(struct sk_buff *skb, unsigned int len)
2867 return pskb_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET;
2870 static inline void *pskb_pull(struct sk_buff *skb, unsigned int len)
2872 if (!pskb_may_pull(skb, len))
2875 skb->len -= len;
2876 return skb->data += len;
2879 void skb_condense(struct sk_buff *skb);
2883 * @skb: buffer to check
2887 static inline unsigned int skb_headroom(const struct sk_buff *skb)
2889 return skb->data - skb->head;
2894 * @skb: buffer to check
2898 static inline int skb_tailroom(const struct sk_buff *skb)
2900 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail;
2905 * @skb: buffer to check
2910 static inline int skb_availroom(const struct sk_buff *skb)
2912 if (skb_is_nonlinear(skb))
2915 return skb->end - skb->tail - skb->reserved_tailroom;
2920 * @skb: buffer to alter
2926 static inline void skb_reserve(struct sk_buff *skb, int len)
2928 skb->data += len;
2929 skb->tail += len;
2934 * @skb: buffer to alter
2944 static inline void skb_tailroom_reserve(struct sk_buff *skb, unsigned int mtu,
2947 SKB_LINEAR_ASSERT(skb);
2948 if (mtu < skb_tailroom(skb) - needed_tailroom)
2950 skb->reserved_tailroom = skb_tailroom(skb) - mtu;
2953 skb->reserved_tailroom = needed_tailroom;
2959 static inline void skb_set_inner_protocol(struct sk_buff *skb,
2962 skb->inner_protocol = protocol;
2963 skb->inner_protocol_type = ENCAP_TYPE_ETHER;
2966 static inline void skb_set_inner_ipproto(struct sk_buff *skb,
2969 skb->inner_ipproto = ipproto;
2970 skb->inner_protocol_type = ENCAP_TYPE_IPPROTO;
2973 static inline void skb_reset_inner_headers(struct sk_buff *skb)
2975 skb->inner_mac_header = skb->mac_header;
2976 skb->inner_network_header = skb->network_header;
2977 skb->inner_transport_header = skb->transport_header;
2980 static inline int skb_mac_header_was_set(const struct sk_buff *skb)
2982 return skb->mac_header != (typeof(skb->mac_header))~0U;
2985 static inline void skb_reset_mac_len(struct sk_buff *skb)
2987 if (!skb_mac_header_was_set(skb)) {
2989 skb->mac_len = 0;
2991 skb->mac_len = skb->network_header - skb->mac_header;
2996 *skb)
2998 return skb->head + skb->inner_transport_header;
3001 static inline int skb_inner_transport_offset(const struct sk_buff *skb)
3003 return skb_inner_transport_header(skb) - skb->data;
3006 static inline void skb_reset_inner_transport_header(struct sk_buff *skb)
3008 long offset = skb->data - skb->head;
3010 DEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb->inner_transport_header))offset);
3011 skb->inner_transport_header = offset;
3014 static inline void skb_set_inner_transport_header(struct sk_buff *skb,
3017 skb_reset_inner_transport_header(skb);
3018 skb->inner_transport_header += offset;
3021 static inline unsigned char *skb_inner_network_header(const struct sk_buff *skb)
3023 return skb->head + skb->inner_network_header;
3026 static inline void skb_reset_inner_network_header(struct sk_buff *skb)
3028 long offset = skb->data - skb->head;
3030 DEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb->inner_network_header))offset);
3031 skb->inner_network_header = offset;
3034 static inline void skb_set_inner_network_header(struct sk_buff *skb,
3037 skb_reset_inner_network_header(skb);
3038 skb->inner_network_header += offset;
3041 static inline bool skb_inner_network_header_was_set(const struct sk_buff *skb)
3043 return skb->inner_network_header > 0;
3046 static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
3048 return skb->head + skb->inner_mac_header;
3051 static inline void skb_reset_inner_mac_header(struct sk_buff *skb)
3053 long offset = skb->data - skb->head;
3055 DEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb->inner_mac_header))offset);
3056 skb->inner_mac_header = offset;
3059 static inline void skb_set_inner_mac_header(struct sk_buff *skb,
3062 skb_reset_inner_mac_header(skb);
3063 skb->inner_mac_header += offset;
3065 static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
3067 return skb->transport_header != (typeof(skb->transport_header))~0U;
3070 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
3072 DEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));
3073 return skb->head + skb->transport_header;
3076 static inline void skb_reset_transport_header(struct sk_buff *skb)
3078 long offset = skb->data - skb->head;
3080 DEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb->transport_header))offset);
3081 skb->transport_header = offset;
3086 * @skb: buffer to alter
3093 skb_reset_transport_header_careful(struct sk_buff *skb)
3095 long offset = skb->data - skb->head;
3097 if (unlikely(offset != (typeof(skb->transport_header))offset))
3100 if (unlikely(offset == (typeof(skb->transport_header))~0U))
3103 skb->transport_header = offset;
3107 static inline void skb_set_transport_header(struct sk_buff *skb,
3110 skb_reset_transport_header(skb);
3111 skb->transport_header += offset;
3114 static inline unsigned char *skb_network_header(const struct sk_buff *skb)
3116 return skb->head + skb->network_header;
3119 static inline void skb_reset_network_header(struct sk_buff *skb)
3121 long offset = skb->data - skb->head;
3123 DEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb->network_header))offset);
3124 skb->network_header = offset;
3127 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
3129 skb_reset_network_header(skb);
3130 skb->network_header += offset;
3133 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
3135 DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
3136 return skb->head + skb->mac_header;
3139 static inline int skb_mac_offset(const struct sk_buff *skb)
3141 return skb_mac_header(skb) - skb->data;
3144 static inline u32 skb_mac_header_len(const struct sk_buff *skb)
3146 DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
3147 return skb->network_header - skb->mac_header;
3150 static inline void skb_unset_mac_header(struct sk_buff *skb)
3152 skb->mac_header = (typeof(skb->mac_header))~0U;
3155 static inline void skb_reset_mac_header(struct sk_buff *skb)
3157 long offset = skb->data - skb->head;
3159 DEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb->mac_header))offset);
3160 skb->mac_header = offset;
3163 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
3165 skb_reset_mac_header(skb);
3166 skb->mac_header += offset;
3169 static inline void skb_pop_mac_header(struct sk_buff *skb)
3171 skb->mac_header = skb->network_header;
3174 static inline void skb_probe_transport_header(struct sk_buff *skb)
3178 if (skb_transport_header_was_set(skb))
3181 if (skb_flow_dissect_flow_keys_basic(NULL, skb, &keys,
3183 skb_set_transport_header(skb, keys.control.thoff);
3186 static inline void skb_mac_header_rebuild(struct sk_buff *skb)
3188 if (skb_mac_header_was_set(skb)) {
3189 const unsigned char *old_mac = skb_mac_header(skb);
3191 skb_set_mac_header(skb, -skb->mac_len);
3192 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
3197 * Leaves skb->data pointing at offset skb->mac_len into the mac_header.
3200 static inline void skb_mac_header_rebuild_full(struct sk_buff *skb, u32 full_mac_len)
3202 if (skb_mac_header_was_set(skb)) {
3203 const unsigned char *old_mac = skb_mac_header(skb);
3205 skb_set_mac_header(skb, -full_mac_len);
3206 memmove(skb_mac_header(skb), old_mac, full_mac_len);
3207 __skb_push(skb, full_mac_len - skb->mac_len);
3211 static inline int skb_checksum_start_offset(const struct sk_buff *skb)
3213 return skb->csum_start - skb_headroom(skb);
3216 static inline unsigned char *skb_checksum_start(const struct sk_buff *skb)
3218 return skb->head + skb->csum_start;
3221 static inline int skb_transport_offset(const struct sk_buff *skb)
3223 return skb_transport_header(skb) - skb->data;
3226 static inline u32 skb_network_header_len(const struct sk_buff *skb)
3228 DEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));
3229 return skb->transport_header - skb->network_header;
3232 static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
3234 return skb->inner_transport_header - skb->inner_network_header;
3237 static inline int skb_network_offset(const struct sk_buff *skb)
3239 return skb_network_header(skb) - skb->data;
3242 static inline int skb_inner_network_offset(const struct sk_buff *skb)
3244 return skb_inner_network_header(skb) - skb->data;
3248 pskb_network_may_pull_reason(struct sk_buff *skb, unsigned int len)
3250 return pskb_may_pull_reason(skb, skb_network_offset(skb) + len);
3253 static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
3255 return pskb_network_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET;
3269 * skb_reserve(skb, NET_IP_ALIGN);
3283 * The networking layer reserves some headroom in skb data (via
3284 * dev_alloc_skb). This is used to avoid having to reallocate skb data when
3306 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
3308 static inline void __skb_set_length(struct sk_buff *skb, unsigned int len)
3310 if (WARN_ON(skb_is_nonlinear(skb)))
3312 skb->len = len;
3313 skb_set_tail_pointer(skb, len);
3316 static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
3318 __skb_set_length(skb, len);
3321 void skb_trim(struct sk_buff *skb, unsigned int len);
3323 static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
3325 if (skb->data_len)
3326 return ___pskb_trim(skb, len);
3327 __skb_trim(skb, len);
3331 static inline int pskb_trim(struct sk_buff *skb, unsigned int len)
3333 skb_might_realloc(skb);
3334 return (len < skb->len) ? __pskb_trim(skb, len) : 0;
3339 * @skb: buffer to alter
3343 * the skb is not cloned so we should never get an error due to out-
3346 static inline void pskb_trim_unique(struct sk_buff *skb, unsigned int len)
3348 int err = pskb_trim(skb, len);
3352 static inline int __skb_grow(struct sk_buff *skb, unsigned int len)
3354 unsigned int diff = len - skb->len;
3356 if (skb_tailroom(skb) < diff) {
3357 int ret = pskb_expand_head(skb, 0, diff - skb_tailroom(skb),
3362 __skb_set_length(skb, len);
3368 * @skb: buffer to orphan
3371 * destructor function and make the @skb unowned. The buffer continues
3374 static inline void skb_orphan(struct sk_buff *skb)
3376 if (skb->destructor) {
3377 skb->destructor(skb);
3378 skb->destructor = NULL;
3379 skb->sk = NULL;
3381 BUG_ON(skb->sk);
3387 * @skb: buffer to orphan frags from
3394 static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask)
3396 if (likely(!skb_zcopy(skb)))
3398 if (skb_shinfo(skb)->flags & SKBFL_DONT_ORPHAN)
3400 return skb_copy_ubufs(skb, gfp_mask);
3403 /* Frags must be orphaned, even if refcounted, if skb might loop to rx path */
3404 static inline int skb_orphan_frags_rx(struct sk_buff *skb, gfp_t gfp_mask)
3406 if (likely(!skb_zcopy(skb)))
3408 return skb_copy_ubufs(skb, gfp_mask);
3423 struct sk_buff *skb;
3425 while ((skb = __skb_dequeue(list)) != NULL)
3426 kfree_skb_reason(skb, reason);
3505 struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp);
3507 if (NET_IP_ALIGN && skb)
3508 skb_reserve(skb, NET_IP_ALIGN);
3509 return skb;
3538 void napi_consume_skb(struct sk_buff *skb, int budget);
3540 void napi_skb_free_stolen_head(struct sk_buff *skb);
3541 void __napi_kfree_skb(struct sk_buff *skb, enum skb_drop_reason reason);
3612 * skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated after RX page
3614 * @skb: The skb that may need pfmemalloc set
3617 struct sk_buff *skb)
3620 skb->pfmemalloc = true;
3624 * skb_frag_off() - Returns the offset of a skb fragment
3633 * skb_frag_off_add() - Increments the offset of a skb fragment by @delta
3634 * @frag: skb fragment
3643 * skb_frag_off_set() - Sets the offset of a skb fragment
3644 * @frag: skb fragment
3653 * skb_frag_off_copy() - Sets the offset of a skb fragment from another fragment
3654 * @fragto: skb fragment where offset is set
3655 * @fragfrom: skb fragment offset is copied from
3754 * @fragto: skb fragment where page is set
3755 * @fragfrom: skb fragment page is copied from
3810 static inline struct sk_buff *pskb_copy(struct sk_buff *skb,
3813 return __pskb_copy(skb, skb_headroom(skb), gfp_mask);
3817 static inline struct sk_buff *pskb_copy_for_clone(struct sk_buff *skb,
3820 return __pskb_copy_fclone(skb, skb_headroom(skb), gfp_mask, true);
3826 * @skb: buffer to check
3832 static inline int skb_clone_writable(const struct sk_buff *skb, unsigned int len)
3834 return !skb_header_cloned(skb) &&
3835 skb_headroom(skb) + len <= skb->hdr_len;
3838 static inline int skb_try_make_writable(struct sk_buff *skb,
3841 return skb_cloned(skb) && !skb_clone_writable(skb, write_len) &&
3842 pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
3845 static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom,
3850 if (headroom > skb_headroom(skb))
3851 delta = headroom - skb_headroom(skb);
3854 return pskb_expand_head(skb, ALIGN(delta, NET_SKB_PAD), 0,
3860 * skb_cow - copy header of skb when it is required
3861 * @skb: buffer to cow
3864 * If the skb passed lacks sufficient headroom or its data part
3866 * is returned and original skb is not changed.
3868 * The result is skb with writable area skb->head...skb->tail
3871 static inline int skb_cow(struct sk_buff *skb, unsigned int headroom)
3873 return __skb_cow(skb, headroom, skb_cloned(skb));
3878 * @skb: buffer to cow
3886 static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
3888 return __skb_cow(skb, headroom, skb_header_cloned(skb));
3893 * @skb: buffer to pad
3899 * success. The skb is freed on error.
3901 static inline int skb_padto(struct sk_buff *skb, unsigned int len)
3903 unsigned int size = skb->len;
3906 return skb_pad(skb, len - size);
3911 * @skb: buffer to pad
3918 * success. The skb is freed on error if @free_on_error is true.
3920 static inline int __must_check __skb_put_padto(struct sk_buff *skb,
3924 unsigned int size = skb->len;
3928 if (__skb_pad(skb, len, free_on_error))
3930 __skb_put(skb, len);
3937 * @skb: buffer to pad
3943 * success. The skb is freed on error.
3945 static inline int __must_check skb_put_padto(struct sk_buff *skb, unsigned int len)
3947 return __skb_put_padto(skb, len, true);
3953 static inline bool skb_can_coalesce_netmem(struct sk_buff *skb, int i,
3956 if (skb_zcopy(skb))
3959 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
3967 static inline bool skb_can_coalesce(struct sk_buff *skb, int i,
3970 return skb_can_coalesce_netmem(skb, i, page_to_netmem(page), off);
3973 static inline int __skb_linearize(struct sk_buff *skb)
3975 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM;
3979 * skb_linearize - convert paged skb to linear one
3980 * @skb: buffer to linarize
3983 * is returned and the old skb data released.
3985 static inline int skb_linearize(struct sk_buff *skb)
3987 return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0;
3992 * @skb: buffer to test
3994 * Return: true if the skb has at least one frag that might be modified
3997 static inline bool skb_has_shared_frag(const struct sk_buff *skb)
3999 return skb_is_nonlinear(skb) &&
4000 skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
4004 * skb_linearize_cow - make sure skb is linear and writable
4005 * @skb: buffer to process
4008 * is returned and the old skb data released.
4010 static inline int skb_linearize_cow(struct sk_buff *skb)
4012 return skb_is_nonlinear(skb) || skb_cloned(skb) ?
4013 __skb_linearize(skb) : 0;
4017 __skb_postpull_rcsum(struct sk_buff *skb, const void *start, unsigned int len,
4020 if (skb->ip_summed == CHECKSUM_COMPLETE)
4021 skb->csum = csum_block_sub(skb->csum,
4023 else if (skb->ip_summed == CHECKSUM_PARTIAL &&
4024 skb_checksum_start_offset(skb) < 0)
4025 skb->ip_summed = CHECKSUM_NONE;
4029 * skb_postpull_rcsum - update checksum for received skb after pull
4030 * @skb: buffer to update
4038 static inline void skb_postpull_rcsum(struct sk_buff *skb,
4041 if (skb->ip_summed == CHECKSUM_COMPLETE)
4042 skb->csum = wsum_negate(csum_partial(start, len,
4043 wsum_negate(skb->csum)));
4044 else if (skb->ip_summed == CHECKSUM_PARTIAL &&
4045 skb_checksum_start_offset(skb) < 0)
4046 skb->ip_summed = CHECKSUM_NONE;
4050 __skb_postpush_rcsum(struct sk_buff *skb, const void *start, unsigned int len,
4053 if (skb->ip_summed == CHECKSUM_COMPLETE)
4054 skb->csum = csum_block_add(skb->csum,
4059 * skb_postpush_rcsum - update checksum for received skb after push
4060 * @skb: buffer to update
4067 static inline void skb_postpush_rcsum(struct sk_buff *skb,
4070 __skb_postpush_rcsum(skb, start, len, 0);
4073 void *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
4076 * skb_push_rcsum - push skb and update receive checksum
4077 * @skb: buffer to update
4086 static inline void *skb_push_rcsum(struct sk_buff *skb, unsigned int len)
4088 skb_push(skb, len);
4089 skb_postpush_rcsum(skb, skb->data, len);
4090 return skb->data;
4093 int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len);
4095 * pskb_trim_rcsum - trim received skb and update checksum
4096 * @skb: buffer to trim
4101 * It can change skb pointers.
4104 static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
4106 skb_might_realloc(skb);
4107 if (likely(len >= skb->len))
4109 return pskb_trim_rcsum_slow(skb, len);
4112 static inline int __skb_trim_rcsum(struct sk_buff *skb, unsigned int len)
4114 if (skb->ip_summed == CHECKSUM_COMPLETE)
4115 skb->ip_summed = CHECKSUM_NONE;
4116 __skb_trim(skb, len);
4120 static inline int __skb_grow_rcsum(struct sk_buff *skb, unsigned int len)
4122 if (skb->ip_summed == CHECKSUM_COMPLETE)
4123 skb->ip_summed = CHECKSUM_NONE;
4124 return __skb_grow(skb, len);
4130 #define skb_rb_next(skb) rb_to_skb(rb_next(&(skb)->rbnode))
4131 #define skb_rb_prev(skb) rb_to_skb(rb_prev(&(skb)->rbnode))
4133 #define skb_queue_walk(queue, skb) \
4134 for (skb = (queue)->next; \
4135 skb != (struct sk_buff *)(queue); \
4136 skb = skb->next)
4138 #define skb_queue_walk_safe(queue, skb, tmp) \
4139 for (skb = (queue)->next, tmp = skb->next; \
4140 skb != (struct sk_buff *)(queue); \
4141 skb = tmp, tmp = skb->next)
4143 #define skb_queue_walk_from(queue, skb) \
4144 for (; skb != (struct sk_buff *)(queue); \
4145 skb = skb->next)
4147 #define skb_rbtree_walk(skb, root) \
4148 for (skb = skb_rb_first(root); skb != NULL; \
4149 skb = skb_rb_next(skb))
4151 #define skb_rbtree_walk_from(skb) \
4152 for (; skb != NULL; \
4153 skb = skb_rb_next(skb))
4155 #define skb_rbtree_walk_from_safe(skb, tmp) \
4156 for (; tmp = skb ? skb_rb_next(skb) : NULL, (skb != NULL); \
4157 skb = tmp)
4159 #define skb_queue_walk_from_safe(queue, skb, tmp) \
4160 for (tmp = skb->next; \
4161 skb != (struct sk_buff *)(queue); \
4162 skb = tmp, tmp = skb->next)
4164 #define skb_queue_reverse_walk(queue, skb) \
4165 for (skb = (queue)->prev; \
4166 skb != (struct sk_buff *)(queue); \
4167 skb = skb->prev)
4169 #define skb_queue_reverse_walk_safe(queue, skb, tmp) \
4170 for (skb = (queue)->prev, tmp = skb->prev; \
4171 skb != (struct sk_buff *)(queue); \
4172 skb = tmp, tmp = skb->prev)
4174 #define skb_queue_reverse_walk_from_safe(queue, skb, tmp) \
4175 for (tmp = skb->prev; \
4176 skb != (struct sk_buff *)(queue); \
4177 skb = tmp, tmp = skb->prev)
4179 static inline bool skb_has_frag_list(const struct sk_buff *skb)
4181 return skb_shinfo(skb)->frag_list != NULL;
4184 static inline void skb_frag_list_init(struct sk_buff *skb)
4186 skb_shinfo(skb)->frag_list = NULL;
4189 #define skb_walk_frags(skb, iter) \
4190 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
4195 const struct sk_buff *skb);
4220 int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, int hlen,
4222 int skb_copy_and_crc32c_datagram_iter(const struct sk_buff *skb, int offset,
4224 int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
4226 int skb_copy_datagram_from_iter_full(struct sk_buff *skb, int offset,
4228 int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *frm);
4229 void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
4230 int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags);
4231 int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len);
4232 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
4233 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
4235 int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
4238 int skb_send_sock_locked(struct sock *sk, struct sk_buff *skb, int offset,
4240 int skb_send_sock_locked_with_flags(struct sock *sk, struct sk_buff *skb,
4242 int skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int len);
4243 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
4247 void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len);
4248 int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen);
4249 void skb_scrub_packet(struct sk_buff *skb, bool xnet);
4250 struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
4251 struct sk_buff *skb_segment_list(struct sk_buff *skb, netdev_features_t features,
4253 struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
4254 int skb_ensure_writable(struct sk_buff *skb, unsigned int write_len);
4255 int skb_ensure_writable_head_tail(struct sk_buff *skb, struct net_device *dev);
4256 int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci);
4257 int skb_vlan_pop(struct sk_buff *skb);
4258 int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
4259 int skb_eth_pop(struct sk_buff *skb);
4260 int skb_eth_push(struct sk_buff *skb, const unsigned char *dst,
4262 int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
4264 int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
4266 int skb_mpls_update_lse(struct sk_buff *skb, __be32 mpls_lse);
4267 int skb_mpls_dec_ttl(struct sk_buff *skb);
4268 struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,
4281 __wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
4283 u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc);
4286 __skb_header_pointer(const struct sk_buff *skb, int offset, int len,
4292 if (!skb || unlikely(skb_copy_bits(skb, offset, buffer, len) < 0))
4299 skb_header_pointer(const struct sk_buff *skb, int offset, int len, void *buffer)
4301 return __skb_header_pointer(skb, offset, len, skb->data,
4302 skb_headlen(skb), buffer);
4309 skb_header_pointer_careful(const struct sk_buff *skb, int offset,
4312 if (unlikely(offset < 0 && -offset > skb_headroom(skb)))
4314 return skb_header_pointer(skb, offset, len, buffer);
4318 skb_pointer_if_linear(const struct sk_buff *skb, int offset, int len)
4320 if (likely(skb_headlen(skb) - offset >= len))
4321 return skb->data + offset;
4326 * skb_needs_linearize - check if we need to linearize a given skb
4328 * @skb: socket buffer to check
4332 * 1. skb has frag_list and the device doesn't support FRAGLIST, or
4333 * 2. skb is fragmented and the device does not support SG.
4335 static inline bool skb_needs_linearize(struct sk_buff *skb,
4338 return skb_is_nonlinear(skb) &&
4339 ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) ||
4340 (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG)));
4343 static inline void skb_copy_from_linear_data(const struct sk_buff *skb,
4347 memcpy(to, skb->data, len);
4350 static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
4354 memcpy(to, skb->data + offset, len);
4357 static inline void skb_copy_to_linear_data(struct sk_buff *skb,
4361 memcpy(skb->data, from, len);
4364 static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
4369 memcpy(skb->data + offset, from, len);
4374 static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
4376 return skb->tstamp;
4380 * skb_get_timestamp - get timestamp from a skb
4381 * @skb: skb to get stamp from
4384 * Timestamps are stored in the skb as offsets to a base timestamp.
4388 static inline void skb_get_timestamp(const struct sk_buff *skb,
4391 *stamp = ns_to_kernel_old_timeval(skb->tstamp);
4394 static inline void skb_get_new_timestamp(const struct sk_buff *skb,
4397 struct timespec64 ts = ktime_to_timespec64(skb->tstamp);
4403 static inline void skb_get_timestampns(const struct sk_buff *skb,
4406 struct timespec64 ts = ktime_to_timespec64(skb->tstamp);
4412 static inline void skb_get_new_timestampns(const struct sk_buff *skb,
4415 struct timespec64 ts = ktime_to_timespec64(skb->tstamp);
4421 static inline void __net_timestamp(struct sk_buff *skb)
4423 skb->tstamp = ktime_get_real();
4424 skb->tstamp_type = SKB_CLOCK_REALTIME;
4432 static inline void skb_set_delivery_time(struct sk_buff *skb, ktime_t kt,
4435 skb->tstamp = kt;
4438 skb->tstamp_type = tstamp_type;
4440 skb->tstamp_type = SKB_CLOCK_REALTIME;
4443 static inline void skb_set_delivery_type_by_clockid(struct sk_buff *skb,
4462 skb_set_delivery_time(skb, kt, tstamp_type);
4468 * If needed, set the skb->tstamp to the (rcv) timestamp.
4470 static inline void skb_clear_delivery_time(struct sk_buff *skb)
4472 if (skb->tstamp_type) {
4473 skb->tstamp_type = SKB_CLOCK_REALTIME;
4475 skb->tstamp = ktime_get_real();
4477 skb->tstamp = 0;
4481 static inline void skb_clear_tstamp(struct sk_buff *skb)
4483 if (skb->tstamp_type)
4486 skb->tstamp = 0;
4489 static inline ktime_t skb_tstamp(const struct sk_buff *skb)
4491 if (skb->tstamp_type)
4494 return skb->tstamp;
4497 static inline ktime_t skb_tstamp_cond(const struct sk_buff *skb, bool cond)
4499 if (skb->tstamp_type != SKB_CLOCK_MONOTONIC && skb->tstamp)
4500 return skb->tstamp;
4508 static inline u8 skb_metadata_len(const struct sk_buff *skb)
4510 return skb_shinfo(skb)->meta_len;
4513 static inline void *skb_metadata_end(const struct sk_buff *skb)
4515 return skb_mac_header(skb);
4570 static inline void skb_metadata_set(struct sk_buff *skb, u8 meta_len)
4572 skb_shinfo(skb)->meta_len = meta_len;
4575 static inline void skb_metadata_clear(struct sk_buff *skb)
4577 skb_metadata_set(skb, 0);
4582 * @skb: packet to operate on
4586 * Moves @n bytes of packet data, can be zero, and all bytes of skb metadata.
4595 static inline void skb_data_move(struct sk_buff *skb, const int len,
4598 const u8 meta_len = skb_metadata_len(skb);
4607 meta_end = skb_metadata_end(skb);
4610 if (WARN_ON_ONCE(meta_end + len != skb->data ||
4611 meta_len > skb_headroom(skb))) {
4612 skb_metadata_clear(skb);
4620 memmove(skb->data, skb->data - len, n);
4625 * @skb: packet to operate on
4631 static inline void skb_postpull_data_move(struct sk_buff *skb,
4636 skb_data_move(skb, len, n);
4641 * @skb: packet to operate on
4647 static inline void skb_postpush_data_move(struct sk_buff *skb,
4652 skb_data_move(skb, -len, n);
4655 struct sk_buff *skb_clone_sk(struct sk_buff *skb);
4659 void skb_clone_tx_timestamp(struct sk_buff *skb);
4660 bool skb_defer_rx_timestamp(struct sk_buff *skb);
4664 static inline void skb_clone_tx_timestamp(struct sk_buff *skb)
4668 static inline bool skb_defer_rx_timestamp(struct sk_buff *skb)
4676 * skb_complete_tx_timestamp() - deliver cloned skb with tx timestamps
4680 * must call this function to return the skb back to the stack with a
4683 * @skb: clone of the original outgoing packet
4687 void skb_complete_tx_timestamp(struct sk_buff *skb,
4695 * skb_tstamp_tx - queue clone of skb with send time stamps
4699 * If the skb has a socket associated, then this function clones the
4700 * skb (thus sharing the actual data and optional structures), stores
4718 * @skb: A socket buffer.
4720 static inline void skb_tx_timestamp(struct sk_buff *skb)
4722 skb_clone_tx_timestamp(skb);
4723 if (skb_shinfo(skb)->tx_flags & (SKBTX_SW_TSTAMP | SKBTX_BPF))
4724 skb_tstamp_tx(skb, NULL);
4728 * skb_complete_wifi_ack - deliver skb with wifi status
4730 * @skb: the original outgoing packet
4734 void skb_complete_wifi_ack(struct sk_buff *skb, bool acked);
4736 __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
4737 __sum16 __skb_checksum_complete(struct sk_buff *skb);
4739 static inline int skb_csum_unnecessary(const struct sk_buff *skb)
4741 return ((skb->ip_summed == CHECKSUM_UNNECESSARY) ||
4742 skb->csum_valid ||
4743 (skb->ip_summed == CHECKSUM_PARTIAL &&
4744 skb_checksum_start_offset(skb) >= 0));
4749 * @skb: packet to process
4752 * the value of skb->csum. The latter can be used to supply the
4760 * if skb->ip_summed is CHECKSUM_UNNECESSARY which indicates that the
4763 static inline __sum16 skb_checksum_complete(struct sk_buff *skb)
4765 return skb_csum_unnecessary(skb) ?
4766 0 : __skb_checksum_complete(skb);
4769 static inline void __skb_decr_checksum_unnecessary(struct sk_buff *skb)
4771 if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
4772 if (skb->csum_level == 0)
4773 skb->ip_summed = CHECKSUM_NONE;
4775 skb->csum_level--;
4779 static __always_inline void __skb_incr_checksum_unnecessary(struct sk_buff *skb)
4781 if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
4782 if (skb->csum_level < SKB_MAX_CSUM_LEVEL)
4783 skb->csum_level++;
4784 } else if (skb->ip_summed == CHECKSUM_NONE) {
4785 skb->ip_summed = CHECKSUM_UNNECESSARY;
4786 skb->csum_level = 0;
4790 static inline void __skb_reset_checksum_unnecessary(struct sk_buff *skb)
4792 if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
4793 skb->ip_summed = CHECKSUM_NONE;
4794 skb->csum_level = 0;
4803 static inline bool __skb_checksum_validate_needed(struct sk_buff *skb,
4807 if (skb_csum_unnecessary(skb) || (zero_okay && !check)) {
4808 skb->csum_valid = 1;
4809 __skb_decr_checksum_unnecessary(skb);
4827 static inline void skb_checksum_complete_unset(struct sk_buff *skb)
4829 if (skb->ip_summed == CHECKSUM_COMPLETE)
4830 skb->ip_summed = CHECKSUM_NONE;
4838 * checksum is stored in skb->csum for use in __skb_checksum_complete
4842 static inline __sum16 __skb_checksum_validate_complete(struct sk_buff *skb,
4846 if (skb->ip_summed == CHECKSUM_COMPLETE) {
4847 if (!csum_fold(csum_add(psum, skb->csum))) {
4848 skb->csum_valid = 1;
4853 skb->csum = psum;
4855 if (complete || skb->len <= CHECKSUM_BREAK) {
4858 csum = __skb_checksum_complete(skb);
4859 skb->csum_valid = !csum;
4866 static inline __wsum null_compute_pseudo(struct sk_buff *skb, int proto)
4881 #define __skb_checksum_validate(skb, proto, complete, \
4885 skb->csum_valid = 0; \
4886 if (__skb_checksum_validate_needed(skb, zero_okay, check)) \
4887 __ret = __skb_checksum_validate_complete(skb, \
4888 complete, compute_pseudo(skb, proto)); \
4892 #define skb_checksum_init(skb, proto, compute_pseudo) \
4893 __skb_checksum_validate(skb, proto, false, false, 0, compute_pseudo)
4895 #define skb_checksum_init_zero_check(skb, proto, check, compute_pseudo) \
4896 __skb_checksum_validate(skb, proto, false, true, check, compute_pseudo)
4898 #define skb_checksum_validate(skb, proto, compute_pseudo) \
4899 __skb_checksum_validate(skb, proto, true, false, 0, compute_pseudo)
4901 #define skb_checksum_validate_zero_check(skb, proto, check, \
4903 __skb_checksum_validate(skb, proto, true, true, check, compute_pseudo)
4905 #define skb_checksum_simple_validate(skb) \
4906 __skb_checksum_validate(skb, 0, true, false, 0, null_compute_pseudo)
4908 static inline bool __skb_checksum_convert_check(struct sk_buff *skb)
4910 return (skb->ip_summed == CHECKSUM_NONE && skb->csum_valid);
4913 static inline void __skb_checksum_convert(struct sk_buff *skb, __wsum pseudo)
4915 skb->csum = ~pseudo;
4916 skb->ip_summed = CHECKSUM_COMPLETE;
4919 #define skb_checksum_try_convert(skb, proto, compute_pseudo) \
4921 if (__skb_checksum_convert_check(skb)) \
4922 __skb_checksum_convert(skb, compute_pseudo(skb, proto)); \
4925 static inline void skb_remcsum_adjust_partial(struct sk_buff *skb, void *ptr,
4928 skb->ip_summed = CHECKSUM_PARTIAL;
4929 skb->csum_start = ((unsigned char *)ptr + start) - skb->head;
4930 skb->csum_offset = offset - start;
4934 * When called, ptr indicates the starting point for skb->csum when
4936 * here, skb_postpull_rcsum is done so skb->csum start is ptr.
4938 static inline void skb_remcsum_process(struct sk_buff *skb, void *ptr,
4944 skb_remcsum_adjust_partial(skb, ptr, start, offset);
4948 if (unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) {
4949 __skb_checksum_complete(skb);
4950 skb_postpull_rcsum(skb, skb->data, ptr - (void *)skb->data);
4953 delta = remcsum_adjust(ptr, skb->csum, start, offset);
4955 /* Adjust skb->csum since we changed the packet */
4956 skb->csum = csum_add(skb->csum, delta);
4959 static inline struct nf_conntrack *skb_nfct(const struct sk_buff *skb)
4962 return (void *)(skb->_nfct & NFCT_PTRMASK);
4968 static inline unsigned long skb_get_nfct(const struct sk_buff *skb)
4971 return skb->_nfct;
4977 static inline void skb_set_nfct(struct sk_buff *skb, unsigned long nfct)
4980 skb->slow_gro |= !!nfct;
4981 skb->_nfct = nfct;
5029 void *__skb_ext_set(struct sk_buff *skb, enum skb_ext_id id,
5031 void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id);
5032 void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id);
5035 static inline void skb_ext_put(struct sk_buff *skb)
5037 if (skb->active_extensions)
5038 __skb_ext_put(skb->extensions);
5065 static inline bool skb_ext_exist(const struct sk_buff *skb, enum skb_ext_id id)
5067 return skb->active_extensions & (1 << id);
5070 static inline void skb_ext_del(struct sk_buff *skb, enum skb_ext_id id)
5072 if (skb_ext_exist(skb, id))
5073 __skb_ext_del(skb, id);
5076 static inline void *skb_ext_find(const struct sk_buff *skb, enum skb_ext_id id)
5078 if (skb_ext_exist(skb, id)) {
5079 struct skb_ext *ext = skb->extensions;
5087 static inline void skb_ext_reset(struct sk_buff *skb)
5089 if (unlikely(skb->active_extensions)) {
5090 __skb_ext_put(skb->extensions);
5091 skb->active_extensions = 0;
5095 static inline bool skb_has_extensions(struct sk_buff *skb)
5097 return unlikely(skb->active_extensions);
5101 static inline void skb_ext_put(struct sk_buff *skb) {}
5102 static inline void skb_ext_reset(struct sk_buff *skb) {}
5103 static inline void skb_ext_del(struct sk_buff *skb, int unused) {}
5106 static inline bool skb_has_extensions(struct sk_buff *skb) { return false; }
5109 static inline void nf_reset_ct(struct sk_buff *skb)
5112 nf_conntrack_put(skb_nfct(skb));
5113 skb->_nfct = 0;
5117 static inline void nf_reset_trace(struct sk_buff *skb)
5120 skb->nf_trace = 0;
5124 static inline void ipvs_reset(struct sk_buff *skb)
5127 skb->ipvs_property = 0;
5160 static inline void skb_init_secmark(struct sk_buff *skb)
5162 skb->secmark = 0;
5168 static inline void skb_init_secmark(struct sk_buff *skb)
5172 static inline int secpath_exists(const struct sk_buff *skb)
5175 return skb_ext_exist(skb, SKB_EXT_SEC_PATH);
5181 static inline bool skb_irq_freeable(const struct sk_buff *skb)
5183 return !skb->destructor &&
5184 !secpath_exists(skb) &&
5185 !skb_nfct(skb) &&
5186 !skb->_skb_refdst &&
5187 !skb_has_frag_list(skb);
5190 static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
5192 skb->queue_mapping = queue_mapping;
5195 static inline u16 skb_get_queue_mapping(const struct sk_buff *skb)
5197 return skb->queue_mapping;
5205 static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue)
5207 skb->queue_mapping = rx_queue + 1;
5210 static inline u16 skb_get_rx_queue(const struct sk_buff *skb)
5212 return skb->queue_mapping - 1;
5215 static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
5217 return skb->queue_mapping != 0;
5220 static inline void skb_set_dst_pending_confirm(struct sk_buff *skb, u32 val)
5222 skb->dst_pending_confirm = val;
5225 static inline bool skb_get_dst_pending_confirm(const struct sk_buff *skb)
5227 return skb->dst_pending_confirm != 0;
5230 static inline struct sec_path *skb_sec_path(const struct sk_buff *skb)
5233 return skb_ext_find(skb, SKB_EXT_SEC_PATH);
5239 static inline bool skb_is_gso(const struct sk_buff *skb)
5241 return skb_shinfo(skb)->gso_size;
5244 /* Note: Should be called only if skb_is_gso(skb) is true */
5245 static inline bool skb_is_gso_v6(const struct sk_buff *skb)
5247 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6;
5250 /* Note: Should be called only if skb_is_gso(skb) is true */
5251 static inline bool skb_is_gso_sctp(const struct sk_buff *skb)
5253 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP;
5256 /* Note: Should be called only if skb_is_gso(skb) is true */
5257 static inline bool skb_is_gso_tcp(const struct sk_buff *skb)
5259 return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6);
5262 static inline void skb_gso_reset(struct sk_buff *skb)
5264 skb_shinfo(skb)->gso_size = 0;
5265 skb_shinfo(skb)->gso_segs = 0;
5266 skb_shinfo(skb)->gso_type = 0;
5285 void __skb_warn_lro_forwarding(const struct sk_buff *skb);
5287 static inline bool skb_warn_if_lro(const struct sk_buff *skb)
5291 const struct skb_shared_info *shinfo = skb_shinfo(skb);
5293 if (skb_is_nonlinear(skb) && shinfo->gso_size != 0 &&
5295 __skb_warn_lro_forwarding(skb);
5301 static inline void skb_forward_csum(struct sk_buff *skb)
5304 if (skb->ip_summed == CHECKSUM_COMPLETE)
5305 skb->ip_summed = CHECKSUM_NONE;
5309 * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
5310 * @skb: skb to check
5316 static inline void skb_checksum_none_assert(const struct sk_buff *skb)
5318 DEBUG_NET_WARN_ON_ONCE(skb->ip_summed != CHECKSUM_NONE);
5321 bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
5323 int skb_checksum_setup(struct sk_buff *skb, bool recalculate);
5324 struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
5326 __sum16(*skb_chkf)(struct sk_buff *skb));
5329 * skb_head_is_locked - Determine if the skb->head is locked down
5330 * @skb: skb to check
5333 * not cloned. This function returns true if the skb head is locked down
5337 static inline bool skb_head_is_locked(const struct sk_buff *skb)
5339 return !skb->head_frag || skb_cloned(skb);
5351 static inline __wsum lco_csum(struct sk_buff *skb)
5353 unsigned char *csum_start = skb_checksum_start(skb);
5354 unsigned char *l4_hdr = skb_transport_header(skb);
5359 skb->csum_offset));
5367 static inline bool skb_is_redirected(const struct sk_buff *skb)
5369 return skb->redirected;
5372 static inline void skb_set_redirected(struct sk_buff *skb, bool from_ingress)
5374 skb->redirected = 1;
5376 skb->from_ingress = from_ingress;
5377 if (skb->from_ingress)
5378 skb_clear_tstamp(skb);
5382 static inline void skb_reset_redirect(struct sk_buff *skb)
5384 skb->redirected = 0;
5387 static inline void skb_set_redirected_noclear(struct sk_buff *skb,
5390 skb->redirected = 1;
5392 skb->from_ingress = from_ingress;
5396 static inline bool skb_csum_is_sctp(struct sk_buff *skb)
5399 return skb->csum_not_inet;
5405 static inline void skb_reset_csum_not_inet(struct sk_buff *skb)
5407 skb->ip_summed = CHECKSUM_NONE;
5409 skb->csum_not_inet = 0;
5413 static inline void skb_set_kcov_handle(struct sk_buff *skb,
5417 skb->kcov_handle = kcov_handle;
5421 static inline u64 skb_get_kcov_handle(struct sk_buff *skb)
5424 return skb->kcov_handle;
5430 static inline void skb_mark_for_recycle(struct sk_buff *skb)
5433 skb->pp_recycle = 1;
5437 ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,