blob: 02972e2ef353d0e32b9acf381f4d2591b43f8a07 [file] [log] [blame]
Jonathan Hart1caaa932013-11-04 15:28:28 -08001package net.onrc.onos.ofcontroller.forwarding;
2
Jonathan Hart17672992013-12-12 16:15:16 -08003import java.net.InetAddress;
Jonathan Harte93aed42013-12-05 18:39:50 -08004import java.util.ArrayList;
5import java.util.Collection;
Jonathan Hartd33a6cf2013-12-10 14:29:08 -08006import java.util.HashMap;
Jonathan Hart1caaa932013-11-04 15:28:28 -08007import java.util.Iterator;
Jonathan Harte93aed42013-12-05 18:39:50 -08008import java.util.List;
9import java.util.Map;
Jonathan Hart5e448782013-12-10 12:36:35 -080010import java.util.concurrent.ConcurrentHashMap;
Jonathan Hart1caaa932013-11-04 15:28:28 -080011
12import net.floodlightcontroller.core.FloodlightContext;
13import net.floodlightcontroller.core.IFloodlightProviderService;
14import net.floodlightcontroller.core.IOFMessageListener;
15import net.floodlightcontroller.core.IOFSwitch;
Jonathan Harte93aed42013-12-05 18:39:50 -080016import net.floodlightcontroller.core.module.FloodlightModuleContext;
17import net.floodlightcontroller.core.module.IFloodlightModule;
18import net.floodlightcontroller.core.module.IFloodlightService;
Jonathan Hart1caaa932013-11-04 15:28:28 -080019import net.floodlightcontroller.packet.Ethernet;
Jonathan Hart17672992013-12-12 16:15:16 -080020import net.floodlightcontroller.packet.IPv4;
Jonathan Hart1caaa932013-11-04 15:28:28 -080021import net.floodlightcontroller.util.MACAddress;
Jonathan Hart17672992013-12-12 16:15:16 -080022import net.onrc.onos.datagrid.IDatagridService;
Jonathan Hart1caaa932013-11-04 15:28:28 -080023import net.onrc.onos.ofcontroller.core.IDeviceStorage;
24import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
25import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
26import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
27import net.onrc.onos.ofcontroller.core.internal.DeviceStorageImpl;
Jonathan Hartd857ad62013-12-14 18:08:17 -080028import net.onrc.onos.ofcontroller.devicemanager.IOnosDeviceService;
Jonathan Hart1caaa932013-11-04 15:28:28 -080029import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
Jonathan Hart7e6df362013-12-10 23:33:59 -080030import net.onrc.onos.ofcontroller.flowprogrammer.IFlowPusherService;
Jonathan Hart17672992013-12-12 16:15:16 -080031import net.onrc.onos.ofcontroller.proxyarp.ArpMessage;
Jonathan Hart1caaa932013-11-04 15:28:28 -080032import net.onrc.onos.ofcontroller.topology.TopologyManager;
33import net.onrc.onos.ofcontroller.util.CallerId;
34import net.onrc.onos.ofcontroller.util.DataPath;
35import net.onrc.onos.ofcontroller.util.Dpid;
Jonathan Hart4fb16d82013-11-07 22:41:32 -080036import net.onrc.onos.ofcontroller.util.FlowEntryMatch;
Jonathan Hart1caaa932013-11-04 15:28:28 -080037import net.onrc.onos.ofcontroller.util.FlowId;
38import net.onrc.onos.ofcontroller.util.FlowPath;
39import net.onrc.onos.ofcontroller.util.FlowPathType;
40import net.onrc.onos.ofcontroller.util.FlowPathUserState;
41import net.onrc.onos.ofcontroller.util.Port;
42import net.onrc.onos.ofcontroller.util.SwitchPort;
43
44import org.openflow.protocol.OFMessage;
45import org.openflow.protocol.OFPacketIn;
Jonathan Hart41d1e912013-11-24 16:50:25 -080046import org.openflow.protocol.OFPacketOut;
47import org.openflow.protocol.OFPort;
Jonathan Hart1caaa932013-11-04 15:28:28 -080048import org.openflow.protocol.OFType;
Jonathan Hart41d1e912013-11-24 16:50:25 -080049import org.openflow.protocol.action.OFAction;
50import org.openflow.protocol.action.OFActionOutput;
Jonathan Hart1caaa932013-11-04 15:28:28 -080051import org.openflow.util.HexString;
52import org.slf4j.Logger;
53import org.slf4j.LoggerFactory;
54
Jonathan Hartd857ad62013-12-14 18:08:17 -080055import com.google.common.collect.LinkedListMultimap;
56import com.google.common.collect.ListMultimap;
Jonathan Hart17672992013-12-12 16:15:16 -080057import com.google.common.net.InetAddresses;
Jonathan Hart5e448782013-12-10 12:36:35 -080058
59public class Forwarding implements IOFMessageListener, IFloodlightModule,
60 IForwardingService {
Jonathan Hart1caaa932013-11-04 15:28:28 -080061 private final static Logger log = LoggerFactory.getLogger(Forwarding.class);
62
Jonathan Hart7e6df362013-12-10 23:33:59 -080063 private final int IDLE_TIMEOUT = 5; // seconds
64 private final int HARD_TIMEOUT = 0; // seconds
65
Jonathan Hart1caaa932013-11-04 15:28:28 -080066 private IFloodlightProviderService floodlightProvider;
67 private IFlowService flowService;
Jonathan Hart7e6df362013-12-10 23:33:59 -080068 private IFlowPusherService flowPusher;
Jonathan Hart17672992013-12-12 16:15:16 -080069 private IDatagridService datagrid;
Jonathan Hart1caaa932013-11-04 15:28:28 -080070
71 private IDeviceStorage deviceStorage;
72 private TopologyManager topologyService;
73
Jonathan Hart5e448782013-12-10 12:36:35 -080074 private Map<Path, Long> pendingFlows;
Jonathan Hartd857ad62013-12-14 18:08:17 -080075 private ListMultimap<Long, PacketToPush> waitingPackets;
Jonathan Hart5e448782013-12-10 12:36:35 -080076
Jonathan Hart7e6df362013-12-10 23:33:59 -080077 private final Object lock = new Object();
78
Jonathan Hart5e448782013-12-10 12:36:35 -080079 public class PacketToPush {
80 public final OFPacketOut packet;
81 public final long dpid;
Jonathan Hart1caaa932013-11-04 15:28:28 -080082
Jonathan Hart5e448782013-12-10 12:36:35 -080083 public PacketToPush(OFPacketOut packet, long dpid) {
84 this.packet = packet;
85 this.dpid = dpid;
86 }
87 }
88
89 public final class Path {
90 public final SwitchPort srcPort;
91 public final SwitchPort dstPort;
92
93 public Path(SwitchPort src, SwitchPort dst) {
94 srcPort = new SwitchPort(new Dpid(src.dpid().value()),
95 new Port(src.port().value()));
96 dstPort = new SwitchPort(new Dpid(dst.dpid().value()),
97 new Port(dst.port().value()));
98 }
99
100 @Override
101 public boolean equals(Object other) {
102 if (!(other instanceof Path)) {
103 return false;
104 }
105
106 Path otherPath = (Path) other;
107 return srcPort.equals(otherPath.srcPort) &&
108 dstPort.equals(otherPath.dstPort);
109 }
110
111 @Override
112 public int hashCode() {
113 int hash = 17;
114 hash = 31 * hash + srcPort.hashCode();
115 hash = 31 * hash + dstPort.hashCode();
116 return hash;
117 }
Jonathan Hart1caaa932013-11-04 15:28:28 -0800118 }
119
Jonathan Harte93aed42013-12-05 18:39:50 -0800120 @Override
121 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Jonathan Hartd33a6cf2013-12-10 14:29:08 -0800122 List<Class<? extends IFloodlightService>> services =
123 new ArrayList<Class<? extends IFloodlightService>>(1);
124 services.add(IForwardingService.class);
125 return services;
Jonathan Harte93aed42013-12-05 18:39:50 -0800126 }
127
128 @Override
129 public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
Jonathan Hartd33a6cf2013-12-10 14:29:08 -0800130 Map<Class<? extends IFloodlightService>, IFloodlightService> impls =
131 new HashMap<Class<? extends IFloodlightService>, IFloodlightService>(1);
132 impls.put(IForwardingService.class, this);
133 return impls;
Jonathan Harte93aed42013-12-05 18:39:50 -0800134 }
135
136 @Override
137 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
138 List<Class<? extends IFloodlightService>> dependencies =
139 new ArrayList<Class<? extends IFloodlightService>>();
140 dependencies.add(IFloodlightProviderService.class);
141 dependencies.add(IFlowService.class);
Jonathan Hart7e6df362013-12-10 23:33:59 -0800142 dependencies.add(IFlowPusherService.class);
Jonathan Hartd857ad62013-12-14 18:08:17 -0800143 dependencies.add(IOnosDeviceService.class);
Jonathan Harte93aed42013-12-05 18:39:50 -0800144 return dependencies;
145 }
146
147 @Override
148 public void init(FloodlightModuleContext context) {
Jonathan Hart7e6df362013-12-10 23:33:59 -0800149 floodlightProvider =
Jonathan Harte93aed42013-12-05 18:39:50 -0800150 context.getServiceImpl(IFloodlightProviderService.class);
Jonathan Hart7e6df362013-12-10 23:33:59 -0800151 flowService = context.getServiceImpl(IFlowService.class);
152 flowPusher = context.getServiceImpl(IFlowPusherService.class);
Jonathan Hart17672992013-12-12 16:15:16 -0800153 datagrid = context.getServiceImpl(IDatagridService.class);
Jonathan Hart1caaa932013-11-04 15:28:28 -0800154
155 floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
156
Jonathan Hart5e448782013-12-10 12:36:35 -0800157 pendingFlows = new ConcurrentHashMap<Path, Long>();
Jonathan Hart7e6df362013-12-10 23:33:59 -0800158 //waitingPackets = Multimaps.synchronizedSetMultimap(
159 //HashMultimap.<Long, PacketToPush>create());
Jonathan Hartd857ad62013-12-14 18:08:17 -0800160 //waitingPackets = HashMultimap.create();
161 waitingPackets = LinkedListMultimap.create();
Jonathan Hart5e448782013-12-10 12:36:35 -0800162
Jonathan Hart1caaa932013-11-04 15:28:28 -0800163 deviceStorage = new DeviceStorageImpl();
164 deviceStorage.init("");
165 topologyService = new TopologyManager();
166 topologyService.init("");
167 }
168
Jonathan Harte93aed42013-12-05 18:39:50 -0800169 @Override
170 public void startUp(FloodlightModuleContext context) {
Jonathan Hart1caaa932013-11-04 15:28:28 -0800171 // no-op
172 }
173
174 @Override
175 public String getName() {
176 return "onosforwarding";
177 }
178
179 @Override
180 public boolean isCallbackOrderingPrereq(OFType type, String name) {
181 return (type == OFType.PACKET_IN) &&
Jonathan Hartd857ad62013-12-14 18:08:17 -0800182 (name.equals("devicemanager") || name.equals("proxyarpmanager")
183 || name.equals("onosdevicemanager"));
Jonathan Hart1caaa932013-11-04 15:28:28 -0800184 }
185
186 @Override
187 public boolean isCallbackOrderingPostreq(OFType type, String name) {
188 return false;
189 }
190
191 @Override
192 public Command receive(
193 IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
194
195 if (msg.getType() != OFType.PACKET_IN) {
196 return Command.CONTINUE;
197 }
198
199 OFPacketIn pi = (OFPacketIn) msg;
200
201 Ethernet eth = IFloodlightProviderService.bcStore.
202 get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
203
Jonathan Hart17672992013-12-12 16:15:16 -0800204 if (eth.getEtherType() != Ethernet.TYPE_IPv4) {
Jonathan Hart1caaa932013-11-04 15:28:28 -0800205 return Command.CONTINUE;
206 }
207
Jonathan Hart17672992013-12-12 16:15:16 -0800208 if (eth.isBroadcast() || eth.isMulticast()) {
209 handleBroadcast(sw, pi, eth);
210 //return Command.CONTINUE;
211 }
212 else {
213 // Unicast
214 handlePacketIn(sw, pi, eth);
215 }
Jonathan Hart1caaa932013-11-04 15:28:28 -0800216
217 return Command.STOP;
218 }
219
Jonathan Hart17672992013-12-12 16:15:16 -0800220 private void handleBroadcast(IOFSwitch sw, OFPacketIn pi, Ethernet eth) {
221 if (log.isTraceEnabled()) {
222 log.trace("Sending broadcast packet to other ONOS instances");
223 }
224
225 IPv4 ipv4Packet = (IPv4) eth.getPayload();
226
227 // TODO We'll put the destination address here, because the current
228 // architecture needs an address. Addresses are only used for replies
229 // however, which don't apply to non-ARP packets. The ArpMessage class
230 // has become a bit too overloaded and should be refactored to
231 // handle all use cases nicely.
232 InetAddress targetAddress =
233 InetAddresses.fromInteger(ipv4Packet.getDestinationAddress());
234
235 // Piggy-back on the ARP mechanism to broadcast this packet out the
236 // edge. Luckily the ARP module doesn't check that the packet is
237 // actually ARP before broadcasting, so we can trick it into sending
238 // our non-ARP packets.
239 // TODO This should be refactored later to account for the new use case.
Jonathan Hartf9bd98d2013-12-13 11:40:55 -0800240 datagrid.sendArpRequest(ArpMessage.newRequest(targetAddress, eth.serialize(),
Jonathan Hartd857ad62013-12-14 18:08:17 -0800241 -1L, (short)-1, sw.getId(), pi.getInPort()));
Jonathan Hart17672992013-12-12 16:15:16 -0800242 }
243
Jonathan Hart1caaa932013-11-04 15:28:28 -0800244 private void handlePacketIn(IOFSwitch sw, OFPacketIn pi, Ethernet eth) {
Jonathan Hart5e448782013-12-10 12:36:35 -0800245 String destinationMac =
246 HexString.toHexString(eth.getDestinationMACAddress());
Jonathan Hart1caaa932013-11-04 15:28:28 -0800247
248 IDeviceObject deviceObject = deviceStorage.getDeviceByMac(
249 destinationMac);
250
251 if (deviceObject == null) {
Jonathan Hart18ad9502013-12-15 18:28:00 -0800252 log.debug("No device entry found for {} - broadcasting packet",
253 destinationMac);
254 handleBroadcast(sw, pi, eth);
Jonathan Hart1caaa932013-11-04 15:28:28 -0800255 return;
256 }
257
Jonathan Hart5e448782013-12-10 12:36:35 -0800258 Iterator<IPortObject> ports = deviceObject.getAttachedPorts().iterator();
Jonathan Hart1caaa932013-11-04 15:28:28 -0800259 if (!ports.hasNext()) {
Jonathan Hart18ad9502013-12-15 18:28:00 -0800260 log.debug("No attachment point found for device {} - broadcasting packet",
261 destinationMac);
262 handleBroadcast(sw, pi, eth);
Jonathan Hart1caaa932013-11-04 15:28:28 -0800263 return;
264 }
265 IPortObject portObject = ports.next();
266 short destinationPort = portObject.getNumber();
267 ISwitchObject switchObject = portObject.getSwitch();
268 long destinationDpid = HexString.toLong(switchObject.getDPID());
269
Jonathan Hart41d1e912013-11-24 16:50:25 -0800270 // TODO SwitchPort, Dpid and Port should probably be immutable
271 // (also, are Dpid and Port are even necessary?)
Jonathan Hart1caaa932013-11-04 15:28:28 -0800272 SwitchPort srcSwitchPort = new SwitchPort(
273 new Dpid(sw.getId()), new Port(pi.getInPort()));
274 SwitchPort dstSwitchPort = new SwitchPort(
275 new Dpid(destinationDpid), new Port(destinationPort));
Jonathan Hartdc3ad702013-11-14 11:34:59 -0800276
277 MACAddress srcMacAddress = MACAddress.valueOf(eth.getSourceMACAddress());
278 MACAddress dstMacAddress = MACAddress.valueOf(eth.getDestinationMACAddress());
Jonathan Hart1caaa932013-11-04 15:28:28 -0800279
Jonathan Hart5e448782013-12-10 12:36:35 -0800280
Jonathan Hart7e6df362013-12-10 23:33:59 -0800281 FlowPath flowPath, reverseFlowPath;
Jonathan Hart5e448782013-12-10 12:36:35 -0800282
283 Path pathspec = new Path(srcSwitchPort, dstSwitchPort);
284 // TODO check concurrency
Jonathan Hart7e6df362013-12-10 23:33:59 -0800285 synchronized (lock) {
286 Long existingFlowId = pendingFlows.get(pathspec);
Jonathan Hartdc3ad702013-11-14 11:34:59 -0800287
Jonathan Hart7e6df362013-12-10 23:33:59 -0800288 if (existingFlowId != null) {
289 log.debug("Found existing flow {}",
290 HexString.toHexString(existingFlowId));
291
292 OFPacketOut po = constructPacketOut(pi, sw);
293 waitingPackets.put(existingFlowId, new PacketToPush(po, sw.getId()));
294 return;
295 }
296
Jonathan Hart7e6df362013-12-10 23:33:59 -0800297 log.debug("Adding new flow between {} at {} and {} at {}",
298 new Object[]{srcMacAddress, srcSwitchPort, dstMacAddress, dstSwitchPort});
299
300
301 CallerId callerId = new CallerId("Forwarding");
302
303 DataPath datapath = new DataPath();
304 datapath.setSrcPort(srcSwitchPort);
305 datapath.setDstPort(dstSwitchPort);
306
307 flowPath = new FlowPath();
308 flowPath.setInstallerId(callerId);
309
310 flowPath.setFlowPathType(FlowPathType.FP_TYPE_SHORTEST_PATH);
311 flowPath.setFlowPathUserState(FlowPathUserState.FP_USER_ADD);
312 flowPath.setFlowEntryMatch(new FlowEntryMatch());
313 flowPath.setIdleTimeout(IDLE_TIMEOUT);
314 flowPath.setHardTimeout(HARD_TIMEOUT);
315 flowPath.flowEntryMatch().enableSrcMac(srcMacAddress);
316 flowPath.flowEntryMatch().enableDstMac(dstMacAddress);
317 flowPath.flowEntryMatch().enableEthernetFrameType(Ethernet.TYPE_IPv4);
318 flowPath.setDataPath(datapath);
319
320
321 DataPath reverseDataPath = new DataPath();
322 // Reverse the ports for the reverse path
323 reverseDataPath.setSrcPort(dstSwitchPort);
324 reverseDataPath.setDstPort(srcSwitchPort);
325
326 // TODO implement copy constructor for FlowPath
327 reverseFlowPath = new FlowPath();
328 reverseFlowPath.setInstallerId(callerId);
329 reverseFlowPath.setFlowPathType(FlowPathType.FP_TYPE_SHORTEST_PATH);
330 reverseFlowPath.setFlowPathUserState(FlowPathUserState.FP_USER_ADD);
331 reverseFlowPath.setIdleTimeout(IDLE_TIMEOUT);
332 reverseFlowPath.setHardTimeout(HARD_TIMEOUT);
333 reverseFlowPath.setFlowEntryMatch(new FlowEntryMatch());
334 // Reverse the MAC addresses for the reverse path
335 reverseFlowPath.flowEntryMatch().enableSrcMac(dstMacAddress);
336 reverseFlowPath.flowEntryMatch().enableDstMac(srcMacAddress);
337 reverseFlowPath.flowEntryMatch().enableEthernetFrameType(Ethernet.TYPE_IPv4);
338 reverseFlowPath.setDataPath(reverseDataPath);
339 reverseFlowPath.dataPath().srcPort().dpid().toString();
340
341 // TODO what happens if no path exists? cleanup
342
343 FlowId flowId = new FlowId(flowService.getNextFlowEntryId());
344 FlowId reverseFlowId = new FlowId(flowService.getNextFlowEntryId());
345
346 flowPath.setFlowId(flowId);
347 reverseFlowPath.setFlowId(reverseFlowId);
348
349 OFPacketOut po = constructPacketOut(pi, sw);
350 Path reversePathSpec = new Path(dstSwitchPort, srcSwitchPort);
351
352 // Add to waiting lists
353 pendingFlows.put(pathspec, flowId.value());
354 pendingFlows.put(reversePathSpec, reverseFlowId.value());
355 waitingPackets.put(flowId.value(), new PacketToPush(po, sw.getId()));
356
Jonathan Hart41d1e912013-11-24 16:50:25 -0800357 }
358
Jonathan Hart5e448782013-12-10 12:36:35 -0800359 flowService.addFlow(reverseFlowPath);
360 flowService.addFlow(flowPath);
Jonathan Hart7e6df362013-12-10 23:33:59 -0800361
Jonathan Hart1caaa932013-11-04 15:28:28 -0800362 }
Jonathan Hartdc3ad702013-11-14 11:34:59 -0800363
Jonathan Hart5e448782013-12-10 12:36:35 -0800364 /*
Jonathan Hartdc3ad702013-11-14 11:34:59 -0800365 private boolean flowExists(SwitchPort srcPort, MACAddress srcMac,
366 SwitchPort dstPort, MACAddress dstMac) {
367 for (FlowPath flow : datagridService.getAllFlows()) {
368 FlowEntryMatch match = flow.flowEntryMatch();
369 // TODO implement FlowEntryMatch.equals();
370 // This is painful to do properly without support in the FlowEntryMatch
371 boolean same = true;
372 if (!match.srcMac().equals(srcMac) ||
373 !match.dstMac().equals(dstMac)) {
374 same = false;
375 }
376 if (!flow.dataPath().srcPort().equals(srcPort) ||
377 !flow.dataPath().dstPort().equals(dstPort)) {
378 same = false;
379 }
380
381 if (same) {
382 log.debug("found flow entry that's the same {}-{}:::{}-{}",
383 new Object[] {srcPort, srcMac, dstPort, dstMac});
384 return true;
385 }
386 }
387
388 return false;
389 }
Jonathan Hart5e448782013-12-10 12:36:35 -0800390 */
Jonathan Hart1caaa932013-11-04 15:28:28 -0800391
Jonathan Hart7e6df362013-12-10 23:33:59 -0800392 private OFPacketOut constructPacketOut(OFPacketIn pi, IOFSwitch sw) {
Jonathan Hart41d1e912013-11-24 16:50:25 -0800393 OFPacketOut po = new OFPacketOut();
394 po.setInPort(OFPort.OFPP_NONE)
395 .setInPort(pi.getInPort())
Jonathan Hart5e448782013-12-10 12:36:35 -0800396 .setActions(new ArrayList<OFAction>())
397 .setLengthU(OFPacketOut.MINIMUM_LENGTH);
Jonathan Hart41d1e912013-11-24 16:50:25 -0800398
399 if (sw.getBuffers() == 0) {
400 po.setBufferId(OFPacketOut.BUFFER_ID_NONE)
401 .setPacketData(pi.getPacketData())
402 .setLengthU(po.getLengthU() + po.getPacketData().length);
403 }
404 else {
405 po.setBufferId(pi.getBufferId());
406 }
407
Jonathan Hart5e448782013-12-10 12:36:35 -0800408 return po;
409 }
Pavlin Radoslavov7208e9a2013-12-11 14:31:07 -0800410
Jonathan Hart5e448782013-12-10 12:36:35 -0800411 @Override
Pavlin Radoslavov7208e9a2013-12-11 14:31:07 -0800412 public void flowsInstalled(Collection<FlowPath> installedFlowPaths) {
413 for (FlowPath flowPath : installedFlowPaths) {
414 flowInstalled(flowPath);
415 }
416 }
417
418 private void flowInstalled(FlowPath installedFlowPath) {
Jonathan Hart5e448782013-12-10 12:36:35 -0800419 // TODO check concurrency
420 // will need to sync and access both collections at once.
421 long flowId = installedFlowPath.flowId().value();
Jonathan Hart5e448782013-12-10 12:36:35 -0800422
Jonathan Hart7e6df362013-12-10 23:33:59 -0800423 Collection<PacketToPush> packets;
424 synchronized (lock) {
425 packets = waitingPackets.removeAll(flowId);
426
427 //remove pending flows entry
428 Path pathToRemove = new Path(installedFlowPath.dataPath().srcPort(),
429 installedFlowPath.dataPath().dstPort());
430 pendingFlows.remove(pathToRemove);
431
432 }
Jonathan Hart5e448782013-12-10 12:36:35 -0800433
434 for (PacketToPush packet : packets) {
435 IOFSwitch sw = floodlightProvider.getSwitches().get(packet.dpid);
436
437 OFPacketOut po = packet.packet;
438 short outPort =
439 installedFlowPath.flowEntries().get(0).outPort().value();
440 po.getActions().add(new OFActionOutput(outPort));
441 po.setActionsLength((short)
442 (po.getActionsLength() + OFActionOutput.MINIMUM_LENGTH));
443 po.setLengthU(po.getLengthU() + OFActionOutput.MINIMUM_LENGTH);
444
Jonathan Hart7e6df362013-12-10 23:33:59 -0800445 flowPusher.add(sw, po);
Jonathan Hart41d1e912013-11-24 16:50:25 -0800446 }
447 }
Jonathan Hart1caaa932013-11-04 15:28:28 -0800448}