From owner-svn-src-head@FreeBSD.ORG Fri Jun 6 15:17:20 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2A227AB7; Fri, 6 Jun 2014 15:17:20 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F2B392CB0; Fri, 6 Jun 2014 15:17:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s56FHJE3087250; Fri, 6 Jun 2014 15:17:19 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s56FHJoL087249; Fri, 6 Jun 2014 15:17:19 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201406061517.s56FHJoL087249@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 6 Jun 2014 15:17:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267168 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jun 2014 15:17:20 -0000 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 #include #include #include /* 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; }