xsk: Keep the shared info of zero-copy buffers in kernel memory
Subsystems (8)
v3 cover xsk: Keep the shared info of zero-copy buffers in kernel memory
A packet that AF_XDP receives in zero-copy mode over several buffers keeps its shared info, the fragment list and its count, in the UMEM, which userspace can write while the kernel uses it. A rewritten list or count makes the kernel read and write out of bounds.
Patch 4 moves the shared info into the buffer pool and lets the device write up to the end of each chunk. Patch 1 makes libeth count XSk XDP_TX buffers one by one, as it read the shared info at a later bulk flush. Patches 2 and 3 fix skb builders that relied on the old tailroom. The generic one sized the skb head from the frame size, and i40e, igb, igc and ixgbe read past the data.
Sashiko found the issues [1], Clément the one of patch 2 earlier [2]. Patch 3 was reproduced on igb in QEMU.
v3 was tested on igb and veth in QEMU, v2 also on virtio-net and on mlx5 hardware. None covers multi-buffer zero copy or the generic skb builder, so i40e, ice, idpf and gve are only build-tested. Intel folks, could you run your multi-buffer zero-copy tests on them?
Maciej will send the ice fix that v2 mentioned. Thanks, Maciej!
Changes in v3:
- Patch 2: describe the 2K chunk case and its impact (Sashiko)
- Patch 4: give the shared info of the pool its own cache lines after the data path members (Maciej)
- Patch 4: say that backports need patches 1 to 3 (Sashiko)
- Add Olek's acks, rebase on net
Changes in v2:
- New patches 2 and 3 (Sashiko, Clément)
- Patches 1 and 4: kernel-doc, buffer flag and ordering fixes (Sashiko)
- Drop the selftest patch, it goes to net-next (Maciej)
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/bpf/[email protected]/
Björn Töpel (4):
libeth: xsk: Count each XDP_TX buffer on its own
xdp: Size zero-copy skbs from the data, not the frame size
intel: Copy the exact length of XSk packets to skbs
xsk: Keep the shared info of zero-copy buffers in kernel memory
drivers/net/ethernet/intel/i40e/i40e_xsk.c | 3 +- drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +- drivers/net/ethernet/intel/igc/igc_main.c | 3 +- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 3 +- include/net/libeth/tx.h | 8 ++-- include/net/libeth/xdp.h | 9 ++++- include/net/libeth/xsk.h | 6 ++- include/net/xdp.h | 32 +++++++++++++--- include/net/xdp_sock_drv.h | 26 +++---------- include/net/xsk_buff_pool.h | 2 + net/core/filter.c | 2 +- net/core/xdp.c | 40 ++++++++++++++------ net/xdp/xdp_umem.c | 3 +- net/xdp/xsk_buff_pool.c | 20 ++++++---- 14 files changed, 97 insertions(+), 63 deletions(-)
base-commit: 7c13d5d5afb4ba2e8634fe5aa0a9f2bca235cb4b
Signature · 1 line
2.53.1-Meta
PATCH v3 1/4 libeth: xsk: Count each XDP_TX buffer on its own
libeth takes the number of buffers of an XSk XDP_TX frame from its shared info, and reports that many completed buffers to the driver. It reads the shared info when it flushes the bulk, not when it queues the frame. The shared info of a zero-copy buffer lives in the UMEM, which userspace may write at any time, so a rewritten count makes libeth report a wrong number. Once the last patch of this series moves the shared info into the buffer pool, the next multi-buffer frame of the same poll can overwrite it before the flush.
A wrong number breaks the in-flight count of XDP_TX buffers that idpf keeps on its XSk queues, and idpf may then complete XDP_TX buffers as XSk xmit frames.
Make libeth count each buffer on its own SQE. Head and fragments each count one completed buffer, and the head counts the packet. Stats stay the same for frames sent in full.
Found by an AI agent while reviewing this code. Not triggered at runtime.
--- include/net/libeth/tx.h | 8 +++++--- include/net/libeth/xdp.h | 9 ++++++++- include/net/libeth/xsk.h | 6 ++++-- 3 files changed, 17 insertions(+), 6 deletions(-)
include/net/libeth/tx.h +5 -3
@@ -22,7 +22,8 @@* @LIBETH_SQE_XDP_XMIT: &xdp_frame, unmap and xdp_return_frame_bulk(), stats * @LIBETH_SQE_XDP_XMIT_FRAG: &xdp_frame frag, only unmap DMA * @LIBETH_SQE_XSK_TX: &libeth_xdp_buff on XSk queue, xsk_buff_free(), stats -* @LIBETH_SQE_XSK_TX_FRAG: &libeth_xdp_buff frag on XSk queue, xsk_buff_free() +* @LIBETH_SQE_XSK_TX_FRAG: &libeth_xdp_buff frag on XSk queue, xsk_buff_free(), +* stats */ enum libeth_sqe_type {LIBETH_SQE_EMPTY =0U ,
@@ -50,9 +51,10 @@ enum libeth_sqe_type {* @xsk: XSk Rx frame from XDP_TX action * @dma: DMA address to unmap * @len: length of the mapped region to unmap -* @nr_frags: number of frags in the frame this buffer belongs to +* @nr_frags: number of frags in the frame this buffer belongs to, not for XSk * @packets: number of physical packets sent for this frame -* @bytes: number of physical bytes sent for this frame +* @bytes: number of physical bytes sent for this frame, or for this buffer +* on XSk * @priv: driver-private scratchpad */ struct libeth_sqe {
include/net/libeth/xdp.h +8 -1
@@ -1794,12 +1794,19 @@ __libeth_xdp_complete_tx(struct libeth_sqe *sqe, struct libeth_cq_pp *cp,switch (type) {case LIBETH_SQE_XDP_TX :case LIBETH_SQE_XDP_XMIT : -case LIBETH_SQE_XSK_TX : cp->xdp_tx -= sqe->nr_frags; cp->xss->packets++; cp->xss->bytes += sqe->bytes;break ; +case LIBETH_SQE_XSK_TX : + cp->xss->packets++; + fallthrough; +case LIBETH_SQE_XSK_TX_FRAG : +/* One buffer per SQE, see libeth_xsk_tx_fill_buf() */ + cp->xdp_tx--; + cp->xss->bytes += sqe->bytes; +break ;default :break ; }
include/net/libeth/xsk.h +4 -2
@@ -129,6 +129,10 @@ libeth_xsk_tx_fill_buf(struct libeth_xdp_tx_frame frm, u32 i, sqe = &sq->sqes[i]; sqe->xsk = xdp; +/* Count each buffer on its own SQE. The shared info of the frame +* may change before the bulk is flushed. +*/ + sqe->bytes = desc.len;if (!(desc.flags &LIBETH_XDP_TX_FIRST )) { sqe->type =LIBETH_SQE_XSK_TX_FRAG ;
@@ -136,8 +140,6 @@ libeth_xsk_tx_fill_buf(struct libeth_xdp_tx_frame frm, u32 i, } sqe->type =LIBETH_SQE_XSK_TX ; -libeth_xdp_tx_fill_stats (sqe, &desc, -xdp_get_shared_info_from_buff (&xdp->base));return desc; }
Signature · 1 line
2.53.1-Meta
PATCH v3 2/4 xdp: Size zero-copy skbs from the data, not the frame size
In reply to Björn Töpelxdp_build_skb_from_zc() gives the skb head the frame size of the XSk buffer, and the skb shared info takes the end of it. A device may fill a single-buffer XSk frame to its end, so a long packet overwrites the shared info of the new skb with packet data. With 2K chunks, no UMEM headroom and the default MTU, a 1514 byte frame that XDP passes on ice, idpf or gve needs 256 + 1514 + 320 = 2090 bytes and gets 2048. The sender controls up to 48 bytes of the shared info, its frag list among them. The last patch of this series lets multi-buffer pools and bpf_xdp_adjust_tail() reach the end of the frame as well.
The copies of the head and of the fragments also round the length up to 16 bytes, and read and write past the end of the data.
Size the head from the data, and copy the exact length. Heads larger than a page come from kmalloc, not the page pool.
Found again by an AI code review agent, and the 2K case by reading the code. Reproduced out of tree, with a test module and the AF_XDP page-pool RFC on fbnic in QEMU.
--- net/core/xdp.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-)
net/core/xdp.c +28 -12
@@ -709,7 +709,7 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb, }memcpy (page_address (page) + offset,skb_frag_address (frag), -LARGEST_ALIGN (len)); + len);__skb_fill_page_desc_noacc (sinfo, i, page, offset, len); tsize += truesize;
@@ -723,6 +723,27 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,return true; } +static struct sk_buff *xdp_zc_alloc_head (struct page_pool *pp, +struct net_device *dev,u32 size) +{ +u32 truesize =SKB_HEAD_ALIGN (size); +struct sk_buff *skb; +void *data; + +if (truesize >PAGE_SIZE ) +return __netdev_alloc_skb (dev, size,GFP_ATOMIC | __GFP_NOWARN); + + data =page_pool_dev_alloc_va (pp, &truesize); +if (unlikely (!data)) +return NULL ; + + skb =napi_build_skb (data, truesize); +if (unlikely (!skb)) +page_pool_free_va (pp, data, true); + +return skb; +} +/** * xdp_build_skb_from_zc - create an skb from XSk &xdp_buff * @xdp: source XSk buff
@@ -730,7 +751,8 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,* Similar to xdp_build_skb_from_buff(), but for XSk frames. Allocate an skb * head, new buffer for the head, copy the data and initialize the skb fields. * If there are frags, allocate new buffers for them and copy. -* Buffers are allocated from the system percpu pools to try recycling them. +* Buffers are allocated from the system percpu pools to try recycling them, +* except a head that does not fit into a page. * If new skb was built successfully, @xdp is returned to XSk pool's freelist. * On error, it remains untouched and the caller must take care of this. *
@@ -738,33 +760,27 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,*/ struct sk_buff *xdp_build_skb_from_zc (struct xdp_buff *xdp) { +u32 size = xdp->data_end - xdp->data_hard_start;const struct xdp_rxq_info *rxq = xdp->rxq;u32 len = xdp->data_end - xdp->data_meta; -u32 truesize = xdp->frame_sz;struct sk_buff *skb =NULL ;struct page_pool *pp;int metalen; -void *data;if (!IS_ENABLED (CONFIG_PAGE_POOL ))return NULL ;local_lock_nested_bh (&system_page_pool.bh_lock); pp =this_cpu_read (system_page_pool.pool); - data =page_pool_dev_alloc_va (pp, &truesize); -if (unlikely (!data)) - goto out; - skb =napi_build_skb (data, truesize); -if (unlikely (!skb)) { -page_pool_free_va (pp, data, true); + skb =xdp_zc_alloc_head (pp, rxq->dev, size); +if (unlikely (!skb)) goto out; - }skb_mark_for_recycle (skb);skb_reserve (skb, xdp->data_meta - xdp->data_hard_start); -memcpy (__skb_put (skb, len), xdp->data_meta,LARGEST_ALIGN (len)); +memcpy (__skb_put (skb, len), xdp->data_meta, len); metalen = xdp->data - xdp->data_meta;if (metalen >0 ) {
Signature · 1 line
2.53.1-Meta
PATCH v3 3/4 intel: Copy the exact length of XSk packets to skbs
In reply to Björn Töpeli40e, igb, igc and ixgbe copy an XSk zero-copy packet that the XDP program passes into a new skb, and round the length of the copy up to a multiple of 8 bytes. The copy then reads up to 7 bytes past the end of the data. When the data ends at the end of the last chunk of the UMEM, the read hits the guard page after the UMEM mapping and faults.
On i40e the device can already fill a single-buffer chunk to its end. The last patch of this series lets multi-buffer pools and bpf_xdp_adjust_tail() reach the end of a chunk on all four.
Copy the exact length.
Found by an AI code review agent in review of this series. Reproduced on igb in QEMU. An AF_XDP socket in zero copy with 4K chunks and only the last chunk of the UMEM in the FILL ring, and an XDP program that adds 4 bytes of metadata, grows the tail to the end of the chunk and passes the packet:
BUG: unable to handle page fault for address: ffa0000001048000 RIP: 0010:memcpy+0xc/0x30 igb_clean_rx_irq_zc+0x8a7/0x1520 igb_poll+0x1039/0x4f50
With this patch the same test passes.
--- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 3 +-- drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +-- drivers/net/ethernet/intel/igc/igc_main.c | 3 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_xsk.c +1 -2
@@ -308,8 +308,7 @@ static struct sk_buff *i40e_construct_skb_zc(struct i40e_ring *rx_ring,if (unlikely (!skb)) goto out; -memcpy (__skb_put (skb, totalsize), xdp->data_meta, -ALIGN (totalsize,sizeof (long ))); +memcpy (__skb_put (skb, totalsize), xdp->data_meta, totalsize);if (metasize) {skb_metadata_set (skb, metasize);
drivers/net/ethernet/intel/igb/igb_xsk.c +1 -2
@@ -280,8 +280,7 @@ static struct sk_buff *igb_construct_skb_zc(struct igb_ring *rx_ring,if (timestamp)skb_hwtstamps (skb)->hwtstamp = timestamp; -memcpy (__skb_put (skb, totalsize), xdp->data_meta, -ALIGN (totalsize,sizeof (long ))); +memcpy (__skb_put (skb, totalsize), xdp->data_meta, totalsize);if (metasize) {skb_metadata_set (skb, metasize);
drivers/net/ethernet/intel/igc/igc_main.c +1 -2
@@ -2749,8 +2749,7 @@ static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring,if (unlikely (!skb))return NULL ; -memcpy (__skb_put (skb, totalsize), xdp->data_meta, -ALIGN (totalsize,sizeof (long ))); +memcpy (__skb_put (skb, totalsize), xdp->data_meta, totalsize);if (metasize) {skb_metadata_set (skb, metasize);
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +1 -2
@@ -224,8 +224,7 @@ static struct sk_buff *ixgbe_construct_skb_zc(struct ixgbe_ring *rx_ring,if (unlikely (!skb))return NULL ; -memcpy (__skb_put (skb, totalsize), xdp->data_meta, -ALIGN (totalsize,sizeof (long ))); +memcpy (__skb_put (skb, totalsize), xdp->data_meta, totalsize);if (metasize) {skb_metadata_set (skb, metasize);
Signature · 1 line
2.53.1-Meta
PATCH v3 4/4 xsk: Keep the shared info of zero-copy buffers in kernel memory
In reply to Björn TöpelA packet that a driver receives in zero-copy mode over several buffers keeps its shared info, the fragment list and its count, in the tailroom of the UMEM chunk of its head. Userspace may write the UMEM at any time, also while the kernel walks the fragments, and a rewritten list or count makes the kernel read and write out of bounds.
Keep the shared info in the buffer pool, which outlives its buffers and the queues that point to it, and let the device write up to the end of the chunk. One shared info per pool is enough, as a pool builds one multi-buffer packet at a time.
Buffers carry a flag for this, set again on every reuse, as drivers may clear the flags of the buffers they receive into.
Multi-buffer pools now give the device the whole chunk, as single-buffer pools already do. Every UMEM accepts a larger headroom, also in copy mode, and bpf_xdp_adjust_tail() can grow a zero-copy packet up to the end of its chunk.
A backport needs patches 1 to 3 of this series, which stop libeth and the skb builders from relying on the old layout.
Found by an AI code review agent, in its review of another series. Not triggered at runtime.
--- include/net/xdp.h | 32 ++++++++++++++++++++++++++------ include/net/xdp_sock_drv.h | 26 ++++++-------------------- include/net/xsk_buff_pool.h | 2 ++ net/core/filter.c | 2 +- net/xdp/xdp_umem.c | 3 +-- net/xdp/xsk_buff_pool.c | 20 ++++++++++++-------- 6 files changed, 48 insertions(+), 37 deletions(-)
include/net/xdp.h +26 -6
@@ -65,6 +65,10 @@ struct xdp_rxq_info {u32 reg_state;struct xdp_mem_info mem;u32 frag_size; +/* Shared info of buffers with %XDP_FLAGS_SINFO_EXT, in the XSk buffer +* pool, set by xsk_pool_set_rxq_info(). +*/ +struct skb_shared_info *ext_sinfo; }____cacheline_aligned ;/* perf critical, avoid false-sharing */ struct xdp_txq_info {
@@ -81,6 +85,13 @@ enum xdp_buff_flags {* XDP program is not attached. */ XDP_FLAGS_FRAGS_UNREADABLE =BIT (2 ), +/* The shared info lives in &xdp_rxq_info.ext_sinfo, not at the end of +* the frame, as userspace may write the frame. The frame reserves no +* tailroom, so the data may reach its end. The pool builds one such +* buffer at a time, so a consumer that uses the shared info later +* must copy what it needs. +*/ + XDP_FLAGS_SINFO_EXT = BIT(3), }; struct xdp_buff {
@@ -178,17 +189,26 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,/* Reserve memory area at end-of data area. * -* This macro reserves tailroom in the XDP buffer by limiting the -* XDP/BPF data access to data_hard_end. Notice same area (and size) -* is used for XDP_PASS, when constructing the SKB via build_skb(). +* This reserves tailroom in the XDP buffer by limiting the XDP/BPF data +* access to data_hard_end. Notice same area (and size) is used for +* XDP_PASS, when constructing the SKB via build_skb(). Buffers with +* %XDP_FLAGS_SINFO_EXT keep the shared info elsewhere and reserve none. */ -#define xdp_data_hard_end (xdp) \ - ((xdp)->data_hard_start + (xdp)->frame_sz - \ - SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) +static __always_inline void *xdp_data_hard_end(const struct xdp_buff *xdp) +{ +u32 tailroom =SKB_DATA_ALIGN (sizeof (struct skb_shared_info )); + +if (xdp->flags &XDP_FLAGS_SINFO_EXT ) + tailroom =0 ; +return xdp->data_hard_start + xdp->frame_sz - tailroom; +}static inline struct skb_shared_info *xdp_get_shared_info_from_buff (const struct xdp_buff *xdp) { +if (xdp->flags &XDP_FLAGS_SINFO_EXT ) +return READ_ONCE (xdp->rxq)->ext_sinfo; +return (struct skb_shared_info *)xdp_data_hard_end (xdp); }
include/net/xdp_sock_drv.h +6 -20
@@ -41,11 +41,6 @@ static inline u32 xsk_pool_get_headroom(struct xsk_buff_pool *pool)return XDP_PACKET_HEADROOM + pool->headroom; } -static inline u32 xsk_pool_get_tailroom (bool mbuf) -{ -return mbuf ?SKB_DATA_ALIGN (sizeof (struct skb_shared_info )) :0 ; -} -static inline u32 xsk_pool_get_chunk_size (struct xsk_buff_pool *pool) {return pool->chunk_size;
@@ -58,18 +53,7 @@ static inline u32 __xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)static inline u32 xsk_pool_get_rx_frame_size (struct xsk_buff_pool *pool) { -u32 frame_size =__xsk_pool_get_rx_frame_size (pool); -struct xdp_umem *umem = pool->umem; -bool mbuf; - -/* Reserve tailroom only for zero-copy pools that opted into -* multi-buffer. The reserved area is used for skb_shared_info, -* matching the XDP core's xdp_data_hard_end() layout. -*/ - mbuf = pool->dev && (umem->flags &XDP_UMEM_SG_FLAG ); - frame_size -=xsk_pool_get_tailroom (mbuf); - -return ALIGN_DOWN (frame_size,128 ); +return ALIGN_DOWN (__xsk_pool_get_rx_frame_size (pool),128 ); }static inline u32 xsk_pool_get_rx_frag_step (struct xsk_buff_pool *pool)
@@ -152,7 +136,6 @@ static inline void xsk_buff_free(struct xdp_buff *xdp)xp_free (pos); } -xdp_get_shared_info_from_buff (xdp)->nr_frags =0 ;xdp_buff_clear_frags_flag (xdp); out:xp_free (xskb);
@@ -226,8 +209,11 @@ static inline void xsk_buff_set_size(struct xdp_buff *xdp, u32 size) xdp->data = xdp->data_hard_start +XDP_PACKET_HEADROOM ; xdp->data_meta = xdp->data; xdp->data_end = xdp->data + size; -/* Frags flag is cleared when the frags of a head are released */ - xdp->flags &=XDP_FLAGS_HAS_FRAGS ; +/* Frags flag is cleared when the frags of a head are released. The +* shared info stays in the pool, see xp_set_rxq_info(), also for a +* buffer whose flags a driver cleared. +*/ + xdp->flags = (xdp->flags &XDP_FLAGS_HAS_FRAGS ) |XDP_FLAGS_SINFO_EXT ; } static inline dma_addr_t xsk_buff_raw_get_dma(struct xsk_buff_pool *pool,
include/net/xsk_buff_pool.h +2 -0
@@ -95,6 +95,8 @@ struct xsk_buff_pool {* destructor callback. */ spinlock_t cq_prod_lock; +/* Own cache lines, as zero-copy multi-buffer Rx writes it per packet */ +struct skb_shared_info sinfo____cacheline_aligned_in_smp ;struct xdp_buff_xsk *free_heads[]; };
net/core/filter.c +1 -1
@@ -4510,7 +4510,7 @@ BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)return bpf_xdp_frags_increase_tail (xdp, offset); } -/* Notice that xdp_data_hard_end have reserved some tailroom */ +/* Notice that xdp_data_hard_end may have reserved some tailroom */ if (unlikely (data_end > data_hard_end))return -EINVAL ;
net/xdp/xdp_umem.c +1 -2
@@ -195,8 +195,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)if (!unaligned_chunks && chunks_rem)return -EINVAL ; -if (headroom > chunk_size -XDP_PACKET_HEADROOM - -SKB_DATA_ALIGN (sizeof (struct skb_shared_info )) -128 ) +if (headroom > chunk_size -XDP_PACKET_HEADROOM -128 )return -EINVAL ;if (mr->flags &XDP_UMEM_TX_METADATA_LEN ) {
net/xdp/xsk_buff_pool.c +12 -8
@@ -107,6 +107,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs, xskb = &pool->heads[i]; xskb->pool = pool; xskb->xdp.frame_sz = umem->chunk_size - umem->headroom; + xskb->xdp.flags =XDP_FLAGS_SINFO_EXT ;INIT_LIST_HEAD (&xskb->list_node);if (pool->unaligned) pool->free_heads[i] = xskb;
@@ -125,8 +126,15 @@ void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq) {u32 i; +/* Userspace may write the UMEM. Keep the shared info in the pool, +* and let the device write up to the end of each chunk. A NAPI may +* still run on the buffers, so publish the shared info first. +*/ + rxq->ext_sinfo = &pool->sinfo; +/* Pairs with READ_ONCE(xdp->rxq) in xdp_get_shared_info_from_buff() */ +smp_wmb ();for (i =0 ; i < pool->heads_cnt; i++) - pool->heads[i].xdp.rxq = rxq; +WRITE_ONCE (pool->heads[i].xdp.rxq, rxq); }EXPORT_SYMBOL (xp_set_rxq_info);
@@ -229,12 +237,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool, segs =1 ; } -/* open-code xsk_pool_get_rx_frame_size() as pool->dev is not -* set yet at this point; we are before getting down to driver -*/ - frame_size =__xsk_pool_get_rx_frame_size (pool) - -xsk_pool_get_tailroom (mbuf); - frame_size =ALIGN_DOWN (frame_size,128 ); + frame_size =xsk_pool_get_rx_frame_size (pool);if (needed > frame_size * segs) { err = -EINVAL ;
@@ -629,7 +632,8 @@ struct xdp_buff *xp_alloc(struct xsk_buff_pool *pool) xskb->xdp.data = xskb->xdp.data_hard_start +XDP_PACKET_HEADROOM ; xskb->xdp.data_meta = xskb->xdp.data; - xskb->xdp.flags &=XDP_FLAGS_HAS_FRAGS ; + xskb->xdp.flags = (xskb->xdp.flags &XDP_FLAGS_HAS_FRAGS ) | +XDP_FLAGS_SINFO_EXT ;if (pool->dev)xp_dma_sync_for_device (pool, xskb->dma, pool->frame_len);
Signature · 1 line
2.53.1-Meta