public static Collection<ForwardingObjective> minusForwardingObjectives(Collection<ForwardingObjective> fo1, Collection<ForwardingObjective> fo2) { Map<Integer, ForwardingObjective> map = new HashMap<>(); for (ForwardingObjective fo : fo1) { map.put(fo.id(), fo); } for (ForwardingObjective fo : fo2) { map.remove(fo.id()); } return map.values(); }
boolean queueFwdObjective(DeviceId deviceId, ForwardingObjective fwd) { boolean queued = false; synchronized (pendingForwards) { // double check the flow objective store, because this block could run // after a notification arrives if (flowObjectiveStore.getNextGroup(fwd.nextId()) == null) { pendingForwards.compute(fwd.nextId(), (id, pending) -> { PendingFlowObjective pendfo = new PendingFlowObjective(deviceId, fwd); if (pending == null) { return Sets.newLinkedHashSet(ImmutableSet.of(pendfo)); } else { pending.add(pendfo); return pending; } }); queued = true; } } if (queued) { log.debug("Queued forwarding objective {} for nextId {} meant for device {}", fwd.id(), fwd.nextId(), deviceId); } return queued; }
protected Collection<FlowRule> processSpecific(ForwardingObjective fwd) { log.debug("Processing specific fwd objective:{} in dev:{} with next:{}", fwd.id(), deviceId, fwd.nextId()); boolean isEthTypeObj = isSupportedEthTypeObjective(fwd); boolean isEthDstObj = isSupportedEthDstObjective(fwd); if (isEthTypeObj) { return processEthTypeSpecificObjective(fwd); } else if (isEthDstObj) { return processEthDstSpecificObjective(fwd); } else { log.warn("processSpecific: Unsupported " + "forwarding objective criteria"); fail(fwd, ObjectiveError.UNSUPPORTED); return Collections.emptySet(); } }
/** * In the OF-DPA 2.0 pipeline, specific forwarding refers to the IP table * (unicast or multicast) or the L2 table (mac + vlan) or the MPLS table. * * @param fwd the forwarding objective of type 'specific' * @return a collection of flow rules. Typically there will be only one * for this type of forwarding objective. An empty set may be * returned if there is an issue in processing the objective. */ protected Collection<FlowRule> processSpecific(ForwardingObjective fwd) { log.debug("Processing specific fwd objective:{} in dev:{} with next:{}", fwd.id(), deviceId, fwd.nextId()); boolean isEthTypeObj = isSupportedEthTypeObjective(fwd); boolean isEthDstObj = isSupportedEthDstObjective(fwd); if (isEthTypeObj) { return processEthTypeSpecific(fwd); } else if (isEthDstObj) { return processEthDstSpecific(fwd); } else { log.warn("processSpecific: Unsupported forwarding objective " + "criteria fwd:{} in dev:{}", fwd.nextId(), deviceId); fail(fwd, ObjectiveError.UNSUPPORTED); return Collections.emptySet(); } }
@Override public ObjectNode encode(ForwardingObjective forwardingObjective, CodecContext context) { checkNotNull(forwardingObjective, NOT_NULL_MESSAGE); final JsonCodec<TrafficTreatment> trafficTreatmentCodec = context.codec(TrafficTreatment.class); final JsonCodec<TrafficSelector> trafficSelectorCodec = context.codec(TrafficSelector.class); // encode common properties ObjectiveCodecHelper och = new ObjectiveCodecHelper(); ObjectNode result = och.encode(forwardingObjective, context); // encode id result.put(ID, forwardingObjective.id()); // encode flag result.put(FLAG, forwardingObjective.flag().toString()); // encode op result.put(OPERATION, forwardingObjective.op().toString()); // encode selector ObjectNode trafficSelectorNode = trafficSelectorCodec.encode(forwardingObjective.selector(), context); result.set(SELECTOR, trafficSelectorNode); // encode nextId if (forwardingObjective.nextId() != null) { result.put(NEXT_ID, forwardingObjective.nextId()); } // encode treatment if (forwardingObjective.treatment() != null) { ObjectNode trafficTreatmentNode = trafficTreatmentCodec.encode(forwardingObjective.treatment(), context); result.set(TREATMENT, trafficTreatmentNode); } return result; }
+ "installing fwd:{} in dev:{}", fwd.id(), deviceId); fail(fwd, ObjectiveError.BADPARAMS); return Collections.emptySet(); filteredSelectorBuilder.matchEthDst(ethCriterion.mac()); log.debug("processing L2 forwarding objective:{} -> next:{} in dev:{}", fwd.id(), fwd.nextId(), deviceId); } else { log.debug("processing L2 Broadcast forwarding objective:{} -> next:{} " + "in dev:{} for vlan:{}", fwd.id(), fwd.nextId(), deviceId, vlanIdCriterion.vlanId()); + "for dev:{}. Expecting only nextId", fwd.id(), deviceId);
+ "installing fwd:{} in dev:{}", fwd.id(), deviceId); fail(fwd, ObjectiveError.BADPARAMS); return Collections.emptySet(); filteredSelectorBuilder.matchEthDst(ethCriterion.mac()); log.debug("processing L2 forwarding objective:{} -> next:{} in dev:{}", fwd.id(), fwd.nextId(), deviceId); } else { log.debug("processing L2 Broadcast forwarding objective:{} -> next:{} " + "in dev:{} for vlan:{}", fwd.id(), fwd.nextId(), deviceId, vlanIdCriterion.vlanId()); + "for dev:{}. Expecting only nextId", fwd.id(), deviceId);
filteredSelectorBuilder.matchEthDst(ethCriterion.mac()); log.debug("processing L2 forwarding objective:{} in dev:{}", fwd.id(), deviceId); } else { log.debug("processing L2 Broadcast forwarding objective:{} " + "in dev:{} for vlan:{}", fwd.id(), deviceId, vlanIdCriterion.vlanId()); log.debug("Adding {} flow-actions for fwd. obj. {} " + "in dev: {}", soGrp.treatment.allInstructions().size(), fwd.id(), deviceId); for (Instruction ins : soGrp.treatment.allInstructions()) { treatmentBuilder.deferred().add(ins); + "in dev: {}", group.id(), fwd.id(), deviceId);
forTableId = ipv4UnicastTableId; log.debug("processing IPv4 specific forwarding objective:{} in dev:{}", fwd.id(), deviceId); } else { filteredSelectorBuilder = filteredSelectorBuilder fwd.id(), deviceId); log.debug("Adding {} flow-actions for fwd. obj. {} -> next:{} " + "in dev: {}", soGroup.treatment.allInstructions().size(), fwd.id(), fwd.nextId(), deviceId); for (Instruction ins : soGroup.treatment.allInstructions()) { treatmentBuilder.add(ins); + "for next:{} in dev: {}", group.id(), fwd.id(), fwd.nextId(), deviceId);
log.debug("Adding {} flow-actions for fwd. obj. {} -> next:{} " + "in dev: {}", soGroup.treatment().allInstructions().size(), fwd.id(), fwd.nextId(), deviceId); for (Instruction ins : soGroup.treatment().allInstructions()) { treatmentBuilder.add(ins); + "for next:{} in dev: {}", group.id(), fwd.id(), fwd.nextId(), deviceId);
forTableId = MULTICAST_ROUTING_TABLE; log.debug("processing IPv4 multicast specific forwarding objective {} -> next:{}" + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); } else { if (ipv4Dst.prefixLength() > 0) { + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); + " in dev {}", fwd.id(), fwd.nextId(), deviceId); log.warn("SR CONTINUE case cannot be handled as MPLS ECMP " + "is not implemented in OF-DPA yet. Aborting this flow {} -> next:{}" + "in this device {}", fwd.id(), fwd.nextId(), deviceId); } else { log.warn("Cannot find group for nextId:{} in dev:{}. Aborting fwd:{}", fwd.nextId(), deviceId, fwd.id()); fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED); return Collections.emptySet();
forTableId = MULTICAST_ROUTING_TABLE; log.debug("processing IPv4 multicast specific forwarding objective {} -> next:{}" + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); } else { if (ipv4Dst.prefixLength() > 0) { + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); + " in dev {}", fwd.id(), fwd.nextId(), deviceId);