Lines Matching refs:skb
502 int skb_zerocopy_iter_dgram(struct sk_buff *skb, struct msghdr *msg, int len);
503 int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
725 void (*destructor)(struct sk_buff *skb);
902 static inline bool skb_pfmemalloc(const struct sk_buff *skb) in skb_pfmemalloc() argument
904 return unlikely(skb->pfmemalloc); in skb_pfmemalloc()
920 static inline struct dst_entry *skb_dst(const struct sk_buff *skb) in skb_dst() argument
925 WARN_ON((skb->_skb_refdst & SKB_DST_NOREF) && in skb_dst()
928 return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK); in skb_dst()
939 static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) in skb_dst_set() argument
941 skb->_skb_refdst = (unsigned long)dst; in skb_dst_set()
954 static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst) in skb_dst_set_noref() argument
957 skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF; in skb_dst_set_noref()
964 static inline bool skb_dst_is_noref(const struct sk_buff *skb) in skb_dst_is_noref() argument
966 return (skb->_skb_refdst & SKB_DST_NOREF) && skb_dst(skb); in skb_dst_is_noref()
973 static inline struct rtable *skb_rtable(const struct sk_buff *skb) in skb_rtable() argument
975 return (struct rtable *)skb_dst(skb); in skb_rtable()
991 static inline unsigned int skb_napi_id(const struct sk_buff *skb) in skb_napi_id() argument
994 return skb->napi_id; in skb_napi_id()
1006 static inline bool skb_unref(struct sk_buff *skb) in skb_unref() argument
1008 if (unlikely(!skb)) in skb_unref()
1010 if (likely(refcount_read(&skb->users) == 1)) in skb_unref()
1012 else if (likely(!refcount_dec_and_test(&skb->users))) in skb_unref()
1018 void skb_release_head_state(struct sk_buff *skb);
1019 void kfree_skb(struct sk_buff *skb);
1021 void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt);
1022 void skb_tx_error(struct sk_buff *skb);
1023 void consume_skb(struct sk_buff *skb);
1024 void __consume_stateless_skb(struct sk_buff *skb);
1025 void __kfree_skb(struct sk_buff *skb);
1028 void kfree_skb_partial(struct sk_buff *skb, bool head_stolen);
1036 struct sk_buff *build_skb_around(struct sk_buff *skb,
1078 const struct sk_buff *skb) in skb_fclone_busy() argument
1082 fclones = container_of(skb, struct sk_buff_fclones, skb1); in skb_fclone_busy()
1084 return skb->fclone == SKB_FCLONE_ORIG && in skb_fclone_busy()
1103 void skb_headers_offset_update(struct sk_buff *skb, int off);
1104 int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask);
1105 struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t priority);
1107 struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t priority);
1108 struct sk_buff *__pskb_copy_fclone(struct sk_buff *skb, int headroom,
1110 static inline struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, in __pskb_copy() argument
1113 return __pskb_copy_fclone(skb, headroom, gfp_mask, false); in __pskb_copy()
1116 int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, gfp_t gfp_mask);
1117 struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
1119 struct sk_buff *skb_copy_expand(const struct sk_buff *skb, int newheadroom,
1121 int __must_check skb_to_sgvec_nomark(struct sk_buff *skb, struct scatterlist *sg,
1123 int __must_check skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg,
1125 int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
1126 int __skb_pad(struct sk_buff *skb, int pad, bool free_on_error);
1139 static inline int skb_pad(struct sk_buff *skb, int pad) in skb_pad() argument
1141 return __skb_pad(skb, pad, true); in skb_pad()
1145 int skb_append_pagefrags(struct sk_buff *skb, struct page *page,
1158 void skb_prepare_seq_read(struct sk_buff *skb, unsigned int from,
1164 unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
1200 static inline void skb_clear_hash(struct sk_buff *skb) in skb_clear_hash() argument
1202 skb->hash = 0; in skb_clear_hash()
1203 skb->sw_hash = 0; in skb_clear_hash()
1204 skb->l4_hash = 0; in skb_clear_hash()
1207 static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb) in skb_clear_hash_if_not_l4() argument
1209 if (!skb->l4_hash) in skb_clear_hash_if_not_l4()
1210 skb_clear_hash(skb); in skb_clear_hash_if_not_l4()
1214 __skb_set_hash(struct sk_buff *skb, __u32 hash, bool is_sw, bool is_l4) in __skb_set_hash() argument
1216 skb->l4_hash = is_l4; in __skb_set_hash()
1217 skb->sw_hash = is_sw; in __skb_set_hash()
1218 skb->hash = hash; in __skb_set_hash()
1222 skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type) in skb_set_hash() argument
1225 __skb_set_hash(skb, hash, false, type == PKT_HASH_TYPE_L4); in skb_set_hash()
1229 __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4) in __skb_set_sw_hash() argument
1231 __skb_set_hash(skb, hash, true, is_l4); in __skb_set_sw_hash()
1234 void __skb_get_hash(struct sk_buff *skb);
1235 u32 __skb_get_hash_symmetric(const struct sk_buff *skb);
1236 u32 skb_get_poff(const struct sk_buff *skb);
1237 u32 __skb_get_poff(const struct sk_buff *skb, void *data,
1239 __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
1242 static inline __be32 skb_flow_get_ports(const struct sk_buff *skb, in skb_flow_get_ports() argument
1245 return __skb_flow_get_ports(skb, thoff, ip_proto, NULL, 0); in skb_flow_get_ports()
1283 const struct sk_buff *skb,
1289 static inline bool skb_flow_dissect(const struct sk_buff *skb, in skb_flow_dissect() argument
1293 return __skb_flow_dissect(NULL, skb, flow_dissector, in skb_flow_dissect()
1297 static inline bool skb_flow_dissect_flow_keys(const struct sk_buff *skb, in skb_flow_dissect_flow_keys() argument
1302 return __skb_flow_dissect(NULL, skb, &flow_keys_dissector, in skb_flow_dissect_flow_keys()
1308 const struct sk_buff *skb, in skb_flow_dissect_flow_keys_basic() argument
1314 return __skb_flow_dissect(net, skb, &flow_keys_basic_dissector, flow, in skb_flow_dissect_flow_keys_basic()
1318 void skb_flow_dissect_meta(const struct sk_buff *skb,
1327 skb_flow_dissect_ct(const struct sk_buff *skb,
1333 skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
1337 static inline __u32 skb_get_hash(struct sk_buff *skb) in skb_get_hash() argument
1339 if (!skb->l4_hash && !skb->sw_hash) in skb_get_hash()
1340 __skb_get_hash(skb); in skb_get_hash()
1342 return skb->hash; in skb_get_hash()
1345 static inline __u32 skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6 *fl6) in skb_get_hash_flowi6() argument
1347 if (!skb->l4_hash && !skb->sw_hash) { in skb_get_hash_flowi6()
1351 __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys)); in skb_get_hash_flowi6()
1354 return skb->hash; in skb_get_hash_flowi6()
1357 __u32 skb_get_hash_perturb(const struct sk_buff *skb,
1360 static inline __u32 skb_get_hash_raw(const struct sk_buff *skb) in skb_get_hash_raw() argument
1362 return skb->hash; in skb_get_hash_raw()
1381 static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) in skb_end_pointer() argument
1383 return skb->head + skb->end; in skb_end_pointer()
1386 static inline unsigned int skb_end_offset(const struct sk_buff *skb) in skb_end_offset() argument
1388 return skb->end; in skb_end_offset()
1391 static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) in skb_end_pointer() argument
1393 return skb->end; in skb_end_pointer()
1396 static inline unsigned int skb_end_offset(const struct sk_buff *skb) in skb_end_offset() argument
1398 return skb->end - skb->head; in skb_end_offset()
1405 static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb) in skb_hwtstamps() argument
1407 return &skb_shinfo(skb)->hwtstamps; in skb_hwtstamps()
1410 static inline struct ubuf_info *skb_zcopy(struct sk_buff *skb) in skb_zcopy() argument
1412 bool is_zcopy = skb && skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY; in skb_zcopy()
1414 return is_zcopy ? skb_uarg(skb) : NULL; in skb_zcopy()
1417 static inline void skb_zcopy_set(struct sk_buff *skb, struct ubuf_info *uarg, in skb_zcopy_set() argument
1420 if (skb && uarg && !skb_zcopy(skb)) { in skb_zcopy_set()
1425 skb_shinfo(skb)->destructor_arg = uarg; in skb_zcopy_set()
1426 skb_shinfo(skb)->tx_flags |= SKBTX_ZEROCOPY_FRAG; in skb_zcopy_set()
1430 static inline void skb_zcopy_set_nouarg(struct sk_buff *skb, void *val) in skb_zcopy_set_nouarg() argument
1432 skb_shinfo(skb)->destructor_arg = (void *)((uintptr_t) val | 0x1UL); in skb_zcopy_set_nouarg()
1433 skb_shinfo(skb)->tx_flags |= SKBTX_ZEROCOPY_FRAG; in skb_zcopy_set_nouarg()
1436 static inline bool skb_zcopy_is_nouarg(struct sk_buff *skb) in skb_zcopy_is_nouarg() argument
1438 return (uintptr_t) skb_shinfo(skb)->destructor_arg & 0x1UL; in skb_zcopy_is_nouarg()
1441 static inline void *skb_zcopy_get_nouarg(struct sk_buff *skb) in skb_zcopy_get_nouarg() argument
1443 return (void *)((uintptr_t) skb_shinfo(skb)->destructor_arg & ~0x1UL); in skb_zcopy_get_nouarg()
1447 static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy) in skb_zcopy_clear() argument
1449 struct ubuf_info *uarg = skb_zcopy(skb); in skb_zcopy_clear()
1452 if (skb_zcopy_is_nouarg(skb)) { in skb_zcopy_clear()
1461 skb_shinfo(skb)->tx_flags &= ~SKBTX_ZEROCOPY_FRAG; in skb_zcopy_clear()
1466 static inline void skb_zcopy_abort(struct sk_buff *skb) in skb_zcopy_abort() argument
1468 struct ubuf_info *uarg = skb_zcopy(skb); in skb_zcopy_abort()
1472 skb_shinfo(skb)->tx_flags &= ~SKBTX_ZEROCOPY_FRAG; in skb_zcopy_abort()
1476 static inline void skb_mark_not_on_list(struct sk_buff *skb) in skb_mark_not_on_list() argument
1478 skb->next = NULL; in skb_mark_not_on_list()
1481 static inline void skb_list_del_init(struct sk_buff *skb) in skb_list_del_init() argument
1483 __list_del_entry(&skb->list); in skb_list_del_init()
1484 skb_mark_not_on_list(skb); in skb_list_del_init()
1519 const struct sk_buff *skb) in skb_queue_is_last() argument
1521 return skb->next == (const struct sk_buff *) list; in skb_queue_is_last()
1532 const struct sk_buff *skb) in skb_queue_is_first() argument
1534 return skb->prev == (const struct sk_buff *) list; in skb_queue_is_first()
1546 const struct sk_buff *skb) in skb_queue_next() argument
1551 BUG_ON(skb_queue_is_last(list, skb)); in skb_queue_next()
1552 return skb->next; in skb_queue_next()
1564 const struct sk_buff *skb) in skb_queue_prev() argument
1569 BUG_ON(skb_queue_is_first(list, skb)); in skb_queue_prev()
1570 return skb->prev; in skb_queue_prev()
1580 static inline struct sk_buff *skb_get(struct sk_buff *skb) in skb_get() argument
1582 refcount_inc(&skb->users); in skb_get()
1583 return skb; in skb_get()
1598 static inline int skb_cloned(const struct sk_buff *skb) in skb_cloned() argument
1600 return skb->cloned && in skb_cloned()
1601 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1; in skb_cloned()
1604 static inline int skb_unclone(struct sk_buff *skb, gfp_t pri) in skb_unclone() argument
1608 if (skb_cloned(skb)) in skb_unclone()
1609 return pskb_expand_head(skb, 0, 0, pri); in skb_unclone()
1621 static inline int skb_header_cloned(const struct sk_buff *skb) in skb_header_cloned() argument
1625 if (!skb->cloned) in skb_header_cloned()
1628 dataref = atomic_read(&skb_shinfo(skb)->dataref); in skb_header_cloned()
1633 static inline int skb_header_unclone(struct sk_buff *skb, gfp_t pri) in skb_header_unclone() argument
1637 if (skb_header_cloned(skb)) in skb_header_unclone()
1638 return pskb_expand_head(skb, 0, 0, pri); in skb_header_unclone()
1647 static inline void __skb_header_release(struct sk_buff *skb) in __skb_header_release() argument
1649 skb->nohdr = 1; in __skb_header_release()
1650 atomic_set(&skb_shinfo(skb)->dataref, 1 + (1 << SKB_DATAREF_SHIFT)); in __skb_header_release()
1661 static inline int skb_shared(const struct sk_buff *skb) in skb_shared() argument
1663 return refcount_read(&skb->users) != 1; in skb_shared()
1679 static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri) in skb_share_check() argument
1682 if (skb_shared(skb)) { in skb_share_check()
1683 struct sk_buff *nskb = skb_clone(skb, pri); in skb_share_check()
1686 consume_skb(skb); in skb_share_check()
1688 kfree_skb(skb); in skb_share_check()
1689 skb = nskb; in skb_share_check()
1691 return skb; in skb_share_check()
1714 static inline struct sk_buff *skb_unshare(struct sk_buff *skb, in skb_unshare() argument
1718 if (skb_cloned(skb)) { in skb_unshare()
1719 struct sk_buff *nskb = skb_copy(skb, pri); in skb_unshare()
1723 consume_skb(skb); in skb_unshare()
1725 kfree_skb(skb); in skb_unshare()
1726 skb = nskb; in skb_unshare()
1728 return skb; in skb_unshare()
1746 struct sk_buff *skb = list_->next; in skb_peek() local
1748 if (skb == (struct sk_buff *)list_) in skb_peek()
1749 skb = NULL; in skb_peek()
1750 return skb; in skb_peek()
1773 static inline struct sk_buff *skb_peek_next(struct sk_buff *skb, in skb_peek_next() argument
1776 struct sk_buff *next = skb->next; in skb_peek_next()
1798 struct sk_buff *skb = list_->prev; in skb_peek_tail() local
1800 if (skb == (struct sk_buff *)list_) in skb_peek_tail()
1801 skb = NULL; in skb_peek_tail()
1802 return skb; in skb_peek_tail()
2015 void skb_unlink(struct sk_buff *skb, struct sk_buff_head *list);
2016 static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) in __skb_unlink() argument
2021 next = skb->next; in __skb_unlink()
2022 prev = skb->prev; in __skb_unlink()
2023 skb->next = skb->prev = NULL; in __skb_unlink()
2038 struct sk_buff *skb = skb_peek(list); in __skb_dequeue() local
2039 if (skb) in __skb_dequeue()
2040 __skb_unlink(skb, list); in __skb_dequeue()
2041 return skb; in __skb_dequeue()
2055 struct sk_buff *skb = skb_peek_tail(list); in __skb_dequeue_tail() local
2056 if (skb) in __skb_dequeue_tail()
2057 __skb_unlink(skb, list); in __skb_dequeue_tail()
2058 return skb; in __skb_dequeue_tail()
2063 static inline bool skb_is_nonlinear(const struct sk_buff *skb) in skb_is_nonlinear() argument
2065 return skb->data_len; in skb_is_nonlinear()
2068 static inline unsigned int skb_headlen(const struct sk_buff *skb) in skb_headlen() argument
2070 return skb->len - skb->data_len; in skb_headlen()
2073 static inline unsigned int __skb_pagelen(const struct sk_buff *skb) in __skb_pagelen() argument
2077 for (i = skb_shinfo(skb)->nr_frags - 1; (int)i >= 0; i--) in __skb_pagelen()
2078 len += skb_frag_size(&skb_shinfo(skb)->frags[i]); in __skb_pagelen()
2082 static inline unsigned int skb_pagelen(const struct sk_buff *skb) in skb_pagelen() argument
2084 return skb_headlen(skb) + __skb_pagelen(skb); in skb_pagelen()
2100 static inline void __skb_fill_page_desc(struct sk_buff *skb, int i, in __skb_fill_page_desc() argument
2103 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in __skb_fill_page_desc()
2116 skb->pfmemalloc = true; in __skb_fill_page_desc()
2133 static inline void skb_fill_page_desc(struct sk_buff *skb, int i, in skb_fill_page_desc() argument
2136 __skb_fill_page_desc(skb, i, page, off, size); in skb_fill_page_desc()
2137 skb_shinfo(skb)->nr_frags = i + 1; in skb_fill_page_desc()
2140 void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
2143 void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size,
2146 #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) argument
2149 static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) in skb_tail_pointer() argument
2151 return skb->head + skb->tail; in skb_tail_pointer()
2154 static inline void skb_reset_tail_pointer(struct sk_buff *skb) in skb_reset_tail_pointer() argument
2156 skb->tail = skb->data - skb->head; in skb_reset_tail_pointer()
2159 static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset) in skb_set_tail_pointer() argument
2161 skb_reset_tail_pointer(skb); in skb_set_tail_pointer()
2162 skb->tail += offset; in skb_set_tail_pointer()
2166 static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) in skb_tail_pointer() argument
2168 return skb->tail; in skb_tail_pointer()
2171 static inline void skb_reset_tail_pointer(struct sk_buff *skb) in skb_reset_tail_pointer() argument
2173 skb->tail = skb->data; in skb_reset_tail_pointer()
2176 static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset) in skb_set_tail_pointer() argument
2178 skb->tail = skb->data + offset; in skb_set_tail_pointer()
2186 void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
2187 void *skb_put(struct sk_buff *skb, unsigned int len);
2188 static inline void *__skb_put(struct sk_buff *skb, unsigned int len) in __skb_put() argument
2190 void *tmp = skb_tail_pointer(skb); in __skb_put()
2191 SKB_LINEAR_ASSERT(skb); in __skb_put()
2192 skb->tail += len; in __skb_put()
2193 skb->len += len; in __skb_put()
2197 static inline void *__skb_put_zero(struct sk_buff *skb, unsigned int len) in __skb_put_zero() argument
2199 void *tmp = __skb_put(skb, len); in __skb_put_zero()
2205 static inline void *__skb_put_data(struct sk_buff *skb, const void *data, in __skb_put_data() argument
2208 void *tmp = __skb_put(skb, len); in __skb_put_data()
2214 static inline void __skb_put_u8(struct sk_buff *skb, u8 val) in __skb_put_u8() argument
2216 *(u8 *)__skb_put(skb, 1) = val; in __skb_put_u8()
2219 static inline void *skb_put_zero(struct sk_buff *skb, unsigned int len) in skb_put_zero() argument
2221 void *tmp = skb_put(skb, len); in skb_put_zero()
2228 static inline void *skb_put_data(struct sk_buff *skb, const void *data, in skb_put_data() argument
2231 void *tmp = skb_put(skb, len); in skb_put_data()
2238 static inline void skb_put_u8(struct sk_buff *skb, u8 val) in skb_put_u8() argument
2240 *(u8 *)skb_put(skb, 1) = val; in skb_put_u8()
2243 void *skb_push(struct sk_buff *skb, unsigned int len);
2244 static inline void *__skb_push(struct sk_buff *skb, unsigned int len) in __skb_push() argument
2246 skb->data -= len; in __skb_push()
2247 skb->len += len; in __skb_push()
2248 return skb->data; in __skb_push()
2251 void *skb_pull(struct sk_buff *skb, unsigned int len);
2252 static inline void *__skb_pull(struct sk_buff *skb, unsigned int len) in __skb_pull() argument
2254 skb->len -= len; in __skb_pull()
2255 BUG_ON(skb->len < skb->data_len); in __skb_pull()
2256 return skb->data += len; in __skb_pull()
2259 static inline void *skb_pull_inline(struct sk_buff *skb, unsigned int len) in skb_pull_inline() argument
2261 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); in skb_pull_inline()
2264 void *__pskb_pull_tail(struct sk_buff *skb, int delta);
2266 static inline void *__pskb_pull(struct sk_buff *skb, unsigned int len) in __pskb_pull() argument
2268 if (len > skb_headlen(skb) && in __pskb_pull()
2269 !__pskb_pull_tail(skb, len - skb_headlen(skb))) in __pskb_pull()
2271 skb->len -= len; in __pskb_pull()
2272 return skb->data += len; in __pskb_pull()
2275 static inline void *pskb_pull(struct sk_buff *skb, unsigned int len) in pskb_pull() argument
2277 return unlikely(len > skb->len) ? NULL : __pskb_pull(skb, len); in pskb_pull()
2280 static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len) in pskb_may_pull() argument
2282 if (likely(len <= skb_headlen(skb))) in pskb_may_pull()
2284 if (unlikely(len > skb->len)) in pskb_may_pull()
2286 return __pskb_pull_tail(skb, len - skb_headlen(skb)) != NULL; in pskb_may_pull()
2289 void skb_condense(struct sk_buff *skb);
2297 static inline unsigned int skb_headroom(const struct sk_buff *skb) in skb_headroom() argument
2299 return skb->data - skb->head; in skb_headroom()
2308 static inline int skb_tailroom(const struct sk_buff *skb) in skb_tailroom() argument
2310 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail; in skb_tailroom()
2320 static inline int skb_availroom(const struct sk_buff *skb) in skb_availroom() argument
2322 if (skb_is_nonlinear(skb)) in skb_availroom()
2325 return skb->end - skb->tail - skb->reserved_tailroom; in skb_availroom()
2336 static inline void skb_reserve(struct sk_buff *skb, int len) in skb_reserve() argument
2338 skb->data += len; in skb_reserve()
2339 skb->tail += len; in skb_reserve()
2354 static inline void skb_tailroom_reserve(struct sk_buff *skb, unsigned int mtu, in skb_tailroom_reserve() argument
2357 SKB_LINEAR_ASSERT(skb); in skb_tailroom_reserve()
2358 if (mtu < skb_tailroom(skb) - needed_tailroom) in skb_tailroom_reserve()
2360 skb->reserved_tailroom = skb_tailroom(skb) - mtu; in skb_tailroom_reserve()
2363 skb->reserved_tailroom = needed_tailroom; in skb_tailroom_reserve()
2369 static inline void skb_set_inner_protocol(struct sk_buff *skb, in skb_set_inner_protocol() argument
2372 skb->inner_protocol = protocol; in skb_set_inner_protocol()
2373 skb->inner_protocol_type = ENCAP_TYPE_ETHER; in skb_set_inner_protocol()
2376 static inline void skb_set_inner_ipproto(struct sk_buff *skb, in skb_set_inner_ipproto() argument
2379 skb->inner_ipproto = ipproto; in skb_set_inner_ipproto()
2380 skb->inner_protocol_type = ENCAP_TYPE_IPPROTO; in skb_set_inner_ipproto()
2383 static inline void skb_reset_inner_headers(struct sk_buff *skb) in skb_reset_inner_headers() argument
2385 skb->inner_mac_header = skb->mac_header; in skb_reset_inner_headers()
2386 skb->inner_network_header = skb->network_header; in skb_reset_inner_headers()
2387 skb->inner_transport_header = skb->transport_header; in skb_reset_inner_headers()
2390 static inline void skb_reset_mac_len(struct sk_buff *skb) in skb_reset_mac_len() argument
2392 skb->mac_len = skb->network_header - skb->mac_header; in skb_reset_mac_len()
2396 *skb) in skb_inner_transport_header()
2398 return skb->head + skb->inner_transport_header; in skb_inner_transport_header()
2401 static inline int skb_inner_transport_offset(const struct sk_buff *skb) in skb_inner_transport_offset() argument
2403 return skb_inner_transport_header(skb) - skb->data; in skb_inner_transport_offset()
2406 static inline void skb_reset_inner_transport_header(struct sk_buff *skb) in skb_reset_inner_transport_header() argument
2408 skb->inner_transport_header = skb->data - skb->head; in skb_reset_inner_transport_header()
2411 static inline void skb_set_inner_transport_header(struct sk_buff *skb, in skb_set_inner_transport_header() argument
2414 skb_reset_inner_transport_header(skb); in skb_set_inner_transport_header()
2415 skb->inner_transport_header += offset; in skb_set_inner_transport_header()
2418 static inline unsigned char *skb_inner_network_header(const struct sk_buff *skb) in skb_inner_network_header() argument
2420 return skb->head + skb->inner_network_header; in skb_inner_network_header()
2423 static inline void skb_reset_inner_network_header(struct sk_buff *skb) in skb_reset_inner_network_header() argument
2425 skb->inner_network_header = skb->data - skb->head; in skb_reset_inner_network_header()
2428 static inline void skb_set_inner_network_header(struct sk_buff *skb, in skb_set_inner_network_header() argument
2431 skb_reset_inner_network_header(skb); in skb_set_inner_network_header()
2432 skb->inner_network_header += offset; in skb_set_inner_network_header()
2435 static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb) in skb_inner_mac_header() argument
2437 return skb->head + skb->inner_mac_header; in skb_inner_mac_header()
2440 static inline void skb_reset_inner_mac_header(struct sk_buff *skb) in skb_reset_inner_mac_header() argument
2442 skb->inner_mac_header = skb->data - skb->head; in skb_reset_inner_mac_header()
2445 static inline void skb_set_inner_mac_header(struct sk_buff *skb, in skb_set_inner_mac_header() argument
2448 skb_reset_inner_mac_header(skb); in skb_set_inner_mac_header()
2449 skb->inner_mac_header += offset; in skb_set_inner_mac_header()
2451 static inline bool skb_transport_header_was_set(const struct sk_buff *skb) in skb_transport_header_was_set() argument
2453 return skb->transport_header != (typeof(skb->transport_header))~0U; in skb_transport_header_was_set()
2456 static inline unsigned char *skb_transport_header(const struct sk_buff *skb) in skb_transport_header() argument
2458 return skb->head + skb->transport_header; in skb_transport_header()
2461 static inline void skb_reset_transport_header(struct sk_buff *skb) in skb_reset_transport_header() argument
2463 skb->transport_header = skb->data - skb->head; in skb_reset_transport_header()
2466 static inline void skb_set_transport_header(struct sk_buff *skb, in skb_set_transport_header() argument
2469 skb_reset_transport_header(skb); in skb_set_transport_header()
2470 skb->transport_header += offset; in skb_set_transport_header()
2473 static inline unsigned char *skb_network_header(const struct sk_buff *skb) in skb_network_header() argument
2475 return skb->head + skb->network_header; in skb_network_header()
2478 static inline void skb_reset_network_header(struct sk_buff *skb) in skb_reset_network_header() argument
2480 skb->network_header = skb->data - skb->head; in skb_reset_network_header()
2483 static inline void skb_set_network_header(struct sk_buff *skb, const int offset) in skb_set_network_header() argument
2485 skb_reset_network_header(skb); in skb_set_network_header()
2486 skb->network_header += offset; in skb_set_network_header()
2489 static inline unsigned char *skb_mac_header(const struct sk_buff *skb) in skb_mac_header() argument
2491 return skb->head + skb->mac_header; in skb_mac_header()
2494 static inline int skb_mac_offset(const struct sk_buff *skb) in skb_mac_offset() argument
2496 return skb_mac_header(skb) - skb->data; in skb_mac_offset()
2499 static inline u32 skb_mac_header_len(const struct sk_buff *skb) in skb_mac_header_len() argument
2501 return skb->network_header - skb->mac_header; in skb_mac_header_len()
2504 static inline int skb_mac_header_was_set(const struct sk_buff *skb) in skb_mac_header_was_set() argument
2506 return skb->mac_header != (typeof(skb->mac_header))~0U; in skb_mac_header_was_set()
2509 static inline void skb_reset_mac_header(struct sk_buff *skb) in skb_reset_mac_header() argument
2511 skb->mac_header = skb->data - skb->head; in skb_reset_mac_header()
2514 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset) in skb_set_mac_header() argument
2516 skb_reset_mac_header(skb); in skb_set_mac_header()
2517 skb->mac_header += offset; in skb_set_mac_header()
2520 static inline void skb_pop_mac_header(struct sk_buff *skb) in skb_pop_mac_header() argument
2522 skb->mac_header = skb->network_header; in skb_pop_mac_header()
2525 static inline void skb_probe_transport_header(struct sk_buff *skb) in skb_probe_transport_header() argument
2529 if (skb_transport_header_was_set(skb)) in skb_probe_transport_header()
2532 if (skb_flow_dissect_flow_keys_basic(NULL, skb, &keys, in skb_probe_transport_header()
2534 skb_set_transport_header(skb, keys.control.thoff); in skb_probe_transport_header()
2537 static inline void skb_mac_header_rebuild(struct sk_buff *skb) in skb_mac_header_rebuild() argument
2539 if (skb_mac_header_was_set(skb)) { in skb_mac_header_rebuild()
2540 const unsigned char *old_mac = skb_mac_header(skb); in skb_mac_header_rebuild()
2542 skb_set_mac_header(skb, -skb->mac_len); in skb_mac_header_rebuild()
2543 memmove(skb_mac_header(skb), old_mac, skb->mac_len); in skb_mac_header_rebuild()
2547 static inline int skb_checksum_start_offset(const struct sk_buff *skb) in skb_checksum_start_offset() argument
2549 return skb->csum_start - skb_headroom(skb); in skb_checksum_start_offset()
2552 static inline unsigned char *skb_checksum_start(const struct sk_buff *skb) in skb_checksum_start() argument
2554 return skb->head + skb->csum_start; in skb_checksum_start()
2557 static inline int skb_transport_offset(const struct sk_buff *skb) in skb_transport_offset() argument
2559 return skb_transport_header(skb) - skb->data; in skb_transport_offset()
2562 static inline u32 skb_network_header_len(const struct sk_buff *skb) in skb_network_header_len() argument
2564 return skb->transport_header - skb->network_header; in skb_network_header_len()
2567 static inline u32 skb_inner_network_header_len(const struct sk_buff *skb) in skb_inner_network_header_len() argument
2569 return skb->inner_transport_header - skb->inner_network_header; in skb_inner_network_header_len()
2572 static inline int skb_network_offset(const struct sk_buff *skb) in skb_network_offset() argument
2574 return skb_network_header(skb) - skb->data; in skb_network_offset()
2577 static inline int skb_inner_network_offset(const struct sk_buff *skb) in skb_inner_network_offset() argument
2579 return skb_inner_network_header(skb) - skb->data; in skb_inner_network_offset()
2582 static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len) in pskb_network_may_pull() argument
2584 return pskb_may_pull(skb, skb_network_offset(skb) + len); in pskb_network_may_pull()
2635 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
2637 static inline void __skb_set_length(struct sk_buff *skb, unsigned int len) in __skb_set_length() argument
2639 if (WARN_ON(skb_is_nonlinear(skb))) in __skb_set_length()
2641 skb->len = len; in __skb_set_length()
2642 skb_set_tail_pointer(skb, len); in __skb_set_length()
2645 static inline void __skb_trim(struct sk_buff *skb, unsigned int len) in __skb_trim() argument
2647 __skb_set_length(skb, len); in __skb_trim()
2650 void skb_trim(struct sk_buff *skb, unsigned int len);
2652 static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) in __pskb_trim() argument
2654 if (skb->data_len) in __pskb_trim()
2655 return ___pskb_trim(skb, len); in __pskb_trim()
2656 __skb_trim(skb, len); in __pskb_trim()
2660 static inline int pskb_trim(struct sk_buff *skb, unsigned int len) in pskb_trim() argument
2662 return (len < skb->len) ? __pskb_trim(skb, len) : 0; in pskb_trim()
2674 static inline void pskb_trim_unique(struct sk_buff *skb, unsigned int len) in pskb_trim_unique() argument
2676 int err = pskb_trim(skb, len); in pskb_trim_unique()
2680 static inline int __skb_grow(struct sk_buff *skb, unsigned int len) in __skb_grow() argument
2682 unsigned int diff = len - skb->len; in __skb_grow()
2684 if (skb_tailroom(skb) < diff) { in __skb_grow()
2685 int ret = pskb_expand_head(skb, 0, diff - skb_tailroom(skb), in __skb_grow()
2690 __skb_set_length(skb, len); in __skb_grow()
2702 static inline void skb_orphan(struct sk_buff *skb) in skb_orphan() argument
2704 if (skb->destructor) { in skb_orphan()
2705 skb->destructor(skb); in skb_orphan()
2706 skb->destructor = NULL; in skb_orphan()
2707 skb->sk = NULL; in skb_orphan()
2709 BUG_ON(skb->sk); in skb_orphan()
2722 static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask) in skb_orphan_frags() argument
2724 if (likely(!skb_zcopy(skb))) in skb_orphan_frags()
2726 if (!skb_zcopy_is_nouarg(skb) && in skb_orphan_frags()
2727 skb_uarg(skb)->callback == sock_zerocopy_callback) in skb_orphan_frags()
2729 return skb_copy_ubufs(skb, gfp_mask); in skb_orphan_frags()
2733 static inline int skb_orphan_frags_rx(struct sk_buff *skb, gfp_t gfp_mask) in skb_orphan_frags_rx() argument
2735 if (likely(!skb_zcopy(skb))) in skb_orphan_frags_rx()
2737 return skb_copy_ubufs(skb, gfp_mask); in skb_orphan_frags_rx()
2750 struct sk_buff *skb; in __skb_queue_purge() local
2751 while ((skb = __skb_dequeue(list)) != NULL) in __skb_queue_purge()
2752 kfree_skb(skb); in __skb_queue_purge()
2799 struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp); in __netdev_alloc_skb_ip_align() local
2801 if (NET_IP_ALIGN && skb) in __netdev_alloc_skb_ip_align()
2802 skb_reserve(skb, NET_IP_ALIGN); in __netdev_alloc_skb_ip_align()
2803 return skb; in __netdev_alloc_skb_ip_align()
2825 void napi_consume_skb(struct sk_buff *skb, int budget);
2828 void __kfree_skb_defer(struct sk_buff *skb);
2884 struct sk_buff *skb) in skb_propagate_pfmemalloc() argument
2887 skb->pfmemalloc = true; in skb_propagate_pfmemalloc()
2959 static inline void skb_frag_ref(struct sk_buff *skb, int f) in skb_frag_ref() argument
2961 __skb_frag_ref(&skb_shinfo(skb)->frags[f]); in skb_frag_ref()
2982 static inline void skb_frag_unref(struct sk_buff *skb, int f) in skb_frag_unref() argument
2984 __skb_frag_unref(&skb_shinfo(skb)->frags[f]); in skb_frag_unref()
3046 static inline void skb_frag_set_page(struct sk_buff *skb, int f, in skb_frag_set_page() argument
3049 __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page); in skb_frag_set_page()
3074 static inline struct sk_buff *pskb_copy(struct sk_buff *skb, in pskb_copy() argument
3077 return __pskb_copy(skb, skb_headroom(skb), gfp_mask); in pskb_copy()
3081 static inline struct sk_buff *pskb_copy_for_clone(struct sk_buff *skb, in pskb_copy_for_clone() argument
3084 return __pskb_copy_fclone(skb, skb_headroom(skb), gfp_mask, true); in pskb_copy_for_clone()
3096 static inline int skb_clone_writable(const struct sk_buff *skb, unsigned int len) in skb_clone_writable() argument
3098 return !skb_header_cloned(skb) && in skb_clone_writable()
3099 skb_headroom(skb) + len <= skb->hdr_len; in skb_clone_writable()
3102 static inline int skb_try_make_writable(struct sk_buff *skb, in skb_try_make_writable() argument
3105 return skb_cloned(skb) && !skb_clone_writable(skb, write_len) && in skb_try_make_writable()
3106 pskb_expand_head(skb, 0, 0, GFP_ATOMIC); in skb_try_make_writable()
3109 static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom, in __skb_cow() argument
3114 if (headroom > skb_headroom(skb)) in __skb_cow()
3115 delta = headroom - skb_headroom(skb); in __skb_cow()
3118 return pskb_expand_head(skb, ALIGN(delta, NET_SKB_PAD), 0, in __skb_cow()
3135 static inline int skb_cow(struct sk_buff *skb, unsigned int headroom) in skb_cow() argument
3137 return __skb_cow(skb, headroom, skb_cloned(skb)); in skb_cow()
3150 static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom) in skb_cow_head() argument
3152 return __skb_cow(skb, headroom, skb_header_cloned(skb)); in skb_cow_head()
3165 static inline int skb_padto(struct sk_buff *skb, unsigned int len) in skb_padto() argument
3167 unsigned int size = skb->len; in skb_padto()
3170 return skb_pad(skb, len - size); in skb_padto()
3184 static inline int __skb_put_padto(struct sk_buff *skb, unsigned int len, in __skb_put_padto() argument
3187 unsigned int size = skb->len; in __skb_put_padto()
3191 if (__skb_pad(skb, len, free_on_error)) in __skb_put_padto()
3193 __skb_put(skb, len); in __skb_put_padto()
3208 static inline int skb_put_padto(struct sk_buff *skb, unsigned int len) in skb_put_padto() argument
3210 return __skb_put_padto(skb, len, true); in skb_put_padto()
3213 static inline int skb_add_data(struct sk_buff *skb, in skb_add_data() argument
3216 const int off = skb->len; in skb_add_data()
3218 if (skb->ip_summed == CHECKSUM_NONE) { in skb_add_data()
3220 if (csum_and_copy_from_iter_full(skb_put(skb, copy), copy, in skb_add_data()
3222 skb->csum = csum_block_add(skb->csum, csum, off); in skb_add_data()
3225 } else if (copy_from_iter_full(skb_put(skb, copy), copy, from)) in skb_add_data()
3228 __skb_trim(skb, off); in skb_add_data()
3232 static inline bool skb_can_coalesce(struct sk_buff *skb, int i, in skb_can_coalesce() argument
3235 if (skb_zcopy(skb)) in skb_can_coalesce()
3238 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; in skb_can_coalesce()
3246 static inline int __skb_linearize(struct sk_buff *skb) in __skb_linearize() argument
3248 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM; in __skb_linearize()
3258 static inline int skb_linearize(struct sk_buff *skb) in skb_linearize() argument
3260 return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0; in skb_linearize()
3270 static inline bool skb_has_shared_frag(const struct sk_buff *skb) in skb_has_shared_frag() argument
3272 return skb_is_nonlinear(skb) && in skb_has_shared_frag()
3273 skb_shinfo(skb)->tx_flags & SKBTX_SHARED_FRAG; in skb_has_shared_frag()
3283 static inline int skb_linearize_cow(struct sk_buff *skb) in skb_linearize_cow() argument
3285 return skb_is_nonlinear(skb) || skb_cloned(skb) ? in skb_linearize_cow()
3286 __skb_linearize(skb) : 0; in skb_linearize_cow()
3290 __skb_postpull_rcsum(struct sk_buff *skb, const void *start, unsigned int len, in __skb_postpull_rcsum() argument
3293 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpull_rcsum()
3294 skb->csum = csum_block_sub(skb->csum, in __skb_postpull_rcsum()
3296 else if (skb->ip_summed == CHECKSUM_PARTIAL && in __skb_postpull_rcsum()
3297 skb_checksum_start_offset(skb) < 0) in __skb_postpull_rcsum()
3298 skb->ip_summed = CHECKSUM_NONE; in __skb_postpull_rcsum()
3311 static inline void skb_postpull_rcsum(struct sk_buff *skb, in skb_postpull_rcsum() argument
3314 __skb_postpull_rcsum(skb, start, len, 0); in skb_postpull_rcsum()
3318 __skb_postpush_rcsum(struct sk_buff *skb, const void *start, unsigned int len, in __skb_postpush_rcsum() argument
3321 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpush_rcsum()
3322 skb->csum = csum_block_add(skb->csum, in __skb_postpush_rcsum()
3335 static inline void skb_postpush_rcsum(struct sk_buff *skb, in skb_postpush_rcsum() argument
3338 __skb_postpush_rcsum(skb, start, len, 0); in skb_postpush_rcsum()
3341 void *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
3354 static inline void *skb_push_rcsum(struct sk_buff *skb, unsigned int len) in skb_push_rcsum() argument
3356 skb_push(skb, len); in skb_push_rcsum()
3357 skb_postpush_rcsum(skb, skb->data, len); in skb_push_rcsum()
3358 return skb->data; in skb_push_rcsum()
3361 int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len);
3372 static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len) in pskb_trim_rcsum() argument
3374 if (likely(len >= skb->len)) in pskb_trim_rcsum()
3376 return pskb_trim_rcsum_slow(skb, len); in pskb_trim_rcsum()
3379 static inline int __skb_trim_rcsum(struct sk_buff *skb, unsigned int len) in __skb_trim_rcsum() argument
3381 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_trim_rcsum()
3382 skb->ip_summed = CHECKSUM_NONE; in __skb_trim_rcsum()
3383 __skb_trim(skb, len); in __skb_trim_rcsum()
3387 static inline int __skb_grow_rcsum(struct sk_buff *skb, unsigned int len) in __skb_grow_rcsum() argument
3389 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_grow_rcsum()
3390 skb->ip_summed = CHECKSUM_NONE; in __skb_grow_rcsum()
3391 return __skb_grow(skb, len); in __skb_grow_rcsum()
3397 #define skb_rb_next(skb) rb_to_skb(rb_next(&(skb)->rbnode)) argument
3398 #define skb_rb_prev(skb) rb_to_skb(rb_prev(&(skb)->rbnode)) argument
3400 #define skb_queue_walk(queue, skb) \ argument
3401 for (skb = (queue)->next; \
3402 skb != (struct sk_buff *)(queue); \
3403 skb = skb->next)
3405 #define skb_queue_walk_safe(queue, skb, tmp) \ argument
3406 for (skb = (queue)->next, tmp = skb->next; \
3407 skb != (struct sk_buff *)(queue); \
3408 skb = tmp, tmp = skb->next)
3410 #define skb_queue_walk_from(queue, skb) \ argument
3411 for (; skb != (struct sk_buff *)(queue); \
3412 skb = skb->next)
3414 #define skb_rbtree_walk(skb, root) \ argument
3415 for (skb = skb_rb_first(root); skb != NULL; \
3416 skb = skb_rb_next(skb))
3418 #define skb_rbtree_walk_from(skb) \ argument
3419 for (; skb != NULL; \
3420 skb = skb_rb_next(skb))
3422 #define skb_rbtree_walk_from_safe(skb, tmp) \ argument
3423 for (; tmp = skb ? skb_rb_next(skb) : NULL, (skb != NULL); \
3424 skb = tmp)
3426 #define skb_queue_walk_from_safe(queue, skb, tmp) \ argument
3427 for (tmp = skb->next; \
3428 skb != (struct sk_buff *)(queue); \
3429 skb = tmp, tmp = skb->next)
3431 #define skb_queue_reverse_walk(queue, skb) \ argument
3432 for (skb = (queue)->prev; \
3433 skb != (struct sk_buff *)(queue); \
3434 skb = skb->prev)
3436 #define skb_queue_reverse_walk_safe(queue, skb, tmp) \ argument
3437 for (skb = (queue)->prev, tmp = skb->prev; \
3438 skb != (struct sk_buff *)(queue); \
3439 skb = tmp, tmp = skb->prev)
3441 #define skb_queue_reverse_walk_from_safe(queue, skb, tmp) \ argument
3442 for (tmp = skb->prev; \
3443 skb != (struct sk_buff *)(queue); \
3444 skb = tmp, tmp = skb->prev)
3446 static inline bool skb_has_frag_list(const struct sk_buff *skb) in skb_has_frag_list() argument
3448 return skb_shinfo(skb)->frag_list != NULL; in skb_has_frag_list()
3451 static inline void skb_frag_list_init(struct sk_buff *skb) in skb_frag_list_init() argument
3453 skb_shinfo(skb)->frag_list = NULL; in skb_frag_list_init()
3456 #define skb_walk_frags(skb, iter) \ argument
3457 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
3461 const struct sk_buff *skb);
3466 struct sk_buff *skb),
3471 struct sk_buff *skb),
3476 struct sk_buff *skb),
3489 int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, int hlen,
3491 int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset,
3494 int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
3496 int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *frm);
3497 void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
3498 void __skb_free_datagram_locked(struct sock *sk, struct sk_buff *skb, int len);
3500 struct sk_buff *skb) in skb_free_datagram_locked() argument
3502 __skb_free_datagram_locked(sk, skb, 0); in skb_free_datagram_locked()
3504 int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags);
3505 int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len);
3506 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
3507 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
3509 int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
3512 int skb_send_sock_locked(struct sock *sk, struct sk_buff *skb, int offset,
3514 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
3518 void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len);
3519 int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen);
3520 void skb_scrub_packet(struct sk_buff *skb, bool xnet);
3521 bool skb_gso_validate_network_len(const struct sk_buff *skb, unsigned int mtu);
3522 bool skb_gso_validate_mac_len(const struct sk_buff *skb, unsigned int len);
3523 struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
3524 struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
3525 int skb_ensure_writable(struct sk_buff *skb, int write_len);
3526 int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci);
3527 int skb_vlan_pop(struct sk_buff *skb);
3528 int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
3529 int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
3531 int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len);
3532 int skb_mpls_update_lse(struct sk_buff *skb, __be32 mpls_lse);
3533 int skb_mpls_dec_ttl(struct sk_buff *skb);
3534 struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,
3554 __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
3556 __wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
3560 __skb_header_pointer(const struct sk_buff *skb, int offset, in __skb_header_pointer() argument
3566 if (!skb || in __skb_header_pointer()
3567 skb_copy_bits(skb, offset, buffer, len) < 0) in __skb_header_pointer()
3574 skb_header_pointer(const struct sk_buff *skb, int offset, int len, void *buffer) in skb_header_pointer() argument
3576 return __skb_header_pointer(skb, offset, len, skb->data, in skb_header_pointer()
3577 skb_headlen(skb), buffer); in skb_header_pointer()
3590 static inline bool skb_needs_linearize(struct sk_buff *skb, in skb_needs_linearize() argument
3593 return skb_is_nonlinear(skb) && in skb_needs_linearize()
3594 ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) || in skb_needs_linearize()
3595 (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG))); in skb_needs_linearize()
3598 static inline void skb_copy_from_linear_data(const struct sk_buff *skb, in skb_copy_from_linear_data() argument
3602 memcpy(to, skb->data, len); in skb_copy_from_linear_data()
3605 static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb, in skb_copy_from_linear_data_offset() argument
3609 memcpy(to, skb->data + offset, len); in skb_copy_from_linear_data_offset()
3612 static inline void skb_copy_to_linear_data(struct sk_buff *skb, in skb_copy_to_linear_data() argument
3616 memcpy(skb->data, from, len); in skb_copy_to_linear_data()
3619 static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb, in skb_copy_to_linear_data_offset() argument
3624 memcpy(skb->data + offset, from, len); in skb_copy_to_linear_data_offset()
3629 static inline ktime_t skb_get_ktime(const struct sk_buff *skb) in skb_get_ktime() argument
3631 return skb->tstamp; in skb_get_ktime()
3643 static inline void skb_get_timestamp(const struct sk_buff *skb, in skb_get_timestamp() argument
3646 *stamp = ns_to_kernel_old_timeval(skb->tstamp); in skb_get_timestamp()
3649 static inline void skb_get_new_timestamp(const struct sk_buff *skb, in skb_get_new_timestamp() argument
3652 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestamp()
3658 static inline void skb_get_timestampns(const struct sk_buff *skb, in skb_get_timestampns() argument
3661 *stamp = ktime_to_timespec(skb->tstamp); in skb_get_timestampns()
3664 static inline void skb_get_new_timestampns(const struct sk_buff *skb, in skb_get_new_timestampns() argument
3667 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestampns()
3673 static inline void __net_timestamp(struct sk_buff *skb) in __net_timestamp() argument
3675 skb->tstamp = ktime_get_real(); in __net_timestamp()
3688 static inline u8 skb_metadata_len(const struct sk_buff *skb) in skb_metadata_len() argument
3690 return skb_shinfo(skb)->meta_len; in skb_metadata_len()
3693 static inline void *skb_metadata_end(const struct sk_buff *skb) in skb_metadata_end() argument
3695 return skb_mac_header(skb); in skb_metadata_end()
3747 static inline void skb_metadata_set(struct sk_buff *skb, u8 meta_len) in skb_metadata_set() argument
3749 skb_shinfo(skb)->meta_len = meta_len; in skb_metadata_set()
3752 static inline void skb_metadata_clear(struct sk_buff *skb) in skb_metadata_clear() argument
3754 skb_metadata_set(skb, 0); in skb_metadata_clear()
3757 struct sk_buff *skb_clone_sk(struct sk_buff *skb);
3761 void skb_clone_tx_timestamp(struct sk_buff *skb);
3762 bool skb_defer_rx_timestamp(struct sk_buff *skb);
3766 static inline void skb_clone_tx_timestamp(struct sk_buff *skb) in skb_clone_tx_timestamp() argument
3770 static inline bool skb_defer_rx_timestamp(struct sk_buff *skb) in skb_defer_rx_timestamp() argument
3789 void skb_complete_tx_timestamp(struct sk_buff *skb,
3822 static inline void skb_tx_timestamp(struct sk_buff *skb) in skb_tx_timestamp() argument
3824 skb_clone_tx_timestamp(skb); in skb_tx_timestamp()
3825 if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP) in skb_tx_timestamp()
3826 skb_tstamp_tx(skb, NULL); in skb_tx_timestamp()
3836 void skb_complete_wifi_ack(struct sk_buff *skb, bool acked);
3838 __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
3839 __sum16 __skb_checksum_complete(struct sk_buff *skb);
3841 static inline int skb_csum_unnecessary(const struct sk_buff *skb) in skb_csum_unnecessary() argument
3843 return ((skb->ip_summed == CHECKSUM_UNNECESSARY) || in skb_csum_unnecessary()
3844 skb->csum_valid || in skb_csum_unnecessary()
3845 (skb->ip_summed == CHECKSUM_PARTIAL && in skb_csum_unnecessary()
3846 skb_checksum_start_offset(skb) >= 0)); in skb_csum_unnecessary()
3865 static inline __sum16 skb_checksum_complete(struct sk_buff *skb) in skb_checksum_complete() argument
3867 return skb_csum_unnecessary(skb) ? in skb_checksum_complete()
3868 0 : __skb_checksum_complete(skb); in skb_checksum_complete()
3871 static inline void __skb_decr_checksum_unnecessary(struct sk_buff *skb) in __skb_decr_checksum_unnecessary() argument
3873 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_decr_checksum_unnecessary()
3874 if (skb->csum_level == 0) in __skb_decr_checksum_unnecessary()
3875 skb->ip_summed = CHECKSUM_NONE; in __skb_decr_checksum_unnecessary()
3877 skb->csum_level--; in __skb_decr_checksum_unnecessary()
3881 static inline void __skb_incr_checksum_unnecessary(struct sk_buff *skb) in __skb_incr_checksum_unnecessary() argument
3883 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_incr_checksum_unnecessary()
3884 if (skb->csum_level < SKB_MAX_CSUM_LEVEL) in __skb_incr_checksum_unnecessary()
3885 skb->csum_level++; in __skb_incr_checksum_unnecessary()
3886 } else if (skb->ip_summed == CHECKSUM_NONE) { in __skb_incr_checksum_unnecessary()
3887 skb->ip_summed = CHECKSUM_UNNECESSARY; in __skb_incr_checksum_unnecessary()
3888 skb->csum_level = 0; in __skb_incr_checksum_unnecessary()
3897 static inline bool __skb_checksum_validate_needed(struct sk_buff *skb, in __skb_checksum_validate_needed() argument
3901 if (skb_csum_unnecessary(skb) || (zero_okay && !check)) { in __skb_checksum_validate_needed()
3902 skb->csum_valid = 1; in __skb_checksum_validate_needed()
3903 __skb_decr_checksum_unnecessary(skb); in __skb_checksum_validate_needed()
3921 static inline void skb_checksum_complete_unset(struct sk_buff *skb) in skb_checksum_complete_unset() argument
3923 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_checksum_complete_unset()
3924 skb->ip_summed = CHECKSUM_NONE; in skb_checksum_complete_unset()
3936 static inline __sum16 __skb_checksum_validate_complete(struct sk_buff *skb, in __skb_checksum_validate_complete() argument
3940 if (skb->ip_summed == CHECKSUM_COMPLETE) { in __skb_checksum_validate_complete()
3941 if (!csum_fold(csum_add(psum, skb->csum))) { in __skb_checksum_validate_complete()
3942 skb->csum_valid = 1; in __skb_checksum_validate_complete()
3947 skb->csum = psum; in __skb_checksum_validate_complete()
3949 if (complete || skb->len <= CHECKSUM_BREAK) { in __skb_checksum_validate_complete()
3952 csum = __skb_checksum_complete(skb); in __skb_checksum_validate_complete()
3953 skb->csum_valid = !csum; in __skb_checksum_validate_complete()
3960 static inline __wsum null_compute_pseudo(struct sk_buff *skb, int proto) in null_compute_pseudo() argument
3975 #define __skb_checksum_validate(skb, proto, complete, \ argument
3979 skb->csum_valid = 0; \
3980 if (__skb_checksum_validate_needed(skb, zero_okay, check)) \
3981 __ret = __skb_checksum_validate_complete(skb, \
3982 complete, compute_pseudo(skb, proto)); \
3986 #define skb_checksum_init(skb, proto, compute_pseudo) \ argument
3987 __skb_checksum_validate(skb, proto, false, false, 0, compute_pseudo)
3989 #define skb_checksum_init_zero_check(skb, proto, check, compute_pseudo) \ argument
3990 __skb_checksum_validate(skb, proto, false, true, check, compute_pseudo)
3992 #define skb_checksum_validate(skb, proto, compute_pseudo) \ argument
3993 __skb_checksum_validate(skb, proto, true, false, 0, compute_pseudo)
3995 #define skb_checksum_validate_zero_check(skb, proto, check, \ argument
3997 __skb_checksum_validate(skb, proto, true, true, check, compute_pseudo)
3999 #define skb_checksum_simple_validate(skb) \ argument
4000 __skb_checksum_validate(skb, 0, true, false, 0, null_compute_pseudo)
4002 static inline bool __skb_checksum_convert_check(struct sk_buff *skb) in __skb_checksum_convert_check() argument
4004 return (skb->ip_summed == CHECKSUM_NONE && skb->csum_valid); in __skb_checksum_convert_check()
4007 static inline void __skb_checksum_convert(struct sk_buff *skb, __wsum pseudo) in __skb_checksum_convert() argument
4009 skb->csum = ~pseudo; in __skb_checksum_convert()
4010 skb->ip_summed = CHECKSUM_COMPLETE; in __skb_checksum_convert()
4013 #define skb_checksum_try_convert(skb, proto, compute_pseudo) \ argument
4015 if (__skb_checksum_convert_check(skb)) \
4016 __skb_checksum_convert(skb, compute_pseudo(skb, proto)); \
4019 static inline void skb_remcsum_adjust_partial(struct sk_buff *skb, void *ptr, in skb_remcsum_adjust_partial() argument
4022 skb->ip_summed = CHECKSUM_PARTIAL; in skb_remcsum_adjust_partial()
4023 skb->csum_start = ((unsigned char *)ptr + start) - skb->head; in skb_remcsum_adjust_partial()
4024 skb->csum_offset = offset - start; in skb_remcsum_adjust_partial()
4032 static inline void skb_remcsum_process(struct sk_buff *skb, void *ptr, in skb_remcsum_process() argument
4038 skb_remcsum_adjust_partial(skb, ptr, start, offset); in skb_remcsum_process()
4042 if (unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) { in skb_remcsum_process()
4043 __skb_checksum_complete(skb); in skb_remcsum_process()
4044 skb_postpull_rcsum(skb, skb->data, ptr - (void *)skb->data); in skb_remcsum_process()
4047 delta = remcsum_adjust(ptr, skb->csum, start, offset); in skb_remcsum_process()
4050 skb->csum = csum_add(skb->csum, delta); in skb_remcsum_process()
4053 static inline struct nf_conntrack *skb_nfct(const struct sk_buff *skb) in skb_nfct() argument
4056 return (void *)(skb->_nfct & NFCT_PTRMASK); in skb_nfct()
4062 static inline unsigned long skb_get_nfct(const struct sk_buff *skb) in skb_get_nfct() argument
4065 return skb->_nfct; in skb_get_nfct()
4071 static inline void skb_set_nfct(struct sk_buff *skb, unsigned long nfct) in skb_set_nfct() argument
4074 skb->_nfct = nfct; in skb_set_nfct()
4109 void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id);
4110 void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id);
4113 static inline void skb_ext_put(struct sk_buff *skb) in skb_ext_put() argument
4115 if (skb->active_extensions) in skb_ext_put()
4116 __skb_ext_put(skb->extensions); in skb_ext_put()
4143 static inline bool skb_ext_exist(const struct sk_buff *skb, enum skb_ext_id id) in skb_ext_exist() argument
4145 return skb->active_extensions & (1 << id); in skb_ext_exist()
4148 static inline void skb_ext_del(struct sk_buff *skb, enum skb_ext_id id) in skb_ext_del() argument
4150 if (skb_ext_exist(skb, id)) in skb_ext_del()
4151 __skb_ext_del(skb, id); in skb_ext_del()
4154 static inline void *skb_ext_find(const struct sk_buff *skb, enum skb_ext_id id) in skb_ext_find() argument
4156 if (skb_ext_exist(skb, id)) { in skb_ext_find()
4157 struct skb_ext *ext = skb->extensions; in skb_ext_find()
4165 static inline void skb_ext_reset(struct sk_buff *skb) in skb_ext_reset() argument
4167 if (unlikely(skb->active_extensions)) { in skb_ext_reset()
4168 __skb_ext_put(skb->extensions); in skb_ext_reset()
4169 skb->active_extensions = 0; in skb_ext_reset()
4173 static inline bool skb_has_extensions(struct sk_buff *skb) in skb_has_extensions() argument
4175 return unlikely(skb->active_extensions); in skb_has_extensions()
4178 static inline void skb_ext_put(struct sk_buff *skb) {} in skb_ext_put() argument
4179 static inline void skb_ext_reset(struct sk_buff *skb) {} in skb_ext_reset() argument
4180 static inline void skb_ext_del(struct sk_buff *skb, int unused) {} in skb_ext_del() argument
4183 static inline bool skb_has_extensions(struct sk_buff *skb) { return false; } in skb_has_extensions() argument
4186 static inline void nf_reset_ct(struct sk_buff *skb) in nf_reset_ct() argument
4189 nf_conntrack_put(skb_nfct(skb)); in nf_reset_ct()
4190 skb->_nfct = 0; in nf_reset_ct()
4194 static inline void nf_reset_trace(struct sk_buff *skb) in nf_reset_trace() argument
4197 skb->nf_trace = 0; in nf_reset_trace()
4201 static inline void ipvs_reset(struct sk_buff *skb) in ipvs_reset() argument
4204 skb->ipvs_property = 0; in ipvs_reset()
4236 static inline void skb_init_secmark(struct sk_buff *skb) in skb_init_secmark() argument
4238 skb->secmark = 0; in skb_init_secmark()
4244 static inline void skb_init_secmark(struct sk_buff *skb) in skb_init_secmark() argument
4248 static inline int secpath_exists(const struct sk_buff *skb) in secpath_exists() argument
4251 return skb_ext_exist(skb, SKB_EXT_SEC_PATH); in secpath_exists()
4257 static inline bool skb_irq_freeable(const struct sk_buff *skb) in skb_irq_freeable() argument
4259 return !skb->destructor && in skb_irq_freeable()
4260 !secpath_exists(skb) && in skb_irq_freeable()
4261 !skb_nfct(skb) && in skb_irq_freeable()
4262 !skb->_skb_refdst && in skb_irq_freeable()
4263 !skb_has_frag_list(skb); in skb_irq_freeable()
4266 static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping) in skb_set_queue_mapping() argument
4268 skb->queue_mapping = queue_mapping; in skb_set_queue_mapping()
4271 static inline u16 skb_get_queue_mapping(const struct sk_buff *skb) in skb_get_queue_mapping() argument
4273 return skb->queue_mapping; in skb_get_queue_mapping()
4281 static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue) in skb_record_rx_queue() argument
4283 skb->queue_mapping = rx_queue + 1; in skb_record_rx_queue()
4286 static inline u16 skb_get_rx_queue(const struct sk_buff *skb) in skb_get_rx_queue() argument
4288 return skb->queue_mapping - 1; in skb_get_rx_queue()
4291 static inline bool skb_rx_queue_recorded(const struct sk_buff *skb) in skb_rx_queue_recorded() argument
4293 return skb->queue_mapping != 0; in skb_rx_queue_recorded()
4296 static inline void skb_set_dst_pending_confirm(struct sk_buff *skb, u32 val) in skb_set_dst_pending_confirm() argument
4298 skb->dst_pending_confirm = val; in skb_set_dst_pending_confirm()
4301 static inline bool skb_get_dst_pending_confirm(const struct sk_buff *skb) in skb_get_dst_pending_confirm() argument
4303 return skb->dst_pending_confirm != 0; in skb_get_dst_pending_confirm()
4306 static inline struct sec_path *skb_sec_path(const struct sk_buff *skb) in skb_sec_path() argument
4309 return skb_ext_find(skb, SKB_EXT_SEC_PATH); in skb_sec_path()
4331 #define SKB_GSO_CB(skb) ((struct skb_gso_cb *)((skb)->cb + SKB_SGO_CB_OFFSET)) argument
4339 static inline int gso_pskb_expand_head(struct sk_buff *skb, int extra) in gso_pskb_expand_head() argument
4344 headroom = skb_headroom(skb); in gso_pskb_expand_head()
4345 ret = pskb_expand_head(skb, extra, 0, GFP_ATOMIC); in gso_pskb_expand_head()
4349 new_headroom = skb_headroom(skb); in gso_pskb_expand_head()
4350 SKB_GSO_CB(skb)->mac_offset += (new_headroom - headroom); in gso_pskb_expand_head()
4354 static inline void gso_reset_checksum(struct sk_buff *skb, __wsum res) in gso_reset_checksum() argument
4357 if (skb->remcsum_offload) in gso_reset_checksum()
4360 SKB_GSO_CB(skb)->csum = res; in gso_reset_checksum()
4361 SKB_GSO_CB(skb)->csum_start = skb_checksum_start(skb) - skb->head; in gso_reset_checksum()
4372 static inline __sum16 gso_make_checksum(struct sk_buff *skb, __wsum res) in gso_make_checksum() argument
4374 unsigned char *csum_start = skb_transport_header(skb); in gso_make_checksum()
4375 int plen = (skb->head + SKB_GSO_CB(skb)->csum_start) - csum_start; in gso_make_checksum()
4376 __wsum partial = SKB_GSO_CB(skb)->csum; in gso_make_checksum()
4378 SKB_GSO_CB(skb)->csum = res; in gso_make_checksum()
4379 SKB_GSO_CB(skb)->csum_start = csum_start - skb->head; in gso_make_checksum()
4384 static inline bool skb_is_gso(const struct sk_buff *skb) in skb_is_gso() argument
4386 return skb_shinfo(skb)->gso_size; in skb_is_gso()
4390 static inline bool skb_is_gso_v6(const struct sk_buff *skb) in skb_is_gso_v6() argument
4392 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; in skb_is_gso_v6()
4396 static inline bool skb_is_gso_sctp(const struct sk_buff *skb) in skb_is_gso_sctp() argument
4398 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP; in skb_is_gso_sctp()
4402 static inline bool skb_is_gso_tcp(const struct sk_buff *skb) in skb_is_gso_tcp() argument
4404 return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6); in skb_is_gso_tcp()
4407 static inline void skb_gso_reset(struct sk_buff *skb) in skb_gso_reset() argument
4409 skb_shinfo(skb)->gso_size = 0; in skb_gso_reset()
4410 skb_shinfo(skb)->gso_segs = 0; in skb_gso_reset()
4411 skb_shinfo(skb)->gso_type = 0; in skb_gso_reset()
4430 void __skb_warn_lro_forwarding(const struct sk_buff *skb);
4432 static inline bool skb_warn_if_lro(const struct sk_buff *skb) in skb_warn_if_lro() argument
4436 const struct skb_shared_info *shinfo = skb_shinfo(skb); in skb_warn_if_lro()
4438 if (skb_is_nonlinear(skb) && shinfo->gso_size != 0 && in skb_warn_if_lro()
4440 __skb_warn_lro_forwarding(skb); in skb_warn_if_lro()
4446 static inline void skb_forward_csum(struct sk_buff *skb) in skb_forward_csum() argument
4449 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_forward_csum()
4450 skb->ip_summed = CHECKSUM_NONE; in skb_forward_csum()
4461 static inline void skb_checksum_none_assert(const struct sk_buff *skb) in skb_checksum_none_assert() argument
4464 BUG_ON(skb->ip_summed != CHECKSUM_NONE); in skb_checksum_none_assert()
4468 bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
4470 int skb_checksum_setup(struct sk_buff *skb, bool recalculate);
4471 struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
4473 __sum16(*skb_chkf)(struct sk_buff *skb));
4484 static inline bool skb_head_is_locked(const struct sk_buff *skb) in skb_head_is_locked() argument
4486 return !skb->head_frag || skb_cloned(skb); in skb_head_is_locked()
4498 static inline __wsum lco_csum(struct sk_buff *skb) in lco_csum() argument
4500 unsigned char *csum_start = skb_checksum_start(skb); in lco_csum()
4501 unsigned char *l4_hdr = skb_transport_header(skb); in lco_csum()
4506 skb->csum_offset)); in lco_csum()