org.onosproject.net.flowobjective.ForwardingObjective Java Examples
The following examples show how to use
org.onosproject.net.flowobjective.ForwardingObjective.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SfcFlowRuleInstallerImpl.java From onos with Apache License 2.0 | 6 votes |
/** * Send service-function-forwarder to OVS. * * @param selector traffic selector * @param treatment traffic treatment * @param deviceId device id * @param type operation type * @param priority priority of classifier */ public void sendSfcRule(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, DeviceId deviceId, Objective.Operation type, int priority) { log.info("Sending sfc flow rule. Selector {}, Treatment {}", selector.toString(), treatment.toString()); ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE) .withPriority(priority); if (type.equals(Objective.Operation.ADD)) { log.debug("flowClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("flowClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #2
Source File: ForwardingObjectiveTranslator.java From onos with Apache License 2.0 | 6 votes |
private static TrafficTreatment nextIdOrTreatment( ForwardingObjective obj, PiTableId tableId) throws FabricPipelinerException { if (obj.nextId() == null) { return obj.treatment(); } else { if (!NEXT_ID_ACTIONS.containsKey(tableId)) { throw new FabricPipelinerException(format( "BUG? no next_id action set for table %s", tableId)); } return DefaultTrafficTreatment.builder() .piTableAction( setNextIdAction(obj.nextId(), NEXT_ID_ACTIONS.get(tableId))) .build(); } }
Example #3
Source File: OvsOfdpaPipeline.java From onos with Apache License 2.0 | 6 votes |
/** * Determines if the forwarding objective will be used for double-tagged packets. * * @param fwd Forwarding objective * @return True if the objective was created for double-tagged packets, false otherwise. */ private boolean isDoubleTagged(ForwardingObjective fwd) { if (fwd.nextId() != null) { NextGroup next = getGroupForNextObjective(fwd.nextId()); if (next != null) { List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data()); // we only need the top level group's key Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst()); if (group != null) { int groupId = group.id().id(); if (((groupId & ~TYPE_MASK) == L3_UNICAST_TYPE) && ((groupId & TYPE_L3UG_DOUBLE_VLAN_MASK) == TYPE_L3UG_DOUBLE_VLAN_MASK)) { return true; } } } } return false; }
Example #4
Source File: FlowObjectiveCompositionManager.java From onos with Apache License 2.0 | 6 votes |
@Override public void run() { try { Pipeliner pipeliner = getDevicePipeliner(deviceId); if (pipeliner != null) { if (objective instanceof NextObjective) { pipeliner.next((NextObjective) objective); } else if (objective instanceof ForwardingObjective) { pipeliner.forward((ForwardingObjective) objective); } else { pipeliner.filter((FilteringObjective) objective); } } else if (numAttempts < INSTALL_RETRY_ATTEMPTS) { Thread.sleep(INSTALL_RETRY_INTERVAL); executorService.execute(new ObjectiveInstaller(deviceId, objective, numAttempts + 1)); } else { // Otherwise we've tried a few times and failed, report an // error back to the user. objective.context().ifPresent( c -> c.onError(objective, ObjectiveError.NOPIPELINER)); } } catch (Exception e) { log.warn("Exception while installing flow objective", e); } }
Example #5
Source File: L3ForwardServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programRouteRules(DeviceId deviceId, SegmentationId l3Vni, IpAddress dstVmIP, SegmentationId dstVni, MacAddress dstVmGwMac, MacAddress dstVmMac, Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(IP_TYPE) .matchTunnelId(Long.parseLong(l3Vni.segmentationId())) .matchIPDst(IpPrefix.valueOf(dstVmIP, PREFIX_LENGTH)).build(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.setEthSrc(dstVmGwMac) .setEthDst(dstVmMac) .add(Instructions.modTunnelId(Long.parseLong(dstVni .segmentationId()))); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment.build()) .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(L3FWD_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("RouteRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("RouteRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #6
Source File: McastHandler.java From onos with Apache License 2.0 | 6 votes |
/** * Removes entire group on given device. * * @param deviceId device ID * @param mcastIp multicast group to be removed * @param assignedVlan assigned VLAN ID */ private void removeGroupFromDevice(DeviceId deviceId, IpAddress mcastIp, VlanId assignedVlan) { // TODO trace log.info("Removing {} on {} and vlan {}", mcastIp, deviceId, assignedVlan); McastStoreKey mcastStoreKey = new McastStoreKey(mcastIp, deviceId, assignedVlan); // This device is not serving this multicast group if (!mcastNextObjStore.containsKey(mcastStoreKey)) { log.debug("{} is not serving {}. Abort.", deviceId, mcastIp); return; } NextObjective nextObj = mcastNextObjStore.get(mcastStoreKey).value(); ObjectiveContext context = new DefaultObjectiveContext( (objective) -> log.debug("Successfully remove {} on {}, vlan {}", mcastIp, deviceId, assignedVlan), (objective, error) -> log.warn("Failed to remove {} on {}, vlan {}: {}", mcastIp, deviceId, assignedVlan, error)); if (!srManager.deviceConfiguration().isConfigured(deviceId)) { log.debug("skip flow changes on unconfigured device: {}", deviceId); } else { ForwardingObjective fwdObj = mcastUtils.fwdObjBuilder(mcastIp, assignedVlan, nextObj.id()).remove(context); srManager.flowObjectiveService.forward(deviceId, fwdObj); } mcastNextObjStore.remove(mcastStoreKey); }
Example #7
Source File: ForwardingObjectiveTranslator.java From onos with Apache License 2.0 | 6 votes |
private void ipv4RoutingRule(ForwardingObjective obj, Set<Criterion> criteriaWithMeta, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException { final IPCriterion ipDstCriterion = (IPCriterion) criterionNotNull( criteriaWithMeta, Criterion.Type.IPV4_DST); if (ipDstCriterion.ip().prefixLength() == 0) { defaultIpv4Route(obj, resultBuilder); return; } final TrafficSelector selector = DefaultTrafficSelector.builder() .add(ipDstCriterion) .build(); resultBuilder.addFlowRule(flowRule( obj, FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4, selector)); }
Example #8
Source File: RoutingRulePopulator.java From onos with Apache License 2.0 | 6 votes |
private Set<ForwardingObjective.Builder> ndpFwdObjective(PortNumber port, boolean punt, int priority) { Set<ForwardingObjective.Builder> result = Sets.newHashSet(); Lists.newArrayList(NEIGHBOR_SOLICITATION, NEIGHBOR_ADVERTISEMENT, ROUTER_SOLICITATION, ROUTER_ADVERTISEMENT) .forEach(type -> { TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); sBuilder.matchEthType(TYPE_IPV6) .matchIPProtocol(PROTOCOL_ICMP6) .matchIcmpv6Type(type); if (port != null) { sBuilder.matchInPort(port); } TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); if (punt) { tBuilder.punt(); } result.add(fwdObjBuilder(sBuilder.build(), tBuilder.build(), priority)); }); return result; }
Example #9
Source File: ClassifierServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programUserdataClassifierRules(DeviceId deviceId, IpPrefix ipPrefix, IpAddress dstIp, MacAddress dstmac, SegmentationId actionVni, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(ipPrefix) .matchIPDst(IpPrefix.valueOf(dstIp, 32)).build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setTunnelId(Long.parseLong(actionVni.segmentationId())) .setEthDst(dstmac).build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(USERDATA_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("UserdataClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("UserdataClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #10
Source File: ForwardingObjectiveTranslator.java From onos with Apache License 2.0 | 6 votes |
@Override public ObjectiveTranslation doTranslate(ForwardingObjective obj) throws FabricPipelinerException { final ObjectiveTranslation.Builder resultBuilder = ObjectiveTranslation.builder(); switch (obj.flag()) { case SPECIFIC: processSpecificFwd(obj, resultBuilder); break; case VERSATILE: processVersatileFwd(obj, resultBuilder); break; case EGRESS: default: log.warn("Unsupported ForwardingObjective type '{}'", obj.flag()); return ObjectiveTranslation.ofError(ObjectiveError.UNSUPPORTED); } return resultBuilder.build(); }
Example #11
Source File: RoutingRulePopulator.java From onos with Apache License 2.0 | 6 votes |
/** * Populate a bridging rule on given deviceId that matches given mac, given vlan and * output to given port. * * @param deviceId device ID * @param port port * @param mac mac address * @param vlanId VLAN ID * @return future that carries the flow objective if succeeded, null if otherwise */ CompletableFuture<Objective> populateBridging(DeviceId deviceId, PortNumber port, MacAddress mac, VlanId vlanId) { ForwardingObjective.Builder fob = bridgingFwdObjBuilder(deviceId, mac, vlanId, port, false); if (fob == null) { log.warn("Fail to build fwd obj for host {}/{}. Abort.", mac, vlanId); return CompletableFuture.completedFuture(null); } CompletableFuture<Objective> future = new CompletableFuture<>(); ObjectiveContext context = new DefaultObjectiveContext( (objective) -> { log.debug("Brigding rule for {}/{} populated", mac, vlanId); future.complete(objective); }, (objective, error) -> { log.warn("Failed to populate bridging rule for {}/{}: {}", mac, vlanId, error); future.complete(null); }); srManager.flowObjectiveService.forward(deviceId, fob.add(context)); return future; }
Example #12
Source File: L2ForwardServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programLocalOut(DeviceId deviceId, SegmentationId segmentationId, PortNumber outPort, MacAddress sourceMac, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchTunnelId(Long.parseLong(segmentationId.toString())) .matchEthDst(sourceMac).build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(outPort).build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(MAC_PRIORITY); if (type.equals(Objective.Operation.ADD)) { flowObjectiveService.forward(deviceId, objective.add()); } else { flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #13
Source File: FlowObjectiveCompositionUtil.java From onos with Apache License 2.0 | 6 votes |
public static ForwardingObjective composeSequential(ForwardingObjective fo1, ForwardingObjective fo2, int priorityMultiplier) { TrafficSelector revertTrafficSelector = revertTreatmentSelector(fo1.treatment(), fo2.selector()); if (revertTrafficSelector == null) { return null; } TrafficSelector trafficSelector = intersectTrafficSelector(fo1.selector(), revertTrafficSelector); if (trafficSelector == null) { return null; } TrafficTreatment trafficTreatment = unionTrafficTreatment(fo1.treatment(), fo2.treatment()); return DefaultForwardingObjective.builder() .fromApp(fo1.appId()) .makePermanent() .withFlag(ForwardingObjective.Flag.VERSATILE) .withPriority(fo1.priority() * priorityMultiplier + fo2.priority()) .withSelector(trafficSelector) .withTreatment(trafficTreatment) .add(); }
Example #14
Source File: ClassifierServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programLocalIn(DeviceId deviceId, SegmentationId segmentationId, PortNumber inPort, MacAddress srcMac, ApplicationId appid, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchInPort(inPort).matchEthSrc(srcMac).build(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.add(Instructions .modTunnelId(Long.parseLong(segmentationId.toString()))); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment.build()) .withSelector(selector).fromApp(appId).makePermanent() .withFlag(Flag.SPECIFIC).withPriority(L2_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("programLocalIn-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("programLocalIn-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #15
Source File: ClassifierServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programArpClassifierRules(DeviceId deviceId, IpAddress dstIp, SegmentationId actionVni, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(ETH_TYPE.ethType().toShort()) .matchArpTpa(Ip4Address.valueOf(dstIp.toString())) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setTunnelId(Long.parseLong(actionVni.segmentationId())) .build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(ARP_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("ArpClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("ArpClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #16
Source File: XconnectManager.java From onos with Apache License 2.0 | 6 votes |
/** * Creates a bridging forwarding objective builder for XConnect. * * @param key XConnect key * @param nextId next ID of the broadcast group for this XConnect key * @return forwarding objective builder */ private ForwardingObjective.Builder fwdObjBuilder(XconnectKey key, int nextId) { /* * Driver should treat objectives with MacAddress.NONE and !VlanId.NONE * as the VLAN cross-connect broadcast rules */ TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); sbuilder.matchVlanId(key.vlanId()); sbuilder.matchEthDst(MacAddress.NONE); ForwardingObjective.Builder fob = DefaultForwardingObjective.builder(); fob.withFlag(ForwardingObjective.Flag.SPECIFIC) .withSelector(sbuilder.build()) .nextStep(nextId) .withPriority(XCONNECT_PRIORITY) .fromApp(appId) .makePermanent(); return fob; }
Example #17
Source File: ForwardTable.java From onos with Apache License 2.0 | 6 votes |
public ForwardUpdateTable updateForward(ForwardingObjective forwardingObjective) { ForwardUpdateTable updates = new ForwardUpdateTable(); switch (forwardingObjective.op()) { case ADD: this.forwardMap.put(forwardingObjectiveHash(forwardingObjective), forwardingObjective); this.generatedParentForwardingObjectiveMap .put(forwardingObjectiveHash(forwardingObjective), new ArrayList<>()); updates.addObjectives.add(forwardingObjective); break; case REMOVE: if (this.forwardMap.remove(forwardingObjectiveHash(forwardingObjective)) != null) { updates.removeObjectives.add(forwardingObjective); } break; default: break; } return updates; }
Example #18
Source File: XconnectManager.java From onos with Apache License 2.0 | 6 votes |
/** * Creates an ACL forwarding objective builder for XConnect. * * @param vlanId cross connect VLAN id * @return forwarding objective builder */ private ForwardingObjective.Builder aclObjBuilder(VlanId vlanId) { TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); sbuilder.matchVlanId(vlanId); TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); ForwardingObjective.Builder fob = DefaultForwardingObjective.builder(); fob.withFlag(ForwardingObjective.Flag.VERSATILE) .withSelector(sbuilder.build()) .withTreatment(tbuilder.build()) .withPriority(XCONNECT_ACL_PRIORITY) .fromApp(appId) .makePermanent(); return fob; }
Example #19
Source File: ClassifierServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programL3InPortClassifierRules(DeviceId deviceId, PortNumber inPort, MacAddress srcMac, MacAddress dstMac, SegmentationId actionVni, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchInPort(inPort).matchEthSrc(srcMac).matchEthDst(dstMac) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setTunnelId(Long.parseLong(actionVni.segmentationId())).build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(L3_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("L3InternalClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("L3InternalClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #20
Source File: JuniperQfx5100Pipeliner.java From onos with Apache License 2.0 | 6 votes |
private FlowRule processForward(ForwardingObjective fwd) { FlowRule.Builder ruleBuilder = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(fwd.selector()) .withTreatment(fwd.treatment()) .withPriority(fwd.priority()) .fromApp(fwd.appId()) .forTable(DEFAULT_TABLE); if (fwd.permanent()) { ruleBuilder.makePermanent(); } else { ruleBuilder.makeTemporary(fwd.timeout()); } return ruleBuilder.build(); }
Example #21
Source File: Ofdpa2Pipeline.java From onos with Apache License 2.0 | 6 votes |
FlowRule defaultRoute(ForwardingObjective fwd, TrafficSelector.Builder complementarySelector, int forTableId, TrafficTreatment.Builder tb) { FlowRule.Builder rule = DefaultFlowRule.builder() .fromApp(fwd.appId()) .withPriority(fwd.priority()) .forDevice(deviceId) .withSelector(complementarySelector.build()) .withTreatment(tb.build()) .forTable(forTableId); if (fwd.permanent()) { rule.makePermanent(); } else { rule.makeTemporary(fwd.timeout()); } return rule.build(); }
Example #22
Source File: FlowObjectiveManager.java From onos with Apache License 2.0 | 6 votes |
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; }
Example #23
Source File: ClassifierServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programL3ExPortClassifierRules(DeviceId deviceId, PortNumber inPort, IpAddress dstIp, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(Ethernet.TYPE_IPV4).matchInPort(inPort) .matchIPDst(IpPrefix.valueOf(dstIp, 32)).build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(L3_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("L3ExToInClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("L3ExToInClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #24
Source File: SpringOpenTTP.java From onos with Apache License 2.0 | 5 votes |
private boolean isSupportedEthDstObjective(ForwardingObjective fwd) { TrafficSelector selector = fwd.selector(); EthCriterion ethDst = (EthCriterion) selector .getCriterion(Criterion.Type.ETH_DST); VlanIdCriterion vlanId = (VlanIdCriterion) selector .getCriterion(Criterion.Type.VLAN_VID); if (ethDst == null && vlanId == null) { return false; } return true; }
Example #25
Source File: ForwardingObjectiveCodec.java From onos with Apache License 2.0 | 5 votes |
@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; }
Example #26
Source File: OltPipeline.java From onos with Apache License 2.0 | 5 votes |
private void installUpstreamRulesForAnyVlan(ForwardingObjective fwd, Instruction output, Pair<Instruction, Instruction> outerPair) { log.debug("Installing upstream rules for any value vlan"); //match: in port and any-vlan (coming from OLT app.) //action: write metadata, go to table 1 and meter FlowRule.Builder inner = DefaultFlowRule.builder() .fromApp(fwd.appId()) .forDevice(deviceId) .makePermanent() .withPriority(fwd.priority()) .withSelector(fwd.selector()) .withTreatment(buildTreatment(Instructions.transition(QQ_TABLE), fetchMeter(fwd), fetchWriteMetadata(fwd))); //match: in port and any-vlan (coming from OLT app.) //action: immediate: push:QinQ, vlanId (s-tag), write metadata, meter and output FlowRule.Builder outer = DefaultFlowRule.builder() .fromApp(fwd.appId()) .forDevice(deviceId) .forTable(QQ_TABLE) .makePermanent() .withPriority(fwd.priority()) .withSelector(fwd.selector()) .withTreatment(buildTreatment(outerPair.getLeft(), outerPair.getRight(), fetchMeter(fwd), writeMetadataIncludingOnlyTp(fwd), output)); applyRules(fwd, inner, outer); }
Example #27
Source File: OltPipeline.java From onos with Apache License 2.0 | 5 votes |
@Override public void forward(ForwardingObjective fwd) { log.debug("Installing forwarding objective {}", fwd); if (checkForMulticast(fwd)) { processMulticastRule(fwd); return; } TrafficTreatment treatment = fwd.treatment(); List<Instruction> instructions = treatment.allInstructions(); Optional<Instruction> vlanInstruction = instructions.stream() .filter(i -> i.type() == Instruction.Type.L2MODIFICATION) .filter(i -> ((L2ModificationInstruction) i).subtype() == L2ModificationInstruction.L2SubType.VLAN_PUSH || ((L2ModificationInstruction) i).subtype() == L2ModificationInstruction.L2SubType.VLAN_POP) .findAny(); if (!vlanInstruction.isPresent()) { installNoModificationRules(fwd); } else { L2ModificationInstruction vlanIns = (L2ModificationInstruction) vlanInstruction.get(); if (vlanIns.subtype() == L2ModificationInstruction.L2SubType.VLAN_PUSH) { installUpstreamRules(fwd); } else if (vlanIns.subtype() == L2ModificationInstruction.L2SubType.VLAN_POP) { installDownstreamRules(fwd); } else { log.error("Unknown OLT operation: {}", fwd); fail(fwd, ObjectiveError.UNSUPPORTED); return; } } pass(fwd); }
Example #28
Source File: LinkCollectionIntentFlowObjectiveCompiler.java From onos with Apache License 2.0 | 5 votes |
private List<Objective> createBroadcastObjective(ForwardingInstructions instructions, Set<TrafficTreatment> treatmentsWithDifferentPort, LinkCollectionIntent intent) { List<Objective> objectives = Lists.newArrayList(); ForwardingObjective forwardingObjective; NextObjective nextObjective; Integer nextId = flowObjectiveService.allocateNextId(); forwardingObjective = buildForwardingObjective(instructions.selector(), nextId, intent.priority()); DefaultNextObjective.Builder nxBuilder = DefaultNextObjective.builder(); nxBuilder.withId(nextId) .withMeta(instructions.selector()) .withType(NextObjective.Type.BROADCAST) .fromApp(appId) .withPriority(intent.priority()) .makePermanent(); treatmentsWithDifferentPort.forEach(nxBuilder::addTreatment); nextObjective = nxBuilder.add(); objectives.add(forwardingObjective); objectives.add(nextObjective); return objectives; }
Example #29
Source File: FabricForwardingPipelineTest.java From onos with Apache License 2.0 | 5 votes |
private void testSpecificForward(PiTableId expectedTableId, TrafficSelector expectedSelector, TrafficSelector selector, Integer nextId, TrafficTreatment treatment) throws FabricPipelinerException { ForwardingObjective.Builder fwd = DefaultForwardingObjective.builder() .withSelector(selector) .withPriority(PRIORITY) .fromApp(APP_ID) .makePermanent() .withTreatment(treatment) .withFlag(ForwardingObjective.Flag.SPECIFIC); if (nextId != null) { fwd.nextStep(nextId); } ObjectiveTranslation actualTranslation = translator.translate(fwd.add()); FlowRule expectedFlowRule = DefaultFlowRule.builder() .forDevice(DEVICE_ID) .forTable(expectedTableId) .withPriority(PRIORITY) .makePermanent() .withSelector(expectedSelector) .withTreatment(treatment) .fromApp(APP_ID) .build(); ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder() .addFlowRule(expectedFlowRule) .build(); assertEquals(expectedTranslation, actualTranslation); }
Example #30
Source File: AristaPipeliner.java From onos with Apache License 2.0 | 5 votes |
@Override public void forward(ForwardingObjective forwardObjective) { ForwardingObjective newFwd = forwardObjective; Device device = deviceService.getDevice(deviceId); if (forwardObjective.treatment() != null && forwardObjective.treatment().clearedDeferred()) { log.warn("Using 'clear actions' instruction which is not supported by {} {} {} Switch" + " removing the clear deferred from the forwarding objective", device.id(), device.manufacturer(), device.hwVersion()); newFwd = forwardingObjectiveWithoutCleardDef(forwardObjective).orElse(forwardObjective); } super.forward(newFwd); }