From patchwork Wed Jan 10 21:13:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 858582 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WPBf64Mx"; 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 3zH3622jBFz9sNw for ; Thu, 11 Jan 2018 09:07:38 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 11398F58; Wed, 10 Jan 2018 22:07:35 +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 06113E55 for ; Wed, 10 Jan 2018 22:07:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2326A12D for ; Wed, 10 Jan 2018 22:07:31 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id z17so751564pgc.4 for ; Wed, 10 Jan 2018 14:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=fPqDjXFKWdRIwOsHdIQwLFRN8v65QeGFzz98IS6gJr8=; b=WPBf64MxEbedcQln3VtxewXt9rEVjgCsP6tFjgAjb26Zl3wfkk6GJJyIaVCKGi0rIf 3BZf+xyo7IAKmE4xS7uheSXFZj4WBC+11t5nL4sG4cfMLC8aRO+KFBwVOjaWFcbzrHat FCwqwrpYD8qZeRRz6QYoyIq2phtHG+REAOAKP756pHYmJuoWYlHcc2yARgkvHV3LfETi wJDPuoKpBwNyAGUXGumNjcFZIyi74o+ch9y2ArBR1rYmyOCcLOgFW0K7016/u4P3uK41 Q+aNzrY9+MaAKPJAVs6uepgAVzBO1HyVwcbcKePX33t+J8ufN94ZxCO5O4+p9AqP+sT5 9Wkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=fPqDjXFKWdRIwOsHdIQwLFRN8v65QeGFzz98IS6gJr8=; b=ZbXaopjeTw6BBYqItkBGz8VC7AZLl8yC4u0JafaosfYeP3U+iThzM76QRY2Mf92y04 zOSWSDc002JhihAt0coguRfQsrWFtyD5MOQShk14pq/ygqXSs0kOuENoYN/H8V2u3969 KoWYHax9L+n5knXUxDtYk6p9WniuF2z439vR3cnQCzkzwsaddKH3az2XAWkCFvoWIek/ +cFSJtzNUg1I88RzNRPM3fOVj0juk+r5alGd1G6UgPC00awh/de+xNYGmdQdbF54to0o dWYZ/k0y4iFxvmKvRqIG3wLiXGISSXe7Xmwn1Ylm14niYqrGbSoM+HkmXc09EvbW+OQM jhzQ== X-Gm-Message-State: AKGB3mIUbpuqn7dH4zepZfTVcjsFigK130FdKaMp77DCZIzB9P9En6rr okDgLF4TMqeZU3FpIvNEwgr2/jbJ X-Google-Smtp-Source: ACJfBosgW7E87nX64y2+gSmpGgkSfEQvnaY2AkUsMQuaNA+xoXiO56y+1bMs6chF+RvzDwoUse6g7Q== X-Received: by 10.99.116.22 with SMTP id p22mr12001022pgc.4.1515622050366; Wed, 10 Jan 2018 14:07:30 -0800 (PST) Received: from sc9-mailhost1.vmware.com ([208.91.2.1]) by smtp.gmail.com with ESMTPSA id l13sm4088345pgn.9.2018.01.10.14.07.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jan 2018 14:07:29 -0800 (PST) From: William Tu To: dev@openvswitch.org Date: Wed, 10 Jan 2018 13:13:11 -0800 Message-Id: <1515618791-564-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCHv2] tunnel: fix tunnel flags set/clear. 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 Existing code only set these tunnel flags (df, csum, and key) when the flag is set in the output tunnel port, but did not clear when the flag is unset. The patch fixes it by setting and clearing it accordingly. Two existing testcases need to fix: 'tunnel - Geneve option present' has no key set up, so we should match 'flags(df)' instead of 'flags(df|key)'. The second case 'tunnel - concomitant IPv6 and IPv4 tunnels' follows the same pattern. One additional test case 'tunnel - Mix Geneve/GRE options' is added. Signed-off-by: William Tu VMWare-BZ: #2019012 --- v1->v2: refactor the tunnel flag set/unset code. --- ofproto/tunnel.c | 1 + tests/tunnel.at | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c index 770e0103476a..e0214ced69e2 100644 --- a/ofproto/tunnel.c +++ b/ofproto/tunnel.c @@ -464,6 +464,7 @@ tnl_port_send(const struct ofport_dpif *ofport, struct flow *flow, } } + flow->tunnel.flags &= ~(FLOW_TNL_F_MASK & ~FLOW_TNL_PUB_F_MASK); flow->tunnel.flags |= (cfg->dont_fragment ? FLOW_TNL_F_DONT_FRAGMENT : 0) | (cfg->csum ? FLOW_TNL_F_CSUM : 0) | (cfg->out_key_present ? FLOW_TNL_F_KEY : 0); diff --git a/tests/tunnel.at b/tests/tunnel.at index 767af99bfe9c..3c217b344f9b 100644 --- a/tests/tunnel.at +++ b/tests/tunnel.at @@ -647,7 +647,7 @@ Datapath actions: 2 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=1,len=0}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout]) AT_CHECK([tail -2 stdout], [0], [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata1,tun_metadata2=NP,in_port=1,nw_ecn=0,nw_frag=no -Datapath actions: set(tunnel(tun_id=0x0,dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0x1,len=0}),flags(df|key))),6081 +Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0x1,len=0}),flags(df))),6081 ]) OVS_VSWITCHD_STOP @@ -668,14 +668,45 @@ AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0,src=1.1.1.1,dst=1.1.1.2,ttl=64),in_port(4789)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], - [Datapath actions: set(tunnel(tun_id=0x0,ipv6_dst=2001:cafe::1,ttl=64,tp_dst=4789,flags(df|key))),4789 + [Datapath actions: set(tunnel(ipv6_dst=2001:cafe::1,ttl=64,tp_dst=4789,flags(df))),4789 ]) AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x0,ipv6_src=2001:cafe::1,ipv6_dst=2001:cafe::2,ttl=64),in_port(4789)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], - [Datapath actions: set(tunnel(tun_id=0x0,dst=1.1.1.1,ttl=64,tp_dst=4789,flags(df|key))),4789 + [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=4789,flags(df))),4789 ]) OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([tunnel - Mix Geneve/GRE options]) +OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \ + options:remote_ip=1.1.1.1 options:csum=true ofport_request=1 \ + -- add-port br0 p2 -- set Interface p2 type=dummy \ + ofport_request=2 ofport_request=2 \ + -- add-port br0 p3 -- set Interface p3 type=gre \ + options:remote_ip=2.2.2.2 options:csum=false options:key=123 ofport_request=3]) +OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP + +AT_DATA([flows.txt], [dnl +priority=1,in_port=1,actions=3 +]) +AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) + +AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], +[0], [dnl + priority=1,in_port=1 actions=output:3 +NXST_FLOW reply: +]) + +dnl the input packet from geneve tunnel has flags(-df+csum+key) flags, making +dnl sure that the output gre tunnel has (+df-csum+key). +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x12345678}),flags(csum|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout]) +AT_CHECK([tail -2 stdout], [0], + [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=-df+csum+key,in_port=1,nw_ecn=0,nw_frag=no +Datapath actions: set(tunnel(tun_id=0x7b,dst=2.2.2.2,ttl=64,flags(df|key))),1 +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP