....and of course the stuff in your two previous e-mails :-). /Magnus
On Wed, Dec 12, 2018 at 8:59 AM Magnus Karlsson <magnus.karls...@gmail.com> wrote: > > On Wed, Dec 12, 2018 at 2:15 AM Daniel Borkmann <dan...@iogearbox.net> wrote: > > > > On 12/10/2018 04:34 PM, Magnus Karlsson wrote: > > [...] > > > +int xsk_create_umem(void *umem_area, __u64 size, struct xsk_prod_ring > > > *fq, > > > + struct xsk_cons_ring *cq, > > > + struct xsk_umem_config *usr_config) > > > +{ > > > + struct xdp_mmap_offsets off; > > > + struct xsk_umem_info *umem; > > > + struct xdp_umem_reg mr; > > > + socklen_t optlen; > > > + int err, fd; > > > + void *map; > > > + > > > + if (!umem_area) > > > + return -EFAULT; > > > + if (!size && !xsk_page_aligned(umem_area)) > > > + return -EINVAL; > > > + > > > + fd = socket(AF_XDP, SOCK_RAW, 0); > > > + if (fd < 0) > > > + return -errno; > > > + > > > + umem = calloc(1, sizeof(*umem)); > > > + if (!umem) > > > + return -ENOMEM; > > > > On error, we should also close fd and not 'leak' it into the app, similar > > for other errors below. Same in xsk_create_xdp_socket(), etc. > > Yes definitely. My bad. Will fix this and undoing the mmaps plus any > memory allocation and send a v2. > > Thanks: Magnus