Search in sources :

Example 1 with Builder

use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.

the class CorsaPipelineV3 method processSpecificSwitch.

@Override
protected Collection<FlowRule> processSpecificSwitch(ForwardingObjective fwd) {
    TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchInPort(((PortCriterion) fwd.selector().getCriterion(Criterion.Type.IN_PORT)).port()).matchVlanId(((VlanIdCriterion) fwd.selector().getCriterion(Criterion.Type.VLAN_VID)).vlanId()).build();
    Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector).forTable(VLAN_CIRCUIT_TABLE);
    if (fwd.treatment() != null) {
        ruleBuilder.withTreatment(fwd.treatment());
    } else {
        if (fwd.nextId() != null) {
            NextObjective nextObjective = pendingNext.getIfPresent(fwd.nextId());
            if (nextObjective != null) {
                pendingNext.invalidate(fwd.nextId());
                TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setVlanPcp((byte) 0).setQueue(0).meter(defaultMeterId);
                nextObjective.next().forEach(trafficTreatment -> {
                    trafficTreatment.allInstructions().forEach(instruction -> {
                        treatment.add(instruction);
                    });
                });
                ruleBuilder.withTreatment(treatment.build());
            } else {
                log.warn("The group left!");
                fwd.context().ifPresent(c -> c.onError(fwd, ObjectiveError.GROUPMISSING));
                return ImmutableSet.of();
            }
        } else {
            log.warn("Missing NextObjective ID for ForwardingObjective {}", fwd.id());
            fail(fwd, ObjectiveError.BADPARAMS);
            return ImmutableSet.of();
        }
    }
    if (fwd.permanent()) {
        ruleBuilder.makePermanent();
    } else {
        ruleBuilder.makeTemporary(fwd.timeout());
    }
    return Collections.singletonList(ruleBuilder.build());
}
Also used : NextObjective(org.onosproject.net.flowobjective.NextObjective) Builder(org.onosproject.net.flow.FlowRule.Builder) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 2 with Builder

use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.

the class AbstractCorsaPipeline method processVersatile.

private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
    log.debug("Processing vesatile forwarding objective");
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType == null) {
        log.error("Versatile forwarding objective must include ethType");
        fail(fwd, ObjectiveError.UNKNOWN);
        return ImmutableSet.of();
    }
    Builder rule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(fwd.selector()).withTreatment(fwd.treatment()).withPriority(fwd.priority()).fromApp(fwd.appId()).makePermanent();
    if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
        return processArpTraffic(fwd, rule);
    } else if (ethType.ethType().toShort() == Ethernet.TYPE_LLDP || ethType.ethType().toShort() == Ethernet.TYPE_BSN) {
        return processLinkDiscovery(fwd, rule);
    } else if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
        return processIpTraffic(fwd, rule);
    }
    log.warn("Driver does not support given versatile forwarding objective");
    fail(fwd, ObjectiveError.UNSUPPORTED);
    return ImmutableSet.of();
}
Also used : EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) Builder(org.onosproject.net.flow.FlowRule.Builder) CacheBuilder(com.google.common.cache.CacheBuilder) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 3 with Builder

use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.

the class AbstractCorsaPipeline method processSpecificRoute.

private Collection<FlowRule> processSpecificRoute(ForwardingObjective fwd) {
    TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(((IPCriterion) fwd.selector().getCriterion(Criterion.Type.IPV4_DST)).ip()).build();
    TrafficTreatment.Builder tb = processSpecificRoutingTreatment();
    if (fwd.nextId() != null) {
        NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
        GroupKey key = appKryo.deserialize(next.data());
        Group group = groupService.getGroup(deviceId, key);
        if (group == null) {
            log.warn("The group left!");
            fail(fwd, ObjectiveError.GROUPMISSING);
            return ImmutableSet.of();
        }
        tb.group(group.id());
    } else {
        log.error("Missing NextObjective ID for ForwardingObjective {}", fwd.id());
        fail(fwd, ObjectiveError.BADPARAMS);
        return ImmutableSet.of();
    }
    Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector).withTreatment(tb.build());
    ruleBuilder = processSpecificRoutingRule(ruleBuilder);
    if (fwd.permanent()) {
        ruleBuilder.makePermanent();
    } else {
        ruleBuilder.makeTemporary(fwd.timeout());
    }
    return Collections.singletonList(ruleBuilder.build());
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) NextGroup(org.onosproject.net.behaviour.NextGroup) Group(org.onosproject.net.group.Group) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Builder(org.onosproject.net.flow.FlowRule.Builder) CacheBuilder(com.google.common.cache.CacheBuilder) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 4 with Builder

use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.

the class CorsaPipelineV39 method processUntaggedPackets.

private void processUntaggedPackets(boolean install) {
    deviceService.getPorts(deviceId).forEach(port -> {
        if (!port.number().isLogical()) {
            TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().pushVlan().setVlanId(VlanId.vlanId(NATIVE_VLAN)).transition(VLAN_MAC_XLATE_TABLE);
            TrafficSelector.Builder selector = DefaultTrafficSelector.builder().matchVlanId(VlanId.NONE).matchInPort(port.number());
            Builder rule = DefaultFlowRule.builder().forDevice(deviceId).withTreatment(treatment.build()).withSelector(selector.build()).withPriority(CONTROLLER_PRIORITY).fromApp(appId).makePermanent().forTable(VLAN_CHECK_TABLE);
            processFlowRule(install, rule.build(), "Provisioned vlan untagged packet table");
        }
    });
}
Also used : Builder(org.onosproject.net.flow.FlowRule.Builder) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)4 Builder (org.onosproject.net.flow.FlowRule.Builder)4 TrafficSelector (org.onosproject.net.flow.TrafficSelector)4 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 CacheBuilder (com.google.common.cache.CacheBuilder)2 NextGroup (org.onosproject.net.behaviour.NextGroup)1 EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)1 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)1 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)1 NextObjective (org.onosproject.net.flowobjective.NextObjective)1 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)1 Group (org.onosproject.net.group.Group)1 GroupKey (org.onosproject.net.group.GroupKey)1