diff --git a/src/main/java/net/floodlightcontroller/core/IOFController.java b/src/main/java/net/floodlightcontroller/core/IOFController.java deleted file mode 100644 index dfa871617e5111f3fa53208e199769cd42586322..0000000000000000000000000000000000000000 --- a/src/main/java/net/floodlightcontroller/core/IOFController.java +++ /dev/null @@ -1,23 +0,0 @@ -/** -* 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(); -} diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 77674efe0a7a318a81361ace47ad9037c3dc0184..590d0c353b34ee161f1e1b09248d088e57de6dc7 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -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"; } diff --git a/src/main/java/net/floodlightcontroller/counter/CounterStore.java b/src/main/java/net/floodlightcontroller/counter/CounterStore.java index dca628e5ba85e3f51b5b9d5a0f378567b8c3769d..9ec37349fe065623221244c4a68b7fdaabb0498e 100644 --- a/src/main/java/net/floodlightcontroller/counter/CounterStore.java +++ b/src/main/java/net/floodlightcontroller/counter/CounterStore.java @@ -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()); diff --git a/src/main/java/net/floodlightcontroller/packet/Ethernet.java b/src/main/java/net/floodlightcontroller/packet/Ethernet.java index 9eba6e9baa77960ab048f598a59238541afa1f90..70ba984a155d90b7888f37effe11c6941f8f3f1d 100644 --- a/src/main/java/net/floodlightcontroller/packet/Ethernet.java +++ b/src/main/java/net/floodlightcontroller/packet/Ethernet.java @@ -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]); diff --git a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java index a51bdca73ded072ae4621a24ccb11544466fc5b3..f39520f1e18f09c22687e32fbcb829244966df09 100644 --- a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java +++ b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java @@ -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 { diff --git a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java index d390f2ed9a5a655b754546498e7e191ed69487c8..9227eff8f581f2e2910836ce97ee9f40a2fd677b 100644 --- a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java +++ b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java @@ -57,7 +57,7 @@ public class StaticFlowTests extends FloodlightTestCase { // setup actions List<OFAction> actions = new LinkedList<OFAction>(); TestRule1.put(COLUMN_ACTIONS, "output=1"); - actions.add(new OFActionOutput((short)1, (short) 0)); + actions.add(new OFActionOutput((short)1, (short) Short.MAX_VALUE)); // done FlowMod1.setMatch(match); FlowMod1.setActions(actions); @@ -82,7 +82,7 @@ public class StaticFlowTests extends FloodlightTestCase { // setup actions List<OFAction> actions = new LinkedList<OFAction>(); TestRule2.put(COLUMN_ACTIONS, "output=1"); - actions.add(new OFActionOutput((short)1, (short) 0)); + actions.add(new OFActionOutput((short)1, (short) Short.MAX_VALUE)); // done FlowMod2.setMatch(match); FlowMod2.setActions(actions); @@ -109,7 +109,7 @@ public class StaticFlowTests extends FloodlightTestCase { // setup actions TestRule3.put(COLUMN_ACTIONS, "output=controller"); List<OFAction> actions = new LinkedList<OFAction>(); - actions.add(new OFActionOutput(OFPort.OFPP_CONTROLLER.getValue(), (short) 0)); + actions.add(new OFActionOutput(OFPort.OFPP_CONTROLLER.getValue(), (short) Short.MAX_VALUE)); // done FlowMod3.setMatch(match); FlowMod3.setActions(actions);