Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Sep 2022 11:21:19 -0600
From:      Kim Shrier <kim@westryn.net>
To:        Vincenzo Maffione <vmaffione@freebsd.org>
Cc:        "net@freebsd.org" <net@freebsd.org>, Giuseppe Lettieri <giuseppe.lettieri@unipi.it>
Subject:   Re: Forwarding packets to the host stack in net map lb app
Message-ID:  <DBB84FA5-B7AF-40F1-A76D-FDE50E608686@westryn.net>
In-Reply-To: <CA%2B_eA9jkCYAfTeXho4fNTsqwSCXmxwCuvxkQV3BD_uz9XAAv4w@mail.gmail.com>
References:  <CB07794F-4719-4C1D-B64C-05C8335D329F@westryn.net> <CA%2B_eA9jkCYAfTeXho4fNTsqwSCXmxwCuvxkQV3BD_uz9XAAv4w@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 =
<vmaffione@freebsd.org> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DBB84FA5-B7AF-40F1-A76D-FDE50E608686>