Skip to content
Snippets Groups Projects
Commit 7fbbbbbb authored by Ryan Izard's avatar Ryan Izard
Browse files

Merge pull request #599 from rizard/master

Forwarding bug fix for edge-case simple topology
parents 8481ae10 bdc00f64
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
......@@ -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;
}
......
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