From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <matan@mellanox.com>
Received: from EUR02-AM5-obe.outbound.protection.outlook.com
 (mail-eopbgr00057.outbound.protection.outlook.com [40.107.0.57])
 by dpdk.org (Postfix) with ESMTP id 5DFFD1B4E4;
 Thu,  2 Aug 2018 19:52:19 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=CZ8fXRESRmfGoJkKzfBWbGqeTHl6m/SG6mN1XPyBFeU=;
 b=doDDh60ulIpCOUnDmTPHDUaI247/W7tT5120ZjW2DxrfhESgNgMKgRXLZ+lR2yruXx7TSSowDtiKrEXRfy1CaowBWoNA90cUNtbBLn3knT1MBqE/cxSMiPFXfdPRGxK4cWktfruNZljUUEjBJyyxQ7ZRKdu9Aqhgdg/pf8G5pC8=
Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.41.11) by
 AM0PR0502MB3714.eurprd05.prod.outlook.com (52.133.46.159) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1017.14; Thu, 2 Aug 2018 17:52:18 +0000
Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com
 ([fe80::9d98:d47f:5b50:1f49]) by AM0PR0502MB4019.eurprd05.prod.outlook.com
 ([fe80::9d98:d47f:5b50:1f49%2]) with mapi id 15.20.0995.020; Thu, 2 Aug 2018
 17:52:18 +0000
From: Matan Azrad <matan@mellanox.com>
To: Adrien Mazarguil <adrien.mazarguil@6wind.com>
CC: Keith Wiles <keith.wiles@intel.com>, Ophir Munk <ophirmu@mellanox.com>,
 "dev@dpdk.org" <dev@dpdk.org>, "stable@dpdk.org" <stable@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH] net/tap: fix zeroed flow mask configurations
Thread-Index: AQHUKkxANy4bvWK4qUyNwHKWN0YqIaSshVOAgAA3A8A=
Date: Thu, 2 Aug 2018 17:52:18 +0000
Message-ID: <AM0PR0502MB4019749C9255316DA451E785D22C0@AM0PR0502MB4019.eurprd05.prod.outlook.com>
References: <1533205980-7874-1-git-send-email-matan@mellanox.com>
 <20180802142737.GO5211@6wind.com>
In-Reply-To: <20180802142737.GO5211@6wind.com>
Accept-Language: en-US, he-IL
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [85.64.136.190]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; AM0PR0502MB3714;
 6:iY3ZlWZAU+nkfYVqroSganbvqZwWDR01qvs2oSfXRqrscNK+oxl4e/LLjKAtwPPQ0GH3i2v4YQ+e8ubSBuHJyCiASYUyYwFqvYY7Q9ed9xu9gco2wKTY/9+Hs4w62HlOGWEEK8jToPaUIJFsKgPxVPQmq8uYj1FojMr9AAMVdXP6NpuW/5KtbtS4gLlgRDW3GO2yaDb6EEjzcndVMeOAXJjriP5R7XR8f5SDVNG02mIjtVfZ750Xt4KDY9MWW4LOA9na0gXhHJ4IshBWOcMlyGrsXFB5wjc42VXe4jJJNCs6aczL0on4+GY+Jd4SNvpEehH9W9RtXmTJwgWXMKcZ8fpmjMHCFto4vFJd07UXK7n7IA63rzeS/outH+aglyRtWBOmhAOtYPrY0E/i5zmCP3cdMRGpD6Cfzvf1ZmPuqEQQu2o6x/PC+lTG9hjDBW+lRb3HqEJSGteRk1IIIv0K9Q==;
 5:6bQWj0vb+bED3td9X0KmYjlXpNyHrJGLRXVa7/FG9Z2COr6iIMLw9CyhY/172s0nT29Ab+YZzLC12vAHnUEfBf5tJE3504h2C7SYa78ynz7MmOulkBqnPPKgFb96FLFRLePA64HABOf5YdjUWzweatgAk3ZOCIj9UeSf2dSH4Ok=;
 7:zH4MQVsI6pwC+2to6wiETqsSiQCKfesJzNKX59REYnSzBj4jEseidB6C8vgQW0IK7vn1qde4YU02ggV4GoTjirJHHDuLzhBelzQfEPc0pLEt429hr0cPp+5DFIaQ7jD8hJNdwuhDEUbYImzMEqTZMuci//QTvY4VduYkO9a/dc21beTwuFs2awyswPav0xW+FWBXSiRbL33iJZOw67zyI/bwztasLf+fcEDJRO4v6zJF68+FuWEmCbUOasVP2xBw
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-correlation-id: 564d979a-f691-40ad-fbfa-08d5f8a0b093
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: BCL:0; PCL:0;
 RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);
 SRVR:AM0PR0502MB3714; 
x-ms-traffictypediagnostic: AM0PR0502MB3714:
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=matan@mellanox.com; 
x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr
x-microsoft-antispam-prvs: <AM0PR0502MB37143EE7A6FD6D00442E89B7D22C0@AM0PR0502MB3714.eurprd05.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(200054503718035);
x-ms-exchange-senderadcheck: 1
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
 RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016);
 SRVR:AM0PR0502MB3714; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0502MB3714; 
x-forefront-prvs: 07521929C1
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(136003)(39860400002)(346002)(376002)(366004)(396003)(189003)(199004)(11346002)(81166006)(102836004)(68736007)(6506007)(14454004)(8936002)(81156014)(8676002)(54906003)(3846002)(6116002)(33656002)(229853002)(7736002)(305945005)(7696005)(486006)(86362001)(446003)(99286004)(256004)(186003)(316002)(76176011)(6246003)(26005)(476003)(66066001)(97736004)(6916009)(2906002)(5250100002)(74316002)(6436002)(53936002)(4326008)(25786009)(9686003)(2900100001)(5660300001)(106356001)(478600001)(105586002)(55016002);
 DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3714;
 H:AM0PR0502MB4019.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en;
 PTR:InfoNoRecords; MX:1; A:1; 
received-spf: None (protection.outlook.com: mellanox.com does not designate
 permitted sender hosts)
x-microsoft-antispam-message-info: 9tX8jK/BDmpnzcKDaCZ+y/p5Gyf87FemtG8lRXbWYqipS7pn51+FykakNmOK9Qwzdfb2Y5LMwW82DLmMApwH4ovphWgH7ykIWWjGEsDEO2Qx3jkEXjFo1U+cRWET8oSyE6uVoEVO92lLFk9N4jukWdsXqOXm49pDRSJVj667V7n8pkhs1jms1E6kf5SBtYHq1h0KkUOHjoYsnCn8EQGxOAC/Gsmmlm/qSfaPmPbv5sFSER/sDVTHbGBXsxF/z4N6o2PiM3+KtD99qI7AuHs674qxjoQYNEqPGZOVrl5n+s9YYzibACNxRpci1n3yfvcsPmhBMaizqk4XK810mGSq/++TNa338oYjo8Gjw9O0gw0=
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: Mellanox.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 564d979a-f691-40ad-fbfa-08d5f8a0b093
X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2018 17:52:18.2643 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3714
Subject: Re: [dpdk-dev] [PATCH] net/tap: fix zeroed flow mask configurations
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 02 Aug 2018 17:52:19 -0000

Hi Adrien

From: Adrien Mazarguil
> On Thu, Aug 02, 2018 at 10:33:00AM +0000, Matan Azrad wrote:
> > The rte_flow meaning of zero flow mask configuration is to match all
> > the range of the item value.
> > For example, the flow eth / ipv4 dst spec 1.2.3.4 dst mask 0.0.0.0
> > should much all the ipv4 traffic from the rte_flow API perspective.
> >
> > From some kernel perspectives the above rule means to ignore all the
> > ipv4 traffic (e.g. Ubuntu 16.04, 4.15.10).
> >
> > Due to the fact that the tap PMD should provide the rte_flow meaning,
> > it is necessary to ignore the spec in case the mask is zero when it
> > forwards such like flows to the kernel.
> > So, the above rule should be translated to eth / ipv4 to get the
> > correct meaning.
> >
> > Ignore spec configurations when the mask is zero.
>=20
> I would go further, one should be able to match IP address 0.0.0.0 for in=
stance.
> The PMD should only trust the mask on all fields without looking at spec.

The PMD should convert the RTE flow API to the device configuration,
So I can think on scenarios that the PMD should look on spec.

 See
> below for suggestions.
>=20
> > Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and
> > actions")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Matan Azrad <matan@mellanox.com>
> > ---
> >  drivers/net/tap/tap_flow.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
> > index 6b60e6d..993e6f6 100644
> > --- a/drivers/net/tap/tap_flow.c
> > +++ b/drivers/net/tap/tap_flow.c
> > @@ -537,7 +537,8 @@ tap_flow_create_eth(const struct rte_flow_item
> *item, void *data)
> >  	if (!flow)
> >  		return 0;
> >  	msg =3D &flow->msg;
> > -	if (!is_zero_ether_addr(&spec->dst)) {
> > +	if (!is_zero_ether_addr(&spec->dst) &&
>=20
> This check should be removed.

I don't know why we need this check, and the below checks
So it should be tested before the change.
It may be a different issue.

>=20
> > +	    !is_zero_ether_addr(&mask->dst)) {
> >  		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_DST,
> ETHER_ADDR_LEN,
> >  			   &spec->dst.addr_bytes);
> >  		tap_nlattr_add(&msg->nh,
> > @@ -651,13 +652,13 @@ tap_flow_create_ipv4(const struct rte_flow_item
> *item, void *data)
> >  		info->eth_type =3D htons(ETH_P_IP);
> >  	if (!spec)
> >  		return 0;
> > -	if (spec->hdr.dst_addr) {
> > +	if (spec->hdr.dst_addr && mask->hdr.dst_addr) {
>=20
> Ditto (before &&).
>=20
> >  		tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST,
> >  			     spec->hdr.dst_addr);
> >  		tap_nlattr_add32(&msg->nh,
> TCA_FLOWER_KEY_IPV4_DST_MASK,
> >  			     mask->hdr.dst_addr);
> >  	}
> > -	if (spec->hdr.src_addr) {
> > +	if (spec->hdr.src_addr && mask->hdr.src_addr) {
>=20
> Ditto.
>=20
> >  		tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC,
> >  			     spec->hdr.src_addr);
> >  		tap_nlattr_add32(&msg->nh,
> TCA_FLOWER_KEY_IPV4_SRC_MASK, @@ -707,13
> > +708,15 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void
> *data)
> >  		info->eth_type =3D htons(ETH_P_IPV6);
> >  	if (!spec)
> >  		return 0;
> > -	if (memcmp(spec->hdr.dst_addr, empty_addr, 16)) {
> > +	if (memcmp(spec->hdr.dst_addr, empty_addr, 16) &&
>=20
> Ditto.
>=20
> > +	    memcmp(mask->hdr.dst_addr, empty_addr, 16)) {
> >  		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST,
> >  			   sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr);
> >  		tap_nlattr_add(&msg->nh,
> TCA_FLOWER_KEY_IPV6_DST_MASK,
> >  			   sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr);
> >  	}
> > -	if (memcmp(spec->hdr.src_addr, empty_addr, 16)) {
> > +	if (memcmp(spec->hdr.src_addr, empty_addr, 16) &&
>=20
> Ditto.
>=20
> > +	    memcmp(mask->hdr.src_addr, empty_addr, 16)) {
> >  		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC,
> >  			   sizeof(spec->hdr.src_addr), &spec->hdr.src_addr);
> >  		tap_nlattr_add(&msg->nh,
> TCA_FLOWER_KEY_IPV6_SRC_MASK,
> > --
> > 2.7.4
> >
>=20
> --
> Adrien Mazarguil
> 6WIND