* [PATCH] net/pcap: rx_iface_in stream type support
@ 2018-06-03 13:13 ido goshen
0 siblings, 0 replies; only message in thread
From: ido goshen @ 2018-06-03 13:13 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, ido goshen
Support rx of in direction packets only
Useful for apps that also tx to eth_pcap ports in order not to see them
echoed back in as rx when out direction is also captured
Signed-off-by: ido goshen <ido@cgstowernetworks.com>
---
drivers/net/pcap/rte_eth_pcap.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 6bd4a7d..88bd550 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -26,6 +26,7 @@
#define ETH_PCAP_RX_PCAP_ARG "rx_pcap"
#define ETH_PCAP_TX_PCAP_ARG "tx_pcap"
#define ETH_PCAP_RX_IFACE_ARG "rx_iface"
+#define ETH_PCAP_RX_IFACE_IN_ARG "rx_iface_in"
#define ETH_PCAP_TX_IFACE_ARG "tx_iface"
#define ETH_PCAP_IFACE_ARG "iface"
@@ -83,6 +84,7 @@ struct pmd_devargs {
ETH_PCAP_RX_PCAP_ARG,
ETH_PCAP_TX_PCAP_ARG,
ETH_PCAP_RX_IFACE_ARG,
+ ETH_PCAP_RX_IFACE_IN_ARG,
ETH_PCAP_TX_IFACE_ARG,
ETH_PCAP_IFACE_ARG,
NULL
@@ -726,6 +728,22 @@ struct pmd_devargs {
return 0;
}
+static inline int
+set_iface_direction(const char *iface , const char *key, pcap_t *pcap)
+{
+ if (strcmp(key, ETH_PCAP_RX_IFACE_IN_ARG) == 0) {
+ if (pcap_setdirection(pcap, PCAP_D_IN) < 0) {
+ PMD_LOG(ERR,
+ "Setting %s pcap direction IN failed - %s\n",
+ iface,
+ pcap_geterr(pcap));
+ return -1;
+ }
+ PMD_LOG(INFO, "Setting %s pcap direction IN\n", iface);
+ }
+ return 0;
+}
+
/*
* Opens a NIC for reading packets from it
*/
@@ -740,11 +758,12 @@ struct pmd_devargs {
for (i = 0; i < rx->num_of_queue; i++) {
if (open_single_iface(iface, &pcap) < 0)
return -1;
+ if (set_iface_direction(iface, key, pcap) < 0)
+ return -1;
rx->queue[i].pcap = pcap;
rx->queue[i].name = iface;
rx->queue[i].type = key;
}
-
return 0;
}
@@ -963,7 +982,9 @@ struct pmd_devargs {
is_rx_pcap = 1;
else
pcaps.num_of_queue = rte_kvargs_count(kvlist,
- ETH_PCAP_RX_IFACE_ARG);
+ ETH_PCAP_RX_IFACE_ARG) +
+ rte_kvargs_count(kvlist,
+ ETH_PCAP_RX_IFACE_IN_ARG);
if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES)
pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES;
@@ -971,9 +992,15 @@ struct pmd_devargs {
if (is_rx_pcap)
ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_PCAP_ARG,
&open_rx_pcap, &pcaps);
- else
+ else {
ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_IFACE_ARG,
&open_rx_iface, &pcaps);
+ if (ret == 0)
+ ret = rte_kvargs_process(kvlist,
+ ETH_PCAP_RX_IFACE_IN_ARG,
+ &open_rx_iface,
+ &pcaps);
+ }
if (ret < 0)
goto free_kvlist;
@@ -1046,6 +1073,7 @@ struct pmd_devargs {
ETH_PCAP_RX_PCAP_ARG "=<string> "
ETH_PCAP_TX_PCAP_ARG "=<string> "
ETH_PCAP_RX_IFACE_ARG "=<ifc> "
+ ETH_PCAP_RX_IFACE_IN_ARG "=<ifc> "
ETH_PCAP_TX_IFACE_ARG "=<ifc> "
ETH_PCAP_IFACE_ARG "=<ifc>");
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-06-03 13:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-03 13:13 [PATCH] net/pcap: rx_iface_in stream type support ido goshen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.