DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/tap: restore state of remote device when stopping
@ 2017-06-27  9:29 Thomas Monjalon
  2017-06-27 12:33 ` [dpdk-dev] [PATCH v2] net/tap: restore state of remote device when closing Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2017-06-27  9:29 UTC (permalink / raw)
  To: pascal.mazon; +Cc: dev

When exiting a DPDK application, the TAP remote was left
with the link down even if it was initially up.

The device flags of the remote netdevice are saved when probing,
and restored when calling the stop function.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/tap/rte_eth_tap.c | 18 +++++++++++++++++-
 drivers/net/tap/rte_eth_tap.h |  2 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7cfa0a85d..5128152ee 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -565,11 +565,22 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,
 static int
 tap_link_set_down(struct rte_eth_dev *dev)
 {
+	int err, remote_err;
 	struct pmd_internals *pmd = dev->data->dev_private;
 	struct ifreq ifr = { .ifr_flags = IFF_UP };
 
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
-	return tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE);
+	err = tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_ONLY);
+
+	if (pmd->remote_if_index) {
+		/* Restore initial remote state */
+		remote_err = ioctl(pmd->ioctl_sock, SIOCSIFFLAGS,
+				&pmd->remote_initial_ifr);
+		if (remote_err < 0)
+			err = -1;
+	}
+
+	return err;
 }
 
 static int
@@ -1320,6 +1331,11 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 		}
 		snprintf(pmd->remote_iface, RTE_ETH_NAME_MAX_LEN,
 			 "%s", remote_iface);
+
+		/* Save state of remote device */
+		tap_ioctl(pmd, SIOCGIFFLAGS, &pmd->remote_initial_ifr, 0, REMOTE_ONLY);
+
+		/* Replicate remote MAC address */
 		if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, REMOTE_ONLY) < 0) {
 			RTE_LOG(ERR, PMD, "%s: failed to get %s MAC address.",
 				pmd->name, pmd->remote_iface);
diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h
index ad497b3d1..08a72d279 100644
--- a/drivers/net/tap/rte_eth_tap.h
+++ b/drivers/net/tap/rte_eth_tap.h
@@ -37,6 +37,7 @@
 #include <sys/queue.h>
 #include <sys/uio.h>
 #include <inttypes.h>
+#include <net/if.h>
 
 #include <linux/if_tun.h>
 
@@ -83,6 +84,7 @@ struct pmd_internals {
 	char name[RTE_ETH_NAME_MAX_LEN];  /* Internal Tap device name */
 	uint16_t nb_queues;               /* Number of queues supported */
 	struct ether_addr eth_addr;       /* Mac address of the device port */
+	struct ifreq remote_initial_ifr;  /* remote netdevice flags on init */
 	int remote_if_index;              /* remote netdevice IF_INDEX */
 	int if_index;                     /* IF_INDEX for the port */
 	int ioctl_sock;                   /* socket for ioctl calls */
-- 
2.13.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] net/tap: restore state of remote device when closing
  2017-06-27  9:29 [dpdk-dev] [PATCH] net/tap: restore state of remote device when stopping Thomas Monjalon
@ 2017-06-27 12:33 ` Thomas Monjalon
  2017-06-27 14:14   ` Pascal Mazon
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2017-06-27 12:33 UTC (permalink / raw)
  To: pascal.mazon; +Cc: dev

When exiting a DPDK application, the TAP remote was left
with the link down even if it was initially up.

The device flags of the remote netdevice are saved when probing,
and restored when calling the close function.
The remote state is not set down when calling the stop function anymore.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2: move flags restore from stop to close function
---
 drivers/net/tap/rte_eth_tap.c | 13 ++++++++++++-
 drivers/net/tap/rte_eth_tap.h |  2 ++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7cfa0a85d..df7423536 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -569,7 +569,7 @@ tap_link_set_down(struct rte_eth_dev *dev)
 	struct ifreq ifr = { .ifr_flags = IFF_UP };
 
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
-	return tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE);
+	return tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_ONLY);
 }
 
 static int
@@ -735,6 +735,12 @@ tap_dev_close(struct rte_eth_dev *dev)
 		internals->rxq[i].fd = -1;
 		internals->txq[i].fd = -1;
 	}
+
+	if (internals->remote_if_index) {
+		/* Restore initial remote state */
+		ioctl(internals->ioctl_sock, SIOCSIFFLAGS,
+				&internals->remote_initial_flags);
+	}
 }
 
 static void
@@ -1320,6 +1326,11 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 		}
 		snprintf(pmd->remote_iface, RTE_ETH_NAME_MAX_LEN,
 			 "%s", remote_iface);
+
+		/* Save state of remote device */
+		tap_ioctl(pmd, SIOCGIFFLAGS, &pmd->remote_initial_flags, 0, REMOTE_ONLY);
+
+		/* Replicate remote MAC address */
 		if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, REMOTE_ONLY) < 0) {
 			RTE_LOG(ERR, PMD, "%s: failed to get %s MAC address.",
 				pmd->name, pmd->remote_iface);
diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h
index ad497b3d1..0d5a7df98 100644
--- a/drivers/net/tap/rte_eth_tap.h
+++ b/drivers/net/tap/rte_eth_tap.h
@@ -37,6 +37,7 @@
 #include <sys/queue.h>
 #include <sys/uio.h>
 #include <inttypes.h>
+#include <net/if.h>
 
 #include <linux/if_tun.h>
 
@@ -83,6 +84,7 @@ struct pmd_internals {
 	char name[RTE_ETH_NAME_MAX_LEN];  /* Internal Tap device name */
 	uint16_t nb_queues;               /* Number of queues supported */
 	struct ether_addr eth_addr;       /* Mac address of the device port */
+	struct ifreq remote_initial_flags;   /* Remote netdevice flags on init */
 	int remote_if_index;              /* remote netdevice IF_INDEX */
 	int if_index;                     /* IF_INDEX for the port */
 	int ioctl_sock;                   /* socket for ioctl calls */
-- 
2.13.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/tap: restore state of remote device when closing
  2017-06-27 12:33 ` [dpdk-dev] [PATCH v2] net/tap: restore state of remote device when closing Thomas Monjalon
@ 2017-06-27 14:14   ` Pascal Mazon
  2017-06-28  9:56     ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal Mazon @ 2017-06-27 14:14 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hi,

Looks good to me.

Acked-by: Pascal Mazon <pascal.mazon@6wind.com>

On 06/27/2017 02:33 PM, Thomas Monjalon wrote:
> When exiting a DPDK application, the TAP remote was left
> with the link down even if it was initially up.
>
> The device flags of the remote netdevice are saved when probing,
> and restored when calling the close function.
> The remote state is not set down when calling the stop function anymore.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v2: move flags restore from stop to close function
> ---
>   drivers/net/tap/rte_eth_tap.c | 13 ++++++++++++-
>   drivers/net/tap/rte_eth_tap.h |  2 ++
>   2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 7cfa0a85d..df7423536 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -569,7 +569,7 @@ tap_link_set_down(struct rte_eth_dev *dev)
>   	struct ifreq ifr = { .ifr_flags = IFF_UP };
>   
>   	dev->data->dev_link.link_status = ETH_LINK_DOWN;
> -	return tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE);
> +	return tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_ONLY);
>   }
>   
>   static int
> @@ -735,6 +735,12 @@ tap_dev_close(struct rte_eth_dev *dev)
>   		internals->rxq[i].fd = -1;
>   		internals->txq[i].fd = -1;
>   	}
> +
> +	if (internals->remote_if_index) {
> +		/* Restore initial remote state */
> +		ioctl(internals->ioctl_sock, SIOCSIFFLAGS,
> +				&internals->remote_initial_flags);
> +	}
>   }
>   
>   static void
> @@ -1320,6 +1326,11 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
>   		}
>   		snprintf(pmd->remote_iface, RTE_ETH_NAME_MAX_LEN,
>   			 "%s", remote_iface);
> +
> +		/* Save state of remote device */
> +		tap_ioctl(pmd, SIOCGIFFLAGS, &pmd->remote_initial_flags, 0, REMOTE_ONLY);
> +
> +		/* Replicate remote MAC address */
>   		if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, REMOTE_ONLY) < 0) {
>   			RTE_LOG(ERR, PMD, "%s: failed to get %s MAC address.",
>   				pmd->name, pmd->remote_iface);
> diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h
> index ad497b3d1..0d5a7df98 100644
> --- a/drivers/net/tap/rte_eth_tap.h
> +++ b/drivers/net/tap/rte_eth_tap.h
> @@ -37,6 +37,7 @@
>   #include <sys/queue.h>
>   #include <sys/uio.h>
>   #include <inttypes.h>
> +#include <net/if.h>
>   
>   #include <linux/if_tun.h>
>   
> @@ -83,6 +84,7 @@ struct pmd_internals {
>   	char name[RTE_ETH_NAME_MAX_LEN];  /* Internal Tap device name */
>   	uint16_t nb_queues;               /* Number of queues supported */
>   	struct ether_addr eth_addr;       /* Mac address of the device port */
> +	struct ifreq remote_initial_flags;   /* Remote netdevice flags on init */
>   	int remote_if_index;              /* remote netdevice IF_INDEX */
>   	int if_index;                     /* IF_INDEX for the port */
>   	int ioctl_sock;                   /* socket for ioctl calls */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/tap: restore state of remote device when closing
  2017-06-27 14:14   ` Pascal Mazon
@ 2017-06-28  9:56     ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2017-06-28  9:56 UTC (permalink / raw)
  To: Pascal Mazon, Thomas Monjalon; +Cc: dev


> On 06/27/2017 02:33 PM, Thomas Monjalon wrote:
>> When exiting a DPDK application, the TAP remote was left
>> with the link down even if it was initially up.
>>
>> The device flags of the remote netdevice are saved when probing,
>> and restored when calling the close function.
>> The remote state is not set down when calling the stop function anymore.
>>
>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

> Acked-by: Pascal Mazon <pascal.mazon@6wind.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-28  9:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27  9:29 [dpdk-dev] [PATCH] net/tap: restore state of remote device when stopping Thomas Monjalon
2017-06-27 12:33 ` [dpdk-dev] [PATCH v2] net/tap: restore state of remote device when closing Thomas Monjalon
2017-06-27 14:14   ` Pascal Mazon
2017-06-28  9:56     ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).