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 90DA8235 for ; Tue, 27 Jun 2017 14:33:23 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D75AE21A87; Tue, 27 Jun 2017 08:33:22 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 27 Jun 2017 08:33:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=sP4 pOnjOorWzOzu1MhBBn2bAzDvwb9Ua3aPyPlcaD0U=; b=e0mRWXY2LScWY4fLkI4 uLXA2Ivt/LUq+LTYjnKxolWUxBPLTTl93ZSxEIOstJqmbbAnauUytJA5uJMP7MRz DvwwiTGDFvo5RWglVD0mVR7SQk62oSOp0hS2gmGF61o0vY2koax8x3SVrjjClmL+ Qw0bFndzRC2LQdayqVhFwHKg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=sP4pOnjOorWzOzu1MhBBn2bAzDvwb9Ua3aPyPlcaD 0U=; b=MSIXuLpZNjLcjdppjGYIsqUJZb8L0bd+0IYC2x8nWrjSD/Ey9WyE1L7vP aWDjmnhcMCPv/m2vU7216tzubkc0VPXZgzcoQWWFb4sCGrTqXoZnYrQgjUQWny/J gfiC6//u9hueioahVbNZrhwoYpbfMoVhTYEh4cPSrArZdfv+3jFT7aguynhxTY+g GLwZnREaP1PbFoyHH/6nLqVpHQC/pmmTh2ydVfOD9MI0b475PQgghXYryNIU0WF4 erGdSjwH6IO/3NZdQs6+ceD39x8RUAB0fPanSvRXBcpC51rqneXLm1P/EShdSceZ klzQRNu1xD+T12Kjsu/NjbUmRIOdg== X-ME-Sender: X-Sasl-enc: G1pl51pWeSlCxykkkBEhzdJkqV3mXr8gWdx1xRSp5q40 1498566802 Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 43FB97E74F; Tue, 27 Jun 2017 08:33:22 -0400 (EDT) From: Thomas Monjalon To: pascal.mazon@6wind.com Cc: dev@dpdk.org Date: Tue, 27 Jun 2017 14:33:15 +0200 Message-Id: <20170627123315.11246-1-thomas@monjalon.net> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170627092959.3344-1-thomas@monjalon.net> References: <20170627092959.3344-1-thomas@monjalon.net> Subject: [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 12:33:24 -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 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 */ -- 2.13.1