Java Code Examples for org.onosproject.net.flowobjective.NextObjective#appId()

The following examples show how to use org.onosproject.net.flowobjective.NextObjective#appId() . 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: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private void createL2MulticastGroup(NextObjective nextObj, VlanId vlanId,  List<GroupInfo> groupInfos) {
    // Realize & represent L2 multicast group in OFDPA driver layer
    // TODO : Need to identify significance of OfdpaNextGroup.
    Integer l2MulticastGroupId = L2_MULTICAST_TYPE | (vlanId.toShort() << 16);
    final GroupKey l2MulticastGroupKey = l2MulticastGroupKey(vlanId, deviceId);
    List<Deque<GroupKey>> l2MulticastAllGroup = Lists.newArrayList();
    groupInfos.forEach(groupInfo -> {
        Deque<GroupKey> groupKeyChain = new ArrayDeque<>();
        groupKeyChain.addFirst(groupInfo.innerMostGroupDesc().appCookie());
        groupKeyChain.addFirst(l2MulticastGroupKey);
        l2MulticastAllGroup.add(groupKeyChain);
    });
    OfdpaNextGroup ofdpaL2MulticastGroup = new OfdpaNextGroup(l2MulticastAllGroup, nextObj);
    updatePendingNextObjective(l2MulticastGroupKey, ofdpaL2MulticastGroup);
    // Group Chain Hierarchy creation using group service and thus in device level
    List<GroupBucket> l2McastBuckets = new ArrayList<>();
    groupInfos.forEach(groupInfo -> {
        // Points to L2 interface group directly.
        TrafficTreatment.Builder trafficTreatment = DefaultTrafficTreatment.builder();
        trafficTreatment.group(new GroupId(groupInfo.innerMostGroupDesc().givenGroupId()));
        GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(trafficTreatment.build());
        l2McastBuckets.add(bucket);
    });
    GroupDescription l2MulticastGroupDescription =
            new DefaultGroupDescription(
                    deviceId,
                    ALL,
                    new GroupBuckets(l2McastBuckets),
                    l2MulticastGroupKey,
                    l2MulticastGroupId,
                    nextObj.appId());
    GroupChainElem l2MulticastGce = new GroupChainElem(l2MulticastGroupDescription,
                                                       groupInfos.size(), false, deviceId);
    groupInfos.forEach(groupInfo -> {
        updatePendingGroups(groupInfo.innerMostGroupDesc().appCookie(), l2MulticastGce);
        groupService.addGroup(groupInfo.innerMostGroupDesc());
    });
}
 
Example 2
Source File: AbstractCorsaPipeline.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void next(NextObjective nextObjective) {
    switch (nextObjective.type()) {
        case SIMPLE:
            Collection<TrafficTreatment> treatments = nextObjective.next();
            if (treatments.size() == 1) {
                TrafficTreatment treatment = treatments.iterator().next();
                CorsaTrafficTreatment corsaTreatment = processNextTreatment(treatment);
                final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
                if (corsaTreatment.type() == CorsaTrafficTreatmentType.GROUP) {
                    GroupBucket bucket = DefaultGroupBucket.createIndirectGroupBucket(corsaTreatment.treatment());
                    GroupBuckets buckets = new GroupBuckets(Collections.singletonList(bucket));
                    // group id == null, let group service determine group id
                    GroupDescription groupDescription = new DefaultGroupDescription(deviceId,
                                                                                    GroupDescription.Type.INDIRECT,
                                                                                    buckets,
                                                                                    key,
                                                                                    null,
                                                                                    nextObjective.appId());
                    groupService.addGroup(groupDescription);
                    pendingGroups.put(key, nextObjective);
                } else if (corsaTreatment.type() == CorsaTrafficTreatmentType.ACTIONS) {
                    pendingNext.put(nextObjective.id(), nextObjective);
                    flowObjectiveStore.putNextGroup(nextObjective.id(), new CorsaGroup(key));
                    nextObjective.context().ifPresent(context -> context.onSuccess(nextObjective));
                }
            }
            break;
        case HASHED:
        case BROADCAST:
        case FAILOVER:
            fail(nextObjective, ObjectiveError.UNSUPPORTED);
            log.warn("Unsupported next objective type {}", nextObjective.type());
            break;
        default:
            fail(nextObjective, ObjectiveError.UNKNOWN);
            log.warn("Unknown next objective type {}", nextObjective.type());
    }

}
 
Example 3
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private GroupInfo prepareL3UnicastGroup(NextObjective nextObj, NextGroup next) {

       ImmutableList.Builder<GroupInfo> groupInfoBuilder = ImmutableList.builder();
       TrafficTreatment treatment = nextObj.next().iterator().next();

       VlanId assignedVlan = readVlanFromSelector(nextObj.meta());
       if (assignedVlan == null) {
            log.warn("VLAN ID required by next obj is missing. Abort.");
            return null;
       }

       List<GroupInfo> l2GroupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan);
       GroupDescription l2InterfaceGroupDesc = l2GroupInfos.get(0).innerMostGroupDesc();
       GroupKey l2groupkey = l2InterfaceGroupDesc.appCookie();

       TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
       VlanId vlanid = null;
       MacAddress srcMac;
       MacAddress dstMac;
       for (Instruction ins : treatment.allInstructions()) {
            if (ins.type() == Instruction.Type.L2MODIFICATION) {
                L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
                switch (l2ins.subtype()) {
                    case ETH_DST:
                        dstMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                        outerTtb.setEthDst(dstMac);
                        break;
                    case ETH_SRC:
                        srcMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                        outerTtb.setEthSrc(srcMac);
                        break;
                    case VLAN_ID:
                        vlanid = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
                            outerTtb.setVlanId(vlanid);
                        break;
                    default:
                        break;
                }
            } else {
                log.debug("Driver does not handle this type of TrafficTreatment"
                        + " instruction in l2l3chain:  {} - {}", ins.type(), ins);
            }
       }

       GroupId l2groupId = new GroupId(l2InterfaceGroupDesc.givenGroupId());
       outerTtb.group(l2groupId);

       // we need the top level group's key to point the flow to it
       List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
       GroupKey l3groupkey = gkeys.get(0).peekFirst();
       GroupId grpId = groupService.getGroup(deviceId, l3groupkey).id();
       int l3groupId = grpId.id();

       // create the l3unicast group description to wait for the
       // l2 interface group to be processed
       GroupBucket l3UnicastGroupBucket =  DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());

       GroupDescription l3UnicastGroupDescription = new DefaultGroupDescription(deviceId,
                                                        GroupDescription.Type.INDIRECT,
                                                        new GroupBuckets(Collections.singletonList(
                                                        l3UnicastGroupBucket)), l3groupkey,
                                                        l3groupId, nextObj.appId());

      // store l2groupkey with the groupChainElem for the outer-group that depends on it
      GroupChainElem gce = new GroupChainElem(l3UnicastGroupDescription, 1, false, deviceId);
      updatePendingGroups(l2groupkey, gce);

      log.debug("Trying L3-Interface: device:{} gid:{} gkey:{} nextid:{}",
                        deviceId, Integer.toHexString(l3groupId), l3groupkey, nextObj.id());

      groupInfoBuilder.add(new GroupInfo(l2InterfaceGroupDesc,
                    l3UnicastGroupDescription));

      return groupInfoBuilder.build().iterator().next();
    }
 
Example 4
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private void createL2FloodGroup(NextObjective nextObj, VlanId vlanId,
                                List<GroupInfo> groupInfos) {
    // assemble info for l2 flood group. Since there can be only one flood
    // group for a vlan, its index is always the same - 0
    Integer l2FloodGroupId = L2_FLOOD_TYPE | (vlanId.toShort() << 16);
    final GroupKey l2FloodGroupKey = l2FloodGroupKey(vlanId, deviceId);
    // collection of group buckets pointing to all the l2 interface groups
    List<GroupBucket> l2floodBuckets = generateNextGroupBuckets(groupInfos, ALL);
    // create the l2flood group-description to wait for all the
    // l2interface groups to be processed
    GroupDescription l2floodGroupDescription =
            new DefaultGroupDescription(
                    deviceId,
                    ALL,
                    new GroupBuckets(l2floodBuckets),
                    l2FloodGroupKey,
                    l2FloodGroupId,
                    nextObj.appId());
    log.debug("Trying L2-Flood: device:{} gid:{} gkey:{} nextid:{}",
            deviceId, Integer.toHexString(l2FloodGroupId),
            l2FloodGroupKey, nextObj.id());
    // Put all dependency information into allGroupKeys
    List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList();
    groupInfos.forEach(groupInfo -> {
        Deque<GroupKey> groupKeyChain = new ArrayDeque<>();
        // In this case we should have L2 interface group only
        groupKeyChain.addFirst(groupInfo.nextGroupDesc().appCookie());
        groupKeyChain.addFirst(l2FloodGroupKey);
        allGroupKeys.add(groupKeyChain);
    });
    // Point the next objective to this group
    OfdpaNextGroup ofdpaGrp = new OfdpaNextGroup(allGroupKeys, nextObj);
    updatePendingNextObjective(l2FloodGroupKey, ofdpaGrp);
    GroupChainElem gce = new GroupChainElem(l2floodGroupDescription,
            groupInfos.size(), false, deviceId);
    groupInfos.forEach(groupInfo -> {
        // Point this group to the next group
        updatePendingGroups(groupInfo.nextGroupDesc().appCookie(), gce);
        // Start installing the inner-most group
        groupService.addGroup(groupInfo.innerMostGroupDesc());
    });
}
 
Example 5
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private void createL3MulticastGroup(NextObjective nextObj, VlanId vlanId,
                                    List<GroupInfo> groupInfos) {
    // Let's create a new list mcast buckets
    List<GroupBucket> l3McastBuckets = createL3MulticastBucket(groupInfos);

    int l3MulticastIndex = getNextAvailableIndex();
    int l3MulticastGroupId = L3_MULTICAST_TYPE |
            vlanId.toShort() << 16 | (TYPE_VLAN_MASK & l3MulticastIndex);
    final GroupKey l3MulticastGroupKey =
            new DefaultGroupKey(appKryo.serialize(l3MulticastIndex));

    GroupDescription l3MulticastGroupDesc = new DefaultGroupDescription(deviceId,
            ALL,
            new GroupBuckets(l3McastBuckets),
            l3MulticastGroupKey,
            l3MulticastGroupId,
            nextObj.appId());

    // Put all dependency information into allGroupKeys
    List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList();
    groupInfos.forEach(groupInfo -> {
        Deque<GroupKey> gkeyChain = new ArrayDeque<>();
        gkeyChain.addFirst(groupInfo.innerMostGroupDesc().appCookie());
        // Add L3 interface group to the chain if there is one.
        if (!groupInfo.nextGroupDesc().equals(groupInfo.innerMostGroupDesc())) {
            gkeyChain.addFirst(groupInfo.nextGroupDesc().appCookie());
        }
        gkeyChain.addFirst(l3MulticastGroupKey);
        allGroupKeys.add(gkeyChain);
    });
    // Point the next objective to this group
    OfdpaNextGroup ofdpaGrp = new OfdpaNextGroup(allGroupKeys, nextObj);
    updatePendingNextObjective(l3MulticastGroupKey, ofdpaGrp);
    GroupChainElem outerGce = new GroupChainElem(l3MulticastGroupDesc,
            groupInfos.size(), false, deviceId);
    groupInfos.forEach(groupInfo -> {
        // Point this group (L3 multicast) to the next group
        updatePendingGroups(groupInfo.nextGroupDesc().appCookie(), outerGce);
        // Point next group to inner-most group, if any
        if (!groupInfo.nextGroupDesc().equals(groupInfo.innerMostGroupDesc())) {
            GroupChainElem innerGce = new GroupChainElem(groupInfo.nextGroupDesc(),
                    1, false, deviceId);
            updatePendingGroups(groupInfo.innerMostGroupDesc().appCookie(), innerGce);
        }
        // Start installing the inner-most group
        groupService.addGroup(groupInfo.innerMostGroupDesc());
    });
}
 
Example 6
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private void addBucketToL2HashGroup(NextObjective nextObjective,
                                      List<Deque<GroupKey>> allActiveKeys) {
    // storage for all group keys in the chain of groups created
    List<Deque<GroupKey>> allGroupKeys = new ArrayList<>();
    List<GroupInfo> unsentGroups = new ArrayList<>();
    List<GroupBucket> newBuckets;
    // Prepare the l2 unfiltered groups
    createL2HashBuckets(nextObjective, allGroupKeys, unsentGroups);
    // now we can create the buckets to add to the outermost L2 hash group
    newBuckets = generateNextGroupBuckets(unsentGroups, SELECT);
    // retrieve the original l2 load balance group
    Group l2hashGroup = retrieveTopLevelGroup(allActiveKeys, deviceId,
                                              groupService, nextObjective.id());
    if (l2hashGroup == null) {
        fail(nextObjective, ObjectiveError.GROUPMISSING);
        return;
    }
    GroupKey l2hashGroupKey = l2hashGroup.appCookie();
    int l2hashGroupId = l2hashGroup.id().id();
    GroupDescription l2hashGroupDesc = new DefaultGroupDescription(deviceId,
                                                                   SELECT,
                                                                   new GroupBuckets(newBuckets),
                                                                   l2hashGroupKey,
                                                                   l2hashGroupId,
                                                                   nextObjective.appId());
    GroupChainElem l2hashGce = new GroupChainElem(l2hashGroupDesc,
                                                  unsentGroups.size(),
                                                  true,
                                                  deviceId);
    // update new bucket-chains
    List<Deque<GroupKey>> addedKeys = new ArrayList<>();
    for (Deque<GroupKey> newBucketChain : allGroupKeys) {
        newBucketChain.addFirst(l2hashGroupKey);
        addedKeys.add(newBucketChain);
    }
    updatePendingNextObjective(l2hashGroupKey,
                               new OfdpaNextGroup(addedKeys, nextObjective));
    log.debug("Adding to L2HASH: device:{} gid:{} group key:{} nextId:{}",
              deviceId, Integer.toHexString(l2hashGroupId),
              l2hashGroupKey, nextObjective.id());
    unsentGroups.forEach(groupInfo -> {
        // send the innermost group
        log.debug("Sending innermost group {} in group chain on device {} ",
                  Integer.toHexString(groupInfo.innerMostGroupDesc().givenGroupId()),
                  deviceId);
        updatePendingGroups(groupInfo.nextGroupDesc().appCookie(), l2hashGce);
        groupService.addGroup(groupInfo.innerMostGroupDesc());
    });
}
 
Example 7
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private void addBucketToEcmpHashGroup(NextObjective nextObjective,
                                  List<Deque<GroupKey>> allActiveKeys) {
    // storage for all group keys in the chain of groups created
    List<Deque<GroupKey>> allGroupKeys = new ArrayList<>();
    List<GroupInfo> unsentGroups = new ArrayList<>();
    List<GroupBucket> newBuckets;
    createEcmpHashBucketChains(nextObjective, allGroupKeys, unsentGroups);
    // now we can create the buckets to add to the outermost L3 ECMP group
    newBuckets = generateNextGroupBuckets(unsentGroups, SELECT);
    // retrieve the original L3 ECMP group
    Group l3ecmpGroup = retrieveTopLevelGroup(allActiveKeys, deviceId,
                                              groupService, nextObjective.id());
    if (l3ecmpGroup == null) {
        fail(nextObjective, ObjectiveError.GROUPMISSING);
        return;
    }
    GroupKey l3ecmpGroupKey = l3ecmpGroup.appCookie();
    int l3ecmpGroupId = l3ecmpGroup.id().id();
    // Although GroupDescriptions are not necessary for adding buckets to
    // existing groups, we still use one in the GroupChainElem. When the latter is
    // processed, the info will be extracted for the bucketAdd call to groupService
    GroupDescription l3ecmpGroupDesc =
            new DefaultGroupDescription(deviceId,
                                        SELECT,
                                        new GroupBuckets(newBuckets),
                                        l3ecmpGroupKey,
                                        l3ecmpGroupId,
                                        nextObjective.appId());
    GroupChainElem l3ecmpGce = new GroupChainElem(l3ecmpGroupDesc,
                                                  unsentGroups.size(),
                                                  true,
                                                  deviceId);

    // update new bucket-chains
    List<Deque<GroupKey>> addedKeys = new ArrayList<>();
    for (Deque<GroupKey> newBucketChain : allGroupKeys) {
        newBucketChain.addFirst(l3ecmpGroupKey);
        addedKeys.add(newBucketChain);
    }
    updatePendingNextObjective(l3ecmpGroupKey,
                               new OfdpaNextGroup(addedKeys, nextObjective));
    log.debug("Adding to L3ECMP: device:{} gid:{} group key:{} nextId:{}",
            deviceId, Integer.toHexString(l3ecmpGroupId),
            l3ecmpGroupKey, nextObjective.id());
    unsentGroups.forEach(groupInfo -> {
        // send the innermost group
        log.debug("Sending innermost group {} in group chain on device {} ",
                  Integer.toHexString(groupInfo.innerMostGroupDesc().givenGroupId()),
                  deviceId);
        updatePendingGroups(groupInfo.nextGroupDesc().appCookie(), l3ecmpGce);
        groupService.addGroup(groupInfo.innerMostGroupDesc());
    });
}
 
Example 8
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private void addBucketToL2FloodGroup(NextObjective nextObj,
                                     List<Deque<GroupKey>> allActiveKeys,
                                     List<GroupInfo> groupInfos,
                                     VlanId assignedVlan) {
    Group l2FloodGroup = retrieveTopLevelGroup(allActiveKeys, deviceId,
                                               groupService, nextObj.id());

    if (l2FloodGroup == null) {
        log.warn("Can't find L2 flood group while adding bucket to it. NextObj = {}",
                 nextObj);
        fail(nextObj, ObjectiveError.GROUPMISSING);
        return;
    }

    GroupKey l2floodGroupKey = l2FloodGroup.appCookie();
    int l2floodGroupId = l2FloodGroup.id().id();
    List<GroupBucket> newBuckets = generateNextGroupBuckets(groupInfos, ALL);
    GroupDescription l2FloodGroupDescription =
            new DefaultGroupDescription(deviceId,
                                        ALL,
                                        new GroupBuckets(newBuckets),
                                        l2floodGroupKey,
                                        l2floodGroupId,
                                        nextObj.appId());
    GroupChainElem l2FloodGroupChainElement =
            new GroupChainElem(l2FloodGroupDescription,
                               groupInfos.size(),
                               true,
                               deviceId);


    //ensure assignedVlan applies to the chosen group
    VlanId floodGroupVlan = extractVlanIdFromGroupId(l2floodGroupId);
    if (!floodGroupVlan.equals(assignedVlan)) {
        log.warn("VLAN ID {} does not match Flood group {} to which bucket is "
                         + "being added, for next:{} in dev:{}. Abort.", assignedVlan,
                 Integer.toHexString(l2floodGroupId), nextObj.id(), deviceId);
        fail(nextObj, ObjectiveError.BADPARAMS);
        return;
    }
    List<Deque<GroupKey>> addedKeys = new ArrayList<>();
    groupInfos.forEach(groupInfo -> {
        // update original NextGroup with new bucket-chain
        Deque<GroupKey> newBucketChain = new ArrayDeque<>();
        newBucketChain.addFirst(groupInfo.nextGroupDesc().appCookie());
        newBucketChain.addFirst(l2floodGroupKey);
        addedKeys.add(newBucketChain);
        log.debug("Adding to L2FLOOD: device:{} gid:{} group key:{} nextId:{}",
                  deviceId, Integer.toHexString(l2floodGroupId),
                  l2floodGroupKey, nextObj.id());
        // send the innermost group
        log.debug("Sending innermost group {} in group chain on device {} ",
                  Integer.toHexString(groupInfo.innerMostGroupDesc().givenGroupId()),
                  deviceId);
        updatePendingGroups(groupInfo.nextGroupDesc().appCookie(), l2FloodGroupChainElement);

        DeviceId innerMostGroupDevice = groupInfo.innerMostGroupDesc().deviceId();
        GroupKey innerMostGroupKey = groupInfo.innerMostGroupDesc().appCookie();
        Group existsL2IGroup = groupService.getGroup(innerMostGroupDevice, innerMostGroupKey);

        if (existsL2IGroup != null) {
            // group already exist
            processPendingAddGroupsOrNextObjs(innerMostGroupKey, true);
        } else {
            groupService.addGroup(groupInfo.innerMostGroupDesc());
        }
    });

    updatePendingNextObjective(l2floodGroupKey,
                               new OfdpaNextGroup(addedKeys, nextObj));
}
 
Example 9
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private void addBucketToL3MulticastGroup(NextObjective nextObj,
                                         List<Deque<GroupKey>> allActiveKeys,
                                         List<GroupInfo> groupInfos,
                                         VlanId assignedVlan) {
    // Create the buckets to add to the outermost L3 Multicast group
    List<GroupBucket> newBuckets = createL3MulticastBucket(groupInfos);

    // get the group being edited
    Group l3mcastGroup = retrieveTopLevelGroup(allActiveKeys, deviceId,
                                               groupService, nextObj.id());
    if (l3mcastGroup == null) {
        fail(nextObj, ObjectiveError.GROUPMISSING);
        return;
    }
    GroupKey l3mcastGroupKey = l3mcastGroup.appCookie();
    int l3mcastGroupId = l3mcastGroup.id().id();

    //ensure assignedVlan applies to the chosen group
    VlanId expectedVlan = extractVlanIdFromGroupId(l3mcastGroupId);
    if (!expectedVlan.equals(assignedVlan)) {
        log.warn("VLAN ID {} does not match L3 Mcast group {} to which bucket is "
                + "being added, for next:{} in dev:{}. Abort.", assignedVlan,
                Integer.toHexString(l3mcastGroupId), nextObj.id(), deviceId);
        fail(nextObj, ObjectiveError.BADPARAMS);
    }
    GroupDescription l3mcastGroupDescription =
            new DefaultGroupDescription(deviceId,
                                        ALL,
                                        new GroupBuckets(newBuckets),
                                        l3mcastGroupKey,
                                        l3mcastGroupId,
                                        nextObj.appId());
    GroupChainElem l3mcastGce = new GroupChainElem(l3mcastGroupDescription,
                                                   groupInfos.size(),
                                                   true,
                                                   deviceId);

    List<Deque<GroupKey>> addedKeys = new ArrayList<>();
    groupInfos.forEach(groupInfo -> {
        // update original NextGroup with new bucket-chain
        Deque<GroupKey> newBucketChain = new ArrayDeque<>();
        newBucketChain.addFirst(groupInfo.innerMostGroupDesc().appCookie());
        // Add L3 interface group to the chain if there is one.
        if (!groupInfo.nextGroupDesc().equals(groupInfo.innerMostGroupDesc())) {
            newBucketChain.addFirst(groupInfo.nextGroupDesc().appCookie());
        }
        newBucketChain.addFirst(l3mcastGroupKey);
        addedKeys.add(newBucketChain);

        updatePendingGroups(groupInfo.nextGroupDesc().appCookie(), l3mcastGce);
        // Point next group to inner-most group, if any
        if (!groupInfo.nextGroupDesc().equals(groupInfo.innerMostGroupDesc())) {
            GroupChainElem innerGce = new GroupChainElem(groupInfo.nextGroupDesc(),
                                                         1,
                                                         false,
                                                         deviceId);
            updatePendingGroups(groupInfo.innerMostGroupDesc().appCookie(), innerGce);
        }
        log.debug("Adding to L3MCAST: device:{} gid:{} group key:{} nextId:{}",
                  deviceId, Integer.toHexString(l3mcastGroupId),
                  l3mcastGroupKey, nextObj.id());
        // send the innermost group
        log.debug("Sending innermost group {} in group chain on device {} ",
                  Integer.toHexString(groupInfo.innerMostGroupDesc().givenGroupId()),
                  deviceId);
        groupService.addGroup(groupInfo.innerMostGroupDesc());

    });

    updatePendingNextObjective(l3mcastGroupKey,
                               new OfdpaNextGroup(addedKeys, nextObj));
}
 
Example 10
Source File: NokiaOltPipeline.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public void next(NextObjective nextObjective) {
    if (nextObjective.type() != NextObjective.Type.BROADCAST) {
        log.error("OLT only supports broadcast groups.");
        fail(nextObjective, ObjectiveError.BADPARAMS);
    }

    if (nextObjective.next().size() != 1) {
        log.error("OLT only supports singleton broadcast groups.");
        fail(nextObjective, ObjectiveError.BADPARAMS);
    }

    TrafficTreatment treatment = nextObjective.next().stream().findFirst().get();


    GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment);
    GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));


    pendingGroups.put(key, nextObjective);

    switch (nextObjective.op()) {
        case ADD:
            GroupDescription groupDesc =
                    new DefaultGroupDescription(deviceId,
                                                GroupDescription.Type.ALL,
                                                new GroupBuckets(Collections.singletonList(bucket)),
                                                key,
                                                null,
                                                nextObjective.appId());
            groupService.addGroup(groupDesc);
            break;
        case REMOVE:
            groupService.removeGroup(deviceId, key, nextObjective.appId());
            break;
        case ADD_TO_EXISTING:
            groupService.addBucketsToGroup(deviceId, key,
                                           new GroupBuckets(Collections.singletonList(bucket)),
                                           key, nextObjective.appId());
            break;
        case REMOVE_FROM_EXISTING:
            groupService.removeBucketsFromGroup(deviceId, key,
                                                new GroupBuckets(Collections.singletonList(bucket)),
                                                key, nextObjective.appId());
            break;
        default:
            log.warn("Unknown next objective operation: {}", nextObjective.op());
    }


}
 
Example 11
Source File: CentecV350Pipeline.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public void next(NextObjective nextObjective) {
    switch (nextObjective.type()) {
        case SIMPLE:
            Collection<TrafficTreatment> treatments = nextObjective.next();
            if (treatments.size() == 1) {
                TrafficTreatment treatment = treatments.iterator().next();

                // Since we do not support strip_vlan in PORT_VLAN table, we use mod_vlan
                // to modify the packet to desired vlan.
                // Note: if we use push_vlan here, the switch will add a second VLAN tag to the outgoing
                // packet, which is not what we want.
                TrafficTreatment.Builder treatmentWithoutPushVlan = DefaultTrafficTreatment.builder();
                VlanId modVlanId;
                for (Instruction ins : treatment.allInstructions()) {
                    if (ins.type() == Instruction.Type.L2MODIFICATION) {
                        L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
                        switch (l2ins.subtype()) {
                            case ETH_DST:
                                treatmentWithoutPushVlan.setEthDst(
                                        ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac());
                                break;
                            case ETH_SRC:
                                treatmentWithoutPushVlan.setEthSrc(
                                        ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac());
                                break;
                            case VLAN_ID:
                                modVlanId = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
                                treatmentWithoutPushVlan.setVlanId(modVlanId);
                                break;
                            default:
                                break;
                        }
                    } else if (ins.type() == Instruction.Type.OUTPUT) {
                        //long portNum = ((Instructions.OutputInstruction) ins).port().toLong();
                        treatmentWithoutPushVlan.add(ins);
                    } else {
                        // Ignore the vlan_pcp action since it's does matter much.
                        log.warn("Driver does not handle this type of TrafficTreatment"
                                + " instruction in nextObjectives:  {}", ins.type());
                    }
                }

                GroupBucket bucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatmentWithoutPushVlan.build());
                final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
                GroupDescription groupDescription
                        = new DefaultGroupDescription(deviceId,
                        GroupDescription.Type.INDIRECT,
                        new GroupBuckets(Collections
                                .singletonList(bucket)),
                        key,
                        null, // let group service determine group id
                        nextObjective.appId());
                groupService.addGroup(groupDescription);
                pendingGroups.put(key, nextObjective);
            }
            break;
        case HASHED:
        case BROADCAST:
        case FAILOVER:
            fail(nextObjective, ObjectiveError.UNSUPPORTED);
            log.warn("Unsupported next objective type {}", nextObjective.type());
            break;
        default:
            fail(nextObjective, ObjectiveError.UNKNOWN);
            log.warn("Unknown next objective type {}", nextObjective.type());
    }

}
 
Example 12
Source File: OltPipeline.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public void next(NextObjective nextObjective) {
    if (nextObjective.type() != NextObjective.Type.BROADCAST) {
        log.error("OLT only supports broadcast groups.");
        fail(nextObjective, ObjectiveError.BADPARAMS);
        return;
    }

    if (nextObjective.next().size() != 1 && !nextObjective.op().equals(Objective.Operation.REMOVE)) {
        log.error("OLT only supports singleton broadcast groups.");
        fail(nextObjective, ObjectiveError.BADPARAMS);
        return;
    }

    Optional<TrafficTreatment> treatmentOpt = nextObjective.next().stream().findFirst();
    if (treatmentOpt.isEmpty() && !nextObjective.op().equals(Objective.Operation.REMOVE)) {
        log.error("Next objective {} does not have a treatment", nextObjective);
        fail(nextObjective, ObjectiveError.BADPARAMS);
        return;
    }

    GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));

    pendingGroups.put(key, nextObjective);
    log.trace("NextObjective Operation {}", nextObjective.op());
    switch (nextObjective.op()) {
        case ADD:
            GroupDescription groupDesc =
                    new DefaultGroupDescription(deviceId,
                                                GroupDescription.Type.ALL,
                                                new GroupBuckets(
                                                        Collections.singletonList(
                                                            buildBucket(treatmentOpt.get()))),
                                                key,
                                                null,
                                                nextObjective.appId());
            groupService.addGroup(groupDesc);
            break;
        case REMOVE:
            groupService.removeGroup(deviceId, key, nextObjective.appId());
            break;
        case ADD_TO_EXISTING:
            groupService.addBucketsToGroup(deviceId, key,
                                           new GroupBuckets(
                                                   Collections.singletonList(
                                                           buildBucket(treatmentOpt.get()))),
                                           key, nextObjective.appId());
            break;
        case REMOVE_FROM_EXISTING:
            groupService.removeBucketsFromGroup(deviceId, key,
                                                new GroupBuckets(
                                                        Collections.singletonList(
                                                            buildBucket(treatmentOpt.get()))),
                                                key, nextObjective.appId());
            break;
        default:
            log.warn("Unknown next objective operation: {}", nextObjective.op());
    }


}