Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Dec 2017 08:56:35 +0100
From:      Vincenzo Maffione <v.maffione@gmail.com>
To:        Jim Thompson <jim@netgate.com>
Cc:        Ming Fu <Ming.Fu@esentire.com>,  "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>
Subject:   Re: Netmap: Build a network SPAN/TAP from netmap
Message-ID:  <CA%2B_eA9hZo5AW2Jhec_yKJcmQf4H6OhOH9kepssT4p4AVdywukQ@mail.gmail.com>
In-Reply-To: <3F8E159B-33FC-428E-9A18-64CC298EDBDD@netgate.com>
References:  <c861f08553874dc6b242be45ec6e4ef0@mbx02cmb01p.esentire.local> <3F8E159B-33FC-428E-9A18-64CC298EDBDD@netgate.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Yes, or if you prefer you can simply extend "bridge" forwarding logic to
copy every packet to an additional TAP port. Copying a packet in netmap is
just a matter of initialize the next struct netmap_slot in the destination
(TAP) netmap ring, memcpy() the packet payload and incrementing
ring->cur/ring->head (then you need to TXSYNC or poll() at the end of the
batch.
In any case the application will work on both FreeBSD and Linux, as the API
is the same.

You may also find useful to look at the netmap tutorial, to see more
examples and explanations: https://github.com/vmaffione/netmap-tutorial

Cheers,
  Vincenzo

2017-12-15 6:58 GMT+01:00 Jim Thompson <jim@netgate.com>:

>
>
> > On Dec 14, 2017, at 12:00 PM, Ming Fu <Ming.Fu@esentire.com> wrote:
> >
> > Hi,
> >
> > I am trying to explore the possibility to build a network SPAN/TAP from
> netmap. Similar to the bridge sample, but all packet going through the
> bridge also get copied to a SPAN port. How do I duplicate or clone an
> incoming packet and send the original to bridge peer and the cloned one t=
o
> the SPAN port? Is there an API like FreeBsd m_copypacket() for netmap?
> Would it work for Linux as well?
> >
> > Thanks
> > Ming
>
> Ming,
>
> I=E2=80=99d look at adapting netmap monitors.
>
>     https://github.com/luigirizzo/netmap/blob/master/sys/dev/
> netmap/netmap_monitor.c
>
> For the rest of the solution, look at netmap_user.h, where it explains ho=
w
> to open a port in monitor mode.
>
> https://github.com/luigirizzo/netmap/blob/master/sys/net/netmap_user.h
>
> Essentially, once you have an active netmap port e.g. netmap:ix0, you can
> sniff the traffic by opening additional netmap ports
> named netmap:ix0/r (for rx traffic) or netmap:ix0/t (for tx) or even
> netmap:ix0/rt  (for both tx and rx)
>
> The rest of the code (to inject frames back down another interface) can b=
e
> lifted from the bridge sample.
>
> You could also look at SF-TAP. http://sf-tap.github.io
>
> Jim
>
> _______________________________________________
> freebsd-net@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
>



--=20
Vincenzo Maffione



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B_eA9hZo5AW2Jhec_yKJcmQf4H6OhOH9kepssT4p4AVdywukQ>