diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java index ea3a8aba8a47268bc5bdbd7723d0747b32a369a2..63aad5e3ebfafda042543217f1370f1aad69867e 100755 --- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java @@ -95,6 +95,7 @@ DeviceManagerImpl.DeviceUpdate.Change.*; import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFPacketIn; +import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.IPv4Address; import org.projectfloodlight.openflow.types.MacAddress; @@ -1152,7 +1153,7 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD); // Extract source entity information - Entity srcEntity = getSourceEntityFromPacket(eth, sw.getId(), pi.getMatch().get(MatchField.IN_PORT)); + Entity srcEntity = getSourceEntityFromPacket(eth, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); if (srcEntity == null) { cntInvalidSource.increment(); return Command.STOP; @@ -1164,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.getMatch().get(MatchField.IN_PORT)); + learnDeviceFromArpResponseData(eth, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); // Learn/lookup device information Device srcDevice = learnDeviceByEntity(srcEntity); @@ -1197,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.getMatch().get(MatchField.IN_PORT), eth, + new Object[] { pi, sw.getId().toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)), eth, srcDevice, dstDevice }); } diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java index 77ebe9a8a66c831e95248610c6c63979fe4c8541..abf899c9ca8e8fa160e7cb9f0197ea2e6bef4ff5 100644 --- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java +++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java @@ -47,7 +47,6 @@ import net.floodlightcontroller.routing.IRoutingDecision; import net.floodlightcontroller.routing.IRoutingService; import net.floodlightcontroller.routing.Route; import net.floodlightcontroller.topology.ITopologyService; -import net.floodlightcontroller.util.MatchUtils; import org.projectfloodlight.openflow.protocol.OFFlowMod; import org.projectfloodlight.openflow.protocol.match.Match; @@ -55,6 +54,7 @@ import org.projectfloodlight.openflow.protocol.match.MatchField; import org.projectfloodlight.openflow.protocol.OFFlowModCommand; import org.projectfloodlight.openflow.protocol.OFPacketIn; import org.projectfloodlight.openflow.protocol.OFPacketOut; +import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.EthType; import org.projectfloodlight.openflow.types.IPv4Address; @@ -171,8 +171,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { } protected void doForwardFlow(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx, boolean requestFlowRemovedNotifn) { - Match m = pi.getMatch(); - + OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_13) < 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); @@ -186,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.getMatch().get(MatchField.IN_PORT)); + sw.getId().toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); return; } @@ -199,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.getMatch().get(MatchField.IN_PORT).equals(dstDap.getPort()))) { + if ((sw.getId().equals(dstSwDpid)) && ((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)).equals(dstDap.getPort()))) { on_same_if = true; } break; @@ -220,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.getMatch().get(MatchField.IN_PORT)); + sw.toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); } return; } @@ -254,9 +253,9 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { dstDap.getPort(), U64.of(0)); //cookie = 0, i.e., default route if (route != null) { if (log.isTraceEnabled()) { - log.trace("pushRoute match={} route={} " + + log.trace("pushRoute inPort={} route={} " + "destination={}:{}", - new Object[] { m, route, + new Object[] { inPort, route, dstDap.getSwitchDPID(), dstDap.getPort()}); } @@ -280,8 +279,9 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { // A retentive builder will remember all MatchFields of the parent the builder was generated from // With a normal builder, all parent MatchFields will be lost if any MatchFields are added, mod, del - Match.Builder mb = MatchUtils.createRetentiveBuilder(m); - mb.setExact(MatchField.ETH_SRC, srcMac) + Match.Builder mb = sw.getOFFactory().buildMatch(); + mb.setExact(MatchField.IN_PORT, inPort) + .setExact(MatchField.ETH_SRC, srcMac) .setExact(MatchField.ETH_DST, dstMac); if (!vlan.equals(VlanVid.ZERO)) { @@ -336,11 +336,11 @@ 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.getMatch().get(MatchField.IN_PORT)) == false) { + if (topologyService.isIncomingBroadcastAllowed(sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))) == false) { if (log.isTraceEnabled()) { log.trace("doFlood, drop broadcast packet, pi={}, " + "from a blocked port, srcSwitch=[{},{}], linkInfo={}", - new Object[] {pi, sw.getId(),pi.getMatch().get(MatchField.IN_PORT)}); + new Object[] {pi, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))}); } return; } @@ -357,7 +357,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.getMatch().get(MatchField.IN_PORT)); + pob.setInPort((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); pob.setData(pi.getData()); try { diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index f280411b48d95509c79256915e76fec8f7a20674..e2b53a77707e34434536ee481c4831bc813d4103 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -97,6 +97,7 @@ import org.projectfloodlight.openflow.protocol.OFPacketIn; import org.projectfloodlight.openflow.protocol.OFPacketOut; import org.projectfloodlight.openflow.protocol.OFPortDesc; import org.projectfloodlight.openflow.protocol.OFPortState; +import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.MacAddress; import org.projectfloodlight.openflow.types.OFBufferId; @@ -594,7 +595,7 @@ IFloodlightModule, IInfoProvider { } // If packet-in is from a quarantine port, stop processing. - NodePortTuple npt = new NodePortTuple(sw, pi.getMatch().get(MatchField.IN_PORT)); + NodePortTuple npt = new NodePortTuple(sw, (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); if (quarantineQueue.contains(npt)) { ctrQuarantineDrops.increment(); return Command.STOP; diff --git a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java index 594ec51a3a4825452e24054ebe967596836949d7..878db1c99116ab3e4249d6c4a75a473a165a2077 100644 --- a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java +++ b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java @@ -54,6 +54,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFPacketIn; import org.projectfloodlight.openflow.protocol.OFPacketOut; import org.projectfloodlight.openflow.protocol.OFType; +import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.protocol.action.OFAction; import org.projectfloodlight.openflow.protocol.action.OFActionOutput; import org.projectfloodlight.openflow.types.DatapathId; @@ -348,7 +349,7 @@ public abstract class ForwardingBase implements IOFMessageListener { // 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.getMatch().get(MatchField.IN_PORT).equals(outport)) { + if ((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)).equals(outport)) { if (log.isDebugEnabled()) { log.debug("Attempting to do packet-out to the same " + "interface as packet-in. Dropping packet. " + @@ -380,7 +381,7 @@ public abstract class ForwardingBase implements IOFMessageListener { pob.setData(packetData); } - pob.setInPort(pi.getMatch().get(MatchField.IN_PORT)); + pob.setInPort((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))); try { //TODO @Ryan counterStore.updatePktOutFMCounterStoreLocal(sw, po); diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java index 91079108da337e754688b2f66d2a125540152b4e..605dc65f6e4435bfc77947504f09402024edb7a6 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java @@ -69,6 +69,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFPacketIn; import org.projectfloodlight.openflow.protocol.OFPacketOut; import org.projectfloodlight.openflow.protocol.OFType; +import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.protocol.action.OFAction; import org.projectfloodlight.openflow.protocol.match.MatchField; import org.projectfloodlight.openflow.types.DatapathId; @@ -923,7 +924,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo protected Command dropFilter(DatapathId sw, OFPacketIn pi, FloodlightContext cntx) { Command result = Command.CONTINUE; - OFPort port = pi.getMatch().get(MatchField.IN_PORT); + OFPort port = (pi.getVersion().compareTo(OFVersion.OF_13) < 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.