blob: 6cb5b82ac92da610c43ece0dc140411838b2ea31 [file] [log] [blame]
Saurav Dase3274c82015-05-24 17:21:56 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.driver.pipeline;
17
Saurav Dase3274c82015-05-24 17:21:56 -070018import org.onlab.osgi.ServiceDirectory;
19import org.onlab.packet.Ethernet;
Saurav Das337c7a42015-06-02 15:12:06 -070020import org.onlab.packet.MacAddress;
21import org.onlab.packet.VlanId;
Saurav Dase3274c82015-05-24 17:21:56 -070022import org.onlab.util.KryoNamespace;
23import org.onosproject.core.ApplicationId;
24import org.onosproject.core.CoreService;
25import org.onosproject.net.DeviceId;
Saurav Das337c7a42015-06-02 15:12:06 -070026import org.onosproject.net.PortNumber;
Saurav Dase3274c82015-05-24 17:21:56 -070027import org.onosproject.net.behaviour.NextGroup;
28import org.onosproject.net.behaviour.Pipeliner;
29import org.onosproject.net.behaviour.PipelinerContext;
30import org.onosproject.net.driver.AbstractHandlerBehaviour;
31import org.onosproject.net.flow.DefaultFlowRule;
32import org.onosproject.net.flow.DefaultTrafficSelector;
33import org.onosproject.net.flow.DefaultTrafficTreatment;
34import org.onosproject.net.flow.FlowRule;
35import org.onosproject.net.flow.FlowRuleOperations;
36import org.onosproject.net.flow.FlowRuleOperationsContext;
37import org.onosproject.net.flow.FlowRuleService;
38import org.onosproject.net.flow.TrafficSelector;
39import org.onosproject.net.flow.TrafficTreatment;
40import org.onosproject.net.flow.criteria.Criteria;
41import org.onosproject.net.flow.criteria.Criterion;
42import org.onosproject.net.flow.criteria.EthCriterion;
43import org.onosproject.net.flow.criteria.EthTypeCriterion;
44import org.onosproject.net.flow.criteria.IPCriterion;
Saurav Dase3274c82015-05-24 17:21:56 -070045import org.onosproject.net.flow.criteria.PortCriterion;
46import org.onosproject.net.flow.criteria.VlanIdCriterion;
Saurav Das337c7a42015-06-02 15:12:06 -070047import org.onosproject.net.flow.instructions.Instruction;
48import org.onosproject.net.flow.instructions.L2ModificationInstruction;
Saurav Dase3274c82015-05-24 17:21:56 -070049import org.onosproject.net.flowobjective.FilteringObjective;
50import org.onosproject.net.flowobjective.FlowObjectiveStore;
51import org.onosproject.net.flowobjective.ForwardingObjective;
52import org.onosproject.net.flowobjective.NextObjective;
53import org.onosproject.net.flowobjective.Objective;
54import org.onosproject.net.flowobjective.ObjectiveError;
Saurav Das337c7a42015-06-02 15:12:06 -070055import org.onosproject.store.serializers.KryoNamespaces;
Saurav Dase3274c82015-05-24 17:21:56 -070056import org.slf4j.Logger;
57
Saurav Das337c7a42015-06-02 15:12:06 -070058import java.util.ArrayList;
Saurav Dase3274c82015-05-24 17:21:56 -070059import java.util.Collection;
60import java.util.Collections;
Saurav Das337c7a42015-06-02 15:12:06 -070061import java.util.List;
Sho SHIMIZU45906042016-01-13 23:05:54 -080062import java.util.Objects;
Saurav Das337c7a42015-06-02 15:12:06 -070063import java.util.concurrent.ConcurrentHashMap;
Saurav Dase3274c82015-05-24 17:21:56 -070064
Saurav Dase3274c82015-05-24 17:21:56 -070065import static org.slf4j.LoggerFactory.getLogger;
66
67/**
68 * Pica pipeline handler.
69 */
70public class PicaPipeline extends AbstractHandlerBehaviour implements Pipeliner {
71
Saurav Das337c7a42015-06-02 15:12:06 -070072 protected static final int IP_UNICAST_TABLE = 252;
73 protected static final int ACL_TABLE = 0;
Saurav Dase3274c82015-05-24 17:21:56 -070074
Saurav Das337c7a42015-06-02 15:12:06 -070075 //private static final int CONTROLLER_PRIORITY = 255;
Saurav Dase3274c82015-05-24 17:21:56 -070076 private static final int DROP_PRIORITY = 0;
77 private static final int HIGHEST_PRIORITY = 0xffff;
78
79 private final Logger log = getLogger(getClass());
80
81 private ServiceDirectory serviceDirectory;
82 private FlowRuleService flowRuleService;
83 private CoreService coreService;
Saurav Dase3274c82015-05-24 17:21:56 -070084 private FlowObjectiveStore flowObjectiveStore;
85 private DeviceId deviceId;
86 private ApplicationId appId;
Saurav Das337c7a42015-06-02 15:12:06 -070087 private Collection<Filter> filters;
88 private Collection<ForwardingObjective> pendingVersatiles;
Saurav Dase3274c82015-05-24 17:21:56 -070089
90 private KryoNamespace appKryo = new KryoNamespace.Builder()
Saurav Das337c7a42015-06-02 15:12:06 -070091 .register(KryoNamespaces.API)
Saurav Dase3274c82015-05-24 17:21:56 -070092 .register(PicaGroup.class)
93 .register(byte[].class)
94 .build();
95
Saurav Dase3274c82015-05-24 17:21:56 -070096 @Override
97 public void init(DeviceId deviceId, PipelinerContext context) {
98 this.serviceDirectory = context.directory();
99 this.deviceId = deviceId;
100
Saurav Dase3274c82015-05-24 17:21:56 -0700101 coreService = serviceDirectory.get(CoreService.class);
102 flowRuleService = serviceDirectory.get(FlowRuleService.class);
Saurav Dase3274c82015-05-24 17:21:56 -0700103 flowObjectiveStore = context.store();
Saurav Das337c7a42015-06-02 15:12:06 -0700104 filters = Collections.newSetFromMap(new ConcurrentHashMap<Filter, Boolean>());
105 pendingVersatiles = Collections.newSetFromMap(
106 new ConcurrentHashMap<ForwardingObjective, Boolean>());
Saurav Dase3274c82015-05-24 17:21:56 -0700107 appId = coreService.registerApplication(
108 "org.onosproject.driver.OVSPicaPipeline");
109
110 initializePipeline();
111 }
112
113 @Override
114 public void filter(FilteringObjective filteringObjective) {
115 if (filteringObjective.type() == FilteringObjective.Type.PERMIT) {
116 processFilter(filteringObjective,
117 filteringObjective.op() == Objective.Operation.ADD,
118 filteringObjective.appId());
119 } else {
120 fail(filteringObjective, ObjectiveError.UNSUPPORTED);
121 }
122 }
123
124 @Override
125 public void forward(ForwardingObjective fwd) {
126 Collection<FlowRule> rules;
127 FlowRuleOperations.Builder flowBuilder = FlowRuleOperations.builder();
128
129 rules = processForward(fwd);
130 switch (fwd.op()) {
131 case ADD:
132 rules.stream()
Sho SHIMIZU45906042016-01-13 23:05:54 -0800133 .filter(Objects::nonNull)
Saurav Dase3274c82015-05-24 17:21:56 -0700134 .forEach(flowBuilder::add);
135 break;
136 case REMOVE:
137 rules.stream()
Sho SHIMIZU45906042016-01-13 23:05:54 -0800138 .filter(Objects::nonNull)
Saurav Dase3274c82015-05-24 17:21:56 -0700139 .forEach(flowBuilder::remove);
140 break;
141 default:
142 fail(fwd, ObjectiveError.UNKNOWN);
143 log.warn("Unknown forwarding type {}", fwd.op());
144 }
145
146
147 flowRuleService.apply(flowBuilder.build(new FlowRuleOperationsContext() {
148 @Override
149 public void onSuccess(FlowRuleOperations ops) {
150 pass(fwd);
151 }
152
153 @Override
154 public void onError(FlowRuleOperations ops) {
155 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
156 }
157 }));
158
159 }
160
161 @Override
162 public void next(NextObjective nextObjective) {
163 switch (nextObjective.type()) {
164 case SIMPLE:
165 Collection<TrafficTreatment> treatments = nextObjective.next();
Saurav Das337c7a42015-06-02 15:12:06 -0700166 if (treatments.size() != 1) {
167 log.error("Next Objectives of type Simple should only have a "
168 + "single Traffic Treatment. Next Objective Id:{}", nextObjective.id());
169 fail(nextObjective, ObjectiveError.BADPARAMS);
170 return;
Saurav Dase3274c82015-05-24 17:21:56 -0700171 }
Saurav Das337c7a42015-06-02 15:12:06 -0700172 TrafficTreatment treatment = treatments.iterator().next();
173 TrafficTreatment.Builder filteredTreatment = DefaultTrafficTreatment.builder();
174 VlanId modVlanId;
175 for (Instruction ins : treatment.allInstructions()) {
176 if (ins.type() == Instruction.Type.L2MODIFICATION) {
177 L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
178 switch (l2ins.subtype()) {
179 case ETH_DST:
180 filteredTreatment.setEthDst(
181 ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac());
182 break;
183 case ETH_SRC:
184 filteredTreatment.setEthSrc(
185 ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac());
186 break;
187 case VLAN_ID:
188 modVlanId = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
189 filteredTreatment.setVlanId(modVlanId);
190 break;
191 default:
192 break;
193 }
194 } else if (ins.type() == Instruction.Type.OUTPUT) {
195 //long portNum = ((Instructions.OutputInstruction) ins).port().toLong();
196 filteredTreatment.add(ins);
197 } else {
198 // Ignore the vlan_pcp action since it's does matter much.
199 log.warn("Driver does not handle this type of TrafficTreatment"
200 + " instruction in nextObjectives: {}", ins.type());
201 }
202 }
203 // store for future use
204 flowObjectiveStore.putNextGroup(nextObjective.id(),
205 new PicaGroup(filteredTreatment.build()));
Saurav Dase3274c82015-05-24 17:21:56 -0700206 break;
207 case HASHED:
208 case BROADCAST:
209 case FAILOVER:
210 fail(nextObjective, ObjectiveError.UNSUPPORTED);
211 log.warn("Unsupported next objective type {}", nextObjective.type());
212 break;
213 default:
214 fail(nextObjective, ObjectiveError.UNKNOWN);
215 log.warn("Unknown next objective type {}", nextObjective.type());
216 }
217
218 }
219
220 private Collection<FlowRule> processForward(ForwardingObjective fwd) {
221 switch (fwd.flag()) {
222 case SPECIFIC:
223 return processSpecific(fwd);
224 case VERSATILE:
225 return processVersatile(fwd);
226 default:
227 fail(fwd, ObjectiveError.UNKNOWN);
228 log.warn("Unknown forwarding flag {}", fwd.flag());
229 }
230 return Collections.emptySet();
231 }
232
233 private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
234 log.debug("Processing versatile forwarding objective");
235 TrafficSelector selector = fwd.selector();
Saurav Das598a02f2015-08-31 18:19:30 -0700236 TrafficTreatment treatment = fwd.treatment();
237 Collection<FlowRule> flowrules = new ArrayList<FlowRule>();
238
239 // first add this rule for basic single-table operation
240 // or non-ARP related multi-table operation
241 FlowRule rule = DefaultFlowRule.builder()
242 .forDevice(deviceId)
243 .withSelector(selector)
244 .withTreatment(treatment)
245 .withPriority(fwd.priority())
246 .fromApp(fwd.appId())
247 .makePermanent()
248 .forTable(ACL_TABLE).build();
249 flowrules.add(rule);
Saurav Dase3274c82015-05-24 17:21:56 -0700250
251 EthTypeCriterion ethType =
252 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
253 if (ethType == null) {
Saurav Das598a02f2015-08-31 18:19:30 -0700254 log.warn("No ethType in versatile forwarding obj. Not processing further.");
255 return flowrules;
Saurav Dase3274c82015-05-24 17:21:56 -0700256 }
Saurav Das337c7a42015-06-02 15:12:06 -0700257
Saurav Das598a02f2015-08-31 18:19:30 -0700258 // now deal with possible mix of ARP with filtering objectives
259 // in multi-table scenarios
alshabibcaf1ca22015-06-25 15:18:16 -0700260 if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
Saurav Das337c7a42015-06-02 15:12:06 -0700261 if (filters.isEmpty()) {
262 pendingVersatiles.add(fwd);
Saurav Das598a02f2015-08-31 18:19:30 -0700263 return flowrules;
Saurav Das337c7a42015-06-02 15:12:06 -0700264 }
Saurav Das337c7a42015-06-02 15:12:06 -0700265 for (Filter filter : filters) {
266 flowrules.addAll(processVersatilesWithFilters(filter, fwd));
267 }
Saurav Dase3274c82015-05-24 17:21:56 -0700268 }
Saurav Das598a02f2015-08-31 18:19:30 -0700269 return flowrules;
Saurav Dase3274c82015-05-24 17:21:56 -0700270 }
271
Saurav Das337c7a42015-06-02 15:12:06 -0700272 private Collection<FlowRule> processVersatilesWithFilters(
273 Filter filt, ForwardingObjective fwd) {
274 Collection<FlowRule> flows = new ArrayList<FlowRule>();
275
276 // rule for ARP replies
277 log.debug("adding ARP rule in ACL table");
278 TrafficSelector.Builder sel = DefaultTrafficSelector.builder();
279 TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
280 sel.matchInPort(filt.port());
281 sel.matchVlanId(filt.vlanId());
282 sel.matchEthDst(filt.mac());
283 sel.matchEthType(Ethernet.TYPE_ARP);
284 treat.setOutput(PortNumber.CONTROLLER);
285 FlowRule rule = DefaultFlowRule.builder()
286 .forDevice(deviceId)
287 .withSelector(sel.build())
288 .withTreatment(treat.build())
289 .withPriority(HIGHEST_PRIORITY)
290 .fromApp(appId)
291 .makePermanent()
292 .forTable(ACL_TABLE).build();
293 flows.add(rule);
294
295 // rule for ARP Broadcast
296 sel = DefaultTrafficSelector.builder();
297 treat = DefaultTrafficTreatment.builder();
298 sel.matchInPort(filt.port());
299 sel.matchVlanId(filt.vlanId());
300 sel.matchEthDst(MacAddress.BROADCAST);
301 sel.matchEthType(Ethernet.TYPE_ARP);
302 treat.setOutput(PortNumber.CONTROLLER);
303 rule = DefaultFlowRule.builder()
304 .forDevice(deviceId)
305 .withSelector(sel.build())
306 .withTreatment(treat.build())
307 .withPriority(HIGHEST_PRIORITY)
308 .fromApp(appId)
309 .makePermanent()
310 .forTable(ACL_TABLE).build();
311 flows.add(rule);
312
313 return flows;
314 }
315
316
Saurav Dase3274c82015-05-24 17:21:56 -0700317 private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
318 log.debug("Processing specific forwarding objective");
319 TrafficSelector selector = fwd.selector();
320 EthTypeCriterion ethType =
321 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
alshabibcaf1ca22015-06-25 15:18:16 -0700322 if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
Saurav Dase3274c82015-05-24 17:21:56 -0700323 fail(fwd, ObjectiveError.UNSUPPORTED);
324 return Collections.emptySet();
325 }
326
Saurav Das337c7a42015-06-02 15:12:06 -0700327 List<FlowRule> ipflows = new ArrayList<FlowRule>();
328 for (Filter f: filters) {
329 TrafficSelector filteredSelector =
330 DefaultTrafficSelector.builder()
331 .matchEthType(Ethernet.TYPE_IPV4)
332 .matchIPDst(
Saurav Dase3274c82015-05-24 17:21:56 -0700333 ((IPCriterion)
334 selector.getCriterion(Criterion.Type.IPV4_DST)).ip())
Saurav Das337c7a42015-06-02 15:12:06 -0700335 .matchEthDst(f.mac())
336 .matchVlanId(f.vlanId())
337 .build();
338 TrafficTreatment tt = null;
339 if (fwd.nextId() != null) {
340 NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
341 if (next == null) {
342 log.error("next-id {} does not exist in store", fwd.nextId());
343 return Collections.emptySet();
344 }
345 tt = appKryo.deserialize(next.data());
346 if (tt == null) {
347 log.error("Error in deserializing next-id {}", fwd.nextId());
348 return Collections.emptySet();
349 }
Saurav Dase3274c82015-05-24 17:21:56 -0700350 }
Saurav Das337c7a42015-06-02 15:12:06 -0700351
352 FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
353 .fromApp(fwd.appId())
354 .withPriority(fwd.priority())
355 .forDevice(deviceId)
356 .withSelector(filteredSelector)
357 .withTreatment(tt);
358 if (fwd.permanent()) {
359 ruleBuilder.makePermanent();
360 } else {
361 ruleBuilder.makeTemporary(fwd.timeout());
362 }
363 ruleBuilder.forTable(IP_UNICAST_TABLE);
364 ipflows.add(ruleBuilder.build());
Saurav Dase3274c82015-05-24 17:21:56 -0700365 }
366
Saurav Das337c7a42015-06-02 15:12:06 -0700367 return ipflows;
Saurav Dase3274c82015-05-24 17:21:56 -0700368 }
369
370 private void processFilter(FilteringObjective filt, boolean install,
371 ApplicationId applicationId) {
372 // This driver only processes filtering criteria defined with switch
373 // ports as the key
374 PortCriterion p;
375 if (!filt.key().equals(Criteria.dummy()) &&
376 filt.key().type() == Criterion.Type.IN_PORT) {
377 p = (PortCriterion) filt.key();
378 } else {
379 log.warn("No key defined in filtering objective from app: {}. Not"
380 + "processing filtering objective", applicationId);
381 fail(filt, ObjectiveError.UNKNOWN);
382 return;
383 }
Saurav Das337c7a42015-06-02 15:12:06 -0700384
385 EthCriterion e = null; VlanIdCriterion v = null;
386 Collection<IPCriterion> ips = new ArrayList<IPCriterion>();
Saurav Dase3274c82015-05-24 17:21:56 -0700387 // convert filtering conditions for switch-intfs into flowrules
388 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
389 for (Criterion c : filt.conditions()) {
390 if (c.type() == Criterion.Type.ETH_DST) {
Saurav Das337c7a42015-06-02 15:12:06 -0700391 e = (EthCriterion) c;
Saurav Dase3274c82015-05-24 17:21:56 -0700392 } else if (c.type() == Criterion.Type.VLAN_VID) {
Saurav Das337c7a42015-06-02 15:12:06 -0700393 v = (VlanIdCriterion) c;
Saurav Dase3274c82015-05-24 17:21:56 -0700394 } else if (c.type() == Criterion.Type.IPV4_DST) {
Saurav Das337c7a42015-06-02 15:12:06 -0700395 ips.add((IPCriterion) c);
Saurav Dase3274c82015-05-24 17:21:56 -0700396 } else {
Saurav Das337c7a42015-06-02 15:12:06 -0700397 log.error("Unsupported filter {}", c);
Saurav Dase3274c82015-05-24 17:21:56 -0700398 fail(filt, ObjectiveError.UNSUPPORTED);
Saurav Das337c7a42015-06-02 15:12:06 -0700399 return;
Saurav Dase3274c82015-05-24 17:21:56 -0700400 }
401 }
Saurav Das337c7a42015-06-02 15:12:06 -0700402
403 // cache for later use
404 Filter filter = new Filter(p, e, v, ips);
405 filters.add(filter);
406
407 // apply any pending versatile forwarding objectives
408 for (ForwardingObjective fwd : pendingVersatiles) {
409 Collection<FlowRule> ret = processVersatilesWithFilters(filter, fwd);
410 for (FlowRule fr : ret) {
411 ops.add(fr);
412 }
413 }
414
415 for (IPCriterion ipaddr : ips) {
416 log.debug("adding IP filtering rules in ACL table: {}", ipaddr.ip());
417 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
418 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
419 selector.matchInPort(p.port());
420 selector.matchVlanId(v.vlanId());
421 selector.matchEthDst(e.mac());
422 selector.matchEthType(Ethernet.TYPE_IPV4);
423 selector.matchIPDst(ipaddr.ip()); // router IPs to the controller
424 treatment.setOutput(PortNumber.CONTROLLER);
425 FlowRule rule = DefaultFlowRule.builder()
426 .forDevice(deviceId)
427 .withSelector(selector.build())
428 .withTreatment(treatment.build())
429 .withPriority(HIGHEST_PRIORITY)
430 .fromApp(applicationId)
431 .makePermanent()
432 .forTable(ACL_TABLE).build();
433 ops = ops.add(rule);
434 }
435
Saurav Dase3274c82015-05-24 17:21:56 -0700436 // apply filtering flow rules
437 flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
438 @Override
439 public void onSuccess(FlowRuleOperations ops) {
440 pass(filt);
441 log.info("Applied filtering rules");
442 }
443
444 @Override
445 public void onError(FlowRuleOperations ops) {
446 fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
447 log.info("Failed to apply filtering rules");
448 }
449 }));
450 }
451
452 private void pass(Objective obj) {
453 if (obj.context().isPresent()) {
454 obj.context().get().onSuccess(obj);
455 }
456 }
457
458 private void fail(Objective obj, ObjectiveError error) {
459 if (obj.context().isPresent()) {
460 obj.context().get().onError(obj, error);
461 }
462 }
463
464 private void initializePipeline() {
Saurav Das337c7a42015-06-02 15:12:06 -0700465 //processIpUnicastTable(true);
Jonathan Hartb35540a2015-11-17 09:30:56 -0800466 processAclTable(true);
Saurav Dase3274c82015-05-24 17:21:56 -0700467 }
468
Jonathan Hartb35540a2015-11-17 09:30:56 -0800469 private void processAclTable(boolean install) {
Saurav Dase3274c82015-05-24 17:21:56 -0700470 TrafficSelector.Builder selector;
471 TrafficTreatment.Builder treatment;
472 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
473 FlowRule rule;
474
475 //Drop rule
476 selector = DefaultTrafficSelector.builder();
477 treatment = DefaultTrafficTreatment.builder();
478
Saurav Dase3274c82015-05-24 17:21:56 -0700479 rule = DefaultFlowRule.builder()
480 .forDevice(deviceId)
481 .withSelector(selector.build())
482 .withTreatment(treatment.build())
483 .withPriority(DROP_PRIORITY)
484 .fromApp(appId)
485 .makePermanent()
Saurav Das337c7a42015-06-02 15:12:06 -0700486 .forTable(ACL_TABLE).build();
Saurav Dase3274c82015-05-24 17:21:56 -0700487
488 ops = install ? ops.add(rule) : ops.remove(rule);
489
490 flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
491 @Override
492 public void onSuccess(FlowRuleOperations ops) {
Saurav Das337c7a42015-06-02 15:12:06 -0700493 log.info("Provisioned ACL table");
Saurav Dase3274c82015-05-24 17:21:56 -0700494 }
495
496 @Override
497 public void onError(FlowRuleOperations ops) {
Saurav Das337c7a42015-06-02 15:12:06 -0700498 log.info("Failed to provision ACL table");
Saurav Dase3274c82015-05-24 17:21:56 -0700499 }
500 }));
501 }
502
Saurav Das337c7a42015-06-02 15:12:06 -0700503 private class Filter {
504 private PortCriterion port;
505 private VlanIdCriterion vlan;
506 private EthCriterion eth;
Saurav Dase3274c82015-05-24 17:21:56 -0700507
Saurav Das337c7a42015-06-02 15:12:06 -0700508 @SuppressWarnings("unused")
509 private Collection<IPCriterion> ips;
Saurav Dase3274c82015-05-24 17:21:56 -0700510
Saurav Das337c7a42015-06-02 15:12:06 -0700511 public Filter(PortCriterion p, EthCriterion e, VlanIdCriterion v,
512 Collection<IPCriterion> ips) {
513 this.eth = e;
514 this.port = p;
515 this.vlan = v;
516 this.ips = ips;
Saurav Dase3274c82015-05-24 17:21:56 -0700517 }
Saurav Dase3274c82015-05-24 17:21:56 -0700518
Saurav Das337c7a42015-06-02 15:12:06 -0700519 public PortNumber port() {
520 return port.port();
521 }
Saurav Dase3274c82015-05-24 17:21:56 -0700522
Saurav Das337c7a42015-06-02 15:12:06 -0700523 public VlanId vlanId() {
524 return vlan.vlanId();
525 }
Saurav Dase3274c82015-05-24 17:21:56 -0700526
Saurav Das337c7a42015-06-02 15:12:06 -0700527 public MacAddress mac() {
528 return eth.mac();
Saurav Dase3274c82015-05-24 17:21:56 -0700529 }
530 }
531
532 private class PicaGroup implements NextGroup {
Saurav Das337c7a42015-06-02 15:12:06 -0700533 TrafficTreatment nextActions;
Saurav Dase3274c82015-05-24 17:21:56 -0700534
Saurav Das337c7a42015-06-02 15:12:06 -0700535 public PicaGroup(TrafficTreatment next) {
536 this.nextActions = next;
Saurav Dase3274c82015-05-24 17:21:56 -0700537 }
538
539 @Override
540 public byte[] data() {
Saurav Das337c7a42015-06-02 15:12:06 -0700541 return appKryo.serialize(nextActions);
Saurav Dase3274c82015-05-24 17:21:56 -0700542 }
Saurav Dase3274c82015-05-24 17:21:56 -0700543 }
544}