Message ID | 1576270750-64238-1-git-send-email-u9012063@gmail.com |
---|---|
State | Rejected |
Delegated to: | Ilya Maximets |
Headers | show |
Series | [ovs-dev] netdev-afxdp: Add pcap dump support. | expand |
On 13.12.2019 21:59, William Tu wrote: > Debugging netdev-afxdp is hard because tcpdump does not work > at all, even for generic mode. ovs-tcpdump which uses port > mirroring also does not work for netdev-afxdp. Hmm. Why ovs-tcpdump doesn't work for you? It should not depend on port type. If it doesn't work we need to investigate this case and fix it because it's a very important tool. Best regards, Ilya Maximets.
On Mon, Dec 16, 2019 at 1:41 AM Ilya Maximets <i.maximets@ovn.org> wrote: > > On 13.12.2019 21:59, William Tu wrote: > > Debugging netdev-afxdp is hard because tcpdump does not work > > at all, even for generic mode. ovs-tcpdump which uses port > > mirroring also does not work for netdev-afxdp. > > Hmm. Why ovs-tcpdump doesn't work for you? It should not depend > on port type. If it doesn't work we need to investigate this > case and fix it because it's a very important tool. Because ovs-tcpdump still uses 'tcpdump' tool to capture packets, (dump-cmd=tcpdump) and forward to mirror port. Since tcpdump sees no packet at all when type=afxdp, there is no packets to mirror. William
On 16.12.2019 14:43, William Tu wrote: > On Mon, Dec 16, 2019 at 1:41 AM Ilya Maximets <i.maximets@ovn.org> wrote: >> >> On 13.12.2019 21:59, William Tu wrote: >>> Debugging netdev-afxdp is hard because tcpdump does not work >>> at all, even for generic mode. ovs-tcpdump which uses port >>> mirroring also does not work for netdev-afxdp. >> >> Hmm. Why ovs-tcpdump doesn't work for you? It should not depend >> on port type. If it doesn't work we need to investigate this >> case and fix it because it's a very important tool. > > Because ovs-tcpdump still uses 'tcpdump' tool to capture packets, > (dump-cmd=tcpdump) and forward to mirror port. Since tcpdump > sees no packet at all when type=afxdp, there is no packets to mirror. ovs-tcpdump creates simple tap interface and mirrors all the traffic to it. tcpdump command is started on that tap interface (no xdp here). There is no difference from which port types you're mirroring the traffic. It works for DPDK based ports and should work for afxdp.
On Mon, Dec 16, 2019 at 5:57 AM Ilya Maximets <i.maximets@ovn.org> wrote: > > On 16.12.2019 14:43, William Tu wrote: > > On Mon, Dec 16, 2019 at 1:41 AM Ilya Maximets <i.maximets@ovn.org> wrote: > >> > >> On 13.12.2019 21:59, William Tu wrote: > >>> Debugging netdev-afxdp is hard because tcpdump does not work > >>> at all, even for generic mode. ovs-tcpdump which uses port > >>> mirroring also does not work for netdev-afxdp. > >> > >> Hmm. Why ovs-tcpdump doesn't work for you? It should not depend > >> on port type. If it doesn't work we need to investigate this > >> case and fix it because it's a very important tool. > > > > Because ovs-tcpdump still uses 'tcpdump' tool to capture packets, > > (dump-cmd=tcpdump) and forward to mirror port. Since tcpdump > > sees no packet at all when type=afxdp, there is no packets to mirror. > > ovs-tcpdump creates simple tap interface and mirrors all the traffic > to it. tcpdump command is started on that tap interface (no xdp here). > There is no difference from which port types you're mirroring the traffic. > It works for DPDK based ports and should work for afxdp. I got it working using ovs-tcpdump now, thanks! ex: ovs-tcpdump -i afxdp-p0 -n -l -w /tmp/p0.pcap William
On 16.12.2019 15:27, William Tu wrote: > On Mon, Dec 16, 2019 at 5:57 AM Ilya Maximets <i.maximets@ovn.org> wrote: >> >> On 16.12.2019 14:43, William Tu wrote: >>> On Mon, Dec 16, 2019 at 1:41 AM Ilya Maximets <i.maximets@ovn.org> wrote: >>>> >>>> On 13.12.2019 21:59, William Tu wrote: >>>>> Debugging netdev-afxdp is hard because tcpdump does not work >>>>> at all, even for generic mode. ovs-tcpdump which uses port >>>>> mirroring also does not work for netdev-afxdp. >>>> >>>> Hmm. Why ovs-tcpdump doesn't work for you? It should not depend >>>> on port type. If it doesn't work we need to investigate this >>>> case and fix it because it's a very important tool. >>> >>> Because ovs-tcpdump still uses 'tcpdump' tool to capture packets, >>> (dump-cmd=tcpdump) and forward to mirror port. Since tcpdump >>> sees no packet at all when type=afxdp, there is no packets to mirror. >> >> ovs-tcpdump creates simple tap interface and mirrors all the traffic >> to it. tcpdump command is started on that tap interface (no xdp here). >> There is no difference from which port types you're mirroring the traffic. >> It works for DPDK based ports and should work for afxdp. > > I got it working using ovs-tcpdump now, thanks! > ex: ovs-tcpdump -i afxdp-p0 -n -l -w /tmp/p0.pcap OK. So, this patch is not needed.
On Mon, Dec 16, 2019 at 7:27 AM Ilya Maximets <i.maximets@ovn.org> wrote: > > On 16.12.2019 15:27, William Tu wrote: > > On Mon, Dec 16, 2019 at 5:57 AM Ilya Maximets <i.maximets@ovn.org> wrote: > >> > >> On 16.12.2019 14:43, William Tu wrote: > >>> On Mon, Dec 16, 2019 at 1:41 AM Ilya Maximets <i.maximets@ovn.org> wrote: > >>>> > >>>> On 13.12.2019 21:59, William Tu wrote: > >>>>> Debugging netdev-afxdp is hard because tcpdump does not work > >>>>> at all, even for generic mode. ovs-tcpdump which uses port > >>>>> mirroring also does not work for netdev-afxdp. > >>>> > >>>> Hmm. Why ovs-tcpdump doesn't work for you? It should not depend > >>>> on port type. If it doesn't work we need to investigate this > >>>> case and fix it because it's a very important tool. > >>> > >>> Because ovs-tcpdump still uses 'tcpdump' tool to capture packets, > >>> (dump-cmd=tcpdump) and forward to mirror port. Since tcpdump > >>> sees no packet at all when type=afxdp, there is no packets to mirror. > >> > >> ovs-tcpdump creates simple tap interface and mirrors all the traffic > >> to it. tcpdump command is started on that tap interface (no xdp here). > >> There is no difference from which port types you're mirroring the traffic. > >> It works for DPDK based ports and should work for afxdp. > > > > I got it working using ovs-tcpdump now, thanks! > > ex: ovs-tcpdump -i afxdp-p0 -n -l -w /tmp/p0.pcap > > OK. So, this patch is not needed. I think this patch is still useful, because using 'options:pcap' is much easier than ovs-tcpdump (which requires python libs, creates tap, etc). Another use case is for testsuite, we can compare the packet content by dumpling the pcap file. But this patch might have performance impact even when not enabling it? Regards, William
On 16.12.2019 18:23, William Tu wrote: > On Mon, Dec 16, 2019 at 7:27 AM Ilya Maximets <i.maximets@ovn.org> wrote: >> >> On 16.12.2019 15:27, William Tu wrote: >>> On Mon, Dec 16, 2019 at 5:57 AM Ilya Maximets <i.maximets@ovn.org> wrote: >>>> >>>> On 16.12.2019 14:43, William Tu wrote: >>>>> On Mon, Dec 16, 2019 at 1:41 AM Ilya Maximets <i.maximets@ovn.org> wrote: >>>>>> >>>>>> On 13.12.2019 21:59, William Tu wrote: >>>>>>> Debugging netdev-afxdp is hard because tcpdump does not work >>>>>>> at all, even for generic mode. ovs-tcpdump which uses port >>>>>>> mirroring also does not work for netdev-afxdp. >>>>>> >>>>>> Hmm. Why ovs-tcpdump doesn't work for you? It should not depend >>>>>> on port type. If it doesn't work we need to investigate this >>>>>> case and fix it because it's a very important tool. >>>>> >>>>> Because ovs-tcpdump still uses 'tcpdump' tool to capture packets, >>>>> (dump-cmd=tcpdump) and forward to mirror port. Since tcpdump >>>>> sees no packet at all when type=afxdp, there is no packets to mirror. >>>> >>>> ovs-tcpdump creates simple tap interface and mirrors all the traffic >>>> to it. tcpdump command is started on that tap interface (no xdp here). >>>> There is no difference from which port types you're mirroring the traffic. >>>> It works for DPDK based ports and should work for afxdp. >>> >>> I got it working using ovs-tcpdump now, thanks! >>> ex: ovs-tcpdump -i afxdp-p0 -n -l -w /tmp/p0.pcap >> >> OK. So, this patch is not needed. > > I think this patch is still useful, because using 'options:pcap' > is much easier than ovs-tcpdump (which requires python libs, > creates tap, etc). > Another use case is for testsuite, we can compare the packet > content by dumpling the pcap file. > > But this patch might have performance impact even > when not enabling it? Yes, it will have performance impact since you're calling it from the hot path. Also, current version will not work correctly. clang build fails. (your travis link in commit-message is not correct). To implement the functionality properly you need to protect pcap streams by rcu. I don't think that it's hard to use ovs-tcpdump. Not harder than usual tcpdump. All the additional ports and mirroring are created and configured automatically. Best regards, Ilya Maximets.
On Mon, Dec 16, 2019 at 9:47 AM Ilya Maximets <i.maximets@ovn.org> wrote: > > On 16.12.2019 18:23, William Tu wrote: > > On Mon, Dec 16, 2019 at 7:27 AM Ilya Maximets <i.maximets@ovn.org> wrote: > >> > >> On 16.12.2019 15:27, William Tu wrote: > >>> On Mon, Dec 16, 2019 at 5:57 AM Ilya Maximets <i.maximets@ovn.org> wrote: > >>>> > >>>> On 16.12.2019 14:43, William Tu wrote: > >>>>> On Mon, Dec 16, 2019 at 1:41 AM Ilya Maximets <i.maximets@ovn.org> wrote: > >>>>>> > >>>>>> On 13.12.2019 21:59, William Tu wrote: > >>>>>>> Debugging netdev-afxdp is hard because tcpdump does not work > >>>>>>> at all, even for generic mode. ovs-tcpdump which uses port > >>>>>>> mirroring also does not work for netdev-afxdp. > >>>>>> > >>>>>> Hmm. Why ovs-tcpdump doesn't work for you? It should not depend > >>>>>> on port type. If it doesn't work we need to investigate this > >>>>>> case and fix it because it's a very important tool. > >>>>> > >>>>> Because ovs-tcpdump still uses 'tcpdump' tool to capture packets, > >>>>> (dump-cmd=tcpdump) and forward to mirror port. Since tcpdump > >>>>> sees no packet at all when type=afxdp, there is no packets to mirror. > >>>> > >>>> ovs-tcpdump creates simple tap interface and mirrors all the traffic > >>>> to it. tcpdump command is started on that tap interface (no xdp here). > >>>> There is no difference from which port types you're mirroring the traffic. > >>>> It works for DPDK based ports and should work for afxdp. > >>> > >>> I got it working using ovs-tcpdump now, thanks! > >>> ex: ovs-tcpdump -i afxdp-p0 -n -l -w /tmp/p0.pcap > >> > >> OK. So, this patch is not needed. > > > > I think this patch is still useful, because using 'options:pcap' > > is much easier than ovs-tcpdump (which requires python libs, > > creates tap, etc). > > Another use case is for testsuite, we can compare the packet > > content by dumpling the pcap file. > > > > But this patch might have performance impact even > > when not enabling it? > > Yes, it will have performance impact since you're calling it from > the hot path. > > Also, current version will not work correctly. clang build fails. > (your travis link in commit-message is not correct). > To implement the functionality properly you need to protect pcap > streams by rcu. Thanks, I paste the wrong link The error was here: https://travis-ci.org/williamtu/ovs-travis/builds/624759289 > > I don't think that it's hard to use ovs-tcpdump. Not harder than > usual tcpdump. All the additional ports and mirroring are created > and configured automatically. > > Best regards, Ilya Maximets. OK, make sense. I will use ovs-tcpdump. William
diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c index ca2dfd005b9f..8634526ddec2 100644 --- a/lib/netdev-afxdp.c +++ b/lib/netdev-afxdp.c @@ -42,6 +42,7 @@ #include "openvswitch/list.h" #include "openvswitch/vlog.h" #include "packets.h" +#include "pcap-file.h" #include "socket-util.h" #include "util.h" @@ -591,6 +592,7 @@ netdev_afxdp_set_config(struct netdev *netdev, const struct smap *args, struct netdev_linux *dev = netdev_linux_cast(netdev); const char *str_xdp_mode; enum afxdp_mode xdp_mode; + const char *pcap; bool need_wakeup; int new_n_rxq; @@ -626,6 +628,21 @@ netdev_afxdp_set_config(struct netdev *netdev, const struct smap *args, } #endif + pcap = smap_get(args, "pcap"); + if (pcap) { + dev->rxq_pcap = dev->tx_pcap = ovs_pcap_open(pcap, "ab"); + } else { + const char *rxq_pcap = smap_get(args, "rxq_pcap"); + const char *tx_pcap = smap_get(args, "rx_pcap"); + + if (rxq_pcap) { + dev->rxq_pcap = ovs_pcap_open(rxq_pcap, "ab"); + } + if (tx_pcap) { + dev->tx_pcap = ovs_pcap_open(tx_pcap, "ab"); + } + } + if (dev->requested_n_rxq != new_n_rxq || dev->requested_xdp_mode != xdp_mode || dev->requested_need_wakeup != need_wakeup) { @@ -663,6 +680,14 @@ netdev_afxdp_reconfigure(struct netdev *netdev) ovs_mutex_lock(&dev->mutex); + if (dev->rxq_pcap) { + ovs_pcap_close(dev->rxq_pcap); + } + if (dev->tx_pcap && dev->tx_pcap != dev->rxq_pcap) { + ovs_pcap_close(dev->tx_pcap); + } + dev->rxq_pcap = dev->tx_pcap = NULL; + if (netdev->n_rxq == dev->requested_n_rxq && dev->xdp_mode == dev->requested_xdp_mode && dev->use_need_wakeup == dev->requested_need_wakeup @@ -830,6 +855,10 @@ netdev_afxdp_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch, dp_packet_batch_add(batch, packet); idx_rx++; + + if (OVS_UNLIKELY(dev->rxq_pcap)) { + ovs_pcap_write(dev->rxq_pcap, packet); + } } /* Release the RX queue. */ xsk_ring_cons__release(&xsk_info->rx, rcvd); @@ -1044,6 +1073,14 @@ __netdev_afxdp_batch_send(struct netdev *netdev, int qid, xsk_ring_prod__tx_desc(&xsk_info->tx, idx + i)->addr = index; xsk_ring_prod__tx_desc(&xsk_info->tx, idx + i)->len = dp_packet_size(packet); + + if (OVS_UNLIKELY(dev->tx_pcap)) { + struct dp_packet dp; + + dp_packet_use_const(&dp, dp_packet_data(packet), + dp_packet_size(packet)); + ovs_pcap_write(dev->tx_pcap, &dp); + } } xsk_ring_prod__submit(&xsk_info->tx, dp_packet_batch_size(batch)); xsk_info->outstanding_tx += dp_packet_batch_size(batch); diff --git a/lib/netdev-linux-private.h b/lib/netdev-linux-private.h index 8873caa9d412..c9c3a69f01f9 100644 --- a/lib/netdev-linux-private.h +++ b/lib/netdev-linux-private.h @@ -109,6 +109,7 @@ struct netdev_linux { bool requested_need_wakeup; struct ovs_spin *tx_locks; /* spin lock array for TX queues. */ + struct pcap_file *tx_pcap, *rxq_pcap OVS_GUARDED; #endif };
Debugging netdev-afxdp is hard because tcpdump does not work at all, even for generic mode. ovs-tcpdump which uses port mirroring also does not work for netdev-afxdp. This patch adds options:pcap=<file.pcap> to enable capture the packets from afxdp device. Signed-off-by: William Tu <u9012063@gmail.com> Tested-At: https://travis-ci.org/openvswitch/ovs/builds/624782796 --- lib/netdev-afxdp.c | 37 +++++++++++++++++++++++++++++++++++++ lib/netdev-linux-private.h | 1 + 2 files changed, 38 insertions(+)