Fix for vlan physical port flows on add and remove
authorSam Hague <shague@redhat.com>
Fri, 15 May 2015 18:49:27 +0000 (14:49 -0400)
committerSam Hague <shague@redhat.com>
Fri, 15 May 2015 18:49:27 +0000 (14:49 -0400)
Change-Id: I897fb048bce6fb8610e8855e501b9d9024809c64
Signed-off-by: Sam Hague <shague@redhat.com>
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalHelper.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/MdsalUtils.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java

index c3b0ad21e600c0f77bfa6ef1ab3fbf944d7f2c69..7e9e0ab24d519e73c40fab561ed02a552c39e812 100644 (file)
@@ -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<OvsdbTerminationPointAugmentation> 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<OvsdbTerminationPointAugmentation> 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<Node> nodes, Node node) {
-        OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode);
-        if(bridgeAugmentation != null){
-            InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue();
-    }
-*/
+
     @Override
     public boolean handleInterfaceUpdate(NeutronNetwork network, Node srcNode,
                                          OvsdbTerminationPointAugmentation intf) {
index 7506d68f8e91cf12b43f29ef7b1d876c555b992e..d6a3ac7e3b981e612d3cdd94b9cc0c7be5811449 100644 (file)
@@ -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;
     }
 
index d4129190c86dde6c397caa406e94644da85d028a..5872f4e85f7d31891bf3f96167e6217a19daca66 100644 (file)
@@ -465,7 +465,7 @@ public class MdsalUtils {
     public static List<OvsdbTerminationPointAugmentation> getTerminationPointsOfBridge(Node node) {
         List<OvsdbTerminationPointAugmentation> 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<OvsdbTerminationPointAugmentation> readTerminationPointAugmentationFromDataStore( Node node ) {
+    public static List<OvsdbTerminationPointAugmentation> readTerminationPointAugmentations(Node node) {
         InstanceIdentifier<Node> 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<TerminationPoint> 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<String, String> option = new HashMap<String, String>();
         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;
+    }
 }
index 6142fcf2d082129b8291b0ed165759edef335ca0..624dd4ad6067236edb98a3fc57112348983098af 100644 (file)
@@ -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(
index 7aeab7db874c8c4b4966418a3b87f9c6ac8cf3aa..f95f8ce4017f8162de54f7f591180990a1878e9b 100644 (file)
@@ -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;
     }