From 4361f7543f984cf5f09c0c7070ac6b0f22f3b6b1 Mon Sep 17 00:00:00 2001 From: IWAMOTO Toshihiro Date: Mon, 12 Sep 2016 14:36:18 +0900 Subject: [PATCH] of_interface: Use vlan_tci instead of vlan_vid To pop VLAN tags in learn action generated flows, vlan_tci should be used instead of vlan_vid. Otherwise, VLAN tags with VID=0 are left. Change-Id: Ie38ab860424f6e2e2448abac82c428dae3a8a544 Closes-bug: #1622017 --- .../openvswitch/agent/openflow/native/br_tun.py | 8 ++++---- .../agent/openflow/native/ovs_ryuapp.py | 7 +++++++ .../agent/openflow/native/test_br_tun.py | 16 ++++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py index eed5eac0b4b..52375457777 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py @@ -90,15 +90,15 @@ class OVSTunnelBridge(ovs_bridge.OVSAgentBridge, # addresses (assumes that lvid has already been set by a previous flow) # Once remote mac addresses are learnt, output packet to patch_int flow_specs = [ - ofpp.NXFlowSpecMatch(src=('vlan_vid', 0), - dst=('vlan_vid', 0), + ofpp.NXFlowSpecMatch(src=('vlan_tci', 0), + dst=('vlan_tci', 0), n_bits=12), ofpp.NXFlowSpecMatch(src=('eth_src', 0), dst=('eth_dst', 0), n_bits=48), ofpp.NXFlowSpecLoad(src=0, - dst=('vlan_vid', 0), - n_bits=12), + dst=('vlan_tci', 0), + n_bits=16), ofpp.NXFlowSpecLoad(src=('tunnel_id', 0), dst=('tunnel_id', 0), n_bits=64), diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py index a219b6bb59a..ea22bd7fc72 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py @@ -19,7 +19,9 @@ import functools import ryu.app.ofctl.api # noqa from ryu.base import app_manager from ryu.lib import hub +from ryu.lib import type_desc from ryu.ofproto import ofproto_v1_3 +from ryu.ofproto import oxm_fields from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import br_int @@ -47,6 +49,11 @@ class OVSNeutronAgentRyuApp(app_manager.RyuApp): # Start Ryu event loop thread super(OVSNeutronAgentRyuApp, self).start() + # patch ryu + ofproto_v1_3.oxm_types.append( + oxm_fields.NiciraExtended0('vlan_tci', 4, type_desc.Int2)) + oxm_fields.generate(ofproto_v1_3.__name__) + def _make_br_cls(br_cls): return functools.partial(br_cls, ryu_app=self) diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py index ae6a78625fa..96973561b6c 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py @@ -104,16 +104,16 @@ class OVSTunnelBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase, priority=1, specs=[ ofpp.NXFlowSpecMatch( - dst=('vlan_vid', 0), + dst=('vlan_tci', 0), n_bits=12, - src=('vlan_vid', 0)), + src=('vlan_tci', 0)), ofpp.NXFlowSpecMatch( dst=('eth_dst', 0), n_bits=48, src=('eth_src', 0)), ofpp.NXFlowSpecLoad( - dst=('vlan_vid', 0), - n_bits=12, + dst=('vlan_tci', 0), + n_bits=16, src=0), ofpp.NXFlowSpecLoad( dst=('tunnel_id', 0), @@ -210,16 +210,16 @@ class OVSTunnelBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase, priority=1, specs=[ ofpp.NXFlowSpecMatch( - dst=('vlan_vid', 0), + dst=('vlan_tci', 0), n_bits=12, - src=('vlan_vid', 0)), + src=('vlan_tci', 0)), ofpp.NXFlowSpecMatch( dst=('eth_dst', 0), n_bits=48, src=('eth_src', 0)), ofpp.NXFlowSpecLoad( - dst=('vlan_vid', 0), - n_bits=12, + dst=('vlan_tci', 0), + n_bits=16, src=0), ofpp.NXFlowSpecLoad( dst=('tunnel_id', 0),