From d11b57a26694d397a8578f34e6e717a8f4ea36dd Mon Sep 17 00:00:00 2001 From: Sam Hague Date: Fri, 15 May 2015 14:49:27 -0400 Subject: [PATCH] Fix for vlan physical port flows on add and remove Change-Id: I897fb048bce6fb8610e8855e501b9d9024809c64 Signed-off-by: Sam Hague --- .../providers/openflow13/OF13Provider.java | 79 +++++++------------ .../ovsdb/openstack/netvirt/MdsalHelper.java | 2 +- .../ovsdb/openstack/netvirt/MdsalUtils.java | 28 +++++-- .../openstack/netvirt/SouthboundHandler.java | 3 +- .../impl/BridgeConfigurationManagerImpl.java | 2 +- 5 files changed, 57 insertions(+), 57 deletions(-) diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java index c3b0ad21e6..7e9e0ab24d 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java @@ -920,39 +920,30 @@ public class OF13Provider implements NetworkingProvider { long localPort = MdsalUtils.getOFPort(intf); if (localPort == 0) { - logger.info("programVlanRules: could not find ofPort"); + logger.debug("programVlanRules: could not find ofPort for {}", intf.getName()); return; } String attachedMac = MdsalUtils.getInterfaceExternalIdsValue(intf, Constants.EXTERNAL_ID_VM_MAC); if (attachedMac == null) { - logger.error("programVlanRules: No AttachedMac seen in {}", intf); + logger.debug("programVlanRules: No AttachedMac seen in {}", intf); return; } String phyIfName = bridgeConfigurationManager.getPhysicalInterfaceName(node, network.getProviderPhysicalNetwork()); - List intfs = MdsalUtils.getTerminationPointsOfBridge(node); - for (OvsdbTerminationPointAugmentation ethIntf : intfs) { - if (ethIntf.getName().equals(phyIfName)) { - long ethOFPort = MdsalUtils.getOFPort(ethIntf); - if (ethOFPort == 0) { - logger.warn("programVlanRules: could not find ofPort for physical port"); - return; - } - logger.debug("Identified eth port {} -> OF ({}) on {}", - ethIntf.getName(), ethOFPort, node); - // TODO: add logic to only add rule on remote nodes - programRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(), - attachedMac, ethOFPort); - programLocalIngressVlanRules(node, dpid, network.getProviderSegmentationID(), - attachedMac, localPort, ethOFPort); - return; - } else { - logger.debug("programVlanRules: intf {} does not match phyIfName: {}", - ethIntf.getName(), phyIfName); - } + long ethOFPort = MdsalUtils.getOFPort(node, phyIfName); + if (ethOFPort == 0) { + logger.warn("programVlanRules: could not find ofPort for physical port {}", phyIfName); + return; } + logger.debug("programVlanRules: Identified eth port {} -> ofPort ({}) on {}", + phyIfName, ethOFPort, node); + // TODO: add logic to only add rule on remote nodes + programRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(), + attachedMac, ethOFPort); + programLocalIngressVlanRules(node, dpid, network.getProviderSegmentationID(), + attachedMac, localPort, ethOFPort); } private void removeVlanRules (NeutronNetwork network, Node node, OvsdbTerminationPointAugmentation intf, @@ -967,43 +958,33 @@ public class OF13Provider implements NetworkingProvider { long localPort = MdsalUtils.getOFPort(intf); if (localPort == 0) { - logger.info("removeVlanRules: programVlanRules: could not find ofPort"); + logger.debug("removeVlanRules: programVlanRules: could not find ofPort for {}", intf.getName()); return; } String attachedMac = MdsalUtils.getInterfaceExternalIdsValue(intf, Constants.EXTERNAL_ID_VM_MAC); if (attachedMac == null) { - logger.error("removeVlanRules: No AttachedMac seen in {}", intf); + logger.debug("removeVlanRules: No AttachedMac seen in {}", intf); return; } - List intfs = MdsalUtils.getTerminationPointsOfBridge(node); - for (OvsdbTerminationPointAugmentation ethIntf : intfs) { - if (ethIntf.getName().equalsIgnoreCase(bridgeConfigurationManager.getPhysicalInterfaceName( - node, network.getProviderPhysicalNetwork()))) { - long ethOFPort = MdsalUtils.getOFPort(ethIntf); - if (ethOFPort == 0) { - logger.info("removeVlanRules: programVlanRules: could not find ofPort"); - return; - } - logger.debug("removeVlanRules: Identified eth port {} -> OF ({}) on {}", - ethIntf.getName(), ethOFPort, node); - removeRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(), - attachedMac, localPort, ethOFPort); - if (isLastInstanceOnNode) { - removePerVlanRules(node, dpid, network.getProviderSegmentationID(), localPort, ethOFPort); - } - return; - } + String phyIfName = + bridgeConfigurationManager.getPhysicalInterfaceName(node, network.getProviderPhysicalNetwork()); + long ethOFPort = MdsalUtils.getOFPort(node, phyIfName); + if (ethOFPort == 0) { + logger.warn("removeVlanRules: could not find ofPort for physical port {}", phyIfName); + return; + } + logger.debug("removeVlanRules: Identified eth port {} -> ofPort ({}) on {}", + phyIfName, ethOFPort, node); + + removeRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(), + attachedMac, localPort, ethOFPort); + if (isLastInstanceOnNode) { + removePerVlanRules(node, dpid, network.getProviderSegmentationID(), localPort, ethOFPort); } } -/* - private removeNode(List nodes, Node node) { - OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode); - if(bridgeAugmentation != null){ - InstanceIdentifier ovsdbNodeIid = (InstanceIdentifier) bridgeAugmentation.getManagedBy().getValue(); - } -*/ + @Override public boolean handleInterfaceUpdate(NeutronNetwork network, Node srcNode, OvsdbTerminationPointAugmentation intf) { diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalHelper.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalHelper.java index 7506d68f8e..d6a3ac7e3b 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalHelper.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalHelper.java @@ -174,7 +174,7 @@ public class MdsalHelper { .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID)) .child(Node.class,new NodeKey(createNodeId(ip,port))) .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName))); - LOG.debug("Termination point InstanceIdentigier generated : {}",nodePath); + LOG.debug("Termination point InstanceIdentifier generated : {}",nodePath); return nodePath; } diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalUtils.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalUtils.java index d4129190c8..5872f4e85f 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalUtils.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalUtils.java @@ -465,7 +465,7 @@ public class MdsalUtils { public static List getTerminationPointsOfBridge(Node node) { List tpAugmentations = extractTerminationPointAugmentations(node); if(tpAugmentations.isEmpty()){ - tpAugmentations = readTerminationPointAugmentationFromDataStore(node); + tpAugmentations = readTerminationPointAugmentations(node); } return tpAugmentations; } @@ -506,7 +506,7 @@ public class MdsalUtils { return tpAugmentations; } - public static List readTerminationPointAugmentationFromDataStore( Node node ) { + public static List readTerminationPointAugmentations(Node node) { InstanceIdentifier bridgeNodeIid = MdsalHelper.createInstanceIdentifier(node.getNodeId()); Node operNode = read(LogicalDatastoreType.OPERATIONAL, bridgeNodeIid); if(operNode != null){ @@ -580,10 +580,10 @@ public class MdsalUtils { return put(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build()); } - public static Boolean readTerminationPoint(Node bridgeNode, String bridgeName, String portName) { + public static TerminationPoint readTerminationPoint(Node bridgeNode, String bridgeName, String portName) { InstanceIdentifier tpIid = MdsalHelper.createTerminationPointInstanceIdentifier( bridgeNode, portName); - return read(LogicalDatastoreType.OPERATIONAL, tpIid) != null; + return read(LogicalDatastoreType.OPERATIONAL, tpIid); } public static Boolean addTunnelTerminationPoint(Node bridgeNode, String bridgeName, String portName, String type, @@ -592,8 +592,9 @@ public class MdsalUtils { } public static Boolean isTunnelTerminationPointExist(Node bridgeNode, String bridgeName, String portName){ - return readTerminationPoint(bridgeNode, bridgeName, portName); + return readTerminationPoint(bridgeNode, bridgeName, portName) != null; } + public static Boolean addPatchTerminationPoint(Node node, String bridgeName, String portName, String peerPortName) { Map option = new HashMap(); option.put("peer", peerPortName); @@ -735,4 +736,21 @@ public class MdsalUtils { } return ofPort; } + + public static Long getOFPort(Node bridgeNode, String portName) { + Long ofPort = 0L; + OvsdbTerminationPointAugmentation port = extractTerminationPointAugmentation(bridgeNode, portName); + if (port != null) { + ofPort = getOFPort(port); + } else { + TerminationPoint tp = readTerminationPoint(bridgeNode, null, portName); + if (tp != null) { + port = tp.getAugmentation(OvsdbTerminationPointAugmentation.class); + if (port != null) { + ofPort = getOFPort(port); + } + } + } + return ofPort; + } } diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java index 6142fcf2d0..624dd4ad60 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java @@ -189,7 +189,8 @@ public class SouthboundHandler extends AbstractHandler logger.trace("SouthboundHandler#isInterfaceOfInterest: Interface : {}", terminationPoint); if(terminationPoint.getInterfaceType() == null){ - logger.warn("No type found for the interface : {}", terminationPoint); + // This is OK since eth ports don't have an interface type + logger.info("No type found for the interface : {}", terminationPoint); return false; } return (MdsalHelper.createOvsdbInterfaceType( diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java index 7aeab7db87..f95f8ce401 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java @@ -299,7 +299,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage } } - LOGGER.debug("createNetNetwork: node: {}, status: success", node); + LOGGER.debug("createBridges: node: {}, status: success", node); return true; } -- 2.36.6