From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id C29F91B369 for ; Wed, 14 Feb 2018 09:50:38 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id h9so21310799wre.12 for ; Wed, 14 Feb 2018 00:50:38 -0800 (PST) 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=6IBCdadLkGVJB5DRn8YYa6Q0D6bMOu9RrH3eq2b2R6s=; b=ljYuWbk9G8zvjF4NVSiIVbA74YUnCPEkSs9IZQbNFjZi0kLST4wcE5GVtDN3QHuc1Q ve88B20IOOP4kD1QPb91qvS8V+2rpdF4vGfbBMlfMqFFC6+YIiojrDOb/NM0MNdyvcNG 5rSmxtm3c0QyfSSypVDaJySQOUhEPuP5XT6xWlrXxb9eRXaxLtYMpNIo7+lPJQHVKRxE D3TULcawBKOwDYUpLbirivW9eZVuPPFu/v2sjKCuAvo4P0ovz86VHYtOY7OgaYrsUfL5 DOu4xwxFLL3AqldyOnzzuMaQDE/GTgSJhZGiZ+eiZZuzBh+weAZs2fHaF1qzf7AjG3CY Dr1Q== 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=6IBCdadLkGVJB5DRn8YYa6Q0D6bMOu9RrH3eq2b2R6s=; b=pHpd1kMtlfYNNCfxSpmxCOyy58d3BXXzDtA9DPVd7OxnexnNrcAa84bJIoQc/7MNEW jMgjV8T8ZhEoZUD4jbE9llIYpI0IfDslhT+HaOdNdrJbfo92SdUIP7mWVqG/Xx1TyY4e muj8zyZbrsrCtL5/6GVzCSdOkewMQh0+NyRm7Kun+yDUW51gB2WsQxdofx1+C5otrEsu Ogh49aTMiUkCi/comXNKQcfmHRpF7pA+ehoaebyah9FS6tv+TUN9d08ua8hELwinFhQi xCgKsIUzM84tFwBGBLxRSZVtS8fen8f40OwVyswtrIaf1IEvUN+QW0jF+AEeKZTjww3z 9acg== X-Gm-Message-State: APf1xPCivsLjQHvvcq0bOeAV4M2o1SpcqEpbFjwjeoX8c814fHD9B4Kf CvjXFb7phSkVZUWePGtHVMwlzg== X-Google-Smtp-Source: AH8x226P6HjezMrEU+7Vlm32GrIWH4NkyWhD0KPuNjlOEAaDyPaurMleBQjjDaqgpgHB7fiAvc6htQ== X-Received: by 10.223.134.132 with SMTP id 4mr3858091wrx.10.1518598238455; Wed, 14 Feb 2018 00:50:38 -0800 (PST) Received: from ?IPv6:2a01:e35:2e04:96e0:c150:28ea:209e:273a? ([2a01:e35:2e04:96e0:c150:28ea:209e:273a]) by smtp.gmail.com with ESMTPSA id 30sm8611688wri.48.2018.02.14.00.50.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 00:50:37 -0800 (PST) To: Ophir Munk , dev@dpdk.org Cc: Thomas Monjalon , Olga Shern , stable@dpdk.org References: <1518542172-9334-1-git-send-email-ophirmu@mellanox.com> <1518546947-20932-1-git-send-email-ophirmu@mellanox.com> From: Pascal Mazon Message-ID: Date: Wed, 14 Feb 2018 09:50:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1518546947-20932-1-git-send-email-ophirmu@mellanox.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v2] net/tap: fix promiscuous rules double insersions 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: Wed, 14 Feb 2018 08:50:38 -0000 Hi Ophir, Typo in title: s/insersions/insertions/ I'm ok on principle, I have just a few comments inline. Regards, Pascal On 13/02/2018 19:35, Ophir Munk wrote: > Running testpmd command "port stop all" followed by command "port start > all" may result in a TAP error: > PMD: Kernel refused TC filter rule creation (17): File exists > > Root cause analysis: during the execution of "port start all" command > testpmd calls rte_eth_promiscuous_enable() while during the execution > of "port stop all" command testpmd does not call > rte_eth_promiscuous_enable(). Shouldn't it be rte_eth_promiscuous_disable()? > As a result the TAP PMD is trying to add tc (traffic control command) > promiscuous rules to the remote netvsc device consecutively. From the > kernel point of view it is seen as an attempt to add the same rule more > than once. In recent kernels (e.g. version 4.13) this attempt is rejected > with a "File exists" error. In less recent kernels (e.g. version 4.4) the > same rule may have been accepted twice successfully, which is undesirable. > > In the corrupted code every tc promiscuous rule included a different > handle number parameter. If instead an identical handle number parameter is > used for all tc promiscuous rules - all kernels will reject the second > rule with a "File exists" error, which is easy to identify and to silently > ignore. > > Fixes: 2bc06869cd94 ("net/tap: add remote netdevice traffic capture") > Cc: stable@dpdk.org > > Signed-off-by: Ophir Munk > --- > v2: add detailed commit message > > drivers/net/tap/tap_flow.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c > index 65657f0..d1f4a52 100644 > --- a/drivers/net/tap/tap_flow.c > +++ b/drivers/net/tap/tap_flow.c > @@ -123,6 +123,7 @@ enum key_status_e { > }; > > #define ISOLATE_HANDLE 1 > +#define REMOTE_PROMISCUOUS_HANDLE 2 > > struct rte_flow { > LIST_ENTRY(rte_flow) next; /* Pointer to the next rte_flow structure */ > @@ -1692,9 +1693,15 @@ int tap_flow_implicit_create(struct pmd_internals *pmd, > * The ISOLATE rule is always present and must have a static handle, as > * the action is changed whether the feature is enabled (DROP) or > * disabled (PASSTHRU). > + * There is just one REMOTE_PROMISCUOUS rule in all cases. It should > + * have a static handle such that adding it twice will fail with EEXIST > + * with any kernel version. Remark: old kernels may falsely accept the > + * same REMOTE_PREMISCUOUS rules if they had different handles. s/PREMISCUOUS/PROMISCUOUS/ > */ > if (idx == TAP_ISOLATE) > remote_flow->msg.t.tcm_handle = ISOLATE_HANDLE; > + else if (idx == TAP_REMOTE_PROMISC) > + remote_flow->msg.t.tcm_handle = REMOTE_PROMISCUOUS_HANDLE; > else > tap_flow_set_handle(remote_flow); > if (priv_flow_process(pmd, attr, items, actions, NULL, > @@ -1709,12 +1716,16 @@ int tap_flow_implicit_create(struct pmd_internals *pmd, > } > err = tap_nl_recv_ack(pmd->nlsk_fd); > if (err < 0) { > + /* Silently ignore re-entering remote promiscuous rule */ > + if (errno == EEXIST && idx == TAP_REMOTE_PROMISC) > + goto success; > RTE_LOG(ERR, PMD, > "Kernel refused TC filter rule creation (%d): %s\n", > errno, strerror(errno)); > goto fail; > } > LIST_INSERT_HEAD(&pmd->implicit_flows, remote_flow, next); Are we sure the previous rule is still in the registered implicit flows? > +success: > return 0; > fail: > if (remote_flow)