diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java index 8a58a1f2320b4dfeea720343ce7156429b1d1435..1db7e728d08fa06904b74fb185ec1640b58e159a 100644 --- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java +++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java @@ -20,6 +20,7 @@ package net.floodlightcontroller.forwarding; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -47,6 +48,7 @@ import net.floodlightcontroller.routing.IRoutingDecision; import net.floodlightcontroller.routing.IRoutingService; import net.floodlightcontroller.routing.Route; import net.floodlightcontroller.topology.ITopologyService; +import net.floodlightcontroller.topology.NodePortTuple; import org.projectfloodlight.openflow.protocol.OFFlowMod; import org.projectfloodlight.openflow.protocol.OFFlowModCommand; @@ -79,7 +81,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { // We found a routing decision (i.e. Firewall is enabled... it's the only thing that makes RoutingDecisions) if (decision != null) { if (log.isTraceEnabled()) { - log.trace("Forwaring decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi); + log.trace("Forwarding decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi); } switch(decision.getRoutingAction()) { @@ -223,6 +225,9 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { dstDap.getSwitchDPID(), dstDap.getPort(), U64.of(0)); //cookie = 0, i.e., default route + Match m = createMatchFromPacket(sw, inPort, cntx); + U64 cookie = AppCookie.makeCookie(FORWARDING_APP_ID, 0); + if (route != null) { log.debug("pushRoute inPort={} route={} " + "destination={}:{}", @@ -230,15 +235,24 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { dstDap.getSwitchDPID(), dstDap.getPort()}); - U64 cookie = AppCookie.makeCookie(FORWARDING_APP_ID, 0); - Match m = createMatchFromPacket(sw, inPort, cntx); log.debug("Cretaing flow rules on the route, match rule: {}", m); pushRoute(route, m, pi, sw.getId(), cookie, cntx, requestFlowRemovedNotifn, OFFlowModCommand.ADD); } else { - log.error("Could not compute route between {} and {}. Dropping packet", srcDevice, dstDevice); + /* Route traverses no links --> src/dst devices on same switch */ + log.debug("Could not compute route. Devices should be on same switch src={} and dst={}", srcDevice, dstDevice); + Route r = new Route(srcDevice.getAttachmentPoints()[0].getSwitchDPID(), dstDevice.getAttachmentPoints()[0].getSwitchDPID()); + List<NodePortTuple> path = new ArrayList<NodePortTuple>(2); + path.add(new NodePortTuple(srcDevice.getAttachmentPoints()[0].getSwitchDPID(), + srcDevice.getAttachmentPoints()[0].getPort())); + path.add(new NodePortTuple(dstDevice.getAttachmentPoints()[0].getSwitchDPID(), + dstDevice.getAttachmentPoints()[0].getPort())); + r.setPath(path); + pushRoute(r, m, pi, sw.getId(), cookie, + cntx, requestFlowRemovedNotifn, + OFFlowModCommand.ADD); } } else { log.debug("Destination unknown. Flooding packet"); @@ -365,7 +379,9 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { Set<OFPort> broadcastPorts = this.topologyService.getSwitchBroadcastPorts(sw.getId()); if (broadcastPorts == null) { - return; + log.debug("BroadcastPorts returned null. Assuming single switch w/no links."); + /* Must be a single-switch w/no links */ + broadcastPorts = Collections.singleton(OFPort.FLOOD); } for (OFPort p : broadcastPorts) { diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java index 95cfc57e0794e6efc2edd4cb9d9f5995cd26f27c..9ca3074b0e92b796169f99f0a15c63bd3d6a3c49 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java @@ -1148,7 +1148,12 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo } protected void addOrUpdateSwitch(DatapathId sw) { - // nothing to do here for the time being. + /*TODO react appropriately + addSwitch(sw); + for (OFPortDesc p : switchService.getSwitch(sw).getPorts()) { + addPortToSwitch(sw, p.getPortNo()); + } + */ return; }