1 # Copyright (C) 2014,2015 VA Linux Systems Japan K.K.
2 # Copyright (C) 2014,2015 YAMAMOTO Takashi <yamamoto at valinux co jp>
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
17 from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
18 from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
20 from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
24 class OVSPhysicalBridge(ovs_bridge.OVSAgentBridge,
25 br_dvr_process.OVSDVRProcessMixin):
26 """openvswitch agent physical bridge specific logic."""
28 # Used by OVSDVRProcessMixin
29 dvr_process_table_id = constants.DVR_PROCESS_VLAN
30 dvr_process_next_table_id = constants.LOCAL_VLAN_TRANSLATION
32 def setup_default_table(self):
37 def _local_vlan_match(ofp, ofpp, port, lvid):
38 return ofpp.OFPMatch(in_port=port, vlan_vid=lvid | ofp.OFPVID_PRESENT)
40 def provision_local_vlan(self, port, lvid, segmentation_id, distributed):
41 table_id = constants.LOCAL_VLAN_TRANSLATION if distributed else 0
42 (_dp, ofp, ofpp) = self._get_dp()
43 match = self._local_vlan_match(ofp, ofpp, port, lvid)
44 if segmentation_id is None:
45 actions = [ofpp.OFPActionPopVlan()]
47 vlan_vid = segmentation_id | ofp.OFPVID_PRESENT
48 actions = [ofpp.OFPActionSetField(vlan_vid=vlan_vid)]
49 actions += [ofpp.OFPActionOutput(ofp.OFPP_NORMAL, 0)]
50 self.install_apply_actions(table_id=table_id,
55 def reclaim_local_vlan(self, port, lvid):
56 (_dp, ofp, ofpp) = self._get_dp()
57 match = self._local_vlan_match(ofp, ofpp, port, lvid)
58 self.delete_flows(match=match)
60 def add_dvr_mac_vlan(self, mac, port):
61 self.install_output(table_id=constants.DVR_NOT_LEARN_VLAN,
62 priority=2, eth_src=mac, port=port)
64 def remove_dvr_mac_vlan(self, mac):
65 # REVISIT(yamamoto): match in_port as well?
66 self.delete_flows(table_id=constants.DVR_NOT_LEARN_VLAN,