From patchwork Mon Jul 15 13:58:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1132013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="ARIEI340"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45nQ9j2vM6z9sSd for ; Mon, 15 Jul 2019 23:58:48 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A23F7E52; Mon, 15 Jul 2019 13:58:45 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 66684DB1 for ; Mon, 15 Jul 2019 13:58:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9A0D8876 for ; Mon, 15 Jul 2019 13:58:43 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190715135841euoutp0289e6f293c90e8f237379b10fc1dcad2f~xmVGgaqdp1586315863euoutp02q for ; Mon, 15 Jul 2019 13:58:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190715135841euoutp0289e6f293c90e8f237379b10fc1dcad2f~xmVGgaqdp1586315863euoutp02q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1563199121; bh=b4xZn5QVW165I5JSe927JpC2Is2p71QPzU8iirAIs6w=; h=From:To:Cc:Subject:Date:References:From; b=ARIEI340iRP8hOb4NEWQQKVS6iz6rjPvlcu/RYxX9r9Eqv1SzbMJ0hqWnwJhLT5Wr KTXCYWp/FGKQAgxO6rIs8D4MOA8q15nWRWTKqlmhFi7KJhrd9jVBdiLtzw64KEome0 rALW7W+wDTJTM+B8RDRrEGOo2fKBOtWvNr+WRxY8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190715135840eucas1p169c8beed347fcf934bc17cc6e78500df~xmVFje5251423614236eucas1p1I; Mon, 15 Jul 2019 13:58:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 54.6C.04377.0968C2D5; Mon, 15 Jul 2019 14:58:40 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190715135839eucas1p195631e7778f3433eaf3ff57280d31927~xmVEsdBDN1422414224eucas1p1H; Mon, 15 Jul 2019 13:58:39 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190715135839eusmtrp2bc4b8d584ecfc8243af921e41a0d09ad~xmVEeZyHy0782807828eusmtrp2O; Mon, 15 Jul 2019 13:58:39 +0000 (GMT) X-AuditID: cbfec7f4-113ff70000001119-cf-5d2c86901931 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 05.9A.04146.F868C2D5; Mon, 15 Jul 2019 14:58:39 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190715135838eusmtip15de22c9f079b5366e64e4310b551a6d4~xmVEF7Rt02606726067eusmtip1L; Mon, 15 Jul 2019 13:58:38 +0000 (GMT) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 15 Jul 2019 16:58:34 +0300 Message-Id: <20190715135834.30963-1-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRmVeSWpSXmKPExsWy7djP87oT2nRiDb7/4bZ4NbmB0eJK+092 i7mfnjNaXL/EY/H76zYmB1aPnbPusnss3vOSyePZzf+MHs+v9bB49G1ZxRjAGsVlk5Kak1mW WqRvl8CV0T9nMVNBt2rFnz0HmRoYt8t0MXJySAiYSKxfspeti5GLQ0hgBaPEqsWXmSGcL4wS 7492sEM4nxkl9m6YzwjT8unbQSaIxHJGicsHfkE5PxgldrXvYwKpYhPQkTi1+ghYh4iAtMTr 3jesIEXMAq2MEq2TX4AVCQsYSPxqXcwMYrMIqErc+nqHHcTmFbCW6NtxkRlinbzE6g0HwI6S EDjCJvFm0gs2iISLxPnld5kgbGGJV8e3sEPYMhL/d86HitdL3G95yQjR3MEoMf3QP6iEvcSW 1+eAGjiATtKUWL9LHyLsKNH4aRMjSFhCgE/ixltBkDAzkDlp23RmiDCvREebEES1isTvg8uh zpSSuPnuMztEiYfEon1FIGEhgViJT2sPME9glJuFsGoBI+MqRvHU0uLc9NRio7zUcr3ixNzi 0rx0veT83E2MwMg//e/4lx2Mu/4kHWIU4GBU4uF1SNGOFWJNLCuuzD3EKMHBrCTCa/sVKMSb klhZlVqUH19UmpNafIhRmoNFSZy3muFBtJBAemJJanZqakFqEUyWiYNTqoHRUnurS/fJr8da JLcbr/zD1PLy4OVOpYzCn782m2tcEv6e1WFdFv7e5OXZQ+d+6u3R663oz9de+ezwJWMdj5U/ NG8sstkvcONxZQ/rIi4li9Cm9awsEu7erlsC3zl0q075s2ne449zLG1O3JPo97r9cVN555u9 l1880r/d7xubUT//v8rnuhsflFiKMxINtZiLihMBg8P6tPgCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDLMWRmVeSWpSXmKPExsVy+t/xu7r9bTqxBlsOi1i8mtzAaHGl/Se7 xdxPzxktrl/isfj9dRuTA6vHzll32T0W73nJ5PHs5n9Gj+fXelg8+rasYgxgjdKzKcovLUlV yMgvLrFVija0MNIztLTQMzKx1DM0No+1MjJV0rezSUnNySxLLdK3S9DL6J+zmKmgW7Xiz56D TA2M22W6GDk5JARMJD59O8jUxcjFISSwlFFi07lvrBAJKYkfvy5A2cISf651sUEUfWOUWL1k CjNIgk1AR+LU6iOMILaIgLTE6943rCBFzAKdjBIt1x+DJYQFDCR+tS4Ga2ARUJW49fUOO4jN K2At0bfjIjPEBnmJ1RsOME9g5FnAyLCKUSS1tDg3PbfYUK84Mbe4NC9dLzk/dxMjMOS2Hfu5 eQfjpY3BhxgFOBiVeHgdUrRjhVgTy4orcw8xSnAwK4nw2n4FCvGmJFZWpRblxxeV5qQWH2I0 BVo+kVlKNDkfGA95JfGGpobmFpaG5sbmxmYWSuK8HQIHY4QE0hNLUrNTUwtSi2D6mDg4pRoY 58teW/ZZe4fa4R5OIetTKm+qXieufLnBYNdzm4KkZxHTJn04cLxqDl/zQokJ6rmPuwJ9Cy59 +n9xgf3CO3PObrBo3TT97JRADy65BccC+KslbUKPXXtyWm/12dYlDnw/NVQ9bLcsig84L/z5 uhn74tDTXsevnjtibZjVH7lIt8Ms0XX7L/6f5UosxRmJhlrMRcWJAAGmCPRPAgAA X-CMS-MailID: 20190715135839eucas1p195631e7778f3433eaf3ff57280d31927 X-Msg-Generator: CA X-RootMTR: 20190715135839eucas1p195631e7778f3433eaf3ff57280d31927 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190715135839eucas1p195631e7778f3433eaf3ff57280d31927 References: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH] odp-util: Fix NSH mask parsing. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 'odp_flow_key_to_flow__' is used to parse both keys and masks. However, 'odp_nsh_key_from_attr' expects only 'key' as an argument and fails to parse masks with ODP_FIT_ERROR which causes userspace system tests failures: # make check-system-userspace TESTSUITEFLAGS='-k nsh' |odp_util(revalidator)|WARN| OVS_NSH_KEY_ATTR_MD1 present but declared mdtype 0 is not 1 (NSH_M_TYPE1) |odp_util(revalidator)|WARN| the flow mask in error is: <...> nsh(flags=0ttl=0,mdtype=0,np=255,spi=0x0,si=0), for the following flow key: <...> nsh_ttl=8,nsh_mdtype=1,nsh_np=3,nsh_spi=0x64,nsh_si=3, nsh_c1=0x1020304,nsh_c2=0x5060708,nsh_c3=0x90a0b0c,nsh_c4=0xd0e0f10 <...> Fix that by passing the additional argument 'is_mask' to make it be like all other parsing functions. Additionally fixed missing comma in the 'format_nsh_key'. CC: Yi Yang Fixes: f59cb331c481 ("nsh: rework NSH netlink keys and actions") Signed-off-by: Ilya Maximets Acked-by: William Tu --- lib/odp-util.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index 3a28877e3..84ea4c148 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -264,7 +264,7 @@ static void format_nsh_key(struct ds *ds, const struct ovs_key_nsh *key) { ds_put_format(ds, "flags=%d", key->flags); - ds_put_format(ds, "ttl=%d", key->ttl); + ds_put_format(ds, ",ttl=%d", key->ttl); ds_put_format(ds, ",mdtype=%d", key->mdtype); ds_put_format(ds, ",np=%d", key->np); ds_put_format(ds, ",spi=0x%x", @@ -2798,11 +2798,14 @@ odp_parse_error(struct vlog_rate_limit *rl, char **errorp, } /* Parses OVS_KEY_ATTR_NSH attribute 'attr' into 'nsh' and 'nsh_mask' and - * returns fitness. If 'errorp' is nonnull and the function returns - * ODP_FIT_ERROR, stores a malloc()'d error message in '*errorp'. */ -enum odp_key_fitness -odp_nsh_key_from_attr(const struct nlattr *attr, struct ovs_key_nsh *nsh, - struct ovs_key_nsh *nsh_mask, char **errorp) + * returns fitness. If the attribute is a key, 'is_mask' should be false; + * if it is a mask, 'is_mask' should be true. If 'errorp' is nonnull and the + * function returns ODP_FIT_ERROR, stores a malloc()'d error message in + * '*errorp'. */ +static enum odp_key_fitness +odp_nsh_key_from_attr__(const struct nlattr *attr, bool is_mask, + struct ovs_key_nsh *nsh, struct ovs_key_nsh *nsh_mask, + char **errorp) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); if (errorp) { @@ -2877,7 +2880,7 @@ odp_nsh_key_from_attr(const struct nlattr *attr, struct ovs_key_nsh *nsh, return ODP_FIT_TOO_MUCH; } - if (has_md1 && nsh->mdtype != NSH_M_TYPE1 && !nsh_mask) { + if (!is_mask && has_md1 && nsh->mdtype != NSH_M_TYPE1 && !nsh_mask) { odp_parse_error(&rl, errorp, "OVS_NSH_KEY_ATTR_MD1 present but " "declared mdtype %"PRIu8" is not %d (NSH_M_TYPE1)", nsh->mdtype, NSH_M_TYPE1); @@ -2887,6 +2890,17 @@ odp_nsh_key_from_attr(const struct nlattr *attr, struct ovs_key_nsh *nsh, return ODP_FIT_PERFECT; } +/* Parses OVS_KEY_ATTR_NSH attribute 'attr' into 'nsh' and 'nsh_mask' and + * returns fitness. The attribute should be a key (not a mask). If 'errorp' + * is nonnull and the function returns ODP_FIT_ERROR, stores a malloc()'d error + * message in '*errorp'. */ +enum odp_key_fitness +odp_nsh_key_from_attr(const struct nlattr *attr, struct ovs_key_nsh *nsh, + struct ovs_key_nsh *nsh_mask, char **errorp) +{ + return odp_nsh_key_from_attr__(attr, false, nsh, nsh_mask, errorp); +} + /* Parses OVS_KEY_ATTR_TUNNEL attribute 'attr' into 'tun' and returns fitness. * If the attribute is a key, 'is_mask' should be false; if it is a mask, * 'is_mask' should be true. If 'errorp' is nonnull and the function returns @@ -6750,8 +6764,9 @@ parse_l2_5_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1], *expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_NSH; } if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_NSH)) { - if (odp_nsh_key_from_attr(attrs[OVS_KEY_ATTR_NSH], &flow->nsh, - NULL, errorp) == ODP_FIT_ERROR) { + if (odp_nsh_key_from_attr__(attrs[OVS_KEY_ATTR_NSH], + is_mask, &flow->nsh, + NULL, errorp) == ODP_FIT_ERROR) { return ODP_FIT_ERROR; } if (is_mask) {