On Sun, Apr 26, 2020 at 03:23:54PM +0200, Pablo Neira Ayuso wrote: > Add two new helper functions to skip memcpy()'ing the payload from the > netlink message. > > Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> > --- > include/libnetfilter_queue/pktbuff.h | 3 +++ > src/extra/pktbuff.c | 20 ++++++++++++++++++++ > 2 files changed, 23 insertions(+) > > diff --git a/include/libnetfilter_queue/pktbuff.h b/include/libnetfilter_queue/pktbuff.h > index 42bc153ec337..f9bddaf072fb 100644 > --- a/include/libnetfilter_queue/pktbuff.h > +++ b/include/libnetfilter_queue/pktbuff.h > @@ -4,8 +4,11 @@ > struct pkt_buff; > > struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra); > +struct pkt_buff *pktb_alloc_head(void); > void pktb_free(struct pkt_buff *pktb); > > +void pktb_build_data(struct pkt_buff *pktb, uint8_t *payload, uint32_t len); > + > uint8_t *pktb_data(struct pkt_buff *pktb); > uint32_t pktb_len(struct pkt_buff *pktb); > > diff --git a/src/extra/pktbuff.c b/src/extra/pktbuff.c > index 6dd0ca98aff2..a93e72ac7795 100644 > --- a/src/extra/pktbuff.c > +++ b/src/extra/pktbuff.c > @@ -93,6 +93,26 @@ struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra) > return pktb; > } > > +EXPORT_SYMBOL > +struct pkt_buff *pktb_alloc_head(void) I think we agreed to dispense with this function? > +{ > + struct pkt_buff *pktb; > + > + pktb = calloc(1, sizeof(struct pkt_buff)); The callback (CB) needs to zeroise head: calling calloc() here is ineffective. At least the *mangled* flag must be cleared, also the new *copy_done* flag. > + if (pktb == NULL) > + return NULL; The above 2 lines are unnecessary > + > + return pktb; > +} > + > +EXPORT_SYMBOL > +void pktb_build_data(struct pkt_buff *pktb, uint8_t *payload, uint32_t len) > +{ > + pktb->len = len; > + pktb->data_len = len; > + pktb->data = payload; Also + mangled = false; Maybe nullify the other pointers? > +} > + > /** > * pktb_data - get pointer to network packet > * \param pktb Pointer to userspace packet buffer > -- > 2.20.1 > -Duncan