All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pascal Mazon <pascal.mazon@6wind.com>
To: keith.wiles@intel.com
Cc: dev@dpdk.org, Pascal Mazon <pascal.mazon@6wind.com>
Subject: [PATCH 2/4] net/tap: reflect tap flags on the remote
Date: Fri,  3 Mar 2017 13:27:39 +0100	[thread overview]
Message-ID: <562c8406484ecc8c4ca661b27ba7b4fdde2711ec.1488542158.git.pascal.mazon@6wind.com> (raw)
In-Reply-To: <cover.1488542158.git.pascal.mazon@6wind.com>

Synchronize PROMISC and ALLMULTI flags to the remote netdevice if
possible.

Leave the IFF_UP flag as it is, however.

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
Acked-by: Olga Shern <olgas@mellanox.com>
---
 drivers/net/tap/rte_eth_tap.c | 36 +++++++++++++++++++++++-------------
 drivers/net/tap/tap.h         |  1 +
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 327fefd0d3a1..c77f206b4f60 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -249,7 +249,7 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 }
 
 static int
-tap_link_set_flags(struct pmd_internals *pmd, short flags, int add)
+tap_netdev_set_flags(const char *iface, short flags, int add)
 {
 	struct ifreq ifr;
 	int err, s;
@@ -266,11 +266,11 @@ tap_link_set_flags(struct pmd_internals *pmd, short flags, int add)
 		return -1;
 	}
 	memset(&ifr, 0, sizeof(ifr));
-	snprintf(ifr.ifr_name, IFNAMSIZ, "%s", pmd->name);
+	snprintf(ifr.ifr_name, IFNAMSIZ, "%s", iface);
 	err = ioctl(s, SIOCGIFFLAGS, &ifr);
 	if (err < 0) {
 		RTE_LOG(WARNING, PMD, "Unable to get %s device flags: %s\n",
-			pmd->name, strerror(errno));
+			iface, strerror(errno));
 		close(s);
 		return -1;
 	}
@@ -288,6 +288,7 @@ tap_link_set_flags(struct pmd_internals *pmd, short flags, int add)
 	close(s);
 
 	return 0;
+
 }
 
 static int
@@ -296,7 +297,7 @@ tap_link_set_down(struct rte_eth_dev *dev)
 	struct pmd_internals *pmd = dev->data->dev_private;
 
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
-	return tap_link_set_flags(pmd, IFF_UP | IFF_NOARP, 0);
+	return tap_netdev_set_flags(pmd->name, IFF_UP | IFF_NOARP, 0);
 }
 
 static int
@@ -305,7 +306,7 @@ tap_link_set_up(struct rte_eth_dev *dev)
 	struct pmd_internals *pmd = dev->data->dev_private;
 
 	dev->data->dev_link.link_status = ETH_LINK_UP;
-	return tap_link_set_flags(pmd, IFF_UP | IFF_NOARP, 1);
+	return tap_netdev_set_flags(pmd->name, IFF_UP | IFF_NOARP, 1);
 }
 
 static int
@@ -476,9 +477,11 @@ tap_promisc_enable(struct rte_eth_dev *dev)
 	struct pmd_internals *pmd = dev->data->dev_private;
 
 	dev->data->promiscuous = 1;
-	tap_link_set_flags(pmd, IFF_PROMISC, 1);
-	if (pmd->remote_if_index)
+	tap_netdev_set_flags(pmd->name, IFF_PROMISC, 1);
+	if (pmd->remote_if_index) {
 		tap_flow_implicit_create(pmd, TAP_REMOTE_PROMISC);
+		tap_netdev_set_flags(pmd->remote_iface, IFF_PROMISC, 1);
+	}
 }
 
 static void
@@ -487,9 +490,11 @@ tap_promisc_disable(struct rte_eth_dev *dev)
 	struct pmd_internals *pmd = dev->data->dev_private;
 
 	dev->data->promiscuous = 0;
-	tap_link_set_flags(pmd, IFF_PROMISC, 0);
-	if (pmd->remote_if_index)
+	tap_netdev_set_flags(pmd->name, IFF_PROMISC, 0);
+	if (pmd->remote_if_index) {
 		tap_flow_implicit_destroy(dev, TAP_REMOTE_PROMISC);
+		tap_netdev_set_flags(pmd->remote_iface, IFF_PROMISC, 0);
+	}
 }
 
 static void
@@ -498,9 +503,11 @@ tap_allmulti_enable(struct rte_eth_dev *dev)
 	struct pmd_internals *pmd = dev->data->dev_private;
 
 	dev->data->all_multicast = 1;
-	tap_link_set_flags(pmd, IFF_ALLMULTI, 1);
-	if (pmd->remote_if_index)
+	tap_netdev_set_flags(pmd->name, IFF_ALLMULTI, 1);
+	if (pmd->remote_if_index) {
 		tap_flow_implicit_create(pmd, TAP_REMOTE_ALLMULTI);
+		tap_netdev_set_flags(pmd->remote_iface, IFF_ALLMULTI, 1);
+	}
 }
 
 static void
@@ -509,9 +516,11 @@ tap_allmulti_disable(struct rte_eth_dev *dev)
 	struct pmd_internals *pmd = dev->data->dev_private;
 
 	dev->data->all_multicast = 0;
-	tap_link_set_flags(pmd, IFF_ALLMULTI, 0);
-	if (pmd->remote_if_index)
+	tap_netdev_set_flags(pmd->name, IFF_ALLMULTI, 0);
+	if (pmd->remote_if_index) {
 		tap_flow_implicit_destroy(dev, TAP_REMOTE_ALLMULTI);
+		tap_netdev_set_flags(pmd->remote_iface, IFF_ALLMULTI, 0);
+	}
 }
 
 static void
@@ -924,6 +933,7 @@ eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface)
 	 */
 	pmd->nlsk_fd = nl_init();
 	if (strlen(remote_iface)) {
+		strncpy(pmd->remote_iface, remote_iface, RTE_ETH_NAME_MAX_LEN);
 		pmd->remote_if_index = if_nametoindex(remote_iface);
 		if (!pmd->remote_if_index)
 			RTE_LOG(ERR, PMD, "Could not find %s ifindex: "
diff --git a/drivers/net/tap/tap.h b/drivers/net/tap/tap.h
index a5f83d4feea3..2afd0f9a4a58 100644
--- a/drivers/net/tap/tap.h
+++ b/drivers/net/tap/tap.h
@@ -64,6 +64,7 @@ struct tx_queue {
 
 struct pmd_internals {
 	char name[RTE_ETH_NAME_MAX_LEN]; /* Internal Tap device name */
+	char remote_iface[RTE_ETH_NAME_MAX_LEN]; /* Remote netdevice name */
 	int nlsk_fd; /* Netlink socket fd */
 	uint16_t nb_queues; /* Number of queues supported */
 	struct ether_addr eth_addr; /* Mac address of the device port */
-- 
2.8.0.rc0

  parent reply	other threads:[~2017-03-03 12:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 12:27 [PATCH 0/4] net/tap: remote netdevice traffic capture Pascal Mazon
2017-03-03 12:27 ` [PATCH 1/4] net/tap: add " Pascal Mazon
2017-03-03 12:27 ` Pascal Mazon [this message]
2017-03-03 12:27 ` [PATCH 3/4] net/tap: use the remote MAC address if available Pascal Mazon
2017-03-03 12:27 ` [PATCH 4/4] net/tap: set MTU on the remote Pascal Mazon
2017-03-03 15:54 ` [PATCH 0/4] net/tap: remote netdevice traffic capture Wiles, Keith
2017-03-07 16:38 ` [PATCH v2 0/4] " Pascal Mazon
2017-03-07 16:38   ` [PATCH v2 1/4] net/tap: add " Pascal Mazon
2017-03-07 16:38   ` [PATCH v2 2/4] net/tap: reflect tap flags on the remote Pascal Mazon
2017-03-07 16:38   ` [PATCH v2 3/4] net/tap: use the remote MAC address if available Pascal Mazon
2017-03-07 16:38   ` [PATCH v2 4/4] net/tap: set MTU on the remote Pascal Mazon
2017-03-08 10:06   ` [PATCH v3 0/4] net/tap: remote netdevice traffic capture Pascal Mazon
2017-03-08 10:06     ` [PATCH v3 1/4] net/tap: add " Pascal Mazon
2017-03-08 10:06     ` [PATCH v3 2/4] net/tap: reflect tap flags on the remote Pascal Mazon
2017-03-08 10:06     ` [PATCH v3 3/4] net/tap: use the remote MAC address if available Pascal Mazon
2017-03-08 10:06     ` [PATCH v3 4/4] net/tap: set MTU on the remote Pascal Mazon
2017-03-14  8:34     ` [PATCH v4] net/tap: remote netdevice traffic capture Pascal Mazon
2017-03-14  8:34       ` [PATCH v4] net/tap: add " Pascal Mazon
2017-03-14 14:00         ` Wiles, Keith
2017-03-15 15:03     ` [PATCH v5] net/tap: " Pascal Mazon
2017-03-15 15:03       ` [PATCH v5] net/tap: add " Pascal Mazon
2017-03-23  8:42       ` [PATCH v6 0/1] net/tap: " Pascal Mazon
2017-03-23  8:42         ` [PATCH v6 1/1] net/tap: add " Pascal Mazon
2017-03-24 15:48           ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=562c8406484ecc8c4ca661b27ba7b4fdde2711ec.1488542158.git.pascal.mazon@6wind.com \
    --to=pascal.mazon@6wind.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.