* Re: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
2025-10-22 12:52 ` [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff() Maciej Fijalkowski
@ 2025-10-22 14:53 ` kernel test robot
2025-10-22 14:53 ` kernel test robot
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-10-22 14:53 UTC (permalink / raw)
To: Maciej Fijalkowski, bpf, ast, daniel, hawk
Cc: llvm, oe-kbuild-all, netdev, magnus.karlsson, aleksander.lobakin,
ilias.apalodimas, toke, lorenzo, kuba, Maciej Fijalkowski,
syzbot+ff145014d6b0ce64a173, Ihor Solodrai, Octavian Purdila
Hi Maciej,
kernel test robot noticed the following build errors:
[auto build test ERROR on bpf/master]
url: https://github.com/intel-lab-lkp/linux/commits/Maciej-Fijalkowski/xdp-introduce-xdp_convert_skb_to_buff/20251022-210958
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
patch link: https://lore.kernel.org/r/20251022125209.2649287-2-maciej.fijalkowski%40intel.com
patch subject: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
config: i386-buildonly-randconfig-002-20251022 (https://download.01.org/0day-ci/archive/20251022/202510222209.D4RDn4DI-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251022/202510222209.D4RDn4DI-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510222209.D4RDn4DI-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from fs/select.c:33:
In file included from include/net/busy_poll.h:19:
>> include/net/xdp.h:398:10: error: incompatible pointer to integer conversion assigning to 'u32' (aka 'unsigned int') from 'sk_buff_data_t' (aka 'unsigned char *') [-Wint-conversion]
398 | pkt_len = skb->tail - skb->mac_header;
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
vim +398 include/net/xdp.h
386
387 static inline
388 void xdp_convert_skb_to_buff(struct sk_buff *skb, struct xdp_buff *xdp,
389 struct xdp_rxq_info *xdp_rxq)
390 {
391 u32 frame_sz, pkt_len;
392
393 /* SKB "head" area always have tailroom for skb_shared_info */
394 frame_sz = skb_end_pointer(skb) - skb->head;
395 frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
396
397 DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
> 398 pkt_len = skb->tail - skb->mac_header;
399
400 xdp_init_buff(xdp, frame_sz, xdp_rxq);
401 xdp_prepare_buff(xdp, skb->head, skb->mac_header, pkt_len, true);
402
403 if (skb_is_nonlinear(skb)) {
404 skb_shinfo(skb)->xdp_frags_size = skb->data_len;
405 xdp_buff_set_frags_flag(xdp);
406 } else {
407 xdp_buff_clear_frags_flag(xdp);
408 }
409
410 xdp->rxq->mem.type = page_pool_page_is_pp(virt_to_head_page(xdp->data)) ?
411 MEM_TYPE_PAGE_POOL : MEM_TYPE_PAGE_SHARED;
412 }
413
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
2025-10-22 12:52 ` [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff() Maciej Fijalkowski
2025-10-22 14:53 ` kernel test robot
@ 2025-10-22 14:53 ` kernel test robot
2025-10-22 14:54 ` kernel test robot
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-10-22 14:53 UTC (permalink / raw)
To: Maciej Fijalkowski, bpf, ast, daniel, hawk
Cc: oe-kbuild-all, netdev, magnus.karlsson, aleksander.lobakin,
ilias.apalodimas, toke, lorenzo, kuba, Maciej Fijalkowski,
syzbot+ff145014d6b0ce64a173, Ihor Solodrai, Octavian Purdila
Hi Maciej,
kernel test robot noticed the following build errors:
[auto build test ERROR on bpf/master]
url: https://github.com/intel-lab-lkp/linux/commits/Maciej-Fijalkowski/xdp-introduce-xdp_convert_skb_to_buff/20251022-210958
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
patch link: https://lore.kernel.org/r/20251022125209.2649287-2-maciej.fijalkowski%40intel.com
patch subject: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
config: i386-buildonly-randconfig-003-20251022 (https://download.01.org/0day-ci/archive/20251022/202510222254.hbsPvf4c-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251022/202510222254.hbsPvf4c-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510222254.hbsPvf4c-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/net/busy_poll.h:19,
from io_uring/napi.h:8,
from io_uring/io_uring.c:97:
include/net/xdp.h: In function 'xdp_convert_skb_to_buff':
>> include/net/xdp.h:398:17: error: assignment to 'u32' {aka 'unsigned int'} from 'sk_buff_data_t' {aka 'unsigned char *'} makes integer from pointer without a cast [-Wint-conversion]
398 | pkt_len = skb->tail - skb->mac_header;
| ^
vim +398 include/net/xdp.h
386
387 static inline
388 void xdp_convert_skb_to_buff(struct sk_buff *skb, struct xdp_buff *xdp,
389 struct xdp_rxq_info *xdp_rxq)
390 {
391 u32 frame_sz, pkt_len;
392
393 /* SKB "head" area always have tailroom for skb_shared_info */
394 frame_sz = skb_end_pointer(skb) - skb->head;
395 frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
396
397 DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
> 398 pkt_len = skb->tail - skb->mac_header;
399
400 xdp_init_buff(xdp, frame_sz, xdp_rxq);
401 xdp_prepare_buff(xdp, skb->head, skb->mac_header, pkt_len, true);
402
403 if (skb_is_nonlinear(skb)) {
404 skb_shinfo(skb)->xdp_frags_size = skb->data_len;
405 xdp_buff_set_frags_flag(xdp);
406 } else {
407 xdp_buff_clear_frags_flag(xdp);
408 }
409
410 xdp->rxq->mem.type = page_pool_page_is_pp(virt_to_head_page(xdp->data)) ?
411 MEM_TYPE_PAGE_POOL : MEM_TYPE_PAGE_SHARED;
412 }
413
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
2025-10-22 12:52 ` [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff() Maciej Fijalkowski
2025-10-22 14:53 ` kernel test robot
2025-10-22 14:53 ` kernel test robot
@ 2025-10-22 14:54 ` kernel test robot
2025-10-24 8:07 ` kernel test robot
2025-10-24 9:25 ` Toke Høiland-Jørgensen
4 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-10-22 14:54 UTC (permalink / raw)
To: Maciej Fijalkowski, bpf, ast, daniel, hawk
Cc: oe-kbuild-all, netdev, magnus.karlsson, aleksander.lobakin,
ilias.apalodimas, toke, lorenzo, kuba, Maciej Fijalkowski,
syzbot+ff145014d6b0ce64a173, Ihor Solodrai, Octavian Purdila
Hi Maciej,
kernel test robot noticed the following build warnings:
[auto build test WARNING on bpf/master]
url: https://github.com/intel-lab-lkp/linux/commits/Maciej-Fijalkowski/xdp-introduce-xdp_convert_skb_to_buff/20251022-210958
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
patch link: https://lore.kernel.org/r/20251022125209.2649287-2-maciej.fijalkowski%40intel.com
patch subject: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
config: arm-randconfig-002-20251022 (https://download.01.org/0day-ci/archive/20251022/202510222206.mGdKZo2R-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251022/202510222206.mGdKZo2R-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510222206.mGdKZo2R-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/net/busy_poll.h:19,
from fs/select.c:33:
include/net/xdp.h: In function 'xdp_convert_skb_to_buff':
>> include/net/xdp.h:398:10: warning: assignment to 'u32' {aka 'unsigned int'} from 'sk_buff_data_t' {aka 'unsigned char *'} makes integer from pointer without a cast [-Wint-conversion]
398 | pkt_len = skb->tail - skb->mac_header;
| ^
vim +398 include/net/xdp.h
386
387 static inline
388 void xdp_convert_skb_to_buff(struct sk_buff *skb, struct xdp_buff *xdp,
389 struct xdp_rxq_info *xdp_rxq)
390 {
391 u32 frame_sz, pkt_len;
392
393 /* SKB "head" area always have tailroom for skb_shared_info */
394 frame_sz = skb_end_pointer(skb) - skb->head;
395 frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
396
397 DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
> 398 pkt_len = skb->tail - skb->mac_header;
399
400 xdp_init_buff(xdp, frame_sz, xdp_rxq);
401 xdp_prepare_buff(xdp, skb->head, skb->mac_header, pkt_len, true);
402
403 if (skb_is_nonlinear(skb)) {
404 skb_shinfo(skb)->xdp_frags_size = skb->data_len;
405 xdp_buff_set_frags_flag(xdp);
406 } else {
407 xdp_buff_clear_frags_flag(xdp);
408 }
409
410 xdp->rxq->mem.type = page_pool_page_is_pp(virt_to_head_page(xdp->data)) ?
411 MEM_TYPE_PAGE_POOL : MEM_TYPE_PAGE_SHARED;
412 }
413
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
2025-10-22 12:52 ` [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff() Maciej Fijalkowski
` (2 preceding siblings ...)
2025-10-22 14:54 ` kernel test robot
@ 2025-10-24 8:07 ` kernel test robot
2025-10-24 9:25 ` Toke Høiland-Jørgensen
4 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-10-24 8:07 UTC (permalink / raw)
To: Maciej Fijalkowski, bpf, ast, daniel, hawk
Cc: oe-kbuild-all, netdev, magnus.karlsson, aleksander.lobakin,
ilias.apalodimas, toke, lorenzo, kuba, Maciej Fijalkowski,
syzbot+ff145014d6b0ce64a173, Ihor Solodrai, Octavian Purdila
Hi Maciej,
kernel test robot noticed the following build warnings:
[auto build test WARNING on bpf/master]
url: https://github.com/intel-lab-lkp/linux/commits/Maciej-Fijalkowski/xdp-introduce-xdp_convert_skb_to_buff/20251022-210958
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
patch link: https://lore.kernel.org/r/20251022125209.2649287-2-maciej.fijalkowski%40intel.com
patch subject: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
config: sh-randconfig-r111-20251024 (https://download.01.org/0day-ci/archive/20251024/202510241549.mWZqm0BR-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251024/202510241549.mWZqm0BR-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510241549.mWZqm0BR-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
net/core/dev.c:4164:17: sparse: sparse: context imbalance in '__dev_queue_xmit' - different lock contexts for basic block
net/core/dev.c:5188:9: sparse: sparse: context imbalance in 'kick_defer_list_purge' - different lock contexts for basic block
net/core/dev.c:5290:22: sparse: sparse: context imbalance in 'enqueue_to_backlog' - different lock contexts for basic block
net/core/dev.c: note: in included file (through include/trace/events/xdp.h, include/linux/bpf_trace.h):
>> include/net/xdp.h:398:17: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] pkt_len @@ got unsigned char * @@
include/net/xdp.h:398:17: sparse: expected unsigned int [usertype] pkt_len
include/net/xdp.h:398:17: sparse: got unsigned char *
net/core/dev.c:5678:17: sparse: sparse: context imbalance in 'net_tx_action' - different lock contexts for basic block
net/core/dev.c:6373:9: sparse: sparse: context imbalance in 'flush_backlog' - different lock contexts for basic block
net/core/dev.c:6520:9: sparse: sparse: context imbalance in 'process_backlog' - different lock contexts for basic block
vim +398 include/net/xdp.h
386
387 static inline
388 void xdp_convert_skb_to_buff(struct sk_buff *skb, struct xdp_buff *xdp,
389 struct xdp_rxq_info *xdp_rxq)
390 {
391 u32 frame_sz, pkt_len;
392
393 /* SKB "head" area always have tailroom for skb_shared_info */
394 frame_sz = skb_end_pointer(skb) - skb->head;
395 frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
396
397 DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
> 398 pkt_len = skb->tail - skb->mac_header;
399
400 xdp_init_buff(xdp, frame_sz, xdp_rxq);
401 xdp_prepare_buff(xdp, skb->head, skb->mac_header, pkt_len, true);
402
403 if (skb_is_nonlinear(skb)) {
404 skb_shinfo(skb)->xdp_frags_size = skb->data_len;
405 xdp_buff_set_frags_flag(xdp);
406 } else {
407 xdp_buff_clear_frags_flag(xdp);
408 }
409
410 xdp->rxq->mem.type = page_pool_page_is_pp(virt_to_head_page(xdp->data)) ?
411 MEM_TYPE_PAGE_POOL : MEM_TYPE_PAGE_SHARED;
412 }
413
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
2025-10-22 12:52 ` [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff() Maciej Fijalkowski
` (3 preceding siblings ...)
2025-10-24 8:07 ` kernel test robot
@ 2025-10-24 9:25 ` Toke Høiland-Jørgensen
2025-10-24 17:19 ` Maciej Fijalkowski
4 siblings, 1 reply; 9+ messages in thread
From: Toke Høiland-Jørgensen @ 2025-10-24 9:25 UTC (permalink / raw)
To: Maciej Fijalkowski, bpf, ast, daniel, hawk
Cc: netdev, magnus.karlsson, aleksander.lobakin, ilias.apalodimas,
lorenzo, kuba, Maciej Fijalkowski, syzbot+ff145014d6b0ce64a173,
Ihor Solodrai, Octavian Purdila
Maciej Fijalkowski <maciej.fijalkowski@intel.com> writes:
> Currently, generic XDP hook uses xdp_rxq_info from netstack Rx queues
> which do not have its XDP memory model registered. There is a case when
> XDP program calls bpf_xdp_adjust_tail() BPF helper, which in turn
> releases underlying memory. This happens when it consumes enough amount
> of bytes and when XDP buffer has fragments. For this action the memory
> model knowledge passed to XDP program is crucial so that core can call
> suitable function for freeing/recycling the page.
>
> For netstack queues it defaults to MEM_TYPE_PAGE_SHARED (0) due to lack
> of mem model registration. The problem we're fixing here is when kernel
> copied the skb to new buffer backed by system's page_pool and XDP buffer
> is built around it. Then when bpf_xdp_adjust_tail() calls
> __xdp_return(), it acts incorrectly due to mem type not being set to
> MEM_TYPE_PAGE_POOL and causes a page leak.
>
> Pull out the existing code from bpf_prog_run_generic_xdp() that
> init/prepares xdp_buff onto new helper xdp_convert_skb_to_buff() and
> embed there rxq's mem_type initialization that is assigned to xdp_buff.
> Make it agnostic to current skb->data position.
>
> This problem was triggered by syzbot as well as AF_XDP test suite which
> is about to be integrated to BPF CI.
>
> Reported-by: syzbot+ff145014d6b0ce64a173@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/6756c37b.050a0220.a30f1.019a.GAE@google.com/
> Fixes: e6d5dbdd20aa ("xdp: add multi-buff support for xdp running in generic mode")
> Tested-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
> Co-developed-by: Octavian Purdila <tavip@google.com>
> Signed-off-by: Octavian Purdila <tavip@google.com> # whole analysis, testing, initiating a fix
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> # commit msg and proposed more robust fix
> ---
> include/net/xdp.h | 27 +++++++++++++++++++++++++++
> net/core/dev.c | 25 ++++---------------------
> 2 files changed, 31 insertions(+), 21 deletions(-)
>
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index aa742f413c35..cec43f56ae9a 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
> @@ -384,6 +384,33 @@ struct sk_buff *xdp_build_skb_from_frame(struct xdp_frame *xdpf,
> struct net_device *dev);
> struct xdp_frame *xdpf_clone(struct xdp_frame *xdpf);
>
> +static inline
> +void xdp_convert_skb_to_buff(struct sk_buff *skb, struct xdp_buff *xdp,
> + struct xdp_rxq_info *xdp_rxq)
> +{
> + u32 frame_sz, pkt_len;
> +
> + /* SKB "head" area always have tailroom for skb_shared_info */
> + frame_sz = skb_end_pointer(skb) - skb->head;
> + frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> +
> + DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
> + pkt_len = skb->tail - skb->mac_header;
Should probably just use the helpers here:
pkt_len = skb_tail_pointer(skb) - skb_mac_header(skb);
that way you don't have to open-code the WARN_ON_ONCE, and you get the
right behaviour even when NET_SKBUFF_DATA_USES_OFFSET is set
-Toke
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 bpf 1/2] xdp: introduce xdp_convert_skb_to_buff()
2025-10-24 9:25 ` Toke Høiland-Jørgensen
@ 2025-10-24 17:19 ` Maciej Fijalkowski
0 siblings, 0 replies; 9+ messages in thread
From: Maciej Fijalkowski @ 2025-10-24 17:19 UTC (permalink / raw)
To: Toke Høiland-Jørgensen
Cc: bpf, ast, daniel, hawk, netdev, magnus.karlsson,
aleksander.lobakin, ilias.apalodimas, lorenzo, kuba,
syzbot+ff145014d6b0ce64a173, Ihor Solodrai, Octavian Purdila
On Fri, Oct 24, 2025 at 11:25:26AM +0200, Toke Høiland-Jørgensen wrote:
> Maciej Fijalkowski <maciej.fijalkowski@intel.com> writes:
>
> > Currently, generic XDP hook uses xdp_rxq_info from netstack Rx queues
> > which do not have its XDP memory model registered. There is a case when
> > XDP program calls bpf_xdp_adjust_tail() BPF helper, which in turn
> > releases underlying memory. This happens when it consumes enough amount
> > of bytes and when XDP buffer has fragments. For this action the memory
> > model knowledge passed to XDP program is crucial so that core can call
> > suitable function for freeing/recycling the page.
> >
> > For netstack queues it defaults to MEM_TYPE_PAGE_SHARED (0) due to lack
> > of mem model registration. The problem we're fixing here is when kernel
> > copied the skb to new buffer backed by system's page_pool and XDP buffer
> > is built around it. Then when bpf_xdp_adjust_tail() calls
> > __xdp_return(), it acts incorrectly due to mem type not being set to
> > MEM_TYPE_PAGE_POOL and causes a page leak.
> >
> > Pull out the existing code from bpf_prog_run_generic_xdp() that
> > init/prepares xdp_buff onto new helper xdp_convert_skb_to_buff() and
> > embed there rxq's mem_type initialization that is assigned to xdp_buff.
> > Make it agnostic to current skb->data position.
> >
> > This problem was triggered by syzbot as well as AF_XDP test suite which
> > is about to be integrated to BPF CI.
> >
> > Reported-by: syzbot+ff145014d6b0ce64a173@syzkaller.appspotmail.com
> > Closes: https://lore.kernel.org/netdev/6756c37b.050a0220.a30f1.019a.GAE@google.com/
> > Fixes: e6d5dbdd20aa ("xdp: add multi-buff support for xdp running in generic mode")
> > Tested-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> > Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
> > Co-developed-by: Octavian Purdila <tavip@google.com>
> > Signed-off-by: Octavian Purdila <tavip@google.com> # whole analysis, testing, initiating a fix
> > Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> # commit msg and proposed more robust fix
> > ---
> > include/net/xdp.h | 27 +++++++++++++++++++++++++++
> > net/core/dev.c | 25 ++++---------------------
> > 2 files changed, 31 insertions(+), 21 deletions(-)
> >
> > diff --git a/include/net/xdp.h b/include/net/xdp.h
> > index aa742f413c35..cec43f56ae9a 100644
> > --- a/include/net/xdp.h
> > +++ b/include/net/xdp.h
> > @@ -384,6 +384,33 @@ struct sk_buff *xdp_build_skb_from_frame(struct xdp_frame *xdpf,
> > struct net_device *dev);
> > struct xdp_frame *xdpf_clone(struct xdp_frame *xdpf);
> >
> > +static inline
> > +void xdp_convert_skb_to_buff(struct sk_buff *skb, struct xdp_buff *xdp,
> > + struct xdp_rxq_info *xdp_rxq)
> > +{
> > + u32 frame_sz, pkt_len;
> > +
> > + /* SKB "head" area always have tailroom for skb_shared_info */
> > + frame_sz = skb_end_pointer(skb) - skb->head;
> > + frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> > +
> > + DEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));
> > + pkt_len = skb->tail - skb->mac_header;
>
> Should probably just use the helpers here:
>
> pkt_len = skb_tail_pointer(skb) - skb_mac_header(skb);
>
> that way you don't have to open-code the WARN_ON_ONCE, and you get the
> right behaviour even when NET_SKBUFF_DATA_USES_OFFSET is set
Exactly, I thought I could just strip out skb->head out of calculation,
but apparently not ;)
>
> -Toke
>
^ permalink raw reply [flat|nested] 9+ messages in thread