From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 2DF8B1B05; Fri, 25 May 2018 02:09:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2018 17:09:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,437,1520924400"; d="scan'208";a="42635787" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga008.fm.intel.com with ESMTP; 24 May 2018 17:09:09 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 24 May 2018 17:09:09 -0700 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.235]) by FMSMSX114.amr.corp.intel.com ([10.18.116.8]) with mapi id 14.03.0319.002; Thu, 24 May 2018 17:09:08 -0700 From: "Wiles, Keith" To: Ophir Munk CC: "dev@dpdk.org" , Pascal Mazon , Thomas Monjalon , Olga Shern , Shahaf Shuler , "stable@dpdk.org" Thread-Topic: [PATCH v1] net/tap: fix keep-alive queue not detached Thread-Index: AQHT87SSohER3ANUIE2q4yK+rWnRzqRAByGA Date: Fri, 25 May 2018 00:09:07 +0000 Message-ID: <36821D54-1EFE-4267-8769-9C29FB29DD1E@intel.com> References: <1527203440-29861-1-git-send-email-ophirmu@mellanox.com> In-Reply-To: <1527203440-29861-1-git-send-email-ophirmu@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.78.16] Content-Type: text/plain; charset="us-ascii" Content-ID: <14A2389EDD7069468142D72B661C292F@intel.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH v1] net/tap: fix keep-alive queue not detached X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2018 00:09:11 -0000 > On May 24, 2018, at 6:10 PM, Ophir Munk wrote: >=20 > The TAP keep-alive queue was created in order to keep the TAP device > in Linux even in case all of its Rx/Tx queues are released (in Linux > terminology: even in case all of the TAP device file descriptors are > closed), however, the keep-alive queue itself is attached to the TAP > device like all other Rx/Tx queues and therefore the kernel will > enqueue to it some Rx packets based on the kernel RSS distribution > rules. Those packets are unknown to the application and will remain > lost in the keep-alive queue. > All queues are attached by default to the TAP device after they are > created though TUNSETIFF ioctl call. > The fix is to detach the keep-alive queue after its creation through > TUNSETQUEUE ioctl call. >=20 > Fixes: 3101191c63ab ("net/tap: fix device removal when no queue exist") > Cc: stable@dpdk.org >=20 > Signed-off-by: Ophir Munk > --- > drivers/net/tap/rte_eth_tap.c | 33 +++++++++++++++++++++++++++------ > 1 file changed, 27 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.= c > index 310c7d8..c3af608 100644 > --- a/drivers/net/tap/rte_eth_tap.c > +++ b/drivers/net/tap/rte_eth_tap.c > @@ -95,13 +95,20 @@ enum ioctl_mode { >=20 > static int tap_intr_handle_set(struct rte_eth_dev *dev, int set); >=20 > -/* Tun/Tap allocation routine > +/** > + * Tun/Tap allocation routine > + * > + * @param[in] pmd > + * Pointer to private structure. > + * > + * @param[in] is_keepalive > + * Keepliave flag > * > - * name is the number of the interface to use, unless NULL to take the h= ost > - * supplied name. > + * @return > + * -1 on failure, fd on success > */ > static int > -tun_alloc(struct pmd_internals *pmd) > +tun_alloc(struct pmd_internals *pmd, int is_keepalive) This poor tun_alloc() routine did have a flag, then it was taken out and no= w it is back again :-( > { > struct ifreq ifr; > #ifdef IFF_MULTI_QUEUE > @@ -154,6 +161,20 @@ tun_alloc(struct pmd_internals *pmd) > goto error; > } >=20 > + if (is_keepalive) { > + /* > + * Detach the TUN/TAP keep-alive queue > + * to avoid traffic through it > + */ > + ifr.ifr_flags =3D IFF_DETACH_QUEUE; > + if (ioctl(fd, TUNSETQUEUE, (void *)&ifr) < 0) { > + TAP_LOG(WARNING, > + "Unable to detach keep-alive queue for %s: %s", > + ifr.ifr_name, strerror(errno)); > + goto error; > + } > + } > + > /* Always set the file descriptor to non-blocking */ > if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { > TAP_LOG(WARNING, > @@ -1020,7 +1041,7 @@ tap_setup_queue(struct rte_eth_dev *dev, > pmd->name, *other_fd, dir, qid, *fd); > } else { > /* Both RX and TX fds do not exist (equal -1). Create fd */ > - *fd =3D tun_alloc(pmd); > + *fd =3D tun_alloc(pmd, 0); > if (*fd < 0) { > *fd =3D -1; /* restore original value */ > TAP_LOG(ERR, "%s: tun_alloc() failed.", pmd->name); > @@ -1425,7 +1446,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, ch= ar *tap_name, > * This keep-alive file descriptor will guarantee that the TUN device > * exists even when all of its queues are closed > */ > - pmd->ka_fd =3D tun_alloc(pmd); > + pmd->ka_fd =3D tun_alloc(pmd, 1); > if (pmd->ka_fd =3D=3D -1) { > TAP_LOG(ERR, "Unable to create %s interface", tuntap_name); > goto error_exit; > --=20 > 2.7.4 >=20 Looks good to me. Acked-by: Keith Wiles Regards, Keith