Merge "openvswitch plugin does not remove inbound unicast flow in br-tun"
This commit is contained in:
commit
ba684d7ac2
@ -52,14 +52,14 @@ DEAD_VLAN_TAG = "4095"
|
|||||||
# attributes set).
|
# attributes set).
|
||||||
class LocalVLANMapping:
|
class LocalVLANMapping:
|
||||||
def __init__(self, vlan, network_type, physical_network, segmentation_id,
|
def __init__(self, vlan, network_type, physical_network, segmentation_id,
|
||||||
vif_ids=None):
|
vif_ports=None):
|
||||||
if vif_ids is None:
|
if vif_ports is None:
|
||||||
vif_ids = []
|
vif_ports = {}
|
||||||
self.vlan = vlan
|
self.vlan = vlan
|
||||||
self.network_type = network_type
|
self.network_type = network_type
|
||||||
self.physical_network = physical_network
|
self.physical_network = physical_network
|
||||||
self.segmentation_id = segmentation_id
|
self.segmentation_id = segmentation_id
|
||||||
self.vif_ids = vif_ids
|
self.vif_ports = vif_ports
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ("lv-id = %s type = %s phys-net = %s phys-id = %s" %
|
return ("lv-id = %s type = %s phys-net = %s phys-id = %s" %
|
||||||
@ -185,6 +185,11 @@ class OVSQuantumAgent(object):
|
|||||||
self.topic,
|
self.topic,
|
||||||
consumers)
|
consumers)
|
||||||
|
|
||||||
|
def get_net_uuid(self, vif_id):
|
||||||
|
for network_id, vlan_mapping in self.local_vlan_map.iteritems():
|
||||||
|
if vif_id in vlan_mapping.vif_ports:
|
||||||
|
return network_id
|
||||||
|
|
||||||
def network_delete(self, context, **kwargs):
|
def network_delete(self, context, **kwargs):
|
||||||
LOG.debug("network_delete received")
|
LOG.debug("network_delete received")
|
||||||
network_id = kwargs.get('network_id')
|
network_id = kwargs.get('network_id')
|
||||||
@ -339,7 +344,7 @@ class OVSQuantumAgent(object):
|
|||||||
self.provision_local_vlan(net_uuid, network_type,
|
self.provision_local_vlan(net_uuid, network_type,
|
||||||
physical_network, segmentation_id)
|
physical_network, segmentation_id)
|
||||||
lvm = self.local_vlan_map[net_uuid]
|
lvm = self.local_vlan_map[net_uuid]
|
||||||
lvm.vif_ids.append(port.vif_id)
|
lvm.vif_ports[port.vif_id] = port
|
||||||
|
|
||||||
if network_type == constants.TYPE_GRE:
|
if network_type == constants.TYPE_GRE:
|
||||||
# inbound unicast
|
# inbound unicast
|
||||||
@ -352,28 +357,34 @@ class OVSQuantumAgent(object):
|
|||||||
if int(port.ofport) != -1:
|
if int(port.ofport) != -1:
|
||||||
self.int_br.delete_flows(in_port=port.ofport)
|
self.int_br.delete_flows(in_port=port.ofport)
|
||||||
|
|
||||||
def port_unbound(self, port, net_uuid):
|
def port_unbound(self, vif_id, net_uuid=None):
|
||||||
'''Unbind port.
|
'''Unbind port.
|
||||||
|
|
||||||
Removes corresponding local vlan mapping object if this is its last
|
Removes corresponding local vlan mapping object if this is its last
|
||||||
VIF.
|
VIF.
|
||||||
|
|
||||||
:param port: a ovslib.VifPort object.
|
:param vif_id: the id of the vif
|
||||||
:param net_uuid: the net_uuid this port is associated with.'''
|
:param net_uuid: the net_uuid this port is associated with.'''
|
||||||
if net_uuid not in self.local_vlan_map:
|
if net_uuid is None:
|
||||||
|
net_uuid = self.get_net_uuid(vif_id)
|
||||||
|
|
||||||
|
if not self.local_vlan_map.get(net_uuid):
|
||||||
LOG.info('port_unbound() net_uuid %s not in local_vlan_map' %
|
LOG.info('port_unbound() net_uuid %s not in local_vlan_map' %
|
||||||
net_uuid)
|
net_uuid)
|
||||||
return
|
return
|
||||||
lvm = self.local_vlan_map[net_uuid]
|
lvm = self.local_vlan_map[net_uuid]
|
||||||
|
if lvm.network_type == 'gre':
|
||||||
|
# remove inbound unicast flow
|
||||||
|
self.tun_br.delete_flows(tun_id=lvm.segmentation_id,
|
||||||
|
dl_dst=lvm.vif_ports[vif_id].vif_mac)
|
||||||
|
|
||||||
# REVISIT(rkukura): Does inbound unicast flow need to be removed here?
|
if vif_id in lvm.vif_ports:
|
||||||
|
del lvm.vif_ports[vif_id]
|
||||||
if port.vif_id in lvm.vif_ids:
|
|
||||||
lvm.vif_ids.remove(port.vif_id)
|
|
||||||
else:
|
else:
|
||||||
LOG.info('port_unbound: vid_id %s not in list' % port.vif_id)
|
LOG.info('port_unbound: vid_id %s not in local_vlan_map' %
|
||||||
|
port.vif_id)
|
||||||
|
|
||||||
if not lvm.vif_ids:
|
if not lvm.vif_ports:
|
||||||
self.reclaim_local_vlan(net_uuid, lvm)
|
self.reclaim_local_vlan(net_uuid, lvm)
|
||||||
|
|
||||||
def port_dead(self, port):
|
def port_dead(self, port):
|
||||||
@ -552,7 +563,7 @@ class OVSQuantumAgent(object):
|
|||||||
LOG.info("Removing binding to net-id = " +
|
LOG.info("Removing binding to net-id = " +
|
||||||
old_net_uuid + " for " + str(p)
|
old_net_uuid + " for " + str(p)
|
||||||
+ " added to dead vlan")
|
+ " added to dead vlan")
|
||||||
self.port_unbound(p, old_net_uuid)
|
self.port_unbound(p.vif_id, old_net_uuid)
|
||||||
if p.vif_id in all_bindings:
|
if p.vif_id in all_bindings:
|
||||||
all_bindings[p.vif_id].status = (
|
all_bindings[p.vif_id].status = (
|
||||||
q_const.PORT_STATUS_DOWN)
|
q_const.PORT_STATUS_DOWN)
|
||||||
@ -584,8 +595,7 @@ class OVSQuantumAgent(object):
|
|||||||
q_const.PORT_STATUS_DOWN)
|
q_const.PORT_STATUS_DOWN)
|
||||||
old_port = old_local_bindings.get(vif_id)
|
old_port = old_local_bindings.get(vif_id)
|
||||||
if old_port:
|
if old_port:
|
||||||
self.port_unbound(old_vif_ports[vif_id],
|
self.port_unbound(vif_id, old_port.network_id)
|
||||||
old_port.network_id)
|
|
||||||
# commit any DB changes and expire
|
# commit any DB changes and expire
|
||||||
# data loaded from the database
|
# data loaded from the database
|
||||||
db.commit()
|
db.commit()
|
||||||
@ -664,6 +674,7 @@ class OVSQuantumAgent(object):
|
|||||||
# Nothing to do regarding local networking
|
# Nothing to do regarding local networking
|
||||||
else:
|
else:
|
||||||
LOG.debug("Device %s not defined on plugin", device)
|
LOG.debug("Device %s not defined on plugin", device)
|
||||||
|
self.port_unbound(device)
|
||||||
return resync
|
return resync
|
||||||
|
|
||||||
def process_network_ports(self, port_info):
|
def process_network_ports(self, port_info):
|
||||||
|
@ -28,12 +28,13 @@ NET_UUID = '3faeebfe-5d37-11e1-a64b-000c29d5f0a7'
|
|||||||
LS_ID = '42'
|
LS_ID = '42'
|
||||||
LV_ID = 42
|
LV_ID = 42
|
||||||
LV_IDS = [42, 43]
|
LV_IDS = [42, 43]
|
||||||
LVM = ovs_quantum_agent.LocalVLANMapping(LV_ID, 'gre', None, LS_ID, LV_IDS)
|
|
||||||
VIF_ID = '404deaec-5d37-11e1-a64b-000c29d5f0a8'
|
VIF_ID = '404deaec-5d37-11e1-a64b-000c29d5f0a8'
|
||||||
VIF_MAC = '3c:09:24:1e:78:23'
|
VIF_MAC = '3c:09:24:1e:78:23'
|
||||||
OFPORT_NUM = 1
|
OFPORT_NUM = 1
|
||||||
VIF_PORT = ovs_lib.VifPort('port', OFPORT_NUM,
|
VIF_PORT = ovs_lib.VifPort('port', OFPORT_NUM,
|
||||||
VIF_ID, VIF_MAC, 'switch')
|
VIF_ID, VIF_MAC, 'switch')
|
||||||
|
VIF_PORTS = {LV_ID: VIF_PORT}
|
||||||
|
LVM = ovs_quantum_agent.LocalVLANMapping(LV_ID, 'gre', None, LS_ID, VIF_PORTS)
|
||||||
BCAST_MAC = "01:00:00:00:00:00/01:00:00:00:00:00"
|
BCAST_MAC = "01:00:00:00:00:00/01:00:00:00:00:00"
|
||||||
|
|
||||||
|
|
||||||
@ -140,6 +141,7 @@ class TunnelTest(unittest.TestCase):
|
|||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def testPortUnbound(self):
|
def testPortUnbound(self):
|
||||||
|
self.mock_tun_bridge.delete_flows(dl_dst=VIF_MAC, tun_id=LS_ID)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
a = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
a = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
||||||
self.TUN_BRIDGE,
|
self.TUN_BRIDGE,
|
||||||
@ -147,7 +149,7 @@ class TunnelTest(unittest.TestCase):
|
|||||||
'sudo', 2, 2, False)
|
'sudo', 2, 2, False)
|
||||||
a.available_local_vlans = set([LV_ID])
|
a.available_local_vlans = set([LV_ID])
|
||||||
a.local_vlan_map[NET_UUID] = LVM
|
a.local_vlan_map[NET_UUID] = LVM
|
||||||
a.port_unbound(VIF_PORT, NET_UUID)
|
a.port_unbound(VIF_ID, NET_UUID)
|
||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def testPortDead(self):
|
def testPortDead(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user