Re: [PATCH v18 bpf-next 20/23] net: xdp: introduce bpf_xdp_pointer utility routine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 15 Nov 2021 23:33:14 +0100 Lorenzo Bianconi wrote:
> +	struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp);
> +	u32 headsize = xdp->data_end - xdp->data;
> +	u32 count = 0, frame_offset = headsize;
> +	int i;
> +
> +	if (offset < headsize) {
> +		int size = min_t(int, headsize - offset, len);
> +		void *src = flush ? buf : xdp->data + offset;
> +		void *dst = flush ? xdp->data + offset : buf;
> +
> +		memcpy(dst, src, size);
> +		count = size;
> +		offset = 0;
> +	}

is this missing
	else
		offset -= headsize;
?

I'm struggling to understand this. Say
	headsize = 400
	frag[0].size = 200

	offset = 500
	len = 50

we enter the loop having missed the previous if...

> +	for (i = 0; i < sinfo->nr_frags; i++) {
> +		skb_frag_t *frag = &sinfo->frags[i];
> +		u32 frag_size = skb_frag_size(frag);
> +
> +		if (count >= len)
> +			break;
> +
> +		if (offset < frame_offset + frag_size) {

		500 < 400 + 200 => true

> +			int size = min_t(int, frag_size - offset, len - count);

			size = min(200 - 500, 50 - 0)
			size = -300 ??

> +			void *addr = skb_frag_address(frag);
> +			void *src = flush ? buf + count : addr + offset;
> +			void *dst = flush ? addr + offset : buf + count;
> +
> +			memcpy(dst, src, size);
> +			count += size;
> +			offset = 0;
> +		}
> +		frame_offset += frag_size;



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux