Skip to content

Commit

Permalink
netdev-dpdk: add DPDK pdump capability
Browse files Browse the repository at this point in the history
This commit provides the ability to 'listen' on DPDK ports and save
packets to a pcap file with a DPDK app that uses the librte_pdump
library. One such app is the 'pdump' app that can be found in the DPDK
'app' directory. Instructions on how to use this can be found in
INSTALL.DPDK-ADVANCED.md

Pdump capability in OVS with DPDK will only be initialised if the
CONFIG_RTE_LIBRTE_PMD_PCAP=y and CONFIG_RTE_LIBRTE_PDUMP=y options are
set in DPDK. libpcap is required if the above configuration is used.

Signed-off-by: Ciara Loftus <[email protected]>
Signed-off-by: Daniele Di Proietto <[email protected]>
  • Loading branch information
cloftus authored and ddiproietto committed Aug 13, 2016
1 parent 2b220d1 commit 4b88d67
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
38 changes: 36 additions & 2 deletions INSTALL.DPDK-ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ OVS DPDK ADVANCED INSTALL GUIDE
7. [QOS](#qos)
8. [Rate Limiting](#rl)
9. [Flow Control](#fc)
10. [Vsperf](#vsperf)
10. [Pdump](#pdump)
11. [Vsperf](#vsperf)

## <a name="overview"></a> 1. Overview

Expand Down Expand Up @@ -947,7 +948,40 @@ respective parameter. To disable the flow control at tx side,
`ovs-vsctl set Interface dpdk0 options:tx-flow-ctrl=false`
## <a name="vsperf"></a> 10. Vsperf
## <a name="pdump"></a> 10. Pdump
Pdump allows you to listen on DPDK ports and view the traffic that is
passing on them. To use this utility, one must have libpcap installed
on the system. Furthermore, DPDK must be built with CONFIG_RTE_LIBRTE_PDUMP=y
and CONFIG_RTE_LIBRTE_PMD_PCAP=y.
To use pdump, simply launch OVS as usual. Then, navigate to the 'app/pdump'
directory in DPDK, 'make' the application and run like so:
```
sudo ./build/app/dpdk_pdump --
--pdump port=0,queue=0,rx-dev=/tmp/pkts.pcap
--server-socket-path=/usr/local/var/run/openvswitch
```
The above command captures traffic received on queue 0 of port 0 and stores
it in /tmp/pkts.pcap. Other combinations of port numbers, queues numbers and
pcap locations are of course also available to use. 'server-socket-path' must
be set to the value of ovs_rundir() which typically resolves to
'/usr/local/var/run/openvswitch'.
More information on the pdump app and its usage can be found in the below link.
http://dpdk.org/doc/guides/sample_app_ug/pdump.html
Many tools are available to view the contents of the pcap file. Once example is
tcpdump. Issue the following command to view the contents of 'pkts.pcap':
`tcpdump -r pkts.pcap`
A performance decrease is expected when using a monitoring application like
the DPDK pdump app.
## <a name="vsperf"></a> 11. Vsperf
Vsperf project goal is to develop vSwitch test framework that can be used to
validate the suitability of different vSwitch implementations in a Telco deployment
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Post-v2.5.0
* Basic connection tracking for the userspace datapath (no ALG,
fragmentation or NAT support yet)
* Support for DPDK 16.07
* Optional support for DPDK pdump enabled.
- Increase number of registers to 16.
- ovs-benchmark: This utility has been removed due to lack of use and
bitrot.
Expand Down
23 changes: 23 additions & 0 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ AC_DEFUN([OVS_CHECK_DPDK], [
[AC_SEARCH_LIBS([get_mempolicy],[numa],[],[AC_MSG_ERROR([unable to find libnuma, install the dependency package])])
DPDK_EXTRA_LIB="-lnuma"])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[
#include <rte_config.h>
#if RTE_LIBRTE_PMD_PCAP
#error
#endif
], [])
], [],
[AC_SEARCH_LIBS([pcap_dump],[pcap],[],[AC_MSG_ERROR([unable to find libpcap, install the dependency package])])
DPDK_EXTRA_LIB="-lpcap"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[
#include <rte_config.h>
#if RTE_LIBRTE_PDUMP
#error
#endif
], [])
], [],
[AC_DEFINE([DPDK_PDUMP], [1], [DPDK pdump enabled in OVS.])])
])
# On some systems we have to add -ldl to link with dpdk
#
# This code, at first, tries to link without -ldl (""),
Expand Down
19 changes: 19 additions & 0 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
#include "rte_config.h"
#include "rte_mbuf.h"
#include "rte_meter.h"
#ifdef DPDK_PDUMP
#include "rte_pdump.h"
#endif
#include "rte_virtio_net.h"

VLOG_DEFINE_THIS_MODULE(dpdk);
Expand Down Expand Up @@ -3412,6 +3415,22 @@ dpdk_init__(const struct smap *ovs_other_config)

dpdk_vhost_class_init();

#ifdef DPDK_PDUMP
VLOG_INFO("DPDK pdump packet capture enabled");
err = rte_pdump_init(ovs_rundir());
if (err) {
VLOG_INFO("Error initialising DPDK pdump");
rte_pdump_uninit();
} else {
char *server_socket_path;

server_socket_path = xasprintf("%s/%s", ovs_rundir(),
"pdump_server_socket");
fatal_signal_add_file_to_unlink(server_socket_path);
free(server_socket_path);
}
#endif

/* Finally, register the dpdk classes */
netdev_dpdk_register();
}
Expand Down

0 comments on commit 4b88d67

Please sign in to comment.