From: Pascal Mazon Subject: Re: [PATCH v2] net/tap: restore state of remote device when closing Date: Tue, 27 Jun 2017 16:14:20 +0200 Message-ID: References: <20170627092959.3344-1-thomas@monjalon.net> <20170627123315.11246-1-thomas@monjalon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Thomas Monjalon Return-path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id 3A5EC2C13 for ; Tue, 27 Jun 2017 16:15:16 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id z75so6025414wmc.0 for ; Tue, 27 Jun 2017 07:15:16 -0700 (PDT) In-Reply-To: <20170627123315.11246-1-thomas@monjalon.net> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, Looks good to me. Acked-by: Pascal Mazon 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 > --- > 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 > #include > #include > +#include > > #include > > @@ -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 */