From patchwork Mon May 15 17:04:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 762642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wRRqQ3Vjwz9s0Z for ; Tue, 16 May 2017 03:08:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RnVcGrm9"; dkim-atps=neutral Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AD8E3BAC; Mon, 15 May 2017 17:05:15 +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 33070B7D for ; Mon, 15 May 2017 17:05:12 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id BC17624C for ; Mon, 15 May 2017 17:05:11 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id s62so17679608pgc.0 for ; Mon, 15 May 2017 10:05:11 -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:in-reply-to:references; bh=V2v9MS183zBfXXA58HA2JYeIH1ES/Cy02ho1mUfgA9s=; b=RnVcGrm9iMw4qCetusd6kIofIXj32ldRKK6LHhfrsciO6y3ktx8AK5x1voYGO2FO3g W7aRYLzkoylE6LWDCRcF19u5utXEw/erGGdDfEV+hIKZqoNdA0/tnx2PKLiNt+AF8Uwm 9cT3xcwt1/ph8wKwLAuyOTE1CpEzfcAG722RFkDAhmhAb1ADEnoOM2/p0e6WlRvYHet1 1pMf0hH56z0E7wBVMtcWze/obFWk/vywANTbcbp36Mf9Qu9Ttk5QZuXFJPrndOvtAsvF BhniEMqZNN4vkF9ExbhQqsP5jINYCMMtD2C0nFhCQEYvTTvAmeJ6H9LUvg+/LOk67BVK d4pw== 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:in-reply-to :references; bh=V2v9MS183zBfXXA58HA2JYeIH1ES/Cy02ho1mUfgA9s=; b=TFWDfiKuEDc8kcXEjmg2uhBOXsiy0ywfHnxq0KXDlL1jDsEMqOVmUJuxEH6EvL6mpT bZM7abM4fX7FMDru1BVwaWs36e5mX8e2zx14vDAKviNaEkADvkp3FzVPnh9mTCkVhllq zqjWhQut337AoDO1ewQiXo49MdUTrg85P2jZxFuRZFB6k9T+2y/9wRFYJ7D7Gq+KatoP PC6er8X1dmc/Bry0MZNHbBiXAvgumHY5pKcwp+gwchmnKwH8Ob/cgs9yDapyu4w7MyLJ zFPIgLksdt7RrBI7iaPDVxh4Aubbh1aAcQj9gqb/k3yialCYSK9GbvR5hd+e/khuU5fk CfbQ== X-Gm-Message-State: AODbwcBDWKR8IsatIoyUFoV7hotDpzFN2/u3KP/yW7BU56L8E/xX9gTS 2jKVK90cWsPpqmbcj4M= X-Received: by 10.99.56.81 with SMTP id h17mr7351361pgn.171.1494867911143; Mon, 15 May 2017 10:05:11 -0700 (PDT) Received: from vm-01.vmware.com ([208.91.2.1]) by smtp.gmail.com with ESMTPSA id k86sm4725447pfk.125.2017.05.15.10.05.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 May 2017 10:05:10 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Mon, 15 May 2017 10:04:59 -0700 Message-Id: <1494867899-87288-6-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494867899-87288-1-git-send-email-yihung.wei@gmail.com> References: <1494867899-87288-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM 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] [PATCH 5/5] ofp-util: Fix tun_metadata processing in pakcet-out 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 Pass tun_table to ofputil_handle_packet_out() to correctly decode tunnel metadata in packet-out messages. Signed-off-by: Yi-Hung Wei --- include/openvswitch/ofp-util.h | 1 + lib/ofp-print.c | 2 +- lib/ofp-util.c | 3 ++- ofproto/ofproto.c | 7 +++++-- tests/ofproto-dpif.at | 7 ++++++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/openvswitch/ofp-util.h b/include/openvswitch/ofp-util.h index a0a61cfac23a..4c13ca680f88 100644 --- a/include/openvswitch/ofp-util.h +++ b/include/openvswitch/ofp-util.h @@ -533,6 +533,7 @@ struct ofputil_packet_out { enum ofperr ofputil_decode_packet_out(struct ofputil_packet_out *, const struct ofp_header *, + const struct tun_table *, struct ofpbuf *ofpacts); struct ofpbuf *ofputil_encode_packet_out(const struct ofputil_packet_out *, enum ofputil_protocol protocol); diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 98cbf9c4b13c..6d656b0e977f 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -240,7 +240,7 @@ ofp_print_packet_out(struct ds *string, const struct ofp_header *oh, enum ofperr error; ofpbuf_init(&ofpacts, 64); - error = ofputil_decode_packet_out(&po, oh, &ofpacts); + error = ofputil_decode_packet_out(&po, oh, NULL, &ofpacts); if (error) { ofpbuf_uninit(&ofpacts); ofp_print_error(string, error); diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 5ba11239883e..09eb4fcef6e3 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -4199,6 +4199,7 @@ ofputil_packet_in_private_destroy(struct ofputil_packet_in_private *pin) enum ofperr ofputil_decode_packet_out(struct ofputil_packet_out *po, const struct ofp_header *oh, + const struct tun_table *tun_table, struct ofpbuf *ofpacts) { struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length)); @@ -4211,7 +4212,7 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po, const struct ofp15_packet_out *opo = ofpbuf_pull(&b, sizeof *opo); po->buffer_id = ntohl(opo->buffer_id); - error = oxm_pull_match_loose(&b, true, NULL, &po->flow_metadata); + error = oxm_pull_match_loose(&b, true, tun_table, &po->flow_metadata); if (error) { return error; } diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 23ba3a191034..e77510bc0afe 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3558,7 +3558,8 @@ handle_packet_out(struct ofconn *ofconn, const struct ofp_header *oh) /* Decode message. */ ofpbuf_use_stub(&ofpacts, ofpacts_stub, sizeof ofpacts_stub); - error = ofputil_decode_packet_out(&po, oh, &ofpacts); + error = ofputil_decode_packet_out(&po, oh, ofproto_get_tun_tab(p), + &ofpacts); if (error) { ofpbuf_uninit(&ofpacts); return error; @@ -7925,7 +7926,9 @@ handle_bundle_add(struct ofconn *ofconn, const struct ofp_header *oh) COVERAGE_INC(ofproto_packet_out); /* Decode message. */ - error = ofputil_decode_packet_out(&po, badd.msg, &ofpacts); + error = ofputil_decode_packet_out(&po, badd.msg, + ofproto_get_tun_tab(ofproto), + &ofpacts); if (!error) { po.ofpacts = ofpbuf_steal_data(&ofpacts); /* Move to heap. */ error = ofproto_packet_out_init(ofproto, ofconn, &bmsg->opo, &po); diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 743ac2ab3454..55b082297d0d 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -8372,12 +8372,15 @@ AT_CLEANUP AT_SETUP([ofproto-dpif packet-out pipeline match field (OpenFlow 1.5)]) OVS_VSWITCHD_START +AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=8}->tun_metadata2"]) +AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=1,len=4}->tun_metadata3"]) AT_DATA([flows.txt], [dnl table=0,in_port=1 actions=controller table=0,tun_id=3 actions=controller table=0,metadata=5 actions=controller table=0,reg0=1,reg4=2,reg8=3,reg12=5 actions=controller table=0,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_gbp_id=0x01,tun_gbp_flags=0x03 actions=controller +table=0,tun_metadata3=0x11 actions=controller ]) AT_CHECK([ovs-ofctl -O OpenFlow15 add-flows br0 flows.txt]) @@ -8392,7 +8395,7 @@ AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,tunnel_id=3 packet=0 AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,metadata=5 packet=0001020304050010203040503333 actions=table"]) AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,reg0=1,reg4=2,reg8=3,reg12=5 packet=0001020304050010203040503333 actions=table"]) AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_gbp_id=0x01,tun_gbp_flags=0x03 packet=0001020304050010203040503333 actions=table"]) -AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,tun_metadata33=3 packet=0001020304050010203040503333 actions=table"]) +AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,tun_metadata2=0x22,tun_metadata3=0x11 packet=0001020304050010203040503333 actions=table"]) ovs-appctl -t ovs-ofctl ofctl/barrier OVS_APP_EXIT_AND_WAIT([ovs-ofctl]) @@ -8408,6 +8411,8 @@ OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 reg0=0x1,reg4=0x2,reg8=0x3,reg12 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x3333 OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_gbp_id=1,tun_gbp_flags=0x3,in_port=2 (via packet_out) data_len=14 (unbuffered) vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x3333 +OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 tun_metadata2=0x22,tun_metadata3=0x11,in_port=2 (via packet_out) data_len=14 (unbuffered) +vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x3333 OFPT_BARRIER_REPLY (OF1.5): ])