From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=TMOGYhCeNs1BGME8SY8LPB6kX+lGAFMZeU3yYFniIcU=; b=RanMNc/I0pkoYHUITFxC2Je3DmUYngPJn3Orx84esMhh6qDTtxvJ6lM/I6k51ensVZ bQJRJTzGwe3UATLeND3Mvlfio5pwCJdXZjRvgWanBpkxHvRDpOQyGi2yGlENyREjeRLi joy7HA7bTUXLRG2NwmxqOUJ4ac3qUP3sJ52QlQ9nCcDPN5Nhg4zO4MUZM+O5kAfcqvg8 1D3gkkdV5V/Bwxn+lVCkCZfsc9hSbTYxpO8a4mhorS531JevsiR5Wrcz40zil/P7Szbt w7R79LIaHPumSJmRTs1rRoUgRvEbl7kJ2KQLKCgzBA1aX7ab/CSKXCCGMCtlU3zRvRwq 0HwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=TMOGYhCeNs1BGME8SY8LPB6kX+lGAFMZeU3yYFniIcU=; b=O9Cew7rS8vJQpvYWATeqT+xm2dlR2pEy7Bf9YlxWwKnPuSews2g/W2VbXpbSDq6GYX iYwcZVox2fUWcGTUqPTj0oH4Msl0dxcLRKPFl88032il0LepuLTdlFGB8e3efm53/neR TkQUSLOwh+P3rGhpbhl8lZmhyIMI+YsRvbFCCfAE2Bf2kc5t3pdWES7WhcBa0IZhrMc7 K4Yem6pg38xDPDW9NVG7VClB21ly04zoU2lTpwferQb6N73ijBAVm6BuQIrSekp7iJ+T VjeZPp9Of8sHnkPIvL2zoHgdTu64dP7WTvj0MnTxQh/waPEIwEuCXBn7mb/KdxdzQKXz rIQg== X-Gm-Message-State: AKS2vOw3BS9GkkgqmYAU+iSluLFxSwTAkmj0DiJETKVov4cG+Uo8EiZ3 h0/nrWYTRNLgXkkvlXYeUQ== X-Received: by 10.28.54.65 with SMTP id d62mr3406898wma.85.1498572915531; Tue, 27 Jun 2017 07:15:15 -0700 (PDT) Received: from [10.16.0.184] (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 201sm3534051wmy.15.2017.06.27.07.15.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2017 07:15:14 -0700 (PDT) To: Thomas Monjalon Cc: dev@dpdk.org References: <20170627092959.3344-1-thomas@monjalon.net> <20170627123315.11246-1-thomas@monjalon.net> From: Pascal Mazon Message-ID: Date: Tue, 27 Jun 2017 16:14:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170627123315.11246-1-thomas@monjalon.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v2] net/tap: restore state of remote device when closing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jun 2017 14:15:16 -0000 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 */