From owner-freebsd-net@FreeBSD.ORG Fri Jan 2 15:37:14 2015 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 65F615DE for ; Fri, 2 Jan 2015 15:37:14 +0000 (UTC) Received: from forward-corp1m.cmail.yandex.net (forward-corp1m.cmail.yandex.net [IPv6:2a02:6b8:b030::69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Certum Level IV CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 15EDB662A6 for ; Fri, 2 Jan 2015 15:37:13 +0000 (UTC) Received: from smtpcorp1m.mail.yandex.net (smtpcorp1m.mail.yandex.net [77.88.61.150]) by forward-corp1m.cmail.yandex.net (Yandex) with ESMTP id 4BC726038E for ; Fri, 2 Jan 2015 18:36:59 +0300 (MSK) Received: from smtpcorp1m.mail.yandex.net (localhost [127.0.0.1]) by smtpcorp1m.mail.yandex.net (Yandex) with ESMTP id 902652CA03DC for ; Fri, 2 Jan 2015 18:36:59 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:401:222:4dff:fe50:cd2f]) by smtpcorp1m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id XsuR3qlBTU-axlCMapc; Fri, 2 Jan 2015 18:36:59 +0300 (using TLSv1.2 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1420213019; bh=VjQEz2vgS7q5uENInJ0wiAuVaPgHxhMCSduYboI2L78=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Content-Transfer-Encoding; b=lAZKmF3nktdNxp8Sgcnq63H9EMsw0nuSNkdQfP7PP/lepfSBDbv9iqmSxTS6VxkMa DgpBSC8ZpPVst6O3fEIJNft9f7rwwEk0JozhOo+D4Ei44Lelr/wVVsCuBI3taS7YDV xxWoTzsbCZ4ip4ickH+PzhaX7XUI8rbSutjmMW1o= Authentication-Results: smtpcorp1m.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Message-ID: <54A6BAE0.9020404@yandex-team.ru> Date: Fri, 02 Jan 2015 18:36:00 +0300 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "freebsd-net@freebsd.org" Subject: host pipes and netmap 'emulated mode' Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jan 2015 15:37:14 -0000 Hello list. It looks like it is impossible to use host pipes and emulated netmap mode in some cases. For example, if you're doing something like what traditional router do: packet processing, with kernel-visible logical interfaces, routing daemon running there, you can easily get a panic like this: #0 0xffffffff8094aa76 at kdb_backtrace+0x66 #1 0xffffffff809104ee at panic+0x1ce #2 0xffffffff80cf9660 at trap_fatal+0x290 #3 0xffffffff80cf99c1 at trap_pfault+0x211 #4 0xffffffff80cf9f89 at trap+0x329 #5 0xffffffff80ce30d3 at calltrap+0x8 #6 0xffffffff809d3b5f at ether_demux+0x6f #7 0xffffffff809d3f34 at ether_nh_input+0x204 #8 0xffffffff809dd6d8 at netisr_dispatch_src+0x218 #9 0xffffffff8061b2b5 at netmap_send_up+0x35 #10 0xffffffff8061b3d7 at netmap_txsync_to_host+0x97 #11 0xffffffff8061b400 at netmap_txsync_to_host_compat+0x10 #12 0xffffffff8061de8c at netmap_poll+0x2fc #13 0xffffffff807f2313 at devfs_poll_f+0x63 #14 0xffffffff8095ea3d at sys_poll+0x35d #15 0xffffffff80cf8e0a at amd64_syscall+0x5ea #16 0xffffffff80ce33b7 at Xfast_syscall+0xf7 Uptime: 4m21s The problem here is the following: netmap changes if_input() for the logical network interface and always assumes that generic_rx_handler() is called with netmap-enabled ifp (e.g. original inteface). Unfortunately, there are cases where we have different ifp passed to if_input handler. This particular case is triggered by (*ifp->if_input)(ifv->ifv_ifp, m); line, where "ifp" represents netmap-enabled NIC, and ifv->ifv_ifp represents vlan subinterface. Then, generic_rx_handler() tries to looking NA/GNA structure but fails since vlan subinterface is not netmap-enabled. So, it looks like that we need a way to call original if_input() but I can't imagine (good) one/