Pass tun_table to ofputil_handle_packet_out() to correctly decode tunnel metadata in packet-out messages.
Signed-off-by: Yi-Hung Wei <[email protected]> --- 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): ]) -- 2.7.4 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
