From: Chi-Vien Ly Date: Tue, 17 Sep 2013 22:20:04 +0000 (-0700) Subject: Add the following logics: X-Git-Tag: releasepom-0.1.0~75^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=534f0620272df6bfb9f7d26960f2cd0db895cfc9;hp=-c;p=controller.git Add the following logics: - only send wildcard flowmod delete to the switch when the controller is the cluster's master - ignore nodeAdd notification when the event is triggered by connection manager as a result of a subsequent controller (standby) joining the cluster. Change-Id: I9450df87af4fc9ec306ee5787c48163587d98140 Signed-off-by: Chi-Vien Ly --- 534f0620272df6bfb9f7d26960f2cd0db895cfc9 diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/ISwitch.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/ISwitch.java index af3641823c..d924b66a09 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/ISwitch.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/ISwitch.java @@ -232,4 +232,9 @@ public interface ISwitch { * until the Barrier reply arrives. */ public Object asyncSendBarrierMessage(); + + /** + * Send a FLOW_MOD message with a wildcard match and action=DELETE. + */ + public void deleteAllFlows(); } diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java index 91909d20f5..6e000022df 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java @@ -372,12 +372,6 @@ public class SwitchHandler implements ISwitch { // send feature request OFMessage featureRequest = factory.getMessage(OFType.FEATURES_REQUEST); asyncFastSend(featureRequest); - // delete all pre-existing flows - OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL); - OFFlowMod flowMod = (OFFlowMod) factory.getMessage(OFType.FLOW_MOD); - flowMod.setMatch(match).setCommand(OFFlowMod.OFPFC_DELETE).setOutPort(OFPort.OFPP_NONE) - .setLength((short) OFFlowMod.MINIMUM_LENGTH); - asyncFastSend(flowMod); this.state = SwitchState.WAIT_FEATURES_REPLY; startSwitchTimer(); break; @@ -925,4 +919,14 @@ public class SwitchHandler implements ISwitch { return result; } } + + @Override + public void deleteAllFlows() { + logger.trace("deleteAllFlows on switch {}", HexString.toHexString(this.sid)); + OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL); + OFFlowMod flowMod = (OFFlowMod) factory.getMessage(OFType.FLOW_MOD); + flowMod.setMatch(match).setCommand(OFFlowMod.OFPFC_DELETE).setOutPort(OFPort.OFPP_NONE) + .setLength((short) OFFlowMod.MINIMUM_LENGTH); + asyncFastSend(flowMod); + } } diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java index 8db83f0fc7..15bba670d2 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java @@ -239,6 +239,11 @@ public class InventoryServiceShim implements IContainerListener, if (sw == null) { return; } + Node node = NodeCreator.createOFNode(sw.getId()); + if ((nodeProps.get(node) != null) && (connectionOutService.isLocal(node))) { + logger.debug("Ignore switchAdded {}", sw); + return; + } // Add all the nodeConnectors of this switch Map> ncProps = InventoryServiceHelper @@ -437,7 +442,6 @@ public class InventoryServiceShim implements IContainerListener, for (String container : containers) { notifyInventoryShimInternalListener(container, node, type, props); } - // Notify external listener notifyInventoryShimExternalListener(node, type, props); @@ -511,6 +515,11 @@ public class InventoryServiceShim implements IContainerListener, props.add(b); } + if ((nodeProps.get(node) == null) && (connectionOutService.isLocal(node))) { + // The switch is connected for the first time, flush all flows + // that may exist on this switch + sw.deleteAllFlows(); + } nodeProps.put(node, props); // Notify all internal and external listeners notifyInventoryShimListener(node, type, props);