From 7dadba54cdf65c5343579747c05dc8341e2a2ee8 Mon Sep 17 00:00:00 2001 From: Ryan Izard <rizard@g.clemson.edu> Date: Fri, 7 Nov 2014 08:13:43 -0500 Subject: [PATCH] Some Firewall unit test fixes. Went through all code and corrected pi.getInPort() to (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)). OF1.2 and greater specifies the ingress port as an OXM in the Match. --- .../internal/DeviceManagerImpl.java | 8 ++++---- .../firewall/AllowDropPair.java | 9 +++++++++ .../firewall/Firewall.java | 18 +++++++++++------- .../firewall/FirewallRule.java | 2 +- .../forwarding/Forwarding.java | 15 ++++++++------- .../java/net/floodlightcontroller/hub/Hub.java | 2 +- .../learningswitch/LearningSwitch.java | 14 ++++++++------ .../internal/LinkDiscoveryManager.java | 4 ++-- .../topology/TopologyManager.java | 8 ++++---- .../firewall/FirewallTest.java | 3 +++ 10 files changed, 51 insertions(+), 32 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java index cb867d595..acefd38da 100755 --- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java @@ -1151,9 +1151,9 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT protected Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) { Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD); - + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); // Extract source entity information - Entity srcEntity = getSourceEntityFromPacket(eth, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + Entity srcEntity = getSourceEntityFromPacket(eth, sw.getId(), inPort); if (srcEntity == null) { cntInvalidSource.increment(); return Command.STOP; @@ -1165,7 +1165,7 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT // the IP to MAC mapping of the VRRP IP address. The source // entity will not have that information. Hence, a separate call // to learn devices in such cases. - learnDeviceFromArpResponseData(eth, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + learnDeviceFromArpResponseData(eth, sw.getId(), inPort); // Learn/lookup device information Device srcDevice = learnDeviceByEntity(srcEntity); @@ -1198,7 +1198,7 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT if (logger.isTraceEnabled()) { logger.trace("Received PI: {} on switch {}, port {} *** eth={}" + " *** srcDev={} *** dstDev={} *** ", - new Object[] { pi, sw.getId().toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)), eth, + new Object[] { pi, sw.getId().toString(), inPort, eth, srcDevice, dstDevice }); } diff --git a/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java b/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java index 719e067b9..e769fadfb 100644 --- a/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java +++ b/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java @@ -17,6 +17,7 @@ package net.floodlightcontroller.firewall; +import org.projectfloodlight.openflow.protocol.OFFactory; import org.projectfloodlight.openflow.protocol.match.Match; @@ -25,4 +26,12 @@ public class AllowDropPair { //public int drop = OFMatch.OFPFW_ALL; public Match.Builder allow; public Match.Builder drop; + + @SuppressWarnings("unused") + private AllowDropPair() {}; + + public AllowDropPair(OFFactory factory) { + allow = factory.buildMatch(); + drop = factory.buildMatch(); + } } diff --git a/src/main/java/net/floodlightcontroller/firewall/Firewall.java b/src/main/java/net/floodlightcontroller/firewall/Firewall.java index e95a7d4e4..c50097758 100644 --- a/src/main/java/net/floodlightcontroller/firewall/Firewall.java +++ b/src/main/java/net/floodlightcontroller/firewall/Firewall.java @@ -27,6 +27,8 @@ import java.util.Map; import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFPacketIn; import org.projectfloodlight.openflow.protocol.OFType; +import org.projectfloodlight.openflow.protocol.OFVersion; +import org.projectfloodlight.openflow.protocol.match.MatchField; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.EthType; import org.projectfloodlight.openflow.types.IPv4AddressWithMask; @@ -65,6 +67,7 @@ import org.slf4j.LoggerFactory; * * @author Amer Tahir * @edited KC Wang + * @edited Ryan Izard */ public class Firewall implements IFirewallService, IOFMessageListener, IFloodlightModule { @@ -455,7 +458,7 @@ public class Firewall implements IFirewallService, IOFMessageListener, protected RuleMatchPair matchWithRule(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) { FirewallRule matched_rule = null; Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD); - AllowDropPair adp = new AllowDropPair(); + AllowDropPair adp = new AllowDropPair(sw.getOFFactory()); synchronized (rules) { Iterator<FirewallRule> iter = this.rules.iterator(); @@ -468,7 +471,7 @@ public class Firewall implements IFirewallService, IOFMessageListener, // check if rule matches // AllowDropPair adp's allow and drop matches will modified with what matches // TODO @Ryan might need to re-init adp each time (look into later) - if (rule.matchesThisPacket(sw.getId(), pi.getInPort(), eth, adp) == true) { + if (rule.matchesThisPacket(sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)), eth, adp) == true) { matched_rule = rule; break; } @@ -502,7 +505,8 @@ public class Firewall implements IFirewallService, IOFMessageListener, public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) { Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD); - + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); + // Allowing L2 broadcast + ARP broadcast request (also deny malformed // broadcasts -> L2 broadcast + L3 unicast) if (eth.isBroadcast() == true) { @@ -517,7 +521,7 @@ public class Firewall implements IFirewallService, IOFMessageListener, logger.trace("Allowing broadcast traffic for PacketIn={}", pi); } - decision = new RoutingDecision(sw.getId(), pi.getInPort(), + decision = new RoutingDecision(sw.getId(), inPort, IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE), IRoutingDecision.RoutingAction.MULTICAST); decision.addToContext(cntx); @@ -526,7 +530,7 @@ public class Firewall implements IFirewallService, IOFMessageListener, logger.trace("Blocking malformed broadcast traffic for PacketIn={}", pi); } - decision = new RoutingDecision(sw.getId(), pi.getInPort(), + decision = new RoutingDecision(sw.getId(), inPort, IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE), IRoutingDecision.RoutingAction.DROP); decision.addToContext(cntx); @@ -552,7 +556,7 @@ public class Firewall implements IFirewallService, IOFMessageListener, // Drop the packet if we don't have a rule allowing or dropping it or if we explicitly drop it if (rule == null || rule.action == FirewallRule.FirewallAction.DROP) { - decision = new RoutingDecision(sw.getId(), pi.getInPort(), + decision = new RoutingDecision(sw.getId(), inPort, IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE), IRoutingDecision.RoutingAction.DROP); decision.setMatch(rmp.match); @@ -566,7 +570,7 @@ public class Firewall implements IFirewallService, IOFMessageListener, } // Found a rule and the rule is not a drop, so allow the packet } else { - decision = new RoutingDecision(sw.getId(), pi.getInPort(), + decision = new RoutingDecision(sw.getId(), inPort, IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE), IRoutingDecision.RoutingAction.FORWARD_OR_FLOOD); decision.setMatch(rmp.match); diff --git a/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java b/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java index b32d9c10a..fdb3c1b27 100644 --- a/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java +++ b/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java @@ -81,7 +81,7 @@ public class FirewallRule implements Comparable<FirewallRule> { * The default rule is to match on anything. */ public FirewallRule() { - this.in_port = OFPort.ZERO; + this.in_port = OFPort.ANY; this.dl_src = MacAddress.NONE; this.nw_src_prefix_and_mask = IPv4AddressWithMask.NONE; //this.nw_src_maskbits = 0; diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java index 781cda917..8788a4176 100644 --- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java +++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java @@ -171,7 +171,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { } protected void doForwardFlow(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx, boolean requestFlowRemovedNotifn) { - OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); // Check if we have the location of the destination IDevice dstDevice = IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_DST_DEVICE); @@ -185,7 +185,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { } if (srcIsland == null) { log.debug("No openflow island found for source {}/{}", - sw.getId().toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + sw.getId().toString(), inPort); return; } @@ -198,7 +198,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { DatapathId dstIsland = topologyService.getL2DomainId(dstSwDpid); if ((dstIsland != null) && dstIsland.equals(srcIsland)) { on_same_island = true; - if ((sw.getId().equals(dstSwDpid)) && ((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)).equals(dstDap.getPort()))) { + if (sw.getId().equals(dstSwDpid) && inPort.equals(dstDap.getPort())) { on_same_if = true; } break; @@ -219,7 +219,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { if (log.isTraceEnabled()) { log.trace("Both source and destination are on the same " + "switch/port {}/{}, Action = NOP", - sw.toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + sw.toString(), inPort); } return; } @@ -336,11 +336,12 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { "out message to the switch", recommendation=LogMessageDoc.CHECK_SWITCH) protected void doFlood(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) { - if (topologyService.isIncomingBroadcastAllowed(sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))) == false) { + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); + if (topologyService.isIncomingBroadcastAllowed(sw.getId(), inPort) == false) { if (log.isTraceEnabled()) { log.trace("doFlood, drop broadcast packet, pi={}, " + "from a blocked port, srcSwitch=[{},{}], linkInfo={}", - new Object[] {pi, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))}); + new Object[] {pi, sw.getId(), inPort}); } return; } @@ -357,7 +358,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { // set buffer-id, in-port and packet-data based on packet-in pob.setBufferId(OFBufferId.NO_BUFFER); - pob.setInPort((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + pob.setInPort(inPort); pob.setData(pi.getData()); try { diff --git a/src/main/java/net/floodlightcontroller/hub/Hub.java b/src/main/java/net/floodlightcontroller/hub/Hub.java index ed5efe236..4d3ccf513 100644 --- a/src/main/java/net/floodlightcontroller/hub/Hub.java +++ b/src/main/java/net/floodlightcontroller/hub/Hub.java @@ -99,7 +99,7 @@ public class Hub implements IFloodlightModule, IOFMessageListener { private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) { OFPacketIn pi = (OFPacketIn) msg; OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut(); - pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); // set actions OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput(); diff --git a/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java b/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java index 89c15550b..57b534086 100644 --- a/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java +++ b/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java @@ -291,11 +291,13 @@ public class LearningSwitch if (pi == null) { return; } + + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); // The assumption here is (sw) is the switch that generated the // packet-in. If the input port is the same as output port, then // the packet-out should be ignored. - if ((pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)).equals(outport)) { + if (inPort.equals(outport)) { if (log.isDebugEnabled()) { log.debug("Attempting to do packet-out to the same " + "interface as packet-in. Dropping packet. " + @@ -328,7 +330,7 @@ public class LearningSwitch pob.setBufferId(pi.getBufferId()); } - pob.setInPort(pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); + pob.setInPort(inPort); // If the buffer id is none or the switch doesn's support buffering // we send the data with the packet out @@ -361,7 +363,7 @@ public class LearningSwitch // Set buffer_id, in_port, actions_len pob.setBufferId(packetInMessage.getBufferId()); - pob.setInPort(sw.getOFFactory().getVersion() == OFVersion.OF_10 ? packetInMessage.getInPort() : packetInMessage.getMatch().get(MatchField.IN_PORT)); + pob.setInPort(packetInMessage.getVersion().compareTo(OFVersion.OF_12) < 0 ? packetInMessage.getInPort() : packetInMessage.getMatch().get(MatchField.IN_PORT)); // set actions List<OFAction> actions = new ArrayList<OFAction>(1); @@ -392,6 +394,7 @@ public class LearningSwitch private Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) { // Read in packet data headers by using OFMatch Match m = pi.getMatch(); + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); MacAddress sourceMac = m.get(MatchField.ETH_SRC); MacAddress destMac = m.get(MatchField.ETH_DST); OFVlanVidMatch vlan = m.get(MatchField.VLAN_VID); @@ -415,7 +418,6 @@ public class LearningSwitch } if ((sourceMac.getLong() & 0x010000000000L) == 0) { // If source MAC is a unicast address, learn the port for this MAC/VLAN - OFPort inPort = (pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); this.addToPortMap(sw, sourceMac, vlan.getVlanVid(), inPort); } @@ -428,7 +430,7 @@ public class LearningSwitch // from port map whenever a flow expires, so you would still see // a lot of floods. this.writePacketOutForPacketIn(sw, pi, OFPort.FLOOD); - } else if (outPort.equals(m.get(MatchField.IN_PORT))) { + } else if (outPort.equals(inPort)) { log.trace("ignoring packet that arrived on same port as learned destination:" + " switch {} vlan {} dest MAC {} port {}", new Object[]{ sw, vlan, destMac.toString(), outPort.getPortNumber() }); @@ -470,7 +472,7 @@ public class LearningSwitch } mb2.setExact(MatchField.IN_PORT, outPort); - this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb2.build(), m.get(MatchField.IN_PORT)); + this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb2.build(), inPort); } } return Command.CONTINUE; diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index 5ca1b5eb7..edb512fb9 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -565,7 +565,7 @@ IFloodlightModule, IInfoProvider { FloodlightContext cntx) { Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD); - OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); if (eth.getPayload() instanceof BSN) { BSN bsn = (BSN) eth.getPayload(); if (bsn == null) return Command.STOP; @@ -595,7 +595,7 @@ IFloodlightModule, IInfoProvider { } // If packet-in is from a quarantine port, stop processing. - NodePortTuple npt = new NodePortTuple(sw, (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + NodePortTuple npt = new NodePortTuple(sw, inPort); if (quarantineQueue.contains(npt)) { ctrQuarantineDrops.increment(); return Command.STOP; diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java index b0a76e063..f5473bee1 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java @@ -924,14 +924,14 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo protected Command dropFilter(DatapathId sw, OFPacketIn pi, FloodlightContext cntx) { Command result = Command.CONTINUE; - OFPort port = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)); // If the input port is not allowed for data traffic, drop everything. // BDDP packets will not reach this stage. - if (isAllowed(sw, port) == false) { + if (isAllowed(sw, inPort) == false) { if (log.isTraceEnabled()) { log.trace("Ignoring packet because of topology " + - "restriction on switch={}, port={}", sw.getLong(), port.getPortNumber()); + "restriction on switch={}, port={}", sw.getLong(), inPort.getPortNumber()); result = Command.STOP; } } @@ -1068,7 +1068,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo // remove the incoming switch port if (pinSwitch == sid) { - ports.remove((pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); + ports.remove((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); } // we have all the switch ports to which we need to broadcast. diff --git a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java index 169a97735..245b369b0 100644 --- a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java +++ b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java @@ -29,6 +29,7 @@ import java.util.Map; import net.floodlightcontroller.core.FloodlightContext; import net.floodlightcontroller.core.IFloodlightProviderService; import net.floodlightcontroller.core.IOFSwitch; +import net.floodlightcontroller.core.internal.IOFSwitchService; import net.floodlightcontroller.core.module.FloodlightModuleContext; import net.floodlightcontroller.packet.ARP; import net.floodlightcontroller.packet.Data; @@ -94,6 +95,7 @@ public class FirewallTest extends FloodlightTestCase { DatapathId dpid = DatapathId.of(TestSwitch1DPID); sw = EasyMock.createNiceMock(IOFSwitch.class); expect(sw.getId()).andReturn(dpid).anyTimes(); + expect(sw.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes(); replay(sw); // Load the switch map Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>(); @@ -103,6 +105,7 @@ public class FirewallTest extends FloodlightTestCase { FloodlightModuleContext fmc = new FloodlightModuleContext(); fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider); + fmc.addService(IOFSwitchService.class, mockSwitchManager); fmc.addService(IFirewallService.class, firewall); fmc.addService(IStorageSourceService.class, storageService); fmc.addService(IRestApiService.class, restApi); -- GitLab