Date: Fri, 6 Jun 2014 15:17:19 +0000 (UTC) From: Luigi Rizzo <luigi@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267168 - head/sys/net Message-ID: <201406061517.s56FHJoL087249@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: luigi Date: Fri Jun 6 15:17:19 2014 New Revision: 267168 URL: http://svnweb.freebsd.org/changeset/base/267168 Log: misc bugfixes: - stdio.h is needed for fprint() - make memsize uint32_t to avoid errors due to overflow - honor the *XPOLL flagg in NIOCREGIF requests - mmap fails wit MAP_FAILED, not NULL. MFC after: 3 days Modified: head/sys/net/netmap_user.h Modified: head/sys/net/netmap_user.h ============================================================================== --- head/sys/net/netmap_user.h Fri Jun 6 15:15:27 2014 (r267167) +++ head/sys/net/netmap_user.h Fri Jun 6 15:17:19 2014 (r267168) @@ -133,6 +133,7 @@ nm_ring_space(struct netmap_ring *ring) #ifndef HAVE_NETMAP_WITH_LIBS #define HAVE_NETMAP_WITH_LIBS +#include <stdio.h> #include <sys/time.h> #include <sys/mman.h> #include <string.h> /* memset */ @@ -192,7 +193,7 @@ struct nm_desc { struct nm_desc *self; /* point to self if netmap. */ int fd; void *mem; - int memsize; + uint32_t memsize; int done_mmap; /* set if mem is the result of mmap */ struct netmap_if * const nifp; uint16_t first_tx_ring, last_tx_ring, cur_tx_ring; @@ -404,8 +405,6 @@ nm_open(const char *ifname, const struct errmsg = "invalid ringid"; goto fail; } - /* add the *XPOLL flags */ - nr_ringid |= new_flags & (NETMAP_NO_TX_POLL | NETMAP_DO_RX_POLL); d = (struct nm_desc *)calloc(1, sizeof(*d)); if (d == NULL) { @@ -461,6 +460,9 @@ nm_open(const char *ifname, const struct d->req.nr_flags = parent->req.nr_flags; } } + /* add the *XPOLL flags */ + d->req.nr_ringid |= new_flags & (NETMAP_NO_TX_POLL | NETMAP_DO_RX_POLL); + if (ioctl(d->fd, NIOCREGIF, &d->req)) { errmsg = "NIOCREGIF failed"; goto fail; @@ -472,10 +474,11 @@ nm_open(const char *ifname, const struct d->memsize = parent->memsize; d->mem = parent->mem; } else { + /* XXX TODO: check if memsize is too large (or there is overflow) */ d->memsize = d->req.nr_memsize; d->mem = mmap(0, d->memsize, PROT_WRITE | PROT_READ, MAP_SHARED, d->fd, 0); - if (d->mem == NULL) { + if (d->mem == MAP_FAILED) { errmsg = "mmap failed"; goto fail; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406061517.s56FHJoL087249>