From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00081.outbound.protection.outlook.com [40.107.0.81]) by dpdk.org (Postfix) with ESMTP id 9E2932BD3; Mon, 25 Mar 2019 14:01:46 +0100 (CET) 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=7w+klHHJg+eU9rzbqGKX0/cWb18Xgcp3wXqxsZUT+Yk=; b=rldHCfxOU93DgFJ4rpo0+Ge1GrR5QDuyiimtPMx+rjo5ErR/l3lwgTYokI1rR/ztVEhKl1gDya8+/Y1TwY+dzNnEw53+VW5eDGeTP8QMHMpIwGeNKNF8TQaarp+RvBqYGD9Rp/1j4FBmBjksEseYHCL/mBNCWdc5TWdMeNKSP4s= Received: from AM0PR0502MB3732.eurprd05.prod.outlook.com (52.133.50.17) by AM0PR0502MB3633.eurprd05.prod.outlook.com (52.133.46.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15; Mon, 25 Mar 2019 13:01:43 +0000 Received: from AM0PR0502MB3732.eurprd05.prod.outlook.com ([fe80::eda9:8f7:2e54:f7e1]) by AM0PR0502MB3732.eurprd05.prod.outlook.com ([fe80::eda9:8f7:2e54:f7e1%3]) with mapi id 15.20.1730.019; Mon, 25 Mar 2019 13:01:43 +0000 From: Saleh Alsouqi To: "ferruh.yigit@intel.com" , "roszenrami@gmail.com" CC: "wenzhuo.lu@intel.com" , "jingjing.wu@intel.com" , "bernard.iremonger@intel.com" , "dev@dpdk.org" , Ori Kam , "stable@dpdk.org" , "olivier.matz@6wind.com" , Saleh Alsouqi Thread-Topic: [PATCH v2] app/testpmd: fix mpls encap ipv4 version and ihl Thread-Index: AQHU4wrlxS/oQRFDZkC2pW9lMA6/RA== Date: Mon, 25 Mar 2019 13:01:43 +0000 Message-ID: <20190325130013.3737-1-salehals@mellanox.com> References: <1545136604-22816-1-git-send-email-salehals@mellanox.com> In-Reply-To: <1545136604-22816-1-git-send-email-salehals@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: LNXP265CA0095.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::35) To AM0PR0502MB3732.eurprd05.prod.outlook.com (2603:10a6:208:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=salehals@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 21bae94d-b6f1-4343-dc2c-08d6b1220777 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM0PR0502MB3633; x-ms-traffictypediagnostic: AM0PR0502MB3633: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-forefront-prvs: 0987ACA2E2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(346002)(136003)(39860400002)(396003)(366004)(199004)(189003)(1076003)(66574012)(36756003)(110136005)(6306002)(316002)(107886003)(52116002)(6512007)(54906003)(106356001)(86362001)(105586002)(2501003)(71190400001)(53936002)(4326008)(99286004)(25786009)(3846002)(6116002)(26005)(66066001)(14454004)(186003)(76176011)(6506007)(386003)(8936002)(5660300002)(71200400001)(478600001)(6436002)(486006)(476003)(81166006)(81156014)(11346002)(2616005)(2906002)(446003)(8676002)(7736002)(102836004)(305945005)(6486002)(966005)(97736004)(256004)(50226002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3633; H:AM0PR0502MB3732.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: lCNKTTTYMW7Yit5C8kESxGR8L6O6pztf8SohpKdJIgJ4zMlD3SYue9QtF9qRgNsNIZtuBZeTS8TW71Lpp3DdxKDL8I/uQxQ85w+xcFN4J8upSzUZOOe5Y59FavXu65CbZgpD1rnHW4OAFxbWDHP+YmnFZywPKjPmrdX2caHs3PrgVi/G6tUpCm8HdyZjT9z/z6kJzpTX5rC+Ds//F0C5fp0d4J7Df8fevk5TN0GGtJ0PLH/xLGCex4W4dsk4EqSu2F8vTuiIFbsVDny+WUo5X7RKSwfOfy+nNYRlEmDU6kk8cfN26k0U410F4pTQBat9GYY1pQOzG4oTrAzVCVmcas03dhdJz7BE4wduBrrp+YshqaVGGB2ZcNbXpzqbjdArfRvcRssHdl2D/lneufVo88n4GGLlthu8GSaVI5QRhTQ= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21bae94d-b6f1-4343-dc2c-08d6b1220777 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Mar 2019 13:01:43.6757 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3633 Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix mpls encap ipv4 version and ihl 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: Mon, 25 Mar 2019 13:01:46 -0000 According to ietf rfc791 (see [1]) "The Version field indicates the format of the internet header." "Internet Header Length (ihl) is the length of the internet header in 32 bit words, and thus points to the beginning of the data. Note that the minimum value for a correct header is 5." Having version and ihl set to 0 would result in a corrupted/incorrect encapsulating packet for MPLS, this commit sets these fields to 4 and 5 respectively as a default value. [1] https://tools.ietf.org/html/rfc791 Fixes: 3e77031be855 ("app/testpmd: add MPLSoGRE encapsulation") Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation") Cc: stable@dpdk.org Signed-off-by: Saleh Alsouqi --- v2: - Include netinet/ip.h in librte_net/rte_ip.h to use existing definitions instead of defining our own. - Move definitions from testpmd.h to librte_net/rte_ip.h --- app/test-pmd/cmdline_flow.c | 6 ++++++ lib/librte_net/rte_ip.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 36659a64a..f536307c9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -3767,11 +3767,14 @@ parse_vc_action_mplsogre_encap(struct context *ctx,= const struct token *token, .src_addr =3D mplsogre_encap_conf.ipv4_src, .dst_addr =3D mplsogre_encap_conf.ipv4_dst, .next_proto_id =3D IPPROTO_GRE, + .version_ihl =3D IPV4_VHL_DEF, + .time_to_live =3D IPDEFTTL, }, }; struct rte_flow_item_ipv6 ipv6 =3D { .hdr =3D { .proto =3D IPPROTO_GRE, + .hop_limits =3D IPDEFTTL, }, }; struct rte_flow_item_gre gre =3D { @@ -3955,11 +3958,14 @@ parse_vc_action_mplsoudp_encap(struct context *ctx,= const struct token *token, .src_addr =3D mplsoudp_encap_conf.ipv4_src, .dst_addr =3D mplsoudp_encap_conf.ipv4_dst, .next_proto_id =3D IPPROTO_UDP, + .version_ihl =3D IPV4_VHL_DEF, + .time_to_live =3D IPDEFTTL, }, }; struct rte_flow_item_ipv6 ipv6 =3D { .hdr =3D { .proto =3D IPPROTO_UDP, + .hop_limits =3D IPDEFTTL, }, }; struct rte_flow_item_udp udp =3D { diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index f9b909090..499a2f79c 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -17,6 +17,7 @@ =20 #include #include +#include =20 #include #include @@ -89,6 +90,10 @@ struct ipv4_hdr { #define IS_IPV4_MCAST(x) \ ((x) >=3D IPV4_MIN_MCAST && (x) <=3D IPV4_MAX_MCAST) /**< check if IPv4 a= ddress is multicast */ =20 +/* IPv4 default fields values */ +#define IPV4_MIN_IHL (0x5) +#define IPV4_VHL_DEF (IPVERSION | IPV4_MIN_IHL) + /** * @internal Calculate a sum of all words in the buffer. * Helper routine for the rte_raw_cksum(). --=20 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E0E33A05D3 for ; Mon, 25 Mar 2019 14:01:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9F2052BF4; Mon, 25 Mar 2019 14:01:48 +0100 (CET) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00081.outbound.protection.outlook.com [40.107.0.81]) by dpdk.org (Postfix) with ESMTP id 9E2932BD3; Mon, 25 Mar 2019 14:01:46 +0100 (CET) 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=7w+klHHJg+eU9rzbqGKX0/cWb18Xgcp3wXqxsZUT+Yk=; b=rldHCfxOU93DgFJ4rpo0+Ge1GrR5QDuyiimtPMx+rjo5ErR/l3lwgTYokI1rR/ztVEhKl1gDya8+/Y1TwY+dzNnEw53+VW5eDGeTP8QMHMpIwGeNKNF8TQaarp+RvBqYGD9Rp/1j4FBmBjksEseYHCL/mBNCWdc5TWdMeNKSP4s= Received: from AM0PR0502MB3732.eurprd05.prod.outlook.com (52.133.50.17) by AM0PR0502MB3633.eurprd05.prod.outlook.com (52.133.46.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15; Mon, 25 Mar 2019 13:01:43 +0000 Received: from AM0PR0502MB3732.eurprd05.prod.outlook.com ([fe80::eda9:8f7:2e54:f7e1]) by AM0PR0502MB3732.eurprd05.prod.outlook.com ([fe80::eda9:8f7:2e54:f7e1%3]) with mapi id 15.20.1730.019; Mon, 25 Mar 2019 13:01:43 +0000 From: Saleh Alsouqi To: "ferruh.yigit@intel.com" , "roszenrami@gmail.com" CC: "wenzhuo.lu@intel.com" , "jingjing.wu@intel.com" , "bernard.iremonger@intel.com" , "dev@dpdk.org" , Ori Kam , "stable@dpdk.org" , "olivier.matz@6wind.com" , Saleh Alsouqi Thread-Topic: [PATCH v2] app/testpmd: fix mpls encap ipv4 version and ihl Thread-Index: AQHU4wrlxS/oQRFDZkC2pW9lMA6/RA== Date: Mon, 25 Mar 2019 13:01:43 +0000 Message-ID: <20190325130013.3737-1-salehals@mellanox.com> References: <1545136604-22816-1-git-send-email-salehals@mellanox.com> In-Reply-To: <1545136604-22816-1-git-send-email-salehals@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: LNXP265CA0095.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::35) To AM0PR0502MB3732.eurprd05.prod.outlook.com (2603:10a6:208:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=salehals@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 21bae94d-b6f1-4343-dc2c-08d6b1220777 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM0PR0502MB3633; x-ms-traffictypediagnostic: AM0PR0502MB3633: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-forefront-prvs: 0987ACA2E2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(346002)(136003)(39860400002)(396003)(366004)(199004)(189003)(1076003)(66574012)(36756003)(110136005)(6306002)(316002)(107886003)(52116002)(6512007)(54906003)(106356001)(86362001)(105586002)(2501003)(71190400001)(53936002)(4326008)(99286004)(25786009)(3846002)(6116002)(26005)(66066001)(14454004)(186003)(76176011)(6506007)(386003)(8936002)(5660300002)(71200400001)(478600001)(6436002)(486006)(476003)(81166006)(81156014)(11346002)(2616005)(2906002)(446003)(8676002)(7736002)(102836004)(305945005)(6486002)(966005)(97736004)(256004)(50226002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3633; H:AM0PR0502MB3732.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: lCNKTTTYMW7Yit5C8kESxGR8L6O6pztf8SohpKdJIgJ4zMlD3SYue9QtF9qRgNsNIZtuBZeTS8TW71Lpp3DdxKDL8I/uQxQ85w+xcFN4J8upSzUZOOe5Y59FavXu65CbZgpD1rnHW4OAFxbWDHP+YmnFZywPKjPmrdX2caHs3PrgVi/G6tUpCm8HdyZjT9z/z6kJzpTX5rC+Ds//F0C5fp0d4J7Df8fevk5TN0GGtJ0PLH/xLGCex4W4dsk4EqSu2F8vTuiIFbsVDny+WUo5X7RKSwfOfy+nNYRlEmDU6kk8cfN26k0U410F4pTQBat9GYY1pQOzG4oTrAzVCVmcas03dhdJz7BE4wduBrrp+YshqaVGGB2ZcNbXpzqbjdArfRvcRssHdl2D/lneufVo88n4GGLlthu8GSaVI5QRhTQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21bae94d-b6f1-4343-dc2c-08d6b1220777 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Mar 2019 13:01:43.6757 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3633 Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix mpls encap ipv4 version and ihl 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190325130143.e4atNkFUde7pQ0GtJwL0IklgkVOlaVM1Ov2gtIKSzvo@z> According to ietf rfc791 (see [1]) "The Version field indicates the format of the internet header." "Internet Header Length (ihl) is the length of the internet header in 32 bit words, and thus points to the beginning of the data. Note that the minimum value for a correct header is 5." Having version and ihl set to 0 would result in a corrupted/incorrect encapsulating packet for MPLS, this commit sets these fields to 4 and 5 respectively as a default value. [1] https://tools.ietf.org/html/rfc791 Fixes: 3e77031be855 ("app/testpmd: add MPLSoGRE encapsulation") Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation") Cc: stable@dpdk.org Signed-off-by: Saleh Alsouqi --- v2: - Include netinet/ip.h in librte_net/rte_ip.h to use existing definitions instead of defining our own. - Move definitions from testpmd.h to librte_net/rte_ip.h --- app/test-pmd/cmdline_flow.c | 6 ++++++ lib/librte_net/rte_ip.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 36659a64a..f536307c9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -3767,11 +3767,14 @@ parse_vc_action_mplsogre_encap(struct context *ctx,= const struct token *token, .src_addr =3D mplsogre_encap_conf.ipv4_src, .dst_addr =3D mplsogre_encap_conf.ipv4_dst, .next_proto_id =3D IPPROTO_GRE, + .version_ihl =3D IPV4_VHL_DEF, + .time_to_live =3D IPDEFTTL, }, }; struct rte_flow_item_ipv6 ipv6 =3D { .hdr =3D { .proto =3D IPPROTO_GRE, + .hop_limits =3D IPDEFTTL, }, }; struct rte_flow_item_gre gre =3D { @@ -3955,11 +3958,14 @@ parse_vc_action_mplsoudp_encap(struct context *ctx,= const struct token *token, .src_addr =3D mplsoudp_encap_conf.ipv4_src, .dst_addr =3D mplsoudp_encap_conf.ipv4_dst, .next_proto_id =3D IPPROTO_UDP, + .version_ihl =3D IPV4_VHL_DEF, + .time_to_live =3D IPDEFTTL, }, }; struct rte_flow_item_ipv6 ipv6 =3D { .hdr =3D { .proto =3D IPPROTO_UDP, + .hop_limits =3D IPDEFTTL, }, }; struct rte_flow_item_udp udp =3D { diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index f9b909090..499a2f79c 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -17,6 +17,7 @@ =20 #include #include +#include =20 #include #include @@ -89,6 +90,10 @@ struct ipv4_hdr { #define IS_IPV4_MCAST(x) \ ((x) >=3D IPV4_MIN_MCAST && (x) <=3D IPV4_MAX_MCAST) /**< check if IPv4 a= ddress is multicast */ =20 +/* IPv4 default fields values */ +#define IPV4_MIN_IHL (0x5) +#define IPV4_VHL_DEF (IPVERSION | IPV4_MIN_IHL) + /** * @internal Calculate a sum of all words in the buffer. * Helper routine for the rte_raw_cksum(). --=20 2.17.1