From nobody Mon Sep 26 17:21:19 2022 X-Original-To: net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MbqKz4t3Gz4YKVk for ; Mon, 26 Sep 2022 17:21:27 +0000 (UTC) (envelope-from kim@westryn.net) Received: from mail.westryn.net (mail.westryn.net [199.48.135.251]) (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 4MbqKy6PQLz3Kkd; Mon, 26 Sep 2022 17:21:26 +0000 (UTC) (envelope-from kim@westryn.net) Received: from smtpclient.apple (225x169.ouraynet.com [204.16.225.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.westryn.net (Postfix) with ESMTPSA id 18CDC9432A1; Mon, 26 Sep 2022 11:21:20 -0600 (MDT) Content-Type: text/plain; charset=us-ascii List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Forwarding packets to the host stack in net map lb app From: Kim Shrier In-Reply-To: Date: Mon, 26 Sep 2022 11:21:19 -0600 Cc: "net@freebsd.org" , Giuseppe Lettieri Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Vincenzo Maffione X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Rspamd-Queue-Id: 4MbqKy6PQLz3Kkd X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of kim@westryn.net designates 199.48.135.251 as permitted sender) smtp.mailfrom=kim@westryn.net X-Spamd-Result: default: False [-2.80 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:199.48.135.251]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[net@freebsd.org]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:36236, ipnet:199.48.132.0/22, country:US]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[westryn.net]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Thanks for your input. In the interim, I have actually implemented your second (harder) option = and it appears to be working quite well. I am still testing but it does = look promising. Kim > On Sep 26, 2022, at 10:05 AM, Vincenzo Maffione = wrote: >=20 > I think you could avoid any modifications to lb(8) and take advantage = of the "multiple pipe groups" feature. > You open two groups,=20 > # lb -i netmap:em0/R -p mon:$N -p fwd:$M [...] > Each group receives all the packets arriving on the RX (NIC) rings of = em0. (I'm pretty sure) this happens without packet copies, i.e. by = swapping netmap slots. >=20 > The first group (mon) is for your existing monitor process. The second = one (fwd) would be used for a separate process that handles the host = stack: > - It reads from fwd:$M pipes, selecting only the RX packets that = should be forwarded to the host stack. Selected packets will be = forwarded to netmap:em0^/T. All the other packets are just dropped. > - it forwards all traffic from netmap:em0^/R to netmap:em0/T (e.g. = from the em0 host RX ring to the em0 TX rings). Keep in mind that lb = does not touch em0 TX rings, so there would not be conflicts. In any = case, it is good practice to have lb only open RX rings (netmap:em0/R). > This second process can probably be a modified version of the netmap = bridge, although you have asymmetric three-party forwarding here (fwd/R = --> netmap:em0^T, netmap:em0^/R --> netmap:em0/T). >=20 > The alternative (harder) option would be to actually modify lb(8). You = should probably: > - open netmap:em0^/R and netmap:em0*/T with separate nmport_open() = calls > - parse the packet before pkt_hdr_hash() to select the RX packets = that you need to forward to the host TX ring, and modify the forwarding = logic to perform this task. > - modify the logic of the lb poll() loop so that it also performs the = forwarding from host RX rings to NIC TX rings > I'm not sure that you would have any advantages by choosing this path. >=20 > Cheers, > Vincenzo >=20