Lines Matching +full:mmp +full:- +full:timer

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
7 * Florian La Roche, <rzsfl@rz.uni-sb.de>
28 #include <linux/dma-mapping.h>
39 #include <net/dropreason-core.h>
55 * .. flat-table:: Checksum related device features
58 * * - %NETIF_F_HW_CSUM
59 * - The driver (or its device) is able to compute one
65 * * - %NETIF_F_IP_CSUM
66 * - Driver (device) is only able to checksum plain
75 * * - %NETIF_F_IPV6_CSUM
76 * - Driver (device) is only able to checksum plain
86 * * - %NETIF_F_RXCSUM
87 * - Driver (device) performs receive checksum offload.
99 * - %CHECKSUM_NONE
103 * not in skb->csum. Thus, skb->csum is undefined in this case.
105 * - %CHECKSUM_UNNECESSARY
116 * - TCP: IPv6 and IPv4.
117 * - UDP: IPv4 and IPv6. A device may apply CHECKSUM_UNNECESSARY to a
120 * - GRE: only if the checksum is present in the header.
121 * - SCTP: indicates the CRC in SCTP header has been validated.
122 * - FCOE: indicates the CRC in FC frame has been validated.
126 * For instance if a device receives an IPv6->UDP->GRE->IPv4->TCP packet
131 * checksum is bad, skb->csum_level would be set to zero (TCP checksum is
134 * - %CHECKSUM_COMPLETE
142 * - Even if device supports only some protocols, but is able to produce
143 * skb->csum, it MUST use CHECKSUM_COMPLETE, not CHECKSUM_UNNECESSARY.
144 * - CHECKSUM_COMPLETE is not applicable to SCTP and FCoE protocols.
146 * - %CHECKSUM_PARTIAL
153 * referred to by skb->csum_start + skb->csum_offset and any preceding
158 * Checksumming on transmit for non-GSO
164 * - %CHECKSUM_PARTIAL
172 * checksum refers to a legitimate transport layer checksum -- it is the
190 * - %CHECKSUM_NONE
195 * - %CHECKSUM_UNNECESSARY
200 * - %CHECKSUM_COMPLETE
207 * Non-IP checksum (CRC) offloads
210 * .. flat-table::
213 * * - %NETIF_F_SCTP_CRC
214 * - This feature indicates that a device is capable of
224 * * - %NETIF_F_FCOE_CRC
225 * - This feature indicates that a device is capable of offloading the FCOE
251 /* Maximum value in skb->csum_level */
256 ((X) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
258 /* For X bytes available in skb->head, what is the minimal
266 SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
300 /* always valid & non-NULL from FORWARD on, for physdev match */
357 /* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
365 * skb_frag_size() - Returns the size of a skb fragment
370 return frag->bv_len; in skb_frag_size()
374 * skb_frag_size_set() - Sets the size of a skb fragment
380 frag->bv_len = size; in skb_frag_size_set()
384 * skb_frag_size_add() - Increments the size of a skb fragment by @delta
390 frag->bv_len += delta; in skb_frag_size_add()
394 * skb_frag_size_sub() - Decrements the size of a skb fragment by @delta
400 frag->bv_len -= delta; in skb_frag_size_sub()
404 * skb_frag_must_loop - Test if %p is a high memory page
417 * skb_frag_foreach_page - loop over pages in a fragment
420 * @f_off: offset from start of f->bv_page
424 * non-zero only on first page.
429 * A fragment can hold a compound page, in which case per-page
435 p_off = (f_off) & (PAGE_SIZE - 1), \
437 min_t(u32, f_len, PAGE_SIZE - p_off) : f_len, \
441 p_len = min_t(u32, f_len - copied, PAGE_SIZE)) \
444 * struct skb_shared_hwtstamps - hardware time stamps
451 * skb->tstamp.
559 } mmp; member
562 #define skb_uarg(SKB) ((struct ubuf_info *)(skb_shinfo(SKB)->destructor_arg))
566 int mm_account_pinned_pages(struct mmpin *mmp, size_t size);
567 void mm_unaccount_pinned_pages(struct mmpin *mmp);
579 * the end of the header data, ie. at skb->end.
618 * The higher 16 bits indicate how many of the references are payload-only.
634 * doing the right thing. In practice there's usually only one payload-only skb.
635 * Having multiple payload-only skbs with different lengths of hdr_len is not
636 * possible. The payload-only skbs should never leave their owner.
639 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
709 * - data buffer, containing headers and sometimes payload;
712 * - shared info (struct skb_shared_info) which holds an array of pointers
713 * to read-only data in the (page, offset, length) format.
719 * ---------------
721 * ---------------
722 * ,--------------------------- + head
723 * / ,----------------- + data
724 * / / ,----------- + tail
728 * -----------------------------------------------
730 * -----------------------------------------------
734 * + [page frag] ---------
735 * + frag_list --> | sk_buff |
736 * ---------
741 * struct sk_buff - socket buffer
746 * for retransmit timer
762 * @csum_start: Offset from skb->head where checksumming should start
775 * @offload_fwd_mark: Packet was L2-forwarded in hardware
776 * @offload_l3_fwd_mark: Packet was L3-forwarded in hardware
781 * @nf_skip_egress: packet shall skip nf egress - see netfilter_netdev.h
787 * @tcp_tsorted_anchor: list structure for TCP (tp->tsorted_sent_queue)
802 * @l4_hash: indicate hash is a canonical 4-tuple hash over transport
819 * @mono_delivery_time: When set, skb->tstamp has the
821 * skb->tstamp has the (rcv) timestamp at ingress and
835 * skb->inner_protocol_type == ENCAP_TYPE_IPPROTO;
848 * @users: User count - see {datagram,tcp}.c
1070 /* only usable after checking ->active_extensions != 0 */
1105 * skb_pfmemalloc - Test if the skb was allocated from PFMEMALLOC reserves
1110 return unlikely(skb->pfmemalloc); in skb_pfmemalloc()
1121 * skb_dst - returns skb dst_entry
1131 WARN_ON((skb->_skb_refdst & SKB_DST_NOREF) && in skb_dst()
1134 return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK); in skb_dst()
1138 * skb_dst_set - sets skb dst
1147 skb->slow_gro |= !!dst; in skb_dst_set()
1148 skb->_skb_refdst = (unsigned long)dst; in skb_dst_set()
1152 * skb_dst_set_noref - sets skb dst, hopefully, without taking reference
1164 skb->slow_gro |= !!dst; in skb_dst_set_noref()
1165 skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF; in skb_dst_set_noref()
1169 * skb_dst_is_noref - Test if skb dst isn't refcounted
1174 return (skb->_skb_refdst & SKB_DST_NOREF) && skb_dst(skb); in skb_dst_is_noref()
1178 * skb_rtable - Returns the skb &rtable
1186 /* For mangling skb->pkt_type from user space side from applications
1196 * skb_napi_id - Returns the skb's NAPI id
1202 return skb->napi_id; in skb_napi_id()
1211 return skb->wifi_acked_valid; in skb_wifi_acked_valid()
1218 * skb_unref - decrement the skb's reference count
1227 if (likely(refcount_read(&skb->users) == 1)) in skb_unref()
1229 else if (likely(!refcount_dec_and_test(&skb->users))) in skb_unref()
1239 * kfree_skb - free an sk_buff with 'NOT_SPECIFIED' reason
1287 * alloc_skb - allocate a network buffer
1316 * skb_fclone_busy - check if fclone is busy
1331 return skb->fclone == SKB_FCLONE_ORIG && in skb_fclone_busy()
1332 refcount_read(&fclones->fclone_ref) > 1 && in skb_fclone_busy()
1333 READ_ONCE(fclones->skb2.sk) == sk; in skb_fclone_busy()
1337 * alloc_skb_fclone - allocate a network buffer from fclone cache
1377 * skb_pad - zero pad the tail of an skb
1422 * layer-2 (L2), layer-3 (L3), or layer-4 (L4).
1451 skb->hash = 0; in skb_clear_hash()
1452 skb->sw_hash = 0; in skb_clear_hash()
1453 skb->l4_hash = 0; in skb_clear_hash()
1458 if (!skb->l4_hash) in skb_clear_hash_if_not_l4()
1465 skb->l4_hash = is_l4; in __skb_set_hash()
1466 skb->sw_hash = is_sw; in __skb_set_hash()
1467 skb->hash = hash; in __skb_set_hash()
1565 if (!skb->l4_hash && !skb->sw_hash) in skb_get_hash()
1568 return skb->hash; in skb_get_hash()
1573 if (!skb->l4_hash && !skb->sw_hash) { in skb_get_hash_flowi6()
1580 return skb->hash; in skb_get_hash_flowi6()
1588 return skb->hash; in skb_get_hash_raw()
1593 to->hash = from->hash; in skb_copy_hash()
1594 to->sw_hash = from->sw_hash; in skb_copy_hash()
1595 to->l4_hash = from->l4_hash; in skb_copy_hash()
1602 return skb2->decrypted - skb1->decrypted; in skb_cmp_decrypted()
1612 to->decrypted = from->decrypted; in skb_copy_decrypted()
1619 return skb->head + skb->end; in skb_end_pointer()
1624 return skb->end; in skb_end_offset()
1629 skb->end = offset; in skb_set_end_offset()
1634 return skb->end; in skb_end_pointer()
1639 return skb->end - skb->head; in skb_end_offset()
1644 skb->end = skb->head + offset; in skb_set_end_offset()
1663 return __zerocopy_sg_from_iter(msg, skb->sk, skb, &msg->msg_iter, len); in skb_zerocopy_iter_dgram()
1675 return &skb_shinfo(skb)->hwtstamps; in skb_hwtstamps()
1680 bool is_zcopy = skb && skb_shinfo(skb)->flags & SKBFL_ZEROCOPY_ENABLE; in skb_zcopy()
1687 return skb_shinfo(skb)->flags & SKBFL_PURE_ZEROCOPY; in skb_zcopy_pure()
1692 return skb_shinfo(skb)->flags & SKBFL_MANAGED_FRAG_REFS; in skb_zcopy_managed()
1703 refcount_inc(&uarg->refcnt); in net_zcopy_get()
1708 skb_shinfo(skb)->destructor_arg = uarg; in skb_zcopy_init()
1709 skb_shinfo(skb)->flags |= uarg->flags; in skb_zcopy_init()
1726 skb_shinfo(skb)->destructor_arg = (void *)((uintptr_t) val | 0x1UL); in skb_zcopy_set_nouarg()
1727 skb_shinfo(skb)->flags |= SKBFL_ZEROCOPY_FRAG; in skb_zcopy_set_nouarg()
1732 return (uintptr_t) skb_shinfo(skb)->destructor_arg & 0x1UL; in skb_zcopy_is_nouarg()
1737 return (void *)((uintptr_t) skb_shinfo(skb)->destructor_arg & ~0x1UL); in skb_zcopy_get_nouarg()
1743 uarg->callback(NULL, uarg, true); in net_zcopy_put()
1749 if (uarg->callback == msg_zerocopy_callback) in net_zcopy_put_abort()
1763 uarg->callback(skb, uarg, zerocopy_success); in skb_zcopy_clear()
1765 skb_shinfo(skb)->flags &= ~SKBFL_ALL_ZEROCOPY; in skb_zcopy_clear()
1779 skb->next = NULL; in skb_mark_not_on_list()
1785 skb->next = SKB_LIST_POISON_NEXT; in skb_poison_list()
1789 /* Iterate through singly-linked GSO fragments of an skb. */
1791 for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \
1792 (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)
1796 __list_del_entry(&skb->list); in skb_list_del_init()
1801 * skb_queue_empty - check if a queue is empty
1808 return list->next == (const struct sk_buff *) list; in skb_queue_empty()
1812 * skb_queue_empty_lockless - check if a queue is empty
1820 return READ_ONCE(list->next) == (const struct sk_buff *) list; in skb_queue_empty_lockless()
1825 * skb_queue_is_last - check if skb is the last entry in the queue
1834 return skb->next == (const struct sk_buff *) list; in skb_queue_is_last()
1838 * skb_queue_is_first - check if skb is the first entry in the queue
1847 return skb->prev == (const struct sk_buff *) list; in skb_queue_is_first()
1851 * skb_queue_next - return the next packet in the queue
1865 return skb->next; in skb_queue_next()
1869 * skb_queue_prev - return the prev packet in the queue
1883 return skb->prev; in skb_queue_prev()
1887 * skb_get - reference buffer
1895 refcount_inc(&skb->users); in skb_get()
1904 * skb_cloned - is the buffer a clone
1913 return skb->cloned && in skb_cloned()
1914 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1; in skb_cloned()
1927 /* This variant of skb_unclone() makes sure skb->truesize
1928 * and skb_end_offset() are not changed, whenever a new skb->head is needed.
1944 * skb_header_cloned - is the header a clone
1954 if (!skb->cloned) in skb_header_cloned()
1957 dataref = atomic_read(&skb_shinfo(skb)->dataref); in skb_header_cloned()
1958 dataref = (dataref & SKB_DATAREF_MASK) - (dataref >> SKB_DATAREF_SHIFT); in skb_header_cloned()
1973 * __skb_header_release() - allow clones to use the headroom
1980 skb->nohdr = 1; in __skb_header_release()
1981 atomic_set(&skb_shinfo(skb)->dataref, 1 + (1 << SKB_DATAREF_SHIFT)); in __skb_header_release()
1986 * skb_shared - is the buffer shared
1994 return refcount_read(&skb->users) != 1; in skb_shared()
1998 * skb_share_check - check if buffer is shared and if so clone it
2033 * skb_unshare - make a copy of a shared buffer
2063 * skb_peek - peek at the head of an &sk_buff_head
2077 struct sk_buff *skb = list_->next; in skb_peek()
2085 * __skb_peek - peek at the head of a non-empty &sk_buff_head
2092 return list_->next; in __skb_peek()
2096 * skb_peek_next - peek skb following the given one from a queue
2107 struct sk_buff *next = skb->next; in skb_peek_next()
2115 * skb_peek_tail - peek at the tail of an &sk_buff_head
2129 struct sk_buff *skb = READ_ONCE(list_->prev); in skb_peek_tail()
2138 * skb_queue_len - get queue length
2145 return list_->qlen; in skb_queue_len()
2149 * skb_queue_len_lockless - get queue length
2157 return READ_ONCE(list_->qlen); in skb_queue_len_lockless()
2161 * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
2167 * the spinlock. It can also be used for on-stack sk_buff_head
2172 list->prev = list->next = (struct sk_buff *)list; in __skb_queue_head_init()
2173 list->qlen = 0; in __skb_queue_head_init()
2178 * this is needed for now since a whole lot of users of the skb-queue
2186 spin_lock_init(&list->lock); in skb_queue_head_init()
2194 lockdep_set_class(&list->lock, class); in skb_queue_head_init_class()
2200 * The "__skb_xxxx()" functions are the non-atomic ones that
2210 WRITE_ONCE(newsk->next, next); in __skb_insert()
2211 WRITE_ONCE(newsk->prev, prev); in __skb_insert()
2212 WRITE_ONCE(((struct sk_buff_list *)next)->prev, newsk); in __skb_insert()
2213 WRITE_ONCE(((struct sk_buff_list *)prev)->next, newsk); in __skb_insert()
2214 WRITE_ONCE(list->qlen, list->qlen + 1); in __skb_insert()
2221 struct sk_buff *first = list->next; in __skb_queue_splice()
2222 struct sk_buff *last = list->prev; in __skb_queue_splice()
2224 WRITE_ONCE(first->prev, prev); in __skb_queue_splice()
2225 WRITE_ONCE(prev->next, first); in __skb_queue_splice()
2227 WRITE_ONCE(last->next, next); in __skb_queue_splice()
2228 WRITE_ONCE(next->prev, last); in __skb_queue_splice()
2232 * skb_queue_splice - join two skb lists, this is designed for stacks
2240 __skb_queue_splice(list, (struct sk_buff *) head, head->next); in skb_queue_splice()
2241 head->qlen += list->qlen; in skb_queue_splice()
2246 * skb_queue_splice_init - join two skb lists and reinitialise the emptied list
2256 __skb_queue_splice(list, (struct sk_buff *) head, head->next); in skb_queue_splice_init()
2257 head->qlen += list->qlen; in skb_queue_splice_init()
2263 * skb_queue_splice_tail - join two skb lists, each list being a queue
2271 __skb_queue_splice(list, head->prev, (struct sk_buff *) head); in skb_queue_splice_tail()
2272 head->qlen += list->qlen; in skb_queue_splice_tail()
2277 * skb_queue_splice_tail_init - join two skb lists and reinitialise the emptied list
2288 __skb_queue_splice(list, head->prev, (struct sk_buff *) head); in skb_queue_splice_tail_init()
2289 head->qlen += list->qlen; in skb_queue_splice_tail_init()
2295 * __skb_queue_after - queue a buffer at the list head
2309 __skb_insert(newsk, prev, ((struct sk_buff_list *)prev)->next, list); in __skb_queue_after()
2319 __skb_insert(newsk, ((struct sk_buff_list *)next)->prev, next, list); in __skb_queue_before()
2323 * __skb_queue_head - queue a buffer at the list head
2340 * __skb_queue_tail - queue a buffer at the list tail
2365 WRITE_ONCE(list->qlen, list->qlen - 1); in __skb_unlink()
2366 next = skb->next; in __skb_unlink()
2367 prev = skb->prev; in __skb_unlink()
2368 skb->next = skb->prev = NULL; in __skb_unlink()
2369 WRITE_ONCE(next->prev, prev); in __skb_unlink()
2370 WRITE_ONCE(prev->next, next); in __skb_unlink()
2374 * __skb_dequeue - remove from the head of the queue
2391 * __skb_dequeue_tail - remove from the tail of the queue
2410 return skb->data_len; in skb_is_nonlinear()
2415 return skb->len - skb->data_len; in skb_headlen()
2422 for (i = skb_shinfo(skb)->nr_frags - 1; (int)i >= 0; i--) in __skb_pagelen()
2423 len += skb_frag_size(&skb_shinfo(skb)->frags[i]); in __skb_pagelen()
2436 frag->bv_page = page; in skb_frag_fill_page_desc()
2437 frag->bv_offset = off; in skb_frag_fill_page_desc()
2445 skb_frag_t *frag = &shinfo->frags[i]; in __skb_fill_page_desc_noacc()
2451 * skb_len_add - adds a number to len fields of skb
2457 skb->len += delta; in skb_len_add()
2458 skb->data_len += delta; in skb_len_add()
2459 skb->truesize += delta; in skb_len_add()
2463 * __skb_fill_page_desc - initialise a paged fragment in an skb
2486 skb->pfmemalloc = true; in __skb_fill_page_desc()
2490 * skb_fill_page_desc - initialise a paged fragment in an skb
2497 * As per __skb_fill_page_desc() -- initialises the @i'th fragment of
2507 skb_shinfo(skb)->nr_frags = i + 1; in skb_fill_page_desc()
2511 * skb_fill_page_desc_noacc - initialise a paged fragment in an skb
2528 shinfo->nr_frags = i + 1; in skb_fill_page_desc_noacc()
2542 return skb->head + skb->tail; in skb_tail_pointer()
2547 skb->tail = skb->data - skb->head; in skb_reset_tail_pointer()
2553 skb->tail += offset; in skb_set_tail_pointer()
2559 return skb->tail; in skb_tail_pointer()
2564 skb->tail = skb->data; in skb_reset_tail_pointer()
2569 skb->tail = skb->data + offset; in skb_set_tail_pointer()
2577 if (WARN_ONCE(!skb->len, "%s\n", __func__)) in skb_assert_len()
2591 skb->tail += len; in __skb_put()
2592 skb->len += len; in __skb_put()
2645 skb->data -= len; in __skb_push()
2646 skb->len += len; in __skb_push()
2647 return skb->data; in __skb_push()
2653 skb->len -= len; in __skb_pull()
2654 if (unlikely(skb->len < skb->data_len)) { in __skb_pull()
2656 skb->len += len; in __skb_pull()
2662 return skb->data += len; in __skb_pull()
2667 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); in skb_pull_inline()
2680 if (unlikely(len > skb->len)) in pskb_may_pull_reason()
2683 if (unlikely(!__pskb_pull_tail(skb, len - skb_headlen(skb)))) in pskb_may_pull_reason()
2699 skb->len -= len; in pskb_pull()
2700 return skb->data += len; in pskb_pull()
2706 * skb_headroom - bytes at buffer head
2713 return skb->data - skb->head; in skb_headroom()
2717 * skb_tailroom - bytes at buffer end
2724 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail; in skb_tailroom()
2728 * skb_availroom - bytes at buffer end
2739 return skb->end - skb->tail - skb->reserved_tailroom; in skb_availroom()
2743 * skb_reserve - adjust headroom
2752 skb->data += len; in skb_reserve()
2753 skb->tail += len; in skb_reserve()
2757 * skb_tailroom_reserve - adjust reserved_tailroom
2772 if (mtu < skb_tailroom(skb) - needed_tailroom) in skb_tailroom_reserve()
2774 skb->reserved_tailroom = skb_tailroom(skb) - mtu; in skb_tailroom_reserve()
2777 skb->reserved_tailroom = needed_tailroom; in skb_tailroom_reserve()
2786 skb->inner_protocol = protocol; in skb_set_inner_protocol()
2787 skb->inner_protocol_type = ENCAP_TYPE_ETHER; in skb_set_inner_protocol()
2793 skb->inner_ipproto = ipproto; in skb_set_inner_ipproto()
2794 skb->inner_protocol_type = ENCAP_TYPE_IPPROTO; in skb_set_inner_ipproto()
2799 skb->inner_mac_header = skb->mac_header; in skb_reset_inner_headers()
2800 skb->inner_network_header = skb->network_header; in skb_reset_inner_headers()
2801 skb->inner_transport_header = skb->transport_header; in skb_reset_inner_headers()
2806 skb->mac_len = skb->network_header - skb->mac_header; in skb_reset_mac_len()
2812 return skb->head + skb->inner_transport_header; in skb_inner_transport_header()
2817 return skb_inner_transport_header(skb) - skb->data; in skb_inner_transport_offset()
2822 skb->inner_transport_header = skb->data - skb->head; in skb_reset_inner_transport_header()
2829 skb->inner_transport_header += offset; in skb_set_inner_transport_header()
2834 return skb->head + skb->inner_network_header; in skb_inner_network_header()
2839 skb->inner_network_header = skb->data - skb->head; in skb_reset_inner_network_header()
2846 skb->inner_network_header += offset; in skb_set_inner_network_header()
2851 return skb->head + skb->inner_mac_header; in skb_inner_mac_header()
2856 skb->inner_mac_header = skb->data - skb->head; in skb_reset_inner_mac_header()
2863 skb->inner_mac_header += offset; in skb_set_inner_mac_header()
2867 return skb->transport_header != (typeof(skb->transport_header))~0U; in skb_transport_header_was_set()
2873 return skb->head + skb->transport_header; in skb_transport_header()
2878 skb->transport_header = skb->data - skb->head; in skb_reset_transport_header()
2885 skb->transport_header += offset; in skb_set_transport_header()
2890 return skb->head + skb->network_header; in skb_network_header()
2895 skb->network_header = skb->data - skb->head; in skb_reset_network_header()
2901 skb->network_header += offset; in skb_set_network_header()
2906 return skb->mac_header != (typeof(skb->mac_header))~0U; in skb_mac_header_was_set()
2912 return skb->head + skb->mac_header; in skb_mac_header()
2917 return skb_mac_header(skb) - skb->data; in skb_mac_offset()
2923 return skb->network_header - skb->mac_header; in skb_mac_header_len()
2928 skb->mac_header = (typeof(skb->mac_header))~0U; in skb_unset_mac_header()
2933 skb->mac_header = skb->data - skb->head; in skb_reset_mac_header()
2939 skb->mac_header += offset; in skb_set_mac_header()
2944 skb->mac_header = skb->network_header; in skb_pop_mac_header()
2964 skb_set_mac_header(skb, -skb->mac_len); in skb_mac_header_rebuild()
2965 memmove(skb_mac_header(skb), old_mac, skb->mac_len); in skb_mac_header_rebuild()
2971 return skb->csum_start - skb_headroom(skb); in skb_checksum_start_offset()
2976 return skb->head + skb->csum_start; in skb_checksum_start()
2981 return skb_transport_header(skb) - skb->data; in skb_transport_offset()
2986 return skb->transport_header - skb->network_header; in skb_network_header_len()
2991 return skb->inner_transport_header - skb->inner_network_header; in skb_inner_network_header_len()
2996 return skb_network_header(skb) - skb->data; in skb_network_offset()
3001 return skb_inner_network_header(skb) - skb->data; in skb_inner_network_offset()
3063 skb->len = len; in __skb_set_length()
3076 if (skb->data_len) in __pskb_trim()
3084 return (len < skb->len) ? __pskb_trim(skb, len) : 0; in pskb_trim()
3088 * pskb_trim_unique - remove end from a paged unique (not cloned) buffer
3093 * the skb is not cloned so we should never get an error due to out-
3094 * of-memory.
3104 unsigned int diff = len - skb->len; in __skb_grow()
3107 int ret = pskb_expand_head(skb, 0, diff - skb_tailroom(skb), in __skb_grow()
3117 * skb_orphan - orphan a buffer
3126 if (skb->destructor) { in skb_orphan()
3127 skb->destructor(skb); in skb_orphan()
3128 skb->destructor = NULL; in skb_orphan()
3129 skb->sk = NULL; in skb_orphan()
3131 BUG_ON(skb->sk); in skb_orphan()
3136 * skb_orphan_frags - orphan the frags contained in a buffer
3148 if (skb_shinfo(skb)->flags & SKBFL_DONT_ORPHAN) in skb_orphan_frags()
3162 * __skb_queue_purge_reason - empty a list
3198 * netdev_alloc_frag - allocate a page fragment
3213 return __netdev_alloc_frag_align(fragsz, -align); in netdev_alloc_frag_align()
3220 * netdev_alloc_skb - allocate an skbuff for rx on a specific device
3284 return __napi_alloc_frag_align(fragsz, -align); in napi_alloc_frag_align()
3300 * __dev_alloc_pages - allocate page for network Rx
3330 * __dev_alloc_page - allocate a page for network Rx
3348 * dev_page_is_reusable - check whether a page can be reused for network Rx
3364 * skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated after RX page
3372 skb->pfmemalloc = true; in skb_propagate_pfmemalloc()
3376 * skb_frag_off() - Returns the offset of a skb fragment
3381 return frag->bv_offset; in skb_frag_off()
3385 * skb_frag_off_add() - Increments the offset of a skb fragment by @delta
3391 frag->bv_offset += delta; in skb_frag_off_add()
3395 * skb_frag_off_set() - Sets the offset of a skb fragment
3401 frag->bv_offset = offset; in skb_frag_off_set()
3405 * skb_frag_off_copy() - Sets the offset of a skb fragment from another fragment
3412 fragto->bv_offset = fragfrom->bv_offset; in skb_frag_off_copy()
3416 * skb_frag_page - retrieve the page referred to by a paged fragment
3423 return frag->bv_page; in skb_frag_page()
3427 * __skb_frag_ref - take an addition reference on a paged fragment.
3438 * skb_frag_ref - take an addition reference on a paged fragment of an skb.
3446 __skb_frag_ref(&skb_shinfo(skb)->frags[f]); in skb_frag_ref()
3464 * __skb_frag_unref - release a reference on a paged fragment.
3477 * skb_frag_unref - release a reference on a paged fragment of an skb.
3488 __skb_frag_unref(&shinfo->frags[f], skb->pp_recycle); in skb_frag_unref()
3492 * skb_frag_address - gets the address of the data contained in a paged fragment
3504 * skb_frag_address_safe - gets the address of the data contained in a paged fragment
3520 * skb_frag_page_copy() - sets the page in a fragment from another fragment
3527 fragto->bv_page = fragfrom->bv_page; in skb_frag_page_copy()
3533 * skb_frag_dma_map - maps a paged fragment via the DMA API
3567 * skb_clone_writable - is the header of a clone writable
3577 skb_headroom(skb) + len <= skb->hdr_len; in skb_clone_writable()
3593 delta = headroom - skb_headroom(skb); in __skb_cow()
3602 * skb_cow - copy header of skb when it is required
3610 * The result is skb with writable area skb->head...skb->tail
3619 * skb_cow_head - skb_cow but only making the head writable
3634 * skb_padto - pad an skbuff up to a minimal size
3645 unsigned int size = skb->len; in skb_padto()
3648 return skb_pad(skb, len - size); in skb_padto()
3652 * __skb_put_padto - increase size and pad an skbuff up to a minimal size
3666 unsigned int size = skb->len; in __skb_put_padto()
3669 len -= size; in __skb_put_padto()
3671 return -ENOMEM; in __skb_put_padto()
3678 * skb_put_padto - increase size and pad an skbuff up to a minimal size
3698 const int off = skb->len; in skb_add_data()
3700 if (skb->ip_summed == CHECKSUM_NONE) { in skb_add_data()
3704 skb->csum = csum_block_add(skb->csum, csum, off); in skb_add_data()
3711 return -EFAULT; in skb_add_data()
3720 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; in skb_can_coalesce()
3730 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM; in __skb_linearize()
3734 * skb_linearize - convert paged skb to linear one
3737 * If there is no free memory -ENOMEM is returned, otherwise zero
3746 * skb_has_shared_frag - can any frag be overwritten
3755 skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG; in skb_has_shared_frag()
3759 * skb_linearize_cow - make sure skb is linear and writable
3762 * If there is no free memory -ENOMEM is returned, otherwise zero
3775 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpull_rcsum()
3776 skb->csum = csum_block_sub(skb->csum, in __skb_postpull_rcsum()
3778 else if (skb->ip_summed == CHECKSUM_PARTIAL && in __skb_postpull_rcsum()
3780 skb->ip_summed = CHECKSUM_NONE; in __skb_postpull_rcsum()
3784 * skb_postpull_rcsum - update checksum for received skb after pull
3796 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_postpull_rcsum()
3797 skb->csum = wsum_negate(csum_partial(start, len, in skb_postpull_rcsum()
3798 wsum_negate(skb->csum))); in skb_postpull_rcsum()
3799 else if (skb->ip_summed == CHECKSUM_PARTIAL && in skb_postpull_rcsum()
3801 skb->ip_summed = CHECKSUM_NONE; in skb_postpull_rcsum()
3808 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpush_rcsum()
3809 skb->csum = csum_block_add(skb->csum, in __skb_postpush_rcsum()
3814 * skb_postpush_rcsum - update checksum for received skb after push
3831 * skb_push_rcsum - push skb and update receive checksum
3844 skb_postpush_rcsum(skb, skb->data, len); in skb_push_rcsum()
3845 return skb->data; in skb_push_rcsum()
3850 * pskb_trim_rcsum - trim received skb and update checksum
3861 if (likely(len >= skb->len)) in pskb_trim_rcsum()
3868 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_trim_rcsum()
3869 skb->ip_summed = CHECKSUM_NONE; in __skb_trim_rcsum()
3876 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_grow_rcsum()
3877 skb->ip_summed = CHECKSUM_NONE; in __skb_grow_rcsum()
3884 #define skb_rb_next(skb) rb_to_skb(rb_next(&(skb)->rbnode))
3885 #define skb_rb_prev(skb) rb_to_skb(rb_prev(&(skb)->rbnode))
3888 for (skb = (queue)->next; \
3890 skb = skb->next)
3893 for (skb = (queue)->next, tmp = skb->next; \
3895 skb = tmp, tmp = skb->next)
3899 skb = skb->next)
3914 for (tmp = skb->next; \
3916 skb = tmp, tmp = skb->next)
3919 for (skb = (queue)->prev; \
3921 skb = skb->prev)
3924 for (skb = (queue)->prev, tmp = skb->prev; \
3926 skb = tmp, tmp = skb->prev)
3929 for (tmp = skb->prev; \
3931 skb = tmp, tmp = skb->prev)
3935 return skb_shinfo(skb)->frag_list != NULL; in skb_has_frag_list()
3940 skb_shinfo(skb)->frag_list = NULL; in skb_frag_list_init()
3944 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
3970 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size); in skb_copy_datagram_msg()
4028 return copy_from_iter_full(data, len, &msg->msg_iter) ? 0 : -EFAULT; in memcpy_from_msg()
4033 return copy_to_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT; in memcpy_to_msg()
4052 if (likely(hlen - offset >= len)) in __skb_header_pointer()
4064 return __skb_header_pointer(skb, offset, len, skb->data, in skb_header_pointer()
4071 if (likely(skb_headlen(skb) - offset >= len)) in skb_pointer_if_linear()
4072 return skb->data + offset; in skb_pointer_if_linear()
4077 * skb_needs_linearize - check if we need to linearize a given skb
4091 (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG))); in skb_needs_linearize()
4098 memcpy(to, skb->data, len); in skb_copy_from_linear_data()
4105 memcpy(to, skb->data + offset, len); in skb_copy_from_linear_data_offset()
4112 memcpy(skb->data, from, len); in skb_copy_to_linear_data()
4120 memcpy(skb->data + offset, from, len); in skb_copy_to_linear_data_offset()
4127 return skb->tstamp; in skb_get_ktime()
4131 * skb_get_timestamp - get timestamp from a skb
4142 *stamp = ns_to_kernel_old_timeval(skb->tstamp); in skb_get_timestamp()
4148 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestamp()
4150 stamp->tv_sec = ts.tv_sec; in skb_get_new_timestamp()
4151 stamp->tv_usec = ts.tv_nsec / 1000; in skb_get_new_timestamp()
4157 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_timestampns()
4159 stamp->tv_sec = ts.tv_sec; in skb_get_timestampns()
4160 stamp->tv_nsec = ts.tv_nsec; in skb_get_timestampns()
4166 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestampns()
4168 stamp->tv_sec = ts.tv_sec; in skb_get_new_timestampns()
4169 stamp->tv_nsec = ts.tv_nsec; in skb_get_new_timestampns()
4174 skb->tstamp = ktime_get_real(); in __net_timestamp()
4175 skb->mono_delivery_time = 0; in __net_timestamp()
4186 skb->tstamp = kt; in skb_set_delivery_time()
4187 skb->mono_delivery_time = kt && mono; in skb_set_delivery_time()
4193 * If needed, set the skb->tstamp to the (rcv) timestamp.
4197 if (skb->mono_delivery_time) { in skb_clear_delivery_time()
4198 skb->mono_delivery_time = 0; in skb_clear_delivery_time()
4200 skb->tstamp = ktime_get_real(); in skb_clear_delivery_time()
4202 skb->tstamp = 0; in skb_clear_delivery_time()
4208 if (skb->mono_delivery_time) in skb_clear_tstamp()
4211 skb->tstamp = 0; in skb_clear_tstamp()
4216 if (skb->mono_delivery_time) in skb_tstamp()
4219 return skb->tstamp; in skb_tstamp()
4224 if (!skb->mono_delivery_time && skb->tstamp) in skb_tstamp_cond()
4225 return skb->tstamp; in skb_tstamp_cond()
4235 return skb_shinfo(skb)->meta_len; in skb_metadata_len()
4257 #define __it(x, op) (x -= sizeof(u##op)) in __skb_metadata_differs()
4277 return memcmp(a - meta_len, b - meta_len, meta_len); in __skb_metadata_differs()
4297 skb_shinfo(skb)->meta_len = meta_len; in skb_metadata_set()
4326 * skb_complete_tx_timestamp() - deliver cloned skb with tx timestamps
4345 * skb_tstamp_tx - queue clone of skb with send time stamps
4359 * skb_tx_timestamp() - Driver hook for transmit timestamping
4373 if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP) in skb_tx_timestamp()
4378 * skb_complete_wifi_ack - deliver skb with wifi status
4391 return ((skb->ip_summed == CHECKSUM_UNNECESSARY) || in skb_csum_unnecessary()
4392 skb->csum_valid || in skb_csum_unnecessary()
4393 (skb->ip_summed == CHECKSUM_PARTIAL && in skb_csum_unnecessary()
4398 * skb_checksum_complete - Calculate checksum of an entire packet
4402 * the value of skb->csum. The latter can be used to supply the
4410 * if skb->ip_summed is CHECKSUM_UNNECESSARY which indicates that the
4421 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_decr_checksum_unnecessary()
4422 if (skb->csum_level == 0) in __skb_decr_checksum_unnecessary()
4423 skb->ip_summed = CHECKSUM_NONE; in __skb_decr_checksum_unnecessary()
4425 skb->csum_level--; in __skb_decr_checksum_unnecessary()
4431 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_incr_checksum_unnecessary()
4432 if (skb->csum_level < SKB_MAX_CSUM_LEVEL) in __skb_incr_checksum_unnecessary()
4433 skb->csum_level++; in __skb_incr_checksum_unnecessary()
4434 } else if (skb->ip_summed == CHECKSUM_NONE) { in __skb_incr_checksum_unnecessary()
4435 skb->ip_summed = CHECKSUM_UNNECESSARY; in __skb_incr_checksum_unnecessary()
4436 skb->csum_level = 0; in __skb_incr_checksum_unnecessary()
4442 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_reset_checksum_unnecessary()
4443 skb->ip_summed = CHECKSUM_NONE; in __skb_reset_checksum_unnecessary()
4444 skb->csum_level = 0; in __skb_reset_checksum_unnecessary()
4458 skb->csum_valid = 1; in __skb_checksum_validate_needed()
4471 /* Unset checksum-complete
4474 * (uncompressed for instance) and checksum-complete value is
4479 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_checksum_complete_unset()
4480 skb->ip_summed = CHECKSUM_NONE; in skb_checksum_complete_unset()
4488 * checksum is stored in skb->csum for use in __skb_checksum_complete
4489 * non-zero: value of invalid checksum
4496 if (skb->ip_summed == CHECKSUM_COMPLETE) { in __skb_checksum_validate_complete()
4497 if (!csum_fold(csum_add(psum, skb->csum))) { in __skb_checksum_validate_complete()
4498 skb->csum_valid = 1; in __skb_checksum_validate_complete()
4503 skb->csum = psum; in __skb_checksum_validate_complete()
4505 if (complete || skb->len <= CHECKSUM_BREAK) { in __skb_checksum_validate_complete()
4509 skb->csum_valid = !csum; in __skb_checksum_validate_complete()
4529 * non-zero: value of invalid checksum
4535 skb->csum_valid = 0; \
4560 return (skb->ip_summed == CHECKSUM_NONE && skb->csum_valid); in __skb_checksum_convert_check()
4565 skb->csum = ~pseudo; in __skb_checksum_convert()
4566 skb->ip_summed = CHECKSUM_COMPLETE; in __skb_checksum_convert()
4578 skb->ip_summed = CHECKSUM_PARTIAL; in skb_remcsum_adjust_partial()
4579 skb->csum_start = ((unsigned char *)ptr + start) - skb->head; in skb_remcsum_adjust_partial()
4580 skb->csum_offset = offset - start; in skb_remcsum_adjust_partial()
4584 * When called, ptr indicates the starting point for skb->csum when
4586 * here, skb_postpull_rcsum is done so skb->csum start is ptr.
4598 if (unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) { in skb_remcsum_process()
4600 skb_postpull_rcsum(skb, skb->data, ptr - (void *)skb->data); in skb_remcsum_process()
4603 delta = remcsum_adjust(ptr, skb->csum, start, offset); in skb_remcsum_process()
4605 /* Adjust skb->csum since we changed the packet */ in skb_remcsum_process()
4606 skb->csum = csum_add(skb->csum, delta); in skb_remcsum_process()
4612 return (void *)(skb->_nfct & NFCT_PTRMASK); in skb_nfct()
4621 return skb->_nfct; in skb_get_nfct()
4630 skb->slow_gro |= !!nfct; in skb_set_nfct()
4631 skb->_nfct = nfct; in skb_set_nfct()
4656 * struct skb_ext - sk_buff extensions
4681 if (skb->active_extensions) in skb_ext_put()
4682 __skb_ext_put(skb->extensions); in skb_ext_put()
4688 dst->active_extensions = src->active_extensions; in __skb_ext_copy()
4690 if (src->active_extensions) { in __skb_ext_copy()
4691 struct skb_ext *ext = src->extensions; in __skb_ext_copy()
4693 refcount_inc(&ext->refcnt); in __skb_ext_copy()
4694 dst->extensions = ext; in __skb_ext_copy()
4706 return !!ext->offset[i]; in __skb_ext_exist()
4711 return skb->active_extensions & (1 << id); in skb_ext_exist()
4723 struct skb_ext *ext = skb->extensions; in skb_ext_find()
4725 return (void *)ext + (ext->offset[id] << 3); in skb_ext_find()
4733 if (unlikely(skb->active_extensions)) { in skb_ext_reset()
4734 __skb_ext_put(skb->extensions); in skb_ext_reset()
4735 skb->active_extensions = 0; in skb_ext_reset()
4741 return unlikely(skb->active_extensions); in skb_has_extensions()
4756 skb->_nfct = 0; in nf_reset_ct()
4763 skb->nf_trace = 0; in nf_reset_trace()
4770 skb->ipvs_property = 0; in ipvs_reset()
4779 dst->_nfct = src->_nfct; in __nf_copy()
4784 dst->nf_trace = src->nf_trace; in __nf_copy()
4793 dst->slow_gro = src->slow_gro; in nf_copy()
4800 to->secmark = from->secmark; in skb_copy_secmark()
4805 skb->secmark = 0; in skb_init_secmark()
4826 return !skb->destructor && in skb_irq_freeable()
4829 !skb->_skb_refdst && in skb_irq_freeable()
4835 skb->queue_mapping = queue_mapping; in skb_set_queue_mapping()
4840 return skb->queue_mapping; in skb_get_queue_mapping()
4845 to->queue_mapping = from->queue_mapping; in skb_copy_queue_mapping()
4850 skb->queue_mapping = rx_queue + 1; in skb_record_rx_queue()
4855 return skb->queue_mapping - 1; in skb_get_rx_queue()
4860 return skb->queue_mapping != 0; in skb_rx_queue_recorded()
4865 skb->dst_pending_confirm = val; in skb_set_dst_pending_confirm()
4870 return skb->dst_pending_confirm != 0; in skb_get_dst_pending_confirm()
4884 return skb_shinfo(skb)->gso_size; in skb_is_gso()
4890 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; in skb_is_gso_v6()
4896 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP; in skb_is_gso_sctp()
4902 return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6); in skb_is_gso_tcp()
4907 skb_shinfo(skb)->gso_size = 0; in skb_gso_reset()
4908 skb_shinfo(skb)->gso_segs = 0; in skb_gso_reset()
4909 skb_shinfo(skb)->gso_type = 0; in skb_gso_reset()
4915 if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) in skb_increase_gso_size()
4917 shinfo->gso_size += increment; in skb_increase_gso_size()
4923 if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) in skb_decrease_gso_size()
4925 shinfo->gso_size -= decrement; in skb_decrease_gso_size()
4936 if (skb_is_nonlinear(skb) && shinfo->gso_size != 0 && in skb_warn_if_lro()
4937 unlikely(shinfo->gso_type == 0)) { in skb_warn_if_lro()
4947 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_forward_csum()
4948 skb->ip_summed = CHECKSUM_NONE; in skb_forward_csum()
4952 * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
4961 DEBUG_NET_WARN_ON_ONCE(skb->ip_summed != CHECKSUM_NONE); in skb_checksum_none_assert()
4972 * skb_head_is_locked - Determine if the skb->head is locked down
4982 return !skb->head_frag || skb_cloned(skb); in skb_head_is_locked()
4988 * See Documentation/networking/checksum-offloads.rst for
4991 * pseudo-header) before calling.
5002 skb->csum_offset)); in lco_csum()
5007 return csum_partial(l4_hdr, csum_start - l4_hdr, partial); in lco_csum()
5012 return skb->redirected; in skb_is_redirected()
5017 skb->redirected = 1; in skb_set_redirected()
5019 skb->from_ingress = from_ingress; in skb_set_redirected()
5020 if (skb->from_ingress) in skb_set_redirected()
5027 skb->redirected = 0; in skb_reset_redirect()
5033 skb->redirected = 1; in skb_set_redirected_noclear()
5035 skb->from_ingress = from_ingress; in skb_set_redirected_noclear()
5042 return skb->csum_not_inet; in skb_csum_is_sctp()
5050 skb->ip_summed = CHECKSUM_NONE; in skb_reset_csum_not_inet()
5052 skb->csum_not_inet = 0; in skb_reset_csum_not_inet()
5060 skb->kcov_handle = kcov_handle; in skb_set_kcov_handle()
5067 return skb->kcov_handle; in skb_get_kcov_handle()
5076 skb->pp_recycle = 1; in skb_mark_for_recycle()