Skip to content
Snippets Groups Projects
Commit 1feaa1f0 authored by kwanggithub's avatar kwanggithub
Browse files

Fix tabs - another try

parent b5a429ab
No related branches found
No related tags found
No related merge requests found
/** /**
* Copyright 2012, Jason Parraga, Marist College * Copyright 2012, Jason Parraga, Marist College
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may * Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain * not use this file except in compliance with the License. You may obtain
* a copy of the License at * a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
**/ **/
package net.floodlightcontroller.flowcache; package net.floodlightcontroller.flowcache;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -69,280 +69,281 @@ import net.floodlightcontroller.topology.ITopologyService; ...@@ -69,280 +69,281 @@ import net.floodlightcontroller.topology.ITopologyService;
*/ */
public class PortDownReconciliation implements IFloodlightModule, public class PortDownReconciliation implements IFloodlightModule,
ITopologyListener, IFlowReconcileListener { ITopologyListener, IFlowReconcileListener {
protected static Logger log = LoggerFactory protected static Logger log = LoggerFactory.getLogger(PortDownReconciliation.class);
.getLogger(PortDownReconciliation.class);
protected ITopologyService topology;
protected ITopologyService topology; protected IFloodlightProviderService floodlightProvider;
protected IFloodlightProviderService floodlightProvider; protected IFlowReconcileService frm;
protected IFlowReconcileService frm; protected ILinkDiscoveryService lds;
protected ILinkDiscoveryService lds; protected Map<Link, LinkInfo> links;
protected Map<Link, LinkInfo> links; protected FloodlightContext cntx;
protected FloodlightContext cntx; protected static boolean waiting = false;
protected static boolean waiting = false; protected int statsQueryXId;
protected int statsQueryXId; protected static List<OFFlowStatisticsReply> statsReply;
protected static List<OFFlowStatisticsReply> statsReply;
// ITopologyListener
// ITopologyListener @Override
@Override public void topologyChanged() {
public void topologyChanged() { for (LDUpdate ldu : topology.getLastLinkUpdates()) {
for (LDUpdate ldu : topology.getLastLinkUpdates()) { if (ldu.getOperation()
if (ldu.getOperation().equals( .equals(ILinkDiscovery.UpdateOperation.PORT_DOWN)) {
ILinkDiscovery.UpdateOperation.PORT_DOWN)) {
// Get the switch ID for the OFMatchWithSwDpid object
// Get the switch ID for the OFMatchWithSwDpid object long affectedSwitch = floodlightProvider.getSwitches()
long affectedSwitch = floodlightProvider.getSwitches() .get(ldu.getSrc())
.get(ldu.getSrc()).getId(); .getId();
// Create an OFMatchReconcile object // Create an OFMatchReconcile object
OFMatchReconcile ofmr = new OFMatchReconcile(); OFMatchReconcile ofmr = new OFMatchReconcile();
// Generate an OFMatch objects for the OFMatchWithSwDpid object // Generate an OFMatch objects for the OFMatchWithSwDpid object
OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL); OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
// Generate the OFMatchWithSwDpid // Generate the OFMatchWithSwDpid
OFMatchWithSwDpid ofmatchsw = new OFMatchWithSwDpid(match, OFMatchWithSwDpid ofmatchsw = new OFMatchWithSwDpid(match,
affectedSwitch); affectedSwitch);
// Set the action to update the path to remove flows routing // Set the action to update the path to remove flows routing
// towards the downed port // towards the downed port
ofmr.rcAction = OFMatchReconcile.ReconcileAction.UPDATE_PATH; ofmr.rcAction = OFMatchReconcile.ReconcileAction.UPDATE_PATH;
// Set the match, with the switch dpid // Set the match, with the switch dpid
ofmr.ofmWithSwDpid = ofmatchsw; ofmr.ofmWithSwDpid = ofmatchsw;
// Assign the downed port to the OFMatchReconcile's outPort data member (I added this to // Assign the downed port to the OFMatchReconcile's outPort data
// the OFMatchReconcile class) // member (I added this to
ofmr.outPort = ldu.getSrcPort(); // the OFMatchReconcile class)
ofmr.outPort = ldu.getSrcPort();
// Tell the reconcile manager to reconcile matching flows
frm.reconcileFlow(ofmr); // Tell the reconcile manager to reconcile matching flows
} frm.reconcileFlow(ofmr);
} }
} }
}
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() { @Override
return null; public Collection<Class<? extends IFloodlightService>>
} getModuleServices() {
return null;
@Override }
public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
return null; @Override
} public Map<Class<? extends IFloodlightService>, IFloodlightService>
getServiceImpls() {
@Override return null;
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { }
Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>();
l.add(IFloodlightProviderService.class); @Override
l.add(ITopologyService.class); public Collection<Class<? extends IFloodlightService>>
l.add(IFlowReconcileService.class); getModuleDependencies() {
l.add(ILinkDiscoveryService.class); Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>();
return l; l.add(IFloodlightProviderService.class);
} l.add(ITopologyService.class);
l.add(IFlowReconcileService.class);
@Override l.add(ILinkDiscoveryService.class);
public void init(FloodlightModuleContext context) return l;
throws FloodlightModuleException { }
floodlightProvider = context
.getServiceImpl(IFloodlightProviderService.class); @Override
topology = context.getServiceImpl(ITopologyService.class); public
frm = context.getServiceImpl(IFlowReconcileService.class); void
lds = context.getServiceImpl(ILinkDiscoveryService.class); init(FloodlightModuleContext context)
cntx = new FloodlightContext(); throws FloodlightModuleException {
} floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
topology = context.getServiceImpl(ITopologyService.class);
@Override frm = context.getServiceImpl(IFlowReconcileService.class);
public void startUp(FloodlightModuleContext context) { lds = context.getServiceImpl(ILinkDiscoveryService.class);
topology.addListener(this); cntx = new FloodlightContext();
frm.addFlowReconcileListener(this); }
}
@Override
@Override public void startUp(FloodlightModuleContext context) {
public String getName() { topology.addListener(this);
return "portdownreconciliation"; frm.addFlowReconcileListener(this);
} }
@Override @Override
public boolean isCallbackOrderingPrereq(OFType type, String name) { public String getName() {
return false; return "portdownreconciliation";
} }
@Override @Override
public boolean isCallbackOrderingPostreq(OFType type, String name) { public boolean isCallbackOrderingPrereq(OFType type, String name) {
return true; return false;
} }
/** @Override
* Base case for the reconciliation of flows. This is triggered at the public boolean isCallbackOrderingPostreq(OFType type, String name) {
* switch which is immediately affected by the PORT_DOWN event return true;
* }
* @return the Command whether to STOP or Continue
*/ /**
@Override * Base case for the reconciliation of flows. This is triggered at the
public net.floodlightcontroller.core.IListener.Command reconcileFlows( * switch which is immediately affected by the PORT_DOWN event
ArrayList<OFMatchReconcile> ofmRcList) { *
if (lds != null) { * @return the Command whether to STOP or Continue
links = new HashMap<Link, LinkInfo>(); */
// Get all the switch links from the topology @Override
if (lds.getLinks() != null) public net.floodlightcontroller.core.IListener.Command
links.putAll(lds.getLinks()); reconcileFlows(ArrayList<OFMatchReconcile> ofmRcList) {
if (lds != null) {
for (OFMatchReconcile ofmr : ofmRcList) { links = new HashMap<Link, LinkInfo>();
// We only care about OFMatchReconcile objects that wish to // Get all the switch links from the topology
// update the path to a switch if (lds.getLinks() != null) links.putAll(lds.getLinks());
if (ofmr.rcAction
.equals(OFMatchReconcile.ReconcileAction.UPDATE_PATH)) { for (OFMatchReconcile ofmr : ofmRcList) {
// Get the switch object from the OFMatchReconcile // We only care about OFMatchReconcile objects that wish to
IOFSwitch sw = floodlightProvider.getSwitches().get( // update the path to a switch
ofmr.ofmWithSwDpid.getSwitchDataPathId()); if (ofmr.rcAction.equals(OFMatchReconcile.ReconcileAction.UPDATE_PATH)) {
// Get the switch object from the OFMatchReconcile
// Map data structure that holds the invalid matches and the ingress ports of those matches IOFSwitch sw = floodlightProvider.getSwitches()
Map<Short, List<OFMatch>> invalidBaseIngressAndMatches = new HashMap<Short, List<OFMatch>>(); .get(ofmr.ofmWithSwDpid.getSwitchDataPathId());
// Get the invalid flows // Map data structure that holds the invalid matches and the
List<OFFlowStatisticsReply> flows = getFlows(sw, // ingress ports of those matches
ofmr.outPort); Map<Short, List<OFMatch>> invalidBaseIngressAndMatches = new HashMap<Short, List<OFMatch>>();
// Analyze all the flows with outPorts equaling the downed // Get the invalid flows
// port and extract OFMatch's to trace back to neighbors List<OFFlowStatisticsReply> flows = getFlows(sw,
for (OFFlowStatisticsReply flow : flows) { ofmr.outPort);
// Create a reference to the match for ease
OFMatch match = flow.getMatch(); // Analyze all the flows with outPorts equaling the downed
// port and extract OFMatch's to trace back to neighbors
// Here we utilize an index of input ports which point for (OFFlowStatisticsReply flow : flows) {
// to multiple invalid matches // Create a reference to the match for ease
if (invalidBaseIngressAndMatches.containsKey(match OFMatch match = flow.getMatch();
.getInputPort()))
// If the input port is already in the index, add // Here we utilize an index of input ports which point
// the match to it's list // to multiple invalid matches
invalidBaseIngressAndMatches.get( if (invalidBaseIngressAndMatches.containsKey(match.getInputPort()))
match.getInputPort()).add(match); // If the input port is already in the index, add
else { // the match to it's list
// Otherwise create a new list and add it to the invalidBaseIngressAndMatches.get(match.getInputPort())
// index .add(match);
List<OFMatch> matches = new ArrayList<OFMatch>(); else {
matches.add(match); // Otherwise create a new list and add it to the
invalidBaseIngressAndMatches.put( // index
match.getInputPort(), matches); List<OFMatch> matches = new ArrayList<OFMatch>();
} matches.add(match);
} invalidBaseIngressAndMatches.put(match.getInputPort(),
matches);
// Remove invalid flows from the base switch, if they exist }
if (!flows.isEmpty()) { }
log.debug("Removing flows on switch : " + sw.getId()
+ " with outport: " + ofmr.outPort); // Remove invalid flows from the base switch, if they exist
clearFlowMods(sw, ofmr.outPort); if (!flows.isEmpty()) {
} log.debug("Removing flows on switch : " + sw.getId()
+ " with outport: " + ofmr.outPort);
// Create a list of neighboring switches we need to remove clearFlowMods(sw, ofmr.outPort);
// invalid flows from }
Map<IOFSwitch, Map<Short, List<OFMatch>>> neighborSwitches = new HashMap<IOFSwitch, Map<Short, List<OFMatch>>>();
// Create a list of neighboring switches we need to remove
// Loop through all the links // invalid flows from
for (Link link : links.keySet()) { Map<IOFSwitch, Map<Short, List<OFMatch>>> neighborSwitches = new HashMap<IOFSwitch, Map<Short, List<OFMatch>>>();
// Filter out links we care about
if (link.getDst() == sw.getId()) { // Loop through all the links
// Loop through the links to neighboring switches for (Link link : links.keySet()) {
// which have invalid flows // Filter out links we care about
for (Entry<Short, List<OFMatch>> invalidBaseIngressAndMatch : invalidBaseIngressAndMatches if (link.getDst() == sw.getId()) {
.entrySet()) { // Loop through the links to neighboring switches
// Find links on the network which link to the // which have invalid flows
// ingress ports that have invalidly routed for (Entry<Short, List<OFMatch>> invalidBaseIngressAndMatch : invalidBaseIngressAndMatches.entrySet()) {
// flows // Find links on the network which link to the
if (link.getDstPort() == invalidBaseIngressAndMatch // ingress ports that have invalidly routed
.getKey()) { // flows
Map<Short, List<OFMatch>> invalidNeighborOutportAndMatch = new HashMap<Short, List<OFMatch>>(); if (link.getDstPort() == invalidBaseIngressAndMatch.getKey()) {
// Insert the neighbor's outPort to the base Map<Short, List<OFMatch>> invalidNeighborOutportAndMatch = new HashMap<Short, List<OFMatch>>();
// switch and the invalid match // Insert the neighbor's outPort to the base
invalidNeighborOutportAndMatch.put(link // switch and the invalid match
.getSrcPort(), invalidNeighborOutportAndMatch.put(link.getSrcPort(),
invalidBaseIngressAndMatch invalidBaseIngressAndMatch.getValue());
.getValue()); // Link a neighbor switch's invalid match
// Link a neighbor switch's invalid match // and outport to their Switch object
// and outport to their Switch object neighborSwitches.put(floodlightProvider.getSwitches()
neighborSwitches.put(floodlightProvider .get(link.getSrc()),
.getSwitches().get(link.getSrc()), invalidNeighborOutportAndMatch);
invalidNeighborOutportAndMatch); }
} }
} }
} }
} log.debug("We have " + neighborSwitches.size()
log.debug("We have " + neighborSwitches.size() + " neighboring switches to deal with!");
+ " neighboring switches to deal with!"); // Loop through all the switches we found to have potential
// Loop through all the switches we found to have potential // issues
// issues for (IOFSwitch neighborSwitch : neighborSwitches.keySet()) {
for (IOFSwitch neighborSwitch : neighborSwitches.keySet()) { log.debug("NeighborSwitch ID : "
log.debug("NeighborSwitch ID : " + neighborSwitch.getId());
+ neighborSwitch.getId()); if (neighborSwitches.get(neighborSwitch) != null)
if (neighborSwitches.get(neighborSwitch) != null) deleteInvalidFlows(neighborSwitch,
deleteInvalidFlows(neighborSwitch, neighborSwitches.get(neighborSwitch));
neighborSwitches.get(neighborSwitch)); }
} }
} return Command.CONTINUE;
return Command.CONTINUE; }
} } else {
} else { log.error("Link Discovery Service Is Null");
log.error("Link Discovery Service Is Null"); }
} return Command.CONTINUE;
return Command.CONTINUE; }
}
/** /**
* * @param sw
* @param sw * the switch object that we wish to get flows from
* the switch object that we wish to get flows from * @param outPort
* @param outPort * the output action port we wish to find flows with
* the output action port we wish to find flows with * @return a list of OFFlowStatisticsReply objects or essentially flows
* @return a list of OFFlowStatisticsReply objects or essentially flows */
*/ public List<OFFlowStatisticsReply> getFlows(IOFSwitch sw, Short outPort) {
public List<OFFlowStatisticsReply> getFlows(IOFSwitch sw, Short outPort) {
statsReply = new ArrayList<OFFlowStatisticsReply>();
statsReply = new ArrayList<OFFlowStatisticsReply>(); List<OFStatistics> values = null;
List<OFStatistics> values = null; Future<List<OFStatistics>> future;
Future<List<OFStatistics>> future;
// Statistics request object for getting flows
// Statistics request object for getting flows
OFStatisticsRequest req = new OFStatisticsRequest(); OFStatisticsRequest req = new OFStatisticsRequest();
req.setStatisticType(OFStatisticsType.FLOW); req.setStatisticType(OFStatisticsType.FLOW);
int requestLength = req.getLengthU(); int requestLength = req.getLengthU();
OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest(); OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
specificReq.setMatch(new OFMatch().setWildcards(0xffffffff)); specificReq.setMatch(new OFMatch().setWildcards(0xffffffff));
specificReq.setOutPort(outPort); specificReq.setOutPort(outPort);
specificReq.setTableId((byte) 0xff); specificReq.setTableId((byte) 0xff);
req.setStatistics(Collections.singletonList((OFStatistics)specificReq)); req.setStatistics(Collections.singletonList((OFStatistics) specificReq));
requestLength += specificReq.getLength(); requestLength += specificReq.getLength();
req.setLengthU(requestLength); req.setLengthU(requestLength);
try { try {
//System.out.println(sw.getStatistics(req)); // System.out.println(sw.getStatistics(req));
future = sw.getStatistics(req); future = sw.getStatistics(req);
values = future.get(10, TimeUnit.SECONDS); values = future.get(10, TimeUnit.SECONDS);
if(values != null){ if (values != null) {
for(OFStatistics stat : values){ for (OFStatistics stat : values) {
statsReply.add((OFFlowStatisticsReply)stat); statsReply.add((OFFlowStatisticsReply) stat);
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Failure retrieving statistics from switch " + sw, e); log.error("Failure retrieving statistics from switch " + sw, e);
} }
return statsReply; return statsReply;
} }
/** /**
* * @param sw
* @param sw The switch we wish to remove flows from * The switch we wish to remove flows from
* @param outPort The specific Output Action OutPort of specific flows we wish to delete * @param outPort
*/ * The specific Output Action OutPort of specific flows we wish
public void clearFlowMods(IOFSwitch sw, Short outPort) { * to delete
// Delete all pre-existing flows with the same output action port or outPort */
OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL); public void clearFlowMods(IOFSwitch sw, Short outPort) {
// Delete all pre-existing flows with the same output action port or
// outPort
OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory() OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD)) .getMessage(OFType.FLOW_MOD)).setMatch(match)
.setMatch(match) .setCommand(OFFlowMod.OFPFC_DELETE)
.setCommand(OFFlowMod.OFPFC_DELETE) .setOutPort(outPort)
.setOutPort(outPort) .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
try { try {
List<OFMessage> msglist = new ArrayList<OFMessage>(1); List<OFMessage> msglist = new ArrayList<OFMessage>(1);
msglist.add(fm); msglist.add(fm);
...@@ -351,22 +352,26 @@ public class PortDownReconciliation implements IFloodlightModule, ...@@ -351,22 +352,26 @@ public class PortDownReconciliation implements IFloodlightModule,
log.error("Failed to clear flows on switch {} - {}", this, e); log.error("Failed to clear flows on switch {} - {}", this, e);
} }
} }
/** /**
* * @param sw
* @param sw The switch we wish to remove flows from * The switch we wish to remove flows from
* @param match The specific OFMatch object of specific flows we wish to delete * @param match
* @param outPort The specific Output Action OutPort of specific flows we wish to delete * The specific OFMatch object of specific flows we wish to
*/ * delete
public void clearFlowMods(IOFSwitch sw, OFMatch match, Short outPort) { * @param outPort
// Delete pre-existing flows with the same match, and output action port or outPort * The specific Output Action OutPort of specific flows we wish
match.setWildcards(OFMatch.OFPFW_ALL); * to delete
*/
public void clearFlowMods(IOFSwitch sw, OFMatch match, Short outPort) {
// Delete pre-existing flows with the same match, and output action port
// or outPort
match.setWildcards(OFMatch.OFPFW_ALL);
OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory() OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD)) .getMessage(OFType.FLOW_MOD)).setMatch(match)
.setMatch(match) .setCommand(OFFlowMod.OFPFC_DELETE)
.setCommand(OFFlowMod.OFPFC_DELETE) .setOutPort(outPort)
.setOutPort(outPort) .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
try { try {
List<OFMessage> msglist = new ArrayList<OFMessage>(1); List<OFMessage> msglist = new ArrayList<OFMessage>(1);
msglist.add(fm); msglist.add(fm);
...@@ -376,124 +381,115 @@ public class PortDownReconciliation implements IFloodlightModule, ...@@ -376,124 +381,115 @@ public class PortDownReconciliation implements IFloodlightModule,
} }
} }
/** /**
* Deletes flows with similar matches and output action ports on the * Deletes flows with similar matches and output action ports on the
* specified switch * specified switch
* *
* @param sw * @param sw
* the switch to query flows on * the switch to query flows on
* @param match * @param match
* the problematic OFMatch from the base switch which we wish to * the problematic OFMatch from the base switch which we wish to
* find and remove * find and remove
* @param outPort * @param outPort
* the output action port wanted from the flows, which follows * the output action port wanted from the flows, which follows
* the route to the base switch * the route to the base switch
*/ */
public void deleteInvalidFlows(IOFSwitch sw, public
Map<Short, List<OFMatch>> invalidOutportAndMatch) { void
log.debug("Deleting invalid flows on switch : " + sw.getId()); deleteInvalidFlows(IOFSwitch sw,
Map<Short, List<OFMatch>> invalidOutportAndMatch) {
// A map that holds the input ports and invalid matches on a switch log.debug("Deleting invalid flows on switch : " + sw.getId());
Map<Short, List<OFMatch>> invalidNeighborIngressAndMatches = new HashMap<Short, List<OFMatch>>();
// A map that holds the input ports and invalid matches on a switch
for (Short outPort : invalidOutportAndMatch.keySet()) { Map<Short, List<OFMatch>> invalidNeighborIngressAndMatches = new HashMap<Short, List<OFMatch>>();
// Get the flows on the switch
List<OFFlowStatisticsReply> flows = getFlows(sw, outPort); for (Short outPort : invalidOutportAndMatch.keySet()) {
// Get the flows on the switch
// Analyze all the flows with outPorts pointing to problematic route List<OFFlowStatisticsReply> flows = getFlows(sw, outPort);
for (OFFlowStatisticsReply flow : flows) {
// Loop through all the problematic matches // Analyze all the flows with outPorts pointing to problematic route
for (OFMatch match : invalidOutportAndMatch.get(outPort)) { for (OFFlowStatisticsReply flow : flows) {
// Compare the problematic matches with the match of the flow on the switch // Loop through all the problematic matches
if (HexString.toHexString( for (OFMatch match : invalidOutportAndMatch.get(outPort)) {
flow.getMatch().getDataLayerDestination()).equals( // Compare the problematic matches with the match of the
HexString.toHexString(match // flow on the switch
.getDataLayerDestination())) if (HexString.toHexString(flow.getMatch()
&& HexString.toHexString( .getDataLayerDestination())
flow.getMatch().getDataLayerSource()) .equals(HexString.toHexString(match.getDataLayerDestination()))
.equals(HexString.toHexString(match && HexString.toHexString(flow.getMatch()
.getDataLayerSource())) .getDataLayerSource())
&& flow.getMatch().getDataLayerType() == match .equals(HexString.toHexString(match.getDataLayerSource()))
.getDataLayerType() && flow.getMatch().getDataLayerType() == match.getDataLayerType()
&& flow.getMatch().getDataLayerVirtualLan() == match && flow.getMatch().getDataLayerVirtualLan() == match.getDataLayerVirtualLan()
.getDataLayerVirtualLan() && flow.getMatch().getNetworkDestination() == match.getNetworkDestination()
&& flow.getMatch().getNetworkDestination() == match && flow.getMatch().getNetworkDestinationMaskLen() == match.getNetworkDestinationMaskLen()
.getNetworkDestination() && flow.getMatch().getNetworkProtocol() == match.getNetworkProtocol()
&& flow.getMatch().getNetworkDestinationMaskLen() == match && flow.getMatch().getNetworkSource() == match.getNetworkSource()
.getNetworkDestinationMaskLen() && flow.getMatch().getNetworkSourceMaskLen() == match.getNetworkSourceMaskLen()
&& flow.getMatch().getNetworkProtocol() == match && flow.getMatch().getNetworkTypeOfService() == match.getNetworkTypeOfService()) {
.getNetworkProtocol()
&& flow.getMatch().getNetworkSource() == match // Here we utilize an index of input ports which point
.getNetworkSource() // to multiple invalid matches
&& flow.getMatch().getNetworkSourceMaskLen() == match if (invalidNeighborIngressAndMatches.containsKey(match.getInputPort()))
.getNetworkSourceMaskLen() // If the input port is already in the index, add
&& flow.getMatch().getNetworkTypeOfService() == match // the match to it's list
.getNetworkTypeOfService()) { invalidNeighborIngressAndMatches.get(match.getInputPort())
.add(match);
// Here we utilize an index of input ports which point else {
// to multiple invalid matches // Otherwise create a new list and add it to the
if (invalidNeighborIngressAndMatches.containsKey(match // index
.getInputPort())) List<OFMatch> matches = new ArrayList<OFMatch>();
// If the input port is already in the index, add matches.add(match);
// the match to it's list invalidNeighborIngressAndMatches.put(match.getInputPort(),
invalidNeighborIngressAndMatches.get( matches);
match.getInputPort()).add(match); }
else { // Remove flows from the switch with the invalid match
// Otherwise create a new list and add it to the // and outPort
// index clearFlowMods(sw, flow.getMatch(), outPort);
List<OFMatch> matches = new ArrayList<OFMatch>(); }
matches.add(match); }
invalidNeighborIngressAndMatches.put( }
match.getInputPort(), matches);
} // Create a list of neighboring switches we need to check for
// Remove flows from the switch with the invalid match and outPort // invalid flows
clearFlowMods(sw, flow.getMatch(), outPort); Map<IOFSwitch, Map<Short, List<OFMatch>>> neighborSwitches = new HashMap<IOFSwitch, Map<Short, List<OFMatch>>>();
}
} // Loop through all the links
} for (Link link : links.keySet()) {
// Filter out links we care about
// Create a list of neighboring switches we need to check for if (link.getDst() == sw.getId()) {
// invalid flows // Loop through the ingressPorts that are involved in
Map<IOFSwitch, Map<Short, List<OFMatch>>> neighborSwitches = new HashMap<IOFSwitch, Map<Short, List<OFMatch>>>(); // invalid flows on neighboring switches
for (Entry<Short, List<OFMatch>> ingressPort : invalidNeighborIngressAndMatches.entrySet()) {
// Loop through all the links // Filter out invalid links by matching the link
for (Link link : links.keySet()) { // destination port to our invalid flows ingress port
// Filter out links we care about if (link.getDstPort() == ingressPort.getKey()) {
if (link.getDst() == sw.getId()) { // Generate a match and outPort map since I don't
// Loop through the ingressPorts that are involved in // want to create an object
// invalid flows on neighboring switches Map<Short, List<OFMatch>> invalidNeighborOutportAndMatch = new HashMap<Short, List<OFMatch>>();
for (Entry<Short, List<OFMatch>> ingressPort : invalidNeighborIngressAndMatches invalidNeighborOutportAndMatch.put(link.getSrcPort(),
.entrySet()) { ingressPort.getValue());
// Filter out invalid links by matching the link // Link a neighbor switch's invalid match and
// destination port to our invalid flows ingress port // outport to their Switch object
if (link.getDstPort() == ingressPort.getKey()) { neighborSwitches.put(floodlightProvider.getSwitches()
// Generate a match and outPort map since I don't .get(link.getSrc()),
// want to create an object invalidNeighborOutportAndMatch);
Map<Short, List<OFMatch>> invalidNeighborOutportAndMatch = new HashMap<Short, List<OFMatch>>(); }
invalidNeighborOutportAndMatch.put( }
link.getSrcPort(), ingressPort.getValue()); }
// Link a neighbor switch's invalid match and }
// outport to their Switch object log.debug("We have " + neighborSwitches.size()
neighborSwitches.put(floodlightProvider + " neighbors to deal with!");
.getSwitches().get(link.getSrc()),
invalidNeighborOutportAndMatch); // Loop through all the neighbor switches we found to have
} // invalid matches
} for (IOFSwitch neighborSwitch : neighborSwitches.keySet()) {
} log.debug("NeighborSwitch ID : " + neighborSwitch.getId());
} // Recursively seek out and delete invalid flows on the
log.debug("We have " + neighborSwitches.size() // neighbor switch
+ " neighbors to deal with!"); deleteInvalidFlows(neighborSwitch,
neighborSwitches.get(neighborSwitch));
// Loop through all the neighbor switches we found to have }
// invalid matches }
for (IOFSwitch neighborSwitch : neighborSwitches.keySet()) { }
log.debug("NeighborSwitch ID : " }
+ neighborSwitch.getId());
// Recursively seek out and delete invalid flows on the
// neighbor switch
deleteInvalidFlows(neighborSwitch,
neighborSwitches.get(neighborSwitch));
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment