Search in sources :

Example 1 with NextGroup

use of org.onosproject.net.behaviour.NextGroup in project onos by opennetworkinglab.

the class VirtualNetworkFlowObjectiveManager method getNextMappings.

@Override
public List<String> getNextMappings() {
    List<String> mappings = new ArrayList<>();
    Map<Integer, NextGroup> allnexts = flowObjectiveStore.getAllGroups();
    for (Map.Entry<Integer, NextGroup> e : allnexts.entrySet()) {
        // get the device this next Objective was sent to
        DeviceId deviceId = nextToDevice.get(e.getKey());
        mappings.add("NextId " + e.getKey() + ": " + ((deviceId != null) ? deviceId : "nextId not in this onos instance"));
        if (deviceId != null) {
            // this instance of the controller sent the nextObj to a driver
            Pipeliner pipeliner = getDevicePipeliner(deviceId);
            List<String> nextMappings = pipeliner.getNextMappings(e.getValue());
            if (nextMappings != null) {
                mappings.addAll(nextMappings);
            }
        }
    }
    return mappings;
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) Pipeliner(org.onosproject.net.behaviour.Pipeliner) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with NextGroup

use of org.onosproject.net.behaviour.NextGroup in project onos by opennetworkinglab.

the class SimpleVirtualFlowObjectiveStore method getAllGroups.

@Override
public Map<Integer, NextGroup> getAllGroups(NetworkId networkId) {
    ConcurrentMap<Integer, byte[]> nextGroups = getNextGroups(networkId);
    Map<Integer, NextGroup> nextGroupMappings = new HashMap<>();
    for (int key : nextGroups.keySet()) {
        NextGroup nextGroup = getNextGroup(networkId, key);
        if (nextGroup != null) {
            nextGroupMappings.put(key, nextGroup);
        }
    }
    return nextGroupMappings;
}
Also used : DefaultNextGroup(org.onosproject.net.behaviour.DefaultNextGroup) NextGroup(org.onosproject.net.behaviour.NextGroup) HashMap(java.util.HashMap)

Example 3 with NextGroup

use of org.onosproject.net.behaviour.NextGroup in project onos by opennetworkinglab.

the class CentecV350Pipeline method processSpecific.

private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
    log.debug("Processing specific forwarding objective");
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
        fail(fwd, ObjectiveError.UNSUPPORTED);
        return Collections.emptySet();
    }
    // Must have metadata as key.
    TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchMetadata(DEFAULT_METADATA).matchIPDst(((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip()).build();
    TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
    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 Collections.emptySet();
        }
        tb.group(group.id());
    }
    FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(ROUTE_TABLE_PRIORITY).forDevice(deviceId).withSelector(filteredSelector).withTreatment(tb.build());
    if (fwd.permanent()) {
        ruleBuilder.makePermanent();
    } else {
        ruleBuilder.makeTemporary(fwd.timeout());
    }
    ruleBuilder.forTable(ROUTE_TABLE);
    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) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 4 with NextGroup

use of org.onosproject.net.behaviour.NextGroup in project onos by opennetworkinglab.

the class DefaultSingleTablePipeline method next.

@Override
public void next(NextObjective nextObjective) {
    switch(nextObjective.op()) {
        case ADD:
            // Check next objective
            TrafficTreatment treatment = getTreatment(nextObjective);
            if (treatment == null) {
                // unsupported next objective
                nextObjective.context().ifPresent(context -> context.onError(nextObjective, ObjectiveError.UNSUPPORTED));
                return;
            }
            // We insert the value in the cache
            pendingAddNext.put(nextObjective.id(), nextObjective);
            // Then in the store, this will unblock the queued fwd obj
            flowObjectiveStore.putNextGroup(nextObjective.id(), new SingleGroup(treatment));
            break;
        case REMOVE:
            NextGroup next = flowObjectiveStore.removeNextGroup(nextObjective.id());
            if (next == null) {
                nextObjective.context().ifPresent(context -> context.onError(nextObjective, ObjectiveError.GROUPMISSING));
                return;
            }
            break;
        default:
            log.warn("Unsupported operation {}", nextObjective.op());
    }
    nextObjective.context().ifPresent(context -> context.onSuccess(nextObjective));
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 5 with NextGroup

use of org.onosproject.net.behaviour.NextGroup in project onos by opennetworkinglab.

the class SoftRouterPipeline method processVersatile.

/**
 * SoftRouter has a single versatile table - the filter table.
 * This table can be used to filter entries that reach the next table (FIB table).
 * It can also be used to punt packets to the controller and/or bypass
 * the FIB table to forward out of a port.
 *
 * @param fwd The forwarding objective of type versatile
 * @return  A collection of flow rules meant to be delivered to the flowrule
 *          subsystem. May return empty collection in case of failures.
 */
private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
    log.debug("Received versatile fwd: to next:{}", fwd.nextId());
    Collection<FlowRule> flowrules = new ArrayList<>();
    if (fwd.nextId() == null && fwd.treatment() == null) {
        log.error("Forwarding objective {} from {} must contain " + "nextId or Treatment", fwd.selector(), fwd.appId());
        return Collections.emptySet();
    }
    int tableId = FILTER_TABLE;
    // so that it only takes effect if the packet misses the FIB rules
    if (fwd.treatment() != null && containsPunt(fwd.treatment()) && fwd.selector() != null && matchesIp(fwd.selector()) && !matchesControlTraffic(fwd.selector())) {
        tableId = FIB_TABLE;
    }
    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    if (fwd.treatment() != null) {
        fwd.treatment().immediate().forEach(ins -> ttBuilder.add(ins));
    }
    // convert nextId to flow actions
    if (fwd.nextId() != null) {
        // only acceptable value is output to port
        NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
        if (next == null) {
            log.error("next-id {} does not exist in store", fwd.nextId());
            return Collections.emptySet();
        }
        TrafficTreatment nt = appKryo.deserialize(next.data());
        if (nt == null) {
            log.error("Error in deserializing next-id {}", fwd.nextId());
            return Collections.emptySet();
        }
        for (Instruction ins : nt.allInstructions()) {
            if (ins instanceof OutputInstruction) {
                ttBuilder.add(ins);
            }
        }
    }
    FlowRule rule = DefaultFlowRule.builder().withSelector(fwd.selector()).withTreatment(ttBuilder.build()).forTable(tableId).makePermanent().forDevice(deviceId).fromApp(fwd.appId()).withPriority(fwd.priority()).build();
    flowrules.add(rule);
    return flowrules;
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) ArrayList(java.util.ArrayList) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction)

Aggregations

NextGroup (org.onosproject.net.behaviour.NextGroup)38 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)25 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)25 Group (org.onosproject.net.group.Group)23 TrafficSelector (org.onosproject.net.flow.TrafficSelector)18 Deque (java.util.Deque)17 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)17 FlowRule (org.onosproject.net.flow.FlowRule)17 ArrayList (java.util.ArrayList)16 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)16 Instruction (org.onosproject.net.flow.instructions.Instruction)12 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)12 GroupKey (org.onosproject.net.group.GroupKey)12 ArrayDeque (java.util.ArrayDeque)10 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)10 EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)9 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)9 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)8 IpPrefix (org.onlab.packet.IpPrefix)6 DeviceId (org.onosproject.net.DeviceId)6