From nobody@FreeBSD.org  Thu May 31 14:16:36 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id C1E6A106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 May 2012 14:16:36 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id AD58C8FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 May 2012 14:16:36 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q4VEGa9L070026
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 May 2012 14:16:36 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q4VEGaWp070025;
	Thu, 31 May 2012 14:16:36 GMT
	(envelope-from nobody)
Message-Id: <201205311416.q4VEGaWp070025@red.freebsd.org>
Date: Thu, 31 May 2012 14:16:36 GMT
From: Ming Fu <ming.fu@netsweeper.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Netmap code mixed up tx and rx in iterate counter
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         168497
>Category:       kern
>Synopsis:       Netmap code mixed up tx and rx in iterate counter
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 31 14:20:04 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Ming Fu
>Release:        MAIN
>Organization:
Netsweeper Technologies Inc
>Environment:
>Description:
The netmap_mem2.c function netmap_if_new() contains some Linux only code. However, these linux code have the rx and tx counter mixed up. This is discovered during our experiment of porting netmap to Linux. When the rx and tx has different queues, the mix up will lead to crash.

#ifdef linux
	// XXX initialize the selrecord structs.
	for (i = 0; i < ntx; i++)
-		init_waitqueue_head(&na->rx_rings[i].si);
+		init_waitqueue_head(&na->tx_rings[i].si);
	for (i = 0; i < nrx; i++)
-		init_waitqueue_head(&na->tx_rings[i].si);
+		init_waitqueue_head(&na->rx_rings[i].si);
	init_waitqueue_head(&na->rx_si);
	init_waitqueue_head(&na->tx_si);
#endif

A similar bug was present on the 20120322-netmap-linux.tgz at the beginning of the function netmap_if_new() where the nrx is assigned from the num_tx_queues. However, the second issue does not present in FreeBSD repository.
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
