Skip to content
Snippets Groups Projects
Commit be0a42a5 authored by Alex Reimers's avatar Alex Reimers
Browse files

1 - Static Flow Pusher - On OFActionOutput set max length to be Short.MAX_VALUE

2 - Log PacketIns with no payload and stop processing
3 - Remove unused IOFController interface
parent e7166821
No related branches found
No related tags found
No related merge requests found
/**
* Copyright 2011, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* 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
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.core;
public interface IOFController {
public String getControllerId();
}
......@@ -49,7 +49,6 @@ import java.util.concurrent.TimeoutException;
import net.floodlightcontroller.core.FloodlightContext;
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IInfoProvider;
import net.floodlightcontroller.core.IOFController;
import net.floodlightcontroller.core.IOFMessageListener;
import net.floodlightcontroller.core.IOFMessageListener.Command;
import net.floodlightcontroller.core.IOFSwitch;
......@@ -129,8 +128,7 @@ import org.slf4j.LoggerFactory;
/**
* The main controller class. Handles all setup and network listeners
*/
public class Controller
implements IFloodlightProviderService, IOFController {
public class Controller implements IFloodlightProviderService {
protected static Logger log = LoggerFactory.getLogger(Controller.class);
......@@ -257,6 +255,9 @@ public class Controller
log.error("Error sending role request message to switch {}", sw);
}
}
// Send an update
// TODO send update
}
/**
......@@ -938,6 +939,13 @@ public class Controller
switch (m.getType()) {
case PACKET_IN:
OFPacketIn pi = (OFPacketIn)m;
if (pi.getPacketData().length <= 0) {
log.error("Ignoring PacketIn (Xid = " + pi.getXid() +
") because the data field is empty.");
return;
}
if (Controller.ALWAYS_DECODE_ETH) {
eth = new Ethernet();
eth.deserialize(pi.getPacketData(), 0,
......@@ -986,15 +994,12 @@ public class Controller
pktinProcTime.recordStartTimeComp(listener);
cmd = listener.receive(sw, m, bc);
pktinProcTime.recordEndTimeComp(listener);
//updateCumulativeTimeOneComp(compStartTime_ns,
// listener.getId());
if (Command.STOP.equals(cmd)) {
break;
}
}
pktinProcTime.recordEndTimePktIn(sw, m, bc);
//updateCumulativeTimeTotal(startTime_ns);
} else {
log.error("Unhandled OF Message: {} from {}", m, sw);
}
......@@ -1363,11 +1368,6 @@ public class Controller
return factory;
}
// *************
// IOFController
// *************
@Override
public String getControllerId() {
return "localhost";
}
......
......@@ -82,6 +82,9 @@ public class CounterStore implements IFloodlightModule, ICounterStoreService {
public void updatePacketInCounters(IOFSwitch sw, OFMessage m, Ethernet eth) {
OFPacketIn packet = (OFPacketIn)m;
// Make sure there is data
if (packet.getPacketData().length <= 0) return;
/* Extract the etherType and protocol field for IPv4 packet.
*/
String etherType = String.format("%04x", eth.getEtherType());
......
......@@ -216,6 +216,8 @@ public class Ethernet extends BasePacket {
@Override
public IPacket deserialize(byte[] data, int offset, int length) {
if (length <= 0)
return null;
ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
if (this.destinationMACAddress == null)
this.destinationMACAddress = MACAddress.valueOf(new byte[6]);
......
......@@ -373,7 +373,7 @@ public class StaticFlowEntries {
n = Pattern.compile("output=(?:((?:0x)?\\d+)|(all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(subaction);
if (n.matches()) {
OFActionOutput action = new OFActionOutput();
action.setMaxLength((short) 0);
action.setMaxLength((short) Short.MAX_VALUE);
short port = OFPort.OFPP_NONE.getValue();
if (n.group(1) != null) {
try {
......
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