Re: Forwarding packets to the host stack in net map lb app
Date: Mon, 26 Sep 2022 16:05:03 UTC
I think you could avoid any modifications to lb(8) and take advantage of the "multiple pipe groups" feature. You open two groups, # 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. 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). 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. Cheers, Vincenzo Il giorno dom 18 set 2022 alle ore 23:47 Kim Shrier <kim@westryn.net> ha scritto: > I have a network monitoring program and I am using the lb app from > netmap to distribute packets to netmap pipes. The monitor processes > are successfully receiving packets. > > I would like to modify lb to send some packets to the host stack and > have packets coming from the host stack go out on the monitoring > ethernet interface. > > I am relatively new to using netmap and it is not obvious to me how > to properly send/receive some packets to the host tx/rx rings while > still letting the the netmap pipes forward packets to my monitoring > application. > > I have looked at the bridge app from netmap which opens 2 netmap > ports. It does not seem to me that that would be the right way to > deal with the host stack in the context of lb. > > Should I just process the last tx/rx ring differently from the first ones > that are forwarding packets to the netmap pipes? > > Thanks, > Kim > > > >