[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ8uoz3cCsEJ5ttf3OnU2Gb5eOYTTzGuVT-JzZjYa+gPT_ZV2g@mail.gmail.com>
Date: Wed, 12 Dec 2018 09:08:06 +0100
From: Magnus Karlsson <magnus.karlsson@...il.com>
To: Daniel Borkmann <daniel@...earbox.net>
Cc: Magnus Karlsson <magnus.karlsson@...el.com>,
Björn Töpel <bjorn.topel@...el.com>,
ast@...nel.org, Network Development <netdev@...r.kernel.org>,
Jakub Kicinski <jakub.kicinski@...ronome.com>,
Björn Töpel <bjorn.topel@...il.com>,
"Zhang, Qi Z" <qi.z.zhang@...el.com>,
Jesper Dangaard Brouer <brouer@...hat.com>
Subject: Re: [PATCH bpf-next 1/2] libbpf: add support for using AF_XDP sockets
....and of course the stuff in your two previous e-mails :-).
/Magnus
On Wed, Dec 12, 2018 at 8:59 AM Magnus Karlsson
<magnus.karlsson@...il.com> wrote:
>
> On Wed, Dec 12, 2018 at 2:15 AM Daniel Borkmann <daniel@...earbox.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
Powered by blists - more mailing lists