Re: [PATCH bpf-next] xdp: introduce convert_to_xdp_buff utility routine

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

 



> On Tue, 26 May 2020 15:48:13 +0200
> Lorenzo Bianconi <lorenzo@xxxxxxxxxx> wrote:
> 

[...]

> > diff --git a/include/net/xdp.h b/include/net/xdp.h
> > index 90f11760bd12..5dbdd65866a9 100644
> > --- a/include/net/xdp.h
> > +++ b/include/net/xdp.h
> > @@ -106,6 +106,16 @@ void xdp_warn(const char *msg, const char *func, const int line);
> >  
> >  struct xdp_frame *xdp_convert_zc_to_xdp_frame(struct xdp_buff *xdp);
> >  
> > +static inline
> > +void convert_to_xdp_buff(struct xdp_frame *frame, struct xdp_buff *xdp)
> > +{
> > +	xdp->data_hard_start = (void *)frame;
> 
> This assumption is problematic.  You are suppose to deduct this from
> frame->data pointer.
> 
> Currently the xdp_frame is designed and access such that is is possible
> to use another memory area for xdp_frame.  That would break after this
> change.
> 
> This should instead be:
> 
>  xdp->data_hard_start = frame->data - (frame->headroom + sizeof(struct xdp_frame));

ack, fine. I will fix it v2.

Regards,
Lorenzo

> 
> > +	xdp->data = frame->data;
> > +	xdp->data_end = frame->data + frame->len;
> > +	xdp->data_meta = frame->data - frame->metasize;
> > +	xdp->frame_sz = frame->frame_sz;
> > +}
> > +
> 
> -- 
> Best regards,
>   Jesper Dangaard Brouer
>   MSc.CS, Principal Kernel Engineer at Red Hat
>   LinkedIn: http://www.linkedin.com/in/brouer
> 

Attachment: signature.asc
Description: PGP signature


[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