From patchwork Fri Jun 21 17:51:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1120460 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="Y12jc6Xe"; 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 45Vmh81g6cz9s4Y for ; Sat, 22 Jun 2019 04:00:55 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F09FA1189; Fri, 21 Jun 2019 18:00:52 +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 91183116E for ; Fri, 21 Jun 2019 18:00:51 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0D1CD831 for ; Fri, 21 Jun 2019 18:00:50 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id l19so3727146pgh.9 for ; Fri, 21 Jun 2019 11:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=oUfRCan5y8T+CyvphiI6NCHKXm10MtVH83uUxyRfiL8=; b=Y12jc6XeMhzSn5BAEJU4lqLUaYva96vGUZSzzbW6ZStbfQAtYVyyL6r6G/KO9vO99V N/rRUrTeN0Zn4bmuG8r7Z4vPQL1ixqEsqZeLUAUVZYVN/xhCRGmrA1ifZHfboB8yxf1R 3KOFBvaDDPX7TVCt8nseDsIkUJhn3FHR75R6ZD6JbwKAdNiuoUogW0RyKgpNz6uqIMcE yqjXX9ECaBI8FZJGHpYVrt+abDyd2QBrNSUKzxagDh8g743l+spk88C0s/sfypQTW7TQ wvp4Ere2Bi02lZ0iAx32AaQLLegIW6j17OIAcHndJ83aZLKMOAtcPfDJ/J9/+Y4s2r/0 ZjNw== 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=oUfRCan5y8T+CyvphiI6NCHKXm10MtVH83uUxyRfiL8=; b=UOZn1YjWWNdfkBDn0XtrXHfyQbrrT3NosJc7oghLlsF/qYRBq3bcS65EdiSSqIBgIC KSAcz2Yz2wTROjrQKcnWFAaYSnOyuDcFAPlj0Smb8fiI0X9cNGNPxc5MzsZDBBZSBwZ3 oOf3itti/8dktncMk/I2677Wkj+hIPk2pTS0Eyp0e5UYnR8hXIBd/2YTkkOjyHKfyLwx 6ONKQ2Ls2i2Nv+tMIIpoqYlX3dVqcPI0BaB/zRd+/7xoxd/HMEmD/zpprniXiqKjKfmd WkhTUAFeHPxwi5klDVlyr6I6qteOsLLE98PWhPdOfAVNwnrq/EE7ppVWFWx84li05UPO sAkg== X-Gm-Message-State: APjAAAVJETOMi29o4wX4FPbMLnDPH6E8cWN2gx3Dd2rPh5mDzRh0CU+Y bqVDg/UucwicnLgF43sFv3c1XBJ7 X-Google-Smtp-Source: APXvYqyLOcUSUdwP9PN2YA06KIZ4jPWoVGsz8wG6TquABlwjFGmTtXcvLco0k68VIeClUQgD4umZyA== X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr8147790pjz.140.1561140049101; Fri, 21 Jun 2019 11:00:49 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id o2sm2703228pgp.74.2019.06.21.11.00.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Jun 2019 11:00:47 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Fri, 21 Jun 2019 10:51:23 -0700 Message-Id: <1561139483-24925-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] ofproto-dpif: Fix continuation with patch port 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 This patch fixes the ofp_port to odp_port translation issue on patch port with nxt_resume. When OVS resumes processing a packet from nxt_resume, OVS does not translate the ofp in_port to odp in_port correctly if the packet is originally received from a patch port. Currently,OVS sets the odp in_port for this resume pakcet as ODPP_NONE and push the resume packet back to the datapath. Later on, if the packet goes through a recirc, OVS will generate the following message since it can not translate odp in_port (ODPP_NONE) back to ofp in_port during upcall, and push down a datapath rule to drop the packet. ofproto_dpif_upcall(handler16)|INFO|received packet on unassociated datapath port 4294967295 When OVS revalidates the drop datapath flow with ODPP_NONE in_port, we will see the following warning. ofproto_dpif_upcall(revalidator18)|WARN|Failed to acquire udpif_key corresponding to unexpected flow (Invalid argument): ufid:.... This patch resolves this issue by storing the odp in_port in the continuation messages, and restores the odp in_port before push the packet back to the datapath. VMWare-BZ: 2364696 Signed-off-by: Yi-Hung Wei --- Travis test: * https://travis-ci.org/YiHungWei/ovs/builds/548777476 --- include/openvswitch/ofp-packet.h | 3 +++ lib/ofp-packet.c | 17 +++++++++++++++++ ofproto/ofproto-dpif-upcall.c | 1 + ofproto/ofproto-dpif.c | 4 +--- tests/ofproto-dpif.at | 41 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/include/openvswitch/ofp-packet.h b/include/openvswitch/ofp-packet.h index 67001cb3f5d0..77128d829b6d 100644 --- a/include/openvswitch/ofp-packet.h +++ b/include/openvswitch/ofp-packet.h @@ -140,6 +140,9 @@ struct ofputil_packet_in_private { /* NXCPT_ACTION_SET. */ struct ofpact *action_set; size_t action_set_len; + + /* NXCPT_ODP_PORT. */ + odp_port_t odp_port; }; struct ofpbuf *ofputil_encode_packet_in_private( diff --git a/lib/ofp-packet.c b/lib/ofp-packet.c index a1ffe17de5f6..4579548ee174 100644 --- a/lib/ofp-packet.c +++ b/lib/ofp-packet.c @@ -420,6 +420,7 @@ enum nx_continuation_prop_type { NXCPT_COOKIE, NXCPT_ACTIONS, NXCPT_ACTION_SET, + NXCPT_ODP_PORT, }; /* Only NXT_PACKET_IN2 (not NXT_RESUME) should include NXCPT_USERDATA, so this @@ -506,6 +507,10 @@ ofputil_put_packet_in_private(const struct ofputil_packet_in_private *pin, ofpprop_end(msg, start); } + if (pin->odp_port) { + ofpprop_put_u32(msg, NXCPT_ODP_PORT, odp_to_u32(pin->odp_port)); + } + if (msg->size > inner_ofs) { ofpprop_end(msg, continuation_ofs); } else { @@ -875,6 +880,13 @@ ofputil_decode_packet_in_private(const struct ofp_header *oh, bool loose, error = parse_actions_property(&payload, oh->version, &action_set); break; + case NXCPT_ODP_PORT: { + uint32_t value; + error = ofpprop_parse_u32(&payload, &value); + pin->odp_port = u32_to_odp(value); + break; + } + default: error = OFPPROP_UNKNOWN(loose, "continuation", type); break; @@ -1010,6 +1022,11 @@ ofputil_packet_in_private_format(struct ds *s, ds_put_char(s, '\n'); } + if (pin->odp_port) { + ds_put_format(s, " continuation.odp_port=%"PRIu32, pin->odp_port); + ds_put_char(s, '\n'); + } + if (verbosity > 0) { char *packet = ofp_packet_to_string( public->packet, public->packet_len, diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index a19aa9576b5c..02d7afb2ef8f 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1526,6 +1526,7 @@ process_upcall(struct udpif *udpif, struct upcall *upcall, : NULL), am->pin.up.action_set_len = state->action_set_len, am->pin.up.bridge = upcall->ofproto->uuid; + am->pin.up.odp_port = upcall->packet->md.in_port.odp_port; } /* We don't want to use the upcall 'flow', since it may be diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index eb9c5a5f5534..cbeb6776f99d 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5122,9 +5122,7 @@ nxt_resume(struct ofproto *ofproto_, pkt_metadata_from_flow(&packet.md, &pin->base.flow_metadata.flow); /* Fix up in_port. */ - ofproto_dpif_set_packet_odp_port(ofproto, - pin->base.flow_metadata.flow.in_port.ofp_port, - &packet); + packet.md.in_port.odp_port = pin->odp_port; struct flow headers; flow_extract(&packet, &headers); diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 9640d1cb9f13..dc21c8889d70 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -5434,6 +5434,47 @@ AT_CHECK([test 1 = `$PYTHON "$top_srcdir/utilities/ovs-pcap.in" p2-tx.pcap | wc OVS_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([ofproto-dpif - continuation with patch port]) +AT_KEYWORDS([continuations pause resume]) +OVS_VSWITCHD_START( + [add-port br0 p0 -- set Interface p0 type=dummy -- \ + add-port br0 patch- -- \ + set interface patch- type=patch options:peer=patch+ -- \ + add-br br1 -- set bridge br1 datapath-type=dummy fail-mode=secure -- \ + add-port br1 patch+ -- set interface patch+ type=patch options:peer=patch- +]) +add_of_ports --pcap br1 1 + +flow="in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" + +AT_DATA([flows.txt], [dnl +table=0, in_port=patch+ icmp action=controller(pause), resubmit(,1) +table=1, in_port=patch+ icmp action=ct(table=2) +table=2, in_port=patch+ icmp ct_state=+trk+new action=ct(commit, table=3) +table=3, in_port=patch+ icmp action=p1 +]) + +AT_CHECK([ovs-ofctl add-flow br0 action=normal]) +AT_CHECK([ovs-ofctl -O OpenFlow13 add-flows br1 flows.txt]) + +AT_CAPTURE_FILE([ofctl_monitor.log]) +ovs-ofctl monitor br1 resume --detach --no-chdir --pidfile=ovs-ofctl.pid 2> ofctl_monitor.log + +# Run a packet through the switch. +AT_CHECK([ovs-appctl netdev-dummy/receive p0 "$flow"], [0], [stdout]) + +# Check flow stats +AT_CHECK([ovs-ofctl dump-flows br1], [0], [stdout]) +AT_CHECK([strip_xids < stdout | sed -n 's/duration=[[0-9]]*\.[[0-9]]*s/duration=0.0s/p' | sed -n 's/idle_age=[[0-9]]*/idle_age=0/p' | grep 'table=3' | grep -v 'commit'], [0], [dnl + cookie=0x0, duration=0.0s, table=3, n_packets=1, n_bytes=106, idle_age=0, icmp,in_port=1 actions=output:2 +]) + +# The packet should be received by port 1 +AT_CHECK([test 1 = `$PYTHON "$top_srcdir/utilities/ovs-pcap.in" p1-tx.pcap | wc -l`]) + +OVS_VSWITCHD_STOP +AT_CLEANUP + # Check that pause works after the packet is cloned. AT_SETUP([ofproto-dpif - continuation after clone]) AT_KEYWORDS([continuations clone pause resume])