From patchwork Mon Nov 12 09:28:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 996328 X-Patchwork-Delegate: ian.stokes@intel.com 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="els0O7SD"; 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 42tlnJ3g52z9s4s for ; Mon, 12 Nov 2018 20:28:52 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1F945AE0; Mon, 12 Nov 2018 09:28:51 +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 465B1410 for ; Mon, 12 Nov 2018 09:28:50 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 679A4771 for ; Mon, 12 Nov 2018 09:28:49 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181112092847euoutp01f2dd643061dc8a623d59cfc15f17d3e8~mVmgOhW3A1842718427euoutp01e for ; Mon, 12 Nov 2018 09:28:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181112092847euoutp01f2dd643061dc8a623d59cfc15f17d3e8~mVmgOhW3A1842718427euoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1542014927; bh=mtuwqTi/6Q+iB3bdkyaYN5AmBV2umpfUd2mFzh2fvjo=; h=From:To:Cc:Subject:Date:References:From; b=els0O7SDigjgQxEYzAoPmTiaVVC9djqErl7k62UBwqWnHQ5NTbuUdurlqWno4Oz4Y 7nQkGAogCLCoBFWS9CtH+6g5uc/ViCIN/GbzV845oL0XuYgkIKQuKj+MEdm6xzzjLx Y46z3HzRXUbiutJuky2DC7MZbdAWUUrQgfijwpyU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181112092846eucas1p2659926a925c2279386df517c3b49b6a7~mVmfkW4Gw1366713667eucas1p2o; Mon, 12 Nov 2018 09:28:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D6.41.04806.EC749EB5; Mon, 12 Nov 2018 09:28:46 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20181112092845eucas1p2da7366a1a2ca00643ecdf40861b2b0dd~mVme2PMoh1905819058eucas1p2E; Mon, 12 Nov 2018 09:28:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20181112092845eusmtrp233461b25b95665760bf70b6c55bda005~mVmenZx521032610326eusmtrp2j; Mon, 12 Nov 2018 09:28:45 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-e4-5be947cea32b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 01.5E.04128.DC749EB5; Mon, 12 Nov 2018 09:28:45 +0000 (GMT) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181112092844eusmtip23bb553abfc1bb9810584016860848099~mVmd_7oWE1876418764eusmtip2j; Mon, 12 Nov 2018 09:28:44 +0000 (GMT) From: Ilya Maximets To: ovs-dev@openvswitch.org, Ian Stokes Date: Mon, 12 Nov 2018 12:28:39 +0300 Message-Id: <20181112092839.1724-1-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42LZduznOd1z7i+jDZ7MFLXYMm0yq8WrReeZ La60/2S32PjwLKvF7f09LBaTppxgtJj76Tmjxe05XhZPL/5iduD0WLznJZPHs+mHmTxubD/N 6vHs5n9Gj+fXelg8+rasYvT433yVNYA9issmJTUnsyy1SN8ugStjxdJbTAWH9StmbZjA2sC4 R6WLkZNDQsBEovv4VuYuRi4OIYEVjBKnz1xlgXC+MEqc3TmBCcL5zCixZ9U7RpiWt4tBbJDE ckaJ15cusUM4Pxgl2pfMYAapYhPQkTi1+ghYh4iApUTX9S6wDmaBCUwSE5ZdBprLwSEsYCWx 8JYDSA2LgKrEmx1zwXp5gcJLGi6yQWyTl1i94QDYgRIC39kkZp1ZzQKRcJFoa+tnh7CFJV4d 3wJly0j83zmfCcKul7jf8pIRormDUWL6oX9QCXuJLa/PsYMcwSygKbF+lz5E2FGi+QAoADiA bD6JG28FQcLMQOakbdOZIcK8Eh1tQhDVKhK/Dy5nhrClJG6++wx1gYfErV1zwKYICcRK9O5L ncAoNwth1QJGxlWM4qmlxbnpqcXGeanlesWJucWleel6yfm5mxiBKeP0v+NfdzDu+5N0iFGA g1GJh1ej9EW0EGtiWXFl7iFGCQ5mJRFePp6X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21mIuKEwGTLYlzbAIAAA== X-CMS-MailID: 20181112092845eucas1p2da7366a1a2ca00643ecdf40861b2b0dd X-Msg-Generator: CA X-RootMTR: 20181112092845eucas1p2da7366a1a2ca00643ecdf40861b2b0dd X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181112092845eucas1p2da7366a1a2ca00643ecdf40861b2b0dd 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: Shahaf Shuler , Flavio Leitner , Ilya Maximets Subject: [ovs-dev] [PATCH] netdev-dpdk: Flow validation refactoring. 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 * Dropped 'is_all_zero' function, which is equal to 'is_all_zeros' from util.h . * util.h added to includes. Includes re-sorted within their blocks. (it's hard to figure out where to put new one if there is no order.) Note: linux/if.h depends on sys/socket.h . * 'ovs_u128_is_zero' used instead of manual checking of fields. * Code simplified by using direct pointer to 'match->wc.masks'. * 'sizeof's rewritten to be coding-style complient. Signed-off-by: Ilya Maximets Acked-by: Flavio Leitner --- lib/netdev-dpdk.c | 83 +++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 53 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 7e0a593d0..23f61c690 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -17,10 +17,10 @@ #include #include "netdev-dpdk.h" -#include +#include #include #include -#include +#include #include #include #include @@ -32,13 +32,13 @@ #include #include #include +#include #include #include #include #include -#include #include -#include +#include #include "cmap.h" #include "dirs.h" @@ -51,20 +51,21 @@ #include "odp-util.h" #include "openvswitch/dynamic-string.h" #include "openvswitch/list.h" +#include "openvswitch/match.h" #include "openvswitch/ofp-print.h" +#include "openvswitch/shash.h" #include "openvswitch/vlog.h" -#include "openvswitch/match.h" #include "ovs-numa.h" -#include "ovs-thread.h" #include "ovs-rcu.h" +#include "ovs-thread.h" #include "packets.h" -#include "openvswitch/shash.h" #include "smap.h" #include "sset.h" -#include "unaligned.h" #include "timeval.h" -#include "uuid.h" +#include "unaligned.h" #include "unixctl.h" +#include "util.h" +#include "uuid.h" enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM}; @@ -4635,39 +4636,24 @@ out: return ret; } -static bool -is_all_zero(const void *addr, size_t n) { - size_t i = 0; - const uint8_t *p = (uint8_t *)addr; - - for (i = 0; i < n; i++) { - if (p[i] != 0) { - return false; - } - } - - return true; -} - /* * Check if any unsupported flow patterns are specified. */ static int netdev_dpdk_validate_flow(const struct match *match) { struct match match_zero_wc; + const struct flow *masks = &match->wc.masks; /* Create a wc-zeroed version of flow */ match_init(&match_zero_wc, &match->flow, &match->wc); - if (!is_all_zero(&match_zero_wc.flow.tunnel, - sizeof(match_zero_wc.flow.tunnel))) { + if (!is_all_zeros(&match_zero_wc.flow.tunnel, + sizeof match_zero_wc.flow.tunnel)) { goto err; } - if (match->wc.masks.metadata || - match->wc.masks.skb_priority || - match->wc.masks.pkt_mark || - match->wc.masks.dp_hash) { + if (masks->metadata || masks->skb_priority || + masks->pkt_mark || masks->dp_hash) { goto err; } @@ -4676,38 +4662,31 @@ netdev_dpdk_validate_flow(const struct match *match) { goto err; } - if (match->wc.masks.ct_state || - match->wc.masks.ct_nw_proto || - match->wc.masks.ct_zone || - match->wc.masks.ct_mark || - match->wc.masks.ct_label.u64.hi || - match->wc.masks.ct_label.u64.lo) { + if (masks->ct_state || masks->ct_nw_proto || + masks->ct_zone || masks->ct_mark || + !ovs_u128_is_zero(masks->ct_label)) { goto err; } - if (match->wc.masks.conj_id || - match->wc.masks.actset_output) { + if (masks->conj_id || masks->actset_output) { goto err; } /* unsupported L2 */ - if (!is_all_zero(&match->wc.masks.mpls_lse, - sizeof(match_zero_wc.flow.mpls_lse))) { + if (!is_all_zeros(masks->mpls_lse, sizeof masks->mpls_lse)) { goto err; } /* unsupported L3 */ - if (match->wc.masks.ipv6_label || - match->wc.masks.ct_nw_src || - match->wc.masks.ct_nw_dst || - !is_all_zero(&match->wc.masks.ipv6_src, sizeof(struct in6_addr)) || - !is_all_zero(&match->wc.masks.ipv6_dst, sizeof(struct in6_addr)) || - !is_all_zero(&match->wc.masks.ct_ipv6_src, sizeof(struct in6_addr)) || - !is_all_zero(&match->wc.masks.ct_ipv6_dst, sizeof(struct in6_addr)) || - !is_all_zero(&match->wc.masks.nd_target, sizeof(struct in6_addr)) || - !is_all_zero(&match->wc.masks.nsh, sizeof(struct ovs_key_nsh)) || - !is_all_zero(&match->wc.masks.arp_sha, sizeof(struct eth_addr)) || - !is_all_zero(&match->wc.masks.arp_tha, sizeof(struct eth_addr))) { + if (masks->ipv6_label || masks->ct_nw_src || masks->ct_nw_dst || + !is_all_zeros(&masks->ipv6_src, sizeof masks->ipv6_src) || + !is_all_zeros(&masks->ipv6_dst, sizeof masks->ipv6_dst) || + !is_all_zeros(&masks->ct_ipv6_src, sizeof masks->ct_ipv6_src) || + !is_all_zeros(&masks->ct_ipv6_dst, sizeof masks->ct_ipv6_dst) || + !is_all_zeros(&masks->nd_target, sizeof masks->nd_target) || + !is_all_zeros(&masks->nsh, sizeof masks->nsh) || + !is_all_zeros(&masks->arp_sha, sizeof masks->arp_sha) || + !is_all_zeros(&masks->arp_tha, sizeof masks->arp_tha)) { goto err; } @@ -4717,9 +4696,7 @@ netdev_dpdk_validate_flow(const struct match *match) { } /* unsupported L4 */ - if (match->wc.masks.igmp_group_ip4 || - match->wc.masks.ct_tp_src || - match->wc.masks.ct_tp_dst) { + if (masks->igmp_group_ip4 || masks->ct_tp_src || masks->ct_tp_dst) { goto err; }