blob: 2321d5583ab96feb99c5a2d4a24bd89d0af27c07 [file] [log] [blame]
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -08001package net.floodlightcontroller.flowcache;
2
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -08003import java.io.IOException;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -08004import java.util.ArrayList;
5import java.util.Collection;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -08006import java.util.EnumSet;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -08007import java.util.HashMap;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -08008import java.util.List;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -08009import java.util.Map;
Pavlin Radoslavov01391c92013-03-14 17:13:21 -070010import java.util.TreeMap;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080011import java.util.concurrent.Executors;
12import java.util.concurrent.ScheduledExecutorService;
13import java.util.concurrent.ScheduledFuture;
14import java.util.concurrent.TimeUnit;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080015
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080016import net.floodlightcontroller.core.IFloodlightProviderService;
17import net.floodlightcontroller.core.INetMapStorage;
18import net.floodlightcontroller.core.INetMapTopologyObjects.IFlowEntry;
19import net.floodlightcontroller.core.INetMapTopologyObjects.IFlowPath;
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070020import net.floodlightcontroller.core.INetMapTopologyService.ITopoRouteService;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080021import net.floodlightcontroller.core.IOFSwitch;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080022import net.floodlightcontroller.core.module.FloodlightModuleContext;
23import net.floodlightcontroller.core.module.FloodlightModuleException;
24import net.floodlightcontroller.core.module.IFloodlightModule;
25import net.floodlightcontroller.core.module.IFloodlightService;
26import net.floodlightcontroller.flowcache.IFlowService;
27import net.floodlightcontroller.flowcache.web.FlowWebRoutable;
28import net.floodlightcontroller.restserver.IRestApiService;
29import net.floodlightcontroller.util.CallerId;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080030import net.floodlightcontroller.util.DataPath;
31import net.floodlightcontroller.util.Dpid;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080032import net.floodlightcontroller.util.DataPathEndpoints;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080033import net.floodlightcontroller.util.FlowEntry;
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -070034import net.floodlightcontroller.util.FlowEntryAction;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080035import net.floodlightcontroller.util.FlowEntryId;
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -070036import net.floodlightcontroller.util.FlowEntryMatch;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080037import net.floodlightcontroller.util.FlowEntrySwitchState;
38import net.floodlightcontroller.util.FlowEntryUserState;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080039import net.floodlightcontroller.util.FlowId;
40import net.floodlightcontroller.util.FlowPath;
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -070041import net.floodlightcontroller.util.IPv4Net;
42import net.floodlightcontroller.util.MACAddress;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080043import net.floodlightcontroller.util.OFMessageDamper;
44import net.floodlightcontroller.util.Port;
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070045import net.floodlightcontroller.util.SwitchPort;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080046import net.onrc.onos.util.GraphDBConnection;
47import net.onrc.onos.util.GraphDBConnection.Transaction;
48
49import org.openflow.protocol.OFFlowMod;
50import org.openflow.protocol.OFMatch;
51import org.openflow.protocol.OFPacketOut;
Pavlin Radoslavov78c4e492013-03-12 17:17:48 -070052import org.openflow.protocol.OFPort;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080053import org.openflow.protocol.OFType;
54import org.openflow.protocol.action.OFAction;
55import org.openflow.protocol.action.OFActionOutput;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080056
57import org.slf4j.Logger;
58import org.slf4j.LoggerFactory;
59
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080060public class FlowManager implements IFloodlightModule, IFlowService, INetMapStorage {
61
62 public GraphDBConnection conn;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080063
64 protected IRestApiService restApi;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080065 protected IFloodlightProviderService floodlightProvider;
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070066 protected FloodlightModuleContext context;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080067
68 protected OFMessageDamper messageDamper;
69
Pavlin Radoslavov78c4e492013-03-12 17:17:48 -070070 //
71 // TODO: Values copied from elsewhere (class LearningSwitch).
72 // The local copy should go away!
73 //
74 protected static final int OFMESSAGE_DAMPER_CAPACITY = 50000; // TODO: find sweet spot
75 protected static final int OFMESSAGE_DAMPER_TIMEOUT = 250; // ms
76 public static final short FLOWMOD_DEFAULT_IDLE_TIMEOUT = 0; // infinity
77 public static final short FLOWMOD_DEFAULT_HARD_TIMEOUT = 0; // infinite
78 public static final short PRIORITY_DEFAULT = 100;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080079
Pavlin Radoslavov01391c92013-03-14 17:13:21 -070080 private static long nextFlowEntryId = 1;
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070081 private static long measurementFlowId = 100000;
82 private static String measurementFlowIdStr = "0x186a0"; // 100000
83 private long modifiedMeasurementFlowTime = 0;
Pavlin Radoslavov01391c92013-03-14 17:13:21 -070084
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -080085 /** The logger. */
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080086 private static Logger log = LoggerFactory.getLogger(FlowManager.class);
87
88 // The periodic task(s)
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070089 private final ScheduledExecutorService measureShortestPathScheduler =
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080090 Executors.newScheduledThreadPool(1);
Pavlin Radoslavov571cff92013-03-20 02:01:32 -070091 private final ScheduledExecutorService measureMapReaderScheduler =
92 Executors.newScheduledThreadPool(1);
93 private final ScheduledExecutorService mapReaderScheduler =
94 Executors.newScheduledThreadPool(1);
95
96 final Runnable measureShortestPath = new Runnable() {
97 public void run() {
98 log.debug("Recomputing Shortest Paths from the Network Map Flows...");
99 if (floodlightProvider == null) {
100 log.debug("FloodlightProvider service not found!");
101 return;
102 }
103
104 ITopoRouteService topoRouteService =
105 context.getServiceImpl(ITopoRouteService.class);
106 if (topoRouteService == null) {
107 log.debug("Topology Route Service not found");
108 return;
109 }
110
111 //
112 // Recompute the Shortest Paths for all Flows
113 //
114 int counter = 0;
115 long startTime = System.nanoTime();
116 Iterable<IFlowPath> allFlowPaths = conn.utils().getAllFlowPaths(conn);
117 for (IFlowPath flowPathObj : allFlowPaths) {
118 counter++;
119 FlowId flowId = new FlowId(flowPathObj.getFlowId());
120
121 // log.debug("Found Path {}", flowId.toString());
122 Dpid srcDpid = new Dpid(flowPathObj.getSrcSwitch());
123 Port srcPort = new Port(flowPathObj.getSrcPort());
124 Dpid dstDpid = new Dpid(flowPathObj.getDstSwitch());
125 Port dstPort = new Port(flowPathObj.getDstPort());
126 SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
127 SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
128 DataPath dataPath =
129 topoRouteService.getShortestPath(srcSwitchPort,
130 dstSwitchPort);
131 }
132 conn.endTx(Transaction.COMMIT);
133
134 long estimatedTime = System.nanoTime() - startTime;
135 double rate = (estimatedTime > 0)? ((double)counter * 1000000000) / estimatedTime: 0.0;
136 String logMsg = "MEASUREMENT: Computed " + counter + " shortest paths in " + (double)estimatedTime / 1000000000 + " sec: " + rate + " flows/s";
137 log.debug(logMsg);
138 }
139 };
140
141 final Runnable measureMapReader = new Runnable() {
142 public void run() {
143 if (floodlightProvider == null) {
144 log.debug("FloodlightProvider service not found!");
145 return;
146 }
147
148 //
149 // Fetch all Flow Entries
150 //
151 int counter = 0;
152 long startTime = System.nanoTime();
153 Iterable<IFlowEntry> allFlowEntries = conn.utils().getAllFlowEntries(conn);
154 for (IFlowEntry flowEntryObj : allFlowEntries) {
155 counter++;
156 FlowEntryId flowEntryId =
157 new FlowEntryId(flowEntryObj.getFlowEntryId());
158 String userState = flowEntryObj.getUserState();
159 String switchState = flowEntryObj.getSwitchState();
160 }
161 conn.endTx(Transaction.COMMIT);
162
163 long estimatedTime = System.nanoTime() - startTime;
164 double rate = (estimatedTime > 0)? ((double)counter * 1000000000) / estimatedTime: 0.0;
165 String logMsg = "MEASUREMENT: Fetched " + counter + " flow entries in " + (double)estimatedTime / 1000000000 + " sec: " + rate + " entries/s";
166 log.debug(logMsg);
167 }
168 };
169
170 final Runnable mapReader = new Runnable() {
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800171 public void run() {
172 // log.debug("Reading Flow Entries from the Network Map...");
173 if (floodlightProvider == null) {
174 log.debug("FloodlightProvider service not found!");
175 return;
176 }
177
178 Map<Long, IOFSwitch> mySwitches = floodlightProvider.getSwitches();
179
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700180 Map<Long, IFlowEntry> myFlowEntries = new TreeMap<Long, IFlowEntry>();
181
182 //
183 // Fetch all Flow Entries and select only my Flow Entries
184 //
185 Iterable<IFlowEntry> allFlowEntries = conn.utils().getAllFlowEntries(conn);
186 for (IFlowEntry flowEntryObj : allFlowEntries) {
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800187 FlowEntryId flowEntryId =
188 new FlowEntryId(flowEntryObj.getFlowEntryId());
Pavlin Radoslavov2f9d6332013-03-18 23:05:48 -0700189 String userState = flowEntryObj.getUserState();
190 String switchState = flowEntryObj.getSwitchState();
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800191
Pavlin Radoslavov79a67c12013-03-15 21:05:53 -0700192 log.debug("Found Flow Entry {}: {}",
193 flowEntryId.toString(),
Pavlin Radoslavov2f9d6332013-03-18 23:05:48 -0700194 "User State: " + userState +
195 " Switch State: " + switchState);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800196
197 if (! switchState.equals("FE_SWITCH_NOT_UPDATED")) {
198 // Ignore the entry: nothing to do
199 continue;
200 }
201
202 Dpid dpid = new Dpid(flowEntryObj.getSwitchDpid());
203 IOFSwitch mySwitch = mySwitches.get(dpid.value());
204 if (mySwitch == null) {
Pavlin Radoslavov79a67c12013-03-15 21:05:53 -0700205 log.debug("Flow Entry ignored: not my switch (FlowEntryId = {} DPID = {})", flowEntryId.toString(), dpid.toString());
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800206 continue;
207 }
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700208 myFlowEntries.put(flowEntryId.value(), flowEntryObj);
209 }
210
211 //
212 // Process my Flow Entries
213 //
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700214 Boolean processed_measurement_flow = false;
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700215 for (Map.Entry<Long, IFlowEntry> entry : myFlowEntries.entrySet()) {
216 IFlowEntry flowEntryObj = entry.getValue();
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700217 // Code for measurement purpose
218 {
219 IFlowPath flowObj =
220 conn.utils().getFlowPathByFlowEntry(conn,
221 flowEntryObj);
222 if ((flowObj != null) &&
223 flowObj.getFlowId().equals(measurementFlowIdStr)) {
224 processed_measurement_flow = true;
225 }
226 }
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700227
228 //
229 // TODO: Eliminate the re-fetching of flowEntryId,
230 // userState, switchState, and dpid from the flowEntryObj.
231 //
232 FlowEntryId flowEntryId =
233 new FlowEntryId(flowEntryObj.getFlowEntryId());
234 Dpid dpid = new Dpid(flowEntryObj.getSwitchDpid());
235 String userState = flowEntryObj.getUserState();
236 String switchState = flowEntryObj.getSwitchState();
237 IOFSwitch mySwitch = mySwitches.get(dpid.value());
238 if (mySwitch == null) {
239 log.debug("Flow Entry ignored: not my switch");
240 continue;
241 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800242
243 //
244 // Create the Open Flow Flow Modification Entry to push
245 //
246 OFFlowMod fm =
247 (OFFlowMod) floodlightProvider.getOFMessageFactory()
248 .getMessage(OFType.FLOW_MOD);
249 long cookie = flowEntryId.value();
250
251 short flowModCommand = OFFlowMod.OFPFC_ADD;
252 if (userState.equals("FE_USER_ADD")) {
253 flowModCommand = OFFlowMod.OFPFC_ADD;
254 } else if (userState.equals("FE_USER_MODIFY")) {
255 flowModCommand = OFFlowMod.OFPFC_MODIFY_STRICT;
256 } else if (userState.equals("FE_USER_DELETE")) {
257 flowModCommand = OFFlowMod.OFPFC_DELETE_STRICT;
258 } else {
259 // Unknown user state. Ignore the entry
Pavlin Radoslavov2f9d6332013-03-18 23:05:48 -0700260 log.debug("Flow Entry ignored (FlowEntryId = {}): unknown user state {}",
261 flowEntryId.toString(), userState);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800262 continue;
263 }
264
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -0700265 //
266 // Fetch the match conditions
267 //
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800268 OFMatch match = new OFMatch();
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -0700269 match.setWildcards(OFMatch.OFPFW_ALL);
270 Short matchInPort = flowEntryObj.getMatchInPort();
271 if (matchInPort != null) {
272 match.setInputPort(matchInPort);
273 match.setWildcards(match.getWildcards() & ~OFMatch.OFPFW_IN_PORT);
274 }
275 Short matchEthernetFrameType = flowEntryObj.getMatchEthernetFrameType();
276 if (matchEthernetFrameType != null) {
277 match.setDataLayerType(matchEthernetFrameType);
278 match.setWildcards(match.getWildcards() & ~OFMatch.OFPFW_DL_TYPE);
279 }
280 String matchSrcIPv4Net = flowEntryObj.getMatchSrcIPv4Net();
281 if (matchSrcIPv4Net != null) {
282 match.setFromCIDR(matchSrcIPv4Net, OFMatch.STR_NW_SRC);
283 }
284 String matchDstIPv4Net = flowEntryObj.getMatchDstIPv4Net();
285 if (matchDstIPv4Net != null) {
286 match.setFromCIDR(matchDstIPv4Net, OFMatch.STR_NW_DST);
287 }
288 String matchSrcMac = flowEntryObj.getMatchSrcMac();
289 if (matchSrcMac != null) {
290 match.setDataLayerSource(matchSrcMac);
291 match.setWildcards(match.getWildcards() & ~OFMatch.OFPFW_DL_SRC);
292 }
293 String matchDstMac = flowEntryObj.getMatchDstMac();
294 if (matchDstMac != null) {
295 match.setDataLayerDestination(matchDstMac);
296 match.setWildcards(match.getWildcards() & ~OFMatch.OFPFW_DL_DST);
297 }
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -0700298
299 //
300 // Fetch the actions
301 //
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800302 List<OFAction> actions = new ArrayList<OFAction>();
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -0700303 Short actionOutputPort = flowEntryObj.getActionOutput();
304 if (actionOutputPort != null) {
305 OFActionOutput action = new OFActionOutput();
306 // XXX: The max length is hard-coded for now
307 action.setMaxLength((short)0xffff);
308 action.setPort(actionOutputPort);
309 actions.add(action);
310 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800311
312 fm.setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
313 .setHardTimeout(FLOWMOD_DEFAULT_HARD_TIMEOUT)
Pavlin Radoslavov78c4e492013-03-12 17:17:48 -0700314 .setPriority(PRIORITY_DEFAULT)
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800315 .setBufferId(OFPacketOut.BUFFER_ID_NONE)
316 .setCookie(cookie)
317 .setCommand(flowModCommand)
318 .setMatch(match)
319 .setActions(actions)
320 .setLengthU(OFFlowMod.MINIMUM_LENGTH+OFActionOutput.MINIMUM_LENGTH);
Pavlin Radoslavov78c4e492013-03-12 17:17:48 -0700321 fm.setOutPort(OFPort.OFPP_NONE.getValue());
322 if ((flowModCommand == OFFlowMod.OFPFC_DELETE) ||
323 (flowModCommand == OFFlowMod.OFPFC_DELETE_STRICT)) {
324 if (actionOutputPort != null)
325 fm.setOutPort(actionOutputPort);
326 }
327
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800328 //
329 // TODO: Set the following flag
330 // fm.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
331 // See method ForwardingBase::pushRoute()
332 //
333 try {
334 messageDamper.write(mySwitch, fm, null);
335 mySwitch.flush();
336 flowEntryObj.setSwitchState("FE_SWITCH_UPDATED");
337 if (userState.equals("FE_USER_DELETE")) {
338 // Delete the entry
339 IFlowPath flowObj = null;
340 flowObj = conn.utils().getFlowPathByFlowEntry(conn,
341 flowEntryObj);
342 if (flowObj != null)
343 log.debug("Found FlowPath to be deleted");
344 else
345 log.debug("Did not find FlowPath to be deleted");
346 flowObj.removeFlowEntry(flowEntryObj);
347 conn.utils().removeFlowEntry(conn, flowEntryObj);
348
349 // Test whether the last flow entry
350 Iterable<IFlowEntry> tmpflowEntries =
351 flowObj.getFlowEntries();
352 boolean found = false;
353 for (IFlowEntry tmpflowEntryObj : tmpflowEntries) {
354 found = true;
355 break;
356 }
357 if (! found) {
358 // Remove the Flow Path as well
359 conn.utils().removeFlowPath(conn, flowObj);
360 }
361 }
362 } catch (IOException e) {
363 log.error("Failure writing flow mod from network map", e);
364 }
365 }
366 conn.endTx(Transaction.COMMIT);
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700367
368 if (processed_measurement_flow) {
369 long estimatedTime = System.nanoTime() - modifiedMeasurementFlowTime;
370 String logMsg = "MEASUREMENT: Pushed Flow delay: " +
371 (double)estimatedTime / 1000000000 + " sec";
372 log.debug(logMsg);
373 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800374 }
375 };
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700376
377 /*
378 final ScheduledFuture<?> measureShortestPathHandle =
379 measureShortestPathScheduler.scheduleAtFixedRate(measureShortestPath, 10, 10, TimeUnit.SECONDS);
380 */
381
382 /*
383 final ScheduledFuture<?> measureMapReaderHandle =
384 measureMapReaderScheduler.scheduleAtFixedRate(measureMapReader, 10, 10, TimeUnit.SECONDS);
385 */
386
387 final ScheduledFuture<?> mapReaderHandle =
388 mapReaderScheduler.scheduleAtFixedRate(mapReader, 3, 3, TimeUnit.SECONDS);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800389
390 @Override
391 public void init(String conf) {
392 conn = GraphDBConnection.getInstance(conf);
393 }
394
395 public void finalize() {
396 close();
397 }
398
399 @Override
400 public void close() {
401 conn.close();
402 }
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800403
404 @Override
405 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
406 Collection<Class<? extends IFloodlightService>> l =
407 new ArrayList<Class<? extends IFloodlightService>>();
408 l.add(IFlowService.class);
409 return l;
410 }
411
412 @Override
413 public Map<Class<? extends IFloodlightService>, IFloodlightService>
414 getServiceImpls() {
415 Map<Class<? extends IFloodlightService>,
416 IFloodlightService> m =
417 new HashMap<Class<? extends IFloodlightService>,
418 IFloodlightService>();
419 m.put(IFlowService.class, this);
420 return m;
421 }
422
423 @Override
424 public Collection<Class<? extends IFloodlightService>>
425 getModuleDependencies() {
426 Collection<Class<? extends IFloodlightService>> l =
427 new ArrayList<Class<? extends IFloodlightService>>();
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800428 l.add(IFloodlightProviderService.class);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800429 l.add(IRestApiService.class);
430 return l;
431 }
432
433 @Override
434 public void init(FloodlightModuleContext context)
435 throws FloodlightModuleException {
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700436 this.context = context;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800437 floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800438 restApi = context.getServiceImpl(IRestApiService.class);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800439 messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY,
440 EnumSet.of(OFType.FLOW_MOD),
441 OFMESSAGE_DAMPER_TIMEOUT);
442 // TODO: An ugly hack!
443 String conf = "/tmp/cassandra.titan";
444 this.init(conf);
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800445 }
446
447 @Override
448 public void startUp(FloodlightModuleContext context) {
449 restApi.addRestletRoutable(new FlowWebRoutable());
450 }
451
452 /**
453 * Add a flow.
454 *
455 * Internally, ONOS will automatically register the installer for
456 * receiving Flow Path Notifications for that path.
457 *
458 * @param flowPath the Flow Path to install.
459 * @param flowId the return-by-reference Flow ID as assigned internally.
460 * @return true on success, otherwise false.
461 */
462 @Override
463 public boolean addFlow(FlowPath flowPath, FlowId flowId) {
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700464 if (flowPath.flowId().value() == measurementFlowId) {
465 modifiedMeasurementFlowTime = System.nanoTime();
466 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800467
468 //
469 // Assign the FlowEntry IDs
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700470 // Right now every new flow entry gets a new flow entry ID
471 // TODO: This needs to be redesigned!
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800472 //
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800473 for (FlowEntry flowEntry : flowPath.dataPath().flowEntries()) {
Pavlin Radoslavov01391c92013-03-14 17:13:21 -0700474 long id = nextFlowEntryId++;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800475 flowEntry.setFlowEntryId(new FlowEntryId(id));
476 }
477
478 IFlowPath flowObj = null;
479 try {
480 if ((flowObj = conn.utils().searchFlowPath(conn, flowPath.flowId()))
481 != null) {
482 log.debug("Adding FlowPath with FlowId {}: found existing FlowPath",
483 flowPath.flowId().toString());
484 } else {
485 flowObj = conn.utils().newFlowPath(conn);
486 log.debug("Adding FlowPath with FlowId {}: creating new FlowPath",
487 flowPath.flowId().toString());
488 }
489 } catch (Exception e) {
490 // TODO: handle exceptions
491 conn.endTx(Transaction.ROLLBACK);
492 log.error(":addFlow FlowId:{} failed",
493 flowPath.flowId().toString());
494 }
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700495 if (flowObj == null) {
496 conn.endTx(Transaction.COMMIT);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800497 return false;
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700498 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800499
500 //
501 // Set the Flow key:
502 // - flowId
503 //
504 flowObj.setFlowId(flowPath.flowId().toString());
505 flowObj.setType("flow");
506
507 //
508 // Set the Flow attributes:
509 // - flowPath.installerId()
510 // - flowPath.dataPath().srcPort()
511 // - flowPath.dataPath().dstPort()
512 //
513 flowObj.setInstallerId(flowPath.installerId().toString());
514 flowObj.setSrcSwitch(flowPath.dataPath().srcPort().dpid().toString());
515 flowObj.setSrcPort(flowPath.dataPath().srcPort().port().value());
516 flowObj.setDstSwitch(flowPath.dataPath().dstPort().dpid().toString());
517 flowObj.setDstPort(flowPath.dataPath().dstPort().port().value());
518
519 // Flow edges:
520 // HeadFE
521
522
523 //
524 // Flow Entries:
525 // flowPath.dataPath().flowEntries()
526 //
527 for (FlowEntry flowEntry : flowPath.dataPath().flowEntries()) {
528 IFlowEntry flowEntryObj = null;
529 boolean found = false;
530 try {
531 if ((flowEntryObj = conn.utils().searchFlowEntry(conn, flowEntry.flowEntryId())) != null) {
532 log.debug("Adding FlowEntry with FlowEntryId {}: found existing FlowEntry",
533 flowEntry.flowEntryId().toString());
534 found = true;
535 } else {
536 flowEntryObj = conn.utils().newFlowEntry(conn);
537 log.debug("Adding FlowEntry with FlowEntryId {}: creating new FlowEntry",
538 flowEntry.flowEntryId().toString());
539 }
540 } catch (Exception e) {
541 // TODO: handle exceptions
542 conn.endTx(Transaction.ROLLBACK);
543 log.error(":addFlow FlowEntryId:{} failed",
544 flowEntry.flowEntryId().toString());
545 }
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700546 if (flowEntryObj == null) {
547 conn.endTx(Transaction.COMMIT);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800548 return false;
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700549 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800550
551 //
552 // Set the Flow Entry key:
553 // - flowEntry.flowEntryId()
554 //
555 flowEntryObj.setFlowEntryId(flowEntry.flowEntryId().toString());
556 flowEntryObj.setType("flow_entry");
557
558 //
559 // Set the Flow Entry attributes:
560 // - flowEntry.flowEntryMatch()
561 // - flowEntry.flowEntryActions()
562 // - flowEntry.dpid()
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800563 // - flowEntry.flowEntryUserState()
564 // - flowEntry.flowEntrySwitchState()
565 // - flowEntry.flowEntryErrorState()
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -0700566 // - flowEntry.matchInPort()
567 // - flowEntry.matchEthernetFrameType()
568 // - flowEntry.matchSrcIPv4Net()
569 // - flowEntry.matchDstIPv4Net()
570 // - flowEntry.matchSrcMac()
571 // - flowEntry.matchDstMac()
572 // - flowEntry.actionOutput()
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800573 //
574 flowEntryObj.setSwitchDpid(flowEntry.dpid().toString());
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -0700575 if (flowEntry.flowEntryMatch().matchInPort())
576 flowEntryObj.setMatchInPort(flowEntry.flowEntryMatch().inPort().value());
577 if (flowEntry.flowEntryMatch().matchEthernetFrameType())
578 flowEntryObj.setMatchEthernetFrameType(flowEntry.flowEntryMatch().ethernetFrameType());
579 if (flowEntry.flowEntryMatch().matchSrcIPv4Net())
580 flowEntryObj.setMatchSrcIPv4Net(flowEntry.flowEntryMatch().srcIPv4Net().toString());
581 if (flowEntry.flowEntryMatch().matchDstIPv4Net())
582 flowEntryObj.setMatchDstIPv4Net(flowEntry.flowEntryMatch().dstIPv4Net().toString());
583 if (flowEntry.flowEntryMatch().matchSrcMac())
584 flowEntryObj.setMatchSrcMac(flowEntry.flowEntryMatch().srcMac().toString());
585 if (flowEntry.flowEntryMatch().matchDstMac())
586 flowEntryObj.setMatchDstMac(flowEntry.flowEntryMatch().dstMac().toString());
587
588 for (FlowEntryAction fa : flowEntry.flowEntryActions()) {
589 if (fa.actionOutput() != null)
590 flowEntryObj.setActionOutput(fa.actionOutput().port().value());
591 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800592 // TODO: Hacks with hard-coded state names!
593 if (found)
594 flowEntryObj.setUserState("FE_USER_MODIFY");
595 else
596 flowEntryObj.setUserState("FE_USER_ADD");
597 flowEntryObj.setSwitchState("FE_SWITCH_NOT_UPDATED");
598 //
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800599 // TODO: Take care of the FlowEntryMatch, FlowEntryAction set,
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800600 // and FlowEntryErrorState.
601 //
602
603 // Flow Entries edges:
604 // Flow
605 // NextFE
606 // InPort
607 // OutPort
608 // Switch
609 if (! found)
610 flowObj.addFlowEntry(flowEntryObj);
611 }
612 conn.endTx(Transaction.COMMIT);
613
614 //
615 // TODO: We need a proper Flow ID allocation mechanism.
616 //
617 flowId.setValue(flowPath.flowId().value());
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700618
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800619 return true;
620 }
621
622 /**
623 * Delete a previously added flow.
624 *
625 * @param flowId the Flow ID of the flow to delete.
626 * @return true on success, otherwise false.
627 */
628 @Override
629 public boolean deleteFlow(FlowId flowId) {
Pavlin Radoslavov571cff92013-03-20 02:01:32 -0700630 if (flowId.value() == measurementFlowId) {
631 modifiedMeasurementFlowTime = System.nanoTime();
632 }
633
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800634 IFlowPath flowObj = null;
635 //
636 // We just mark the entries for deletion,
637 // and let the switches remove each individual entry after
638 // it has been removed from the switches.
639 //
640 try {
641 if ((flowObj = conn.utils().searchFlowPath(conn, flowId))
642 != null) {
643 log.debug("Deleting FlowPath with FlowId {}: found existing FlowPath",
644 flowId.toString());
645 } else {
646 log.debug("Deleting FlowPath with FlowId {}: FlowPath not found",
647 flowId.toString());
648 }
649 } catch (Exception e) {
650 // TODO: handle exceptions
651 conn.endTx(Transaction.ROLLBACK);
652 log.error(":deleteFlow FlowId:{} failed", flowId.toString());
653 }
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700654 if (flowObj == null) {
655 conn.endTx(Transaction.COMMIT);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800656 return true; // OK: No such flow
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700657 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800658
659 //
660 // Find and mark for deletion all Flow Entries
661 //
662 Iterable<IFlowEntry> flowEntries = flowObj.getFlowEntries();
663 boolean empty = true; // TODO: an ugly hack
664 for (IFlowEntry flowEntryObj : flowEntries) {
665 empty = false;
666 // flowObj.removeFlowEntry(flowEntryObj);
667 // conn.utils().removeFlowEntry(conn, flowEntryObj);
668 flowEntryObj.setUserState("FE_USER_DELETE");
669 flowEntryObj.setSwitchState("FE_SWITCH_NOT_UPDATED");
670 }
671 // Remove from the database empty flows
672 if (empty)
673 conn.utils().removeFlowPath(conn, flowObj);
674 conn.endTx(Transaction.COMMIT);
675
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800676 return true;
677 }
678
679 /**
Pavlin Radoslavov916832f2013-03-14 17:48:41 -0700680 * Clear the state for a previously added flow.
681 *
682 * @param flowId the Flow ID of the flow to clear.
683 * @return true on success, otherwise false.
684 */
685 @Override
686 public boolean clearFlow(FlowId flowId) {
687 IFlowPath flowObj = null;
688 try {
689 if ((flowObj = conn.utils().searchFlowPath(conn, flowId))
690 != null) {
691 log.debug("Clearing FlowPath with FlowId {}: found existing FlowPath",
692 flowId.toString());
693 } else {
694 log.debug("Clearing FlowPath with FlowId {}: FlowPath not found",
695 flowId.toString());
696 }
697 } catch (Exception e) {
698 // TODO: handle exceptions
699 conn.endTx(Transaction.ROLLBACK);
700 log.error(":clearFlow FlowId:{} failed", flowId.toString());
701 }
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700702 if (flowObj == null) {
703 conn.endTx(Transaction.COMMIT);
Pavlin Radoslavov916832f2013-03-14 17:48:41 -0700704 return true; // OK: No such flow
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700705 }
Pavlin Radoslavov916832f2013-03-14 17:48:41 -0700706
707 //
708 // Remove all Flow Entries
709 //
710 Iterable<IFlowEntry> flowEntries = flowObj.getFlowEntries();
711 for (IFlowEntry flowEntryObj : flowEntries) {
712 flowObj.removeFlowEntry(flowEntryObj);
713 conn.utils().removeFlowEntry(conn, flowEntryObj);
714 }
715 // Remove the Flow itself
716 conn.utils().removeFlowPath(conn, flowObj);
717 conn.endTx(Transaction.COMMIT);
718
719 return true;
720 }
721
722 /**
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800723 * Get a previously added flow.
724 *
725 * @param flowId the Flow ID of the flow to get.
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800726 * @return the Flow Path if found, otherwise null.
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800727 */
728 @Override
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800729 public FlowPath getFlow(FlowId flowId) {
730 IFlowPath flowObj = null;
731 try {
732 if ((flowObj = conn.utils().searchFlowPath(conn, flowId))
733 != null) {
734 log.debug("Get FlowPath with FlowId {}: found existing FlowPath",
735 flowId.toString());
736 } else {
737 log.debug("Get FlowPath with FlowId {}: FlowPath not found",
738 flowId.toString());
739 }
740 } catch (Exception e) {
741 // TODO: handle exceptions
742 conn.endTx(Transaction.ROLLBACK);
743 log.error(":getFlow FlowId:{} failed", flowId.toString());
744 }
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700745 if (flowObj == null) {
746 conn.endTx(Transaction.COMMIT);
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800747 return null; // Flow not found
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700748 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800749
750 //
751 // Extract the Flow state
752 //
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800753 FlowPath flowPath = extractFlowPath(flowObj);
754 conn.endTx(Transaction.COMMIT);
755
756 return flowPath;
757 }
758
759 /**
760 * Get all previously added flows by a specific installer for a given
761 * data path endpoints.
762 *
763 * @param installerId the Caller ID of the installer of the flow to get.
764 * @param dataPathEndpoints the data path endpoints of the flow to get.
765 * @return the Flow Paths if found, otherwise null.
766 */
767 @Override
768 public ArrayList<FlowPath> getAllFlows(CallerId installerId,
769 DataPathEndpoints dataPathEndpoints) {
770 //
771 // TODO: The implementation below is not optimal:
772 // We fetch all flows, and then return only the subset that match
773 // the query conditions.
774 // We should use the appropriate Titan/Gremlin query to filter-out
775 // the flows as appropriate.
776 //
777 ArrayList<FlowPath> allFlows = getAllFlows();
778
779 if (allFlows == null) {
780 log.debug("Get FlowPaths for installerId{} and dataPathEndpoints{}: no FlowPaths found", installerId, dataPathEndpoints);
781 return null;
782 }
783
784 ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
785 for (FlowPath flow : allFlows) {
786 //
787 // TODO: String-based comparison is sub-optimal.
788 // We are using it for now to save us the extra work of
Pavlin Radoslavovc4e76a62013-03-06 10:52:41 -0800789 // implementing the "equals()" and "hashCode()" methods.
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800790 //
791 if (! flow.installerId().toString().equals(installerId.toString()))
792 continue;
793 if (! flow.dataPath().srcPort().toString().equals(dataPathEndpoints.srcPort().toString())) {
794 continue;
795 }
796 if (! flow.dataPath().dstPort().toString().equals(dataPathEndpoints.dstPort().toString())) {
797 continue;
798 }
799 flowPaths.add(flow);
800 }
801
802 if (flowPaths.isEmpty()) {
803 log.debug("Get FlowPaths for installerId{} and dataPathEndpoints{}: no FlowPaths found", installerId, dataPathEndpoints);
804 flowPaths = null;
805 } else {
806 log.debug("Get FlowPaths for installerId{} and dataPathEndpoints{}: FlowPaths are found", installerId, dataPathEndpoints);
807 }
808
809 return flowPaths;
810 }
811
812 /**
813 * Get all installed flows by all installers for given data path endpoints.
814 *
815 * @param dataPathEndpoints the data path endpoints of the flows to get.
816 * @return the Flow Paths if found, otherwise null.
817 */
818 @Override
819 public ArrayList<FlowPath> getAllFlows(DataPathEndpoints dataPathEndpoints) {
820 //
821 // TODO: The implementation below is not optimal:
822 // We fetch all flows, and then return only the subset that match
823 // the query conditions.
824 // We should use the appropriate Titan/Gremlin query to filter-out
825 // the flows as appropriate.
826 //
827 ArrayList<FlowPath> allFlows = getAllFlows();
828
829 if (allFlows == null) {
830 log.debug("Get FlowPaths for dataPathEndpoints{}: no FlowPaths found", dataPathEndpoints);
831 return null;
832 }
833
834 ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
835 for (FlowPath flow : allFlows) {
836 //
837 // TODO: String-based comparison is sub-optimal.
838 // We are using it for now to save us the extra work of
Pavlin Radoslavovc4e76a62013-03-06 10:52:41 -0800839 // implementing the "equals()" and "hashCode()" methods.
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800840 //
841 if (! flow.dataPath().srcPort().toString().equals(dataPathEndpoints.srcPort().toString())) {
842 continue;
843 }
844 if (! flow.dataPath().dstPort().toString().equals(dataPathEndpoints.dstPort().toString())) {
845 continue;
846 }
847 flowPaths.add(flow);
848 }
849
850 if (flowPaths.isEmpty()) {
851 log.debug("Get FlowPaths for dataPathEndpoints{}: no FlowPaths found", dataPathEndpoints);
852 flowPaths = null;
853 } else {
854 log.debug("Get FlowPaths for dataPathEndpoints{}: FlowPaths are found", dataPathEndpoints);
855 }
856
857 return flowPaths;
858 }
859
860 /**
861 * Get all installed flows by all installers.
862 *
863 * @return the Flow Paths if found, otherwise null.
864 */
865 @Override
866 public ArrayList<FlowPath> getAllFlows() {
867 Iterable<IFlowPath> flowPathsObj = null;
868
869 try {
870 if ((flowPathsObj = conn.utils().getAllFlowPaths(conn)) != null) {
871 log.debug("Get all FlowPaths: found FlowPaths");
872 } else {
873 log.debug("Get all FlowPaths: no FlowPaths found");
874 }
875 } catch (Exception e) {
876 // TODO: handle exceptions
877 conn.endTx(Transaction.ROLLBACK);
878 log.error(":getAllFlowPaths failed");
879 }
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700880 if ((flowPathsObj == null) || (flowPathsObj.iterator().hasNext() == false)) {
881 conn.endTx(Transaction.COMMIT);
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800882 return null; // No Flows found
Pavlin Radoslavov89c8f432013-03-15 18:50:46 -0700883 }
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800884
885 ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
886 for (IFlowPath flowObj : flowPathsObj) {
887 //
888 // Extract the Flow state
889 //
890 FlowPath flowPath = extractFlowPath(flowObj);
891 flowPaths.add(flowPath);
892 }
893
894 conn.endTx(Transaction.COMMIT);
895
896 return flowPaths;
897 }
898
899 /**
900 * Extract Flow Path State from a Titan Database Object @ref IFlowPath.
901 *
902 * @param flowObj the object to extract the Flow Path State from.
903 * @return the extracted Flow Path State.
904 */
905 private FlowPath extractFlowPath(IFlowPath flowObj) {
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800906 FlowPath flowPath = new FlowPath();
Pavlin Radoslavov706df052013-03-06 10:49:07 -0800907
908 //
909 // Extract the Flow state
910 //
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800911 flowPath.setFlowId(new FlowId(flowObj.getFlowId()));
912 flowPath.setInstallerId(new CallerId(flowObj.getInstallerId()));
913 flowPath.dataPath().srcPort().setDpid(new Dpid(flowObj.getSrcSwitch()));
914 flowPath.dataPath().srcPort().setPort(new Port(flowObj.getSrcPort()));
915 flowPath.dataPath().dstPort().setDpid(new Dpid(flowObj.getDstSwitch()));
916 flowPath.dataPath().dstPort().setPort(new Port(flowObj.getDstPort()));
917
918 //
919 // Extract all Flow Entries
920 //
921 Iterable<IFlowEntry> flowEntries = flowObj.getFlowEntries();
922 for (IFlowEntry flowEntryObj : flowEntries) {
923 FlowEntry flowEntry = new FlowEntry();
924 flowEntry.setFlowEntryId(new FlowEntryId(flowEntryObj.getFlowEntryId()));
925 flowEntry.setDpid(new Dpid(flowEntryObj.getSwitchDpid()));
Pavlin Radoslavove2f0de82013-03-12 01:39:30 -0700926
927 //
928 // Extract the match conditions
929 //
930 FlowEntryMatch match = new FlowEntryMatch();
931 Short matchInPort = flowEntryObj.getMatchInPort();
932 if (matchInPort != null)
933 match.enableInPort(new Port(matchInPort));
934 Short matchEthernetFrameType = flowEntryObj.getMatchEthernetFrameType();
935 if (matchEthernetFrameType != null)
936 match.enableEthernetFrameType(matchEthernetFrameType);
937 String matchSrcIPv4Net = flowEntryObj.getMatchSrcIPv4Net();
938 if (matchSrcIPv4Net != null)
939 match.enableSrcIPv4Net(new IPv4Net(matchSrcIPv4Net));
940 String matchDstIPv4Net = flowEntryObj.getMatchDstIPv4Net();
941 if (matchDstIPv4Net != null)
942 match.enableDstIPv4Net(new IPv4Net(matchDstIPv4Net));
943 String matchSrcMac = flowEntryObj.getMatchSrcMac();
944 if (matchSrcMac != null)
945 match.enableSrcMac(MACAddress.valueOf(matchSrcMac));
946 String matchDstMac = flowEntryObj.getMatchDstMac();
947 if (matchDstMac != null)
948 match.enableDstMac(MACAddress.valueOf(matchDstMac));
949 flowEntry.setFlowEntryMatch(match);
950
951 //
952 // Extract the actions
953 //
954 ArrayList<FlowEntryAction> actions = new ArrayList<FlowEntryAction>();
955 Short actionOutputPort = flowEntryObj.getActionOutput();
956 if (actionOutputPort != null) {
957 FlowEntryAction action = new FlowEntryAction();
958 action.setActionOutput(new Port(actionOutputPort));
959 actions.add(action);
960 }
961 flowEntry.setFlowEntryActions(actions);
962
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800963 String userState = flowEntryObj.getUserState();
964 flowEntry.setFlowEntryUserState(FlowEntryUserState.valueOf(userState));
965 String switchState = flowEntryObj.getSwitchState();
966 flowEntry.setFlowEntrySwitchState(FlowEntrySwitchState.valueOf(switchState));
967 //
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800968 // TODO: Take care of the FlowEntryMatch, FlowEntryAction set,
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800969 // and FlowEntryErrorState.
970 //
971 flowPath.dataPath().flowEntries().add(flowEntry);
972 }
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -0800973
974 return flowPath;
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800975 }
Pavlin Radoslavov9e5344c2013-02-18 09:58:30 -0800976}