From patchwork Sat Mar 10 17:30:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 884153 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rFDnvBI9"; 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 3zzB9j5Nt2zB2wv for ; Sun, 11 Mar 2018 04:31:05 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D1FDBEC0; Sat, 10 Mar 2018 17:31:01 +0000 (UTC) X-Original-To: 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 E533EEBE for ; Sat, 10 Mar 2018 17:30:59 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f54.google.com (mail-pg0-f54.google.com [74.125.83.54]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 52E375DD for ; Sat, 10 Mar 2018 17:30:59 +0000 (UTC) Received: by mail-pg0-f54.google.com with SMTP id s13so1898177pgn.12 for ; Sat, 10 Mar 2018 09:30:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1s+0DKCgc+uHB1u1W4bbV+wTPMvrj5DGZbl3Eb7jkyU=; b=rFDnvBI9YPUlV5FnvWZn136qRc07GHzqwc9D3SDP7TeTmTQGWRfsJpAbvhmbEEYJi2 c8QNP1Al6ebHqWrTRNHB7NIPMx+yiS6TaPG5iZAeBxkTQ4f/gCJ75scJ8X3jsYXnX84v lCZbAXG7i/nGVPMJ3OYcKZQ23oiSiFY/nqIKnqaw9fPK5i/1ZQ6a+DuEdIocYiSu4zRq exGIYd20vv5ZmnHLbYBlmNNA5KRq8YeuzEQlodAa/GYaDUl8ovtaElpLD6Jl7WgHPtp7 s4aNApS+8xCcjIhPP8Io1uk8z1X4UOMXZWRf7BCf4bAfA1j3rrEoXX5zJgNDROcEvEoD mNGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1s+0DKCgc+uHB1u1W4bbV+wTPMvrj5DGZbl3Eb7jkyU=; b=Dv1wuVl8ZBRkIZa23sjNENQU8XS2cHrIwsarw349g9YdkdatZtJiP/SXhpjOwvi4JQ PVMgnqNDumzen68a1h4WKNjseZDAAqc0hRJHfdYyBAwED+s1LF20fP3GxWz53Mw8fuUO aPmlFxCOAWD8pH+8IsvxV+/CUecrI//d2rNbRpb/EmONYskIRnPdO6YEhlqQ0sWtjnk/ C5SC1hJ5J3PJ6h6XBkfLqq4MOQWno+R74BLk0L/UdQxfX0sZ2k85j0cKwdibh/t9Vsdt 63A0cAV7cs1ddFwm6iT/0kRszbH0Mmp66MasPy8lTyBs6KpYTPJvvfdhx03K/ZDJQ+TV 52Ew== X-Gm-Message-State: AElRT7EpB4PZO7tEHvG25yt/FlZ/W73cVO1iZnKRPQL39NBoLWvIlQB3 OwV5aJP0Oi4zu45z8V2yqsExqYfr X-Google-Smtp-Source: AG47ELvlvlHmB0IV232WrJe955Xenss167ZjMos/hr+2uKBBI/UF6rTCbd7iB8DGHt0HmDQpY04QRg== X-Received: by 10.101.74.135 with SMTP id b7mr2158705pgu.260.1520703057992; Sat, 10 Mar 2018 09:30:57 -0800 (PST) Received: from sc9-mailhost2.vmware.com (c-24-6-248-116.hsd1.ca.comcast.net. [24.6.248.116]) by smtp.gmail.com with ESMTPSA id k3sm8015570pgn.27.2018.03.10.09.30.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 09:30:56 -0800 (PST) From: Yi-Hung Wei To: dev@openvswitch.org Date: Sat, 10 Mar 2018 09:30:34 -0800 Message-Id: <1520703034-3602-1-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] odp-util: Fix ofproto/trace with odp flow 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 Currently, using ofproto/trace to trace a datapath flow with eth_type() but without eth() may hit unexpected behavior because OVS sets the packet_type to be (1, eth_type) when decoding the odp flow key. This patch updates the logic of odp flow key decoding so that the packet_type defaults to (0,0) unless user explicitly specifies the packet_type. An unit test is added to prevent future regression. Travis build: https://travis-ci.org/YiHungWei/ovs/builds/351565383 Reported-by: Amar Padmanabhan Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2017-December/045817.html Reported-by: Su Wang VMWare-BZ: #2070488 Signed-off-by: Yi-Hung Wei --- lib/odp-util.c | 8 -------- tests/ofproto-dpif.at | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index 5da83b4c64c4..682f1d3bd4b5 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -6440,14 +6440,6 @@ odp_flow_key_to_flow__(const struct nlattr *key, size_t key_len, } expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_ETHERNET; } - else if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_ETHERTYPE)) { - ovs_be16 ethertype = nl_attr_get_be16(attrs[OVS_KEY_ATTR_ETHERTYPE]); - if (!is_mask) { - flow->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE, - ntohs(ethertype)); - } - expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_ETHERTYPE; - } /* Get Ethertype or 802.1Q TPID or FLOW_DL_TYPE_NONE. */ if (!parse_ethertype(attrs, present_attrs, &expected_attrs, flow, diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index d2058eddd3eb..13e57b90edd1 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -10162,3 +10162,27 @@ AT_CHECK([grep flow_del ovs-vswitchd.log], [1]) OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([ofproto-dpif - debug ofproto/trace]) +OVS_VSWITCHD_START +add_of_ports br0 1 2 3 4 +AT_DATA([flows.txt], [dnl +table=0 priority=100 in_port=1,udp actions=output:2 +table=0 priority=99 in_port=1 actions=output:3 +]) +AT_CHECK([ovs-ofctl -O OpenFlow15 add-flows br0 flows.txt]) + +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=17,tos=0,ttl=128,frag=no),udp(src=8,dst=9)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: 2 +]) + +AT_CHECK([ovs-ofctl -O OpenFlow15 add-flow br0 "table=0 priority=100 in_port=1,packet_type=(1,0x800) actions=output:4"]) + +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),packet_type(ns=1,id=0x800),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=17,tos=0,ttl=128,frag=no),udp(src=8,dst=9)'], [0], [stdout]) +AT_CHECK([cat stdout | grep output], [0], + [ output:4 +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP