Charles Chan
Committed by Gerrit Code Review

Override processEthDstSpecific in CpqdOFDPA2

CpqdOFDPA2 doesn't need the extension selector for VLAN matching in bridging table
Implement its own processEthDstSpecific instead of using the one inherited from OFDPA

Change-Id: I0dae1e2ccdc062182f3f373bbd8669b3418cd7c1
...@@ -440,6 +440,81 @@ public class CpqdOFDPA2Pipeline extends OFDPA2Pipeline { ...@@ -440,6 +440,81 @@ public class CpqdOFDPA2Pipeline extends OFDPA2Pipeline {
440 return Collections.singletonList(ruleBuilder.build()); 440 return Collections.singletonList(ruleBuilder.build());
441 } 441 }
442 442
443 + @Override
444 + protected Collection<FlowRule> processEthDstSpecific(ForwardingObjective fwd) {
445 + List<FlowRule> rules = new ArrayList<>();
446 +
447 + // Build filtered selector
448 + TrafficSelector selector = fwd.selector();
449 + EthCriterion ethCriterion = (EthCriterion) selector
450 + .getCriterion(Criterion.Type.ETH_DST);
451 + VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) selector
452 + .getCriterion(Criterion.Type.VLAN_VID);
453 +
454 + if (vlanIdCriterion == null) {
455 + log.warn("Forwarding objective for bridging requires vlan. Not "
456 + + "installing fwd:{} in dev:{}", fwd.id(), deviceId);
457 + fail(fwd, ObjectiveError.BADPARAMS);
458 + return Collections.emptySet();
459 + }
460 +
461 + TrafficSelector.Builder filteredSelectorBuilder =
462 + DefaultTrafficSelector.builder();
463 + // Do not match MacAddress for subnet broadcast entry
464 + if (!ethCriterion.mac().equals(MacAddress.NONE)) {
465 + filteredSelectorBuilder.matchEthDst(ethCriterion.mac());
466 + log.debug("processing L2 forwarding objective:{} -> next:{} in dev:{}",
467 + fwd.id(), fwd.nextId(), deviceId);
468 + } else {
469 + log.debug("processing L2 Broadcast forwarding objective:{} -> next:{} "
470 + + "in dev:{} for vlan:{}",
471 + fwd.id(), fwd.nextId(), deviceId, vlanIdCriterion.vlanId());
472 + }
473 + filteredSelectorBuilder.matchVlanId(vlanIdCriterion.vlanId());
474 + TrafficSelector filteredSelector = filteredSelectorBuilder.build();
475 +
476 + if (fwd.treatment() != null) {
477 + log.warn("Ignoring traffic treatment in fwd rule {} meant for L2 table"
478 + + "for dev:{}. Expecting only nextId", fwd.id(), deviceId);
479 + }
480 +
481 + TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
482 + if (fwd.nextId() != null) {
483 + NextGroup next = getGroupForNextObjective(fwd.nextId());
484 + if (next != null) {
485 + List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
486 + // we only need the top level group's key to point the flow to it
487 + Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
488 + if (group != null) {
489 + treatmentBuilder.deferred().group(group.id());
490 + } else {
491 + log.warn("Group with key:{} for next-id:{} not found in dev:{}",
492 + gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
493 + fail(fwd, ObjectiveError.GROUPMISSING);
494 + return Collections.emptySet();
495 + }
496 + }
497 + }
498 + treatmentBuilder.immediate().transition(ACL_TABLE);
499 + TrafficTreatment filteredTreatment = treatmentBuilder.build();
500 +
501 + // Build bridging table entries
502 + FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder();
503 + flowRuleBuilder.fromApp(fwd.appId())
504 + .withPriority(fwd.priority())
505 + .forDevice(deviceId)
506 + .withSelector(filteredSelector)
507 + .withTreatment(filteredTreatment)
508 + .forTable(BRIDGING_TABLE);
509 + if (fwd.permanent()) {
510 + flowRuleBuilder.makePermanent();
511 + } else {
512 + flowRuleBuilder.makeTemporary(fwd.timeout());
513 + }
514 + rules.add(flowRuleBuilder.build());
515 + return rules;
516 + }
517 +
443 /* 518 /*
444 * In the OF-DPA 2.0 pipeline, versatile forwarding objectives go to the 519 * In the OF-DPA 2.0 pipeline, versatile forwarding objectives go to the
445 * ACL table. Because we pop off vlan tags in TMAC table, 520 * ACL table. Because we pop off vlan tags in TMAC table,
......