From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id C2B082BE1 for ; Tue, 27 Jun 2017 11:30:13 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6C9AA21500; Tue, 27 Jun 2017 05:30:13 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 27 Jun 2017 05:30:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=htONxI/eh8nCZsNTL+nBsPYo6MF t3jZshdWz2+u7GQ0=; b=TcMz5mFo0nqdN0htPX7aUSdszoE6cofQa15zBfNjokl JtkKysVpatI7xmVKyioFJ8LnQHIyB9rg71isKn613et4958Uab5wWxnY/sDOWS/Y F//w66SoLk4QpRdYmDGeEoBz46sNT//XdDUsVksDH/QBK/vJGV7r5DDnf3cdoQnE = DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=htONxI /eh8nCZsNTL+nBsPYo6MFt3jZshdWz2+u7GQ0=; b=YKuxPTBiBb+02bWO5WXkfM hjdRurmfgjnLzAYpzRmOvCC12ac2WrApmvYFud0S6dPCDKRwPttTzSAVtijxr/ih q/kfS9BO0JtGJuxJzmLyggY8iWToazgRZHBAxS3Pxi2UlA3EuLsf1OHkviT6vC9v i9/oRMOUniAsGkX33/RqBamU2+ZxUKOD3QQLYxUx+tkIT+ILLrk0pKe27iwQMEa1 opTt3RWZxiFmUTMEcYrbj4tCPI97A6PVV2IQK2QqonpmWbi05iID3V5lZI2eerSp y+atBgRaKfgY3+Ib6yCi8r4q+NdZY6YNutdiNbPkaNTADTh4hQIlKCXDhx7h0vWw == X-ME-Sender: X-Sasl-enc: dAETtZHkaTe/0DZ3rpr3ZaylePP/9dqDfZgG6hZB49TZ 1498555812 Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id C5C8924346; Tue, 27 Jun 2017 05:30:12 -0400 (EDT) From: Thomas Monjalon To: pascal.mazon@6wind.com Cc: dev@dpdk.org Date: Tue, 27 Jun 2017 11:29:59 +0200 Message-Id: <20170627092959.3344-1-thomas@monjalon.net> X-Mailer: git-send-email 2.13.1 Subject: [dpdk-dev] [PATCH] net/tap: restore state of remote device when stopping 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 09:30:14 -0000 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 --- 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 #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_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