Search in sources :

Example 56 with DefaultGroupDescription

use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.

the class OvsOfdpaGroupHandler method createUnfilteredL2L3Chain.

/**
 * Internal implementation of createL2L3Chain to handle double-tagged vlan.
 * L3UG Group carries dummyVlanId and output port information in its groupId,
 * and does not set vlan.
 * L2UG Group only has OUTPUT instruction.
 *
 * @param treatment that needs to be broken up to create the group chain
 * @param nextId of the next objective that needs this group chain
 * @param appId of the application that sent this next objective
 * @return GroupInfo containing the GroupDescription of the
 *         L2 Unfiltered Interface group(inner) and the GroupDescription of the (outer)
 *         L3Unicast group. May return null if there is an error in processing the chain.
 */
private GroupInfo createUnfilteredL2L3Chain(TrafficTreatment treatment, int nextId, ApplicationId appId) {
    // for the l2 unfiltered interface group, get port info
    // for the l3 unicast group, get the src/dst mac, and vlan info
    TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder innerTtb = DefaultTrafficTreatment.builder();
    VlanId vlanId = VlanId.NONE;
    long portNum = 0;
    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();
                    break;
                default:
                    break;
            }
        } else if (ins.type() == Instruction.Type.OUTPUT) {
            portNum = ((Instructions.OutputInstruction) ins).port().toLong();
            innerTtb.add(ins);
        } else {
            log.debug("Driver does not handle this type of TrafficTreatment" + " instruction in l2l3chain:  {} - {}", ins.type(), ins);
        }
    }
    // assemble information for ofdpa l2 unfiltered interface group
    int l2groupId = l2UnfilteredGroupId(portNum);
    // a globally unique groupkey that is different for ports in the same device,
    // but different for the same portnumber on different devices. Also different
    // for the various group-types created out of the same next objective.
    int l2gk = l2UnfilteredGroupKey(deviceId, portNum);
    final GroupKey l2groupkey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l2gk));
    // assemble information for outer group (L3Unicast)
    GroupDescription outerGrpDesc;
    int l3groupId = doubleVlanL3UnicastGroupId(vlanId, portNum);
    final GroupKey l3groupkey = new DefaultGroupKey(Ofdpa3Pipeline.appKryo.serialize(doubleVlanL3UnicastGroupKey(deviceId, vlanId, portNum)));
    outerTtb.group(new GroupId(l2groupId));
    // create the l3unicast group description to wait for the
    // l2 unfiltered interface group to be processed
    GroupBucket l3unicastGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());
    outerGrpDesc = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l3unicastGroupBucket)), l3groupkey, l3groupId, appId);
    log.debug("Trying L3Unicast: device:{} gid:{} gkey:{} nextid:{}", deviceId, Integer.toHexString(l3groupId), l3groupkey, nextId);
    // store l2groupkey with the groupChainElem for the outer-group that depends on it
    OfdpaGroupHandlerUtility.GroupChainElem gce = new OfdpaGroupHandlerUtility.GroupChainElem(outerGrpDesc, 1, false, deviceId);
    updatePendingGroups(l2groupkey, gce);
    // create group description for the inner l2 unfiltered interface group
    GroupBucket l2InterfaceGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(innerTtb.build());
    GroupDescription l2groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l2InterfaceGroupBucket)), l2groupkey, l2groupId, appId);
    log.debug("Trying L2Unfiltered: device:{} gid:{} gkey:{} nextId:{}", deviceId, Integer.toHexString(l2groupId), l2groupkey, nextId);
    return new OfdpaGroupHandlerUtility.GroupInfo(l2groupDescription, outerGrpDesc);
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instructions(org.onosproject.net.flow.instructions.Instructions) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MacAddress(org.onlab.packet.MacAddress) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) OfdpaGroupHandlerUtility(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) VlanId(org.onlab.packet.VlanId)

Example 57 with DefaultGroupDescription

use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.

the class SimpleGroupStoreTest method testGroupOperationFailure.

@Test
public void testGroupOperationFailure() {
    simpleGroupStore.deviceInitialAuditCompleted(D1, true);
    ApplicationId appId = new DefaultApplicationId(2, "org.groupstore.test");
    GroupKey key = new DefaultGroupKey("group1".getBytes());
    PortNumber[] ports = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
    List<PortNumber> outPorts = new ArrayList<>();
    outPorts.add(ports[0]);
    outPorts.add(ports[1]);
    List<GroupBucket> buckets = new ArrayList<>();
    for (PortNumber portNumber : outPorts) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
        buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
    }
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    GroupDescription groupDesc = new DefaultGroupDescription(D1, Group.Type.SELECT, groupBuckets, key, null, appId);
    InternalGroupStoreDelegate checkStoreGroupDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_REQUESTED);
    simpleGroupStore.setDelegate(checkStoreGroupDelegate);
    // Testing storeGroup operation
    simpleGroupStore.storeGroupDescription(groupDesc);
    simpleGroupStore.unsetDelegate(checkStoreGroupDelegate);
    // Testing Group add operation failure
    Group createdGroup = simpleGroupStore.getGroup(D1, key);
    checkStoreGroupDelegate.verifyGroupId(createdGroup.id());
    GroupOperation groupAddOp = GroupOperation.createAddGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupAddFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_FAILED);
    simpleGroupStore.setDelegate(checkGroupAddFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupAddOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupAddFailureDelegate);
    GroupOperation groupModOp = GroupOperation.createModifyGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupModFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_UPDATE_FAILED);
    simpleGroupStore.setDelegate(checkGroupModFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupModOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupModFailureDelegate);
    GroupOperation groupDelOp = GroupOperation.createDeleteGroupOperation(createdGroup.id(), createdGroup.type());
    InternalGroupStoreDelegate checkGroupDelFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_REMOVE_FAILED);
    simpleGroupStore.setDelegate(checkGroupDelFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupDelOp);
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ArrayList(java.util.ArrayList) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) PortNumber(org.onosproject.net.PortNumber) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupOperation(org.onosproject.net.group.GroupOperation) Test(org.junit.Test)

Example 58 with DefaultGroupDescription

use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.

the class KubevirtGroupRuleManager method setRule.

@Override
public void setRule(ApplicationId appId, DeviceId deviceId, int groupId, GroupDescription.Type type, List<GroupBucket> buckets, boolean install) {
    Group group = groupService.getGroup(deviceId, getGroupKey(groupId));
    if (install) {
        if (group == null) {
            GroupDescription groupDesc = new DefaultGroupDescription(deviceId, type, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId);
            groupService.addGroup(groupDesc);
            log.debug("Adding group table rule {}", groupId);
        }
    } else {
        if (group != null) {
            groupService.removeGroup(deviceId, getGroupKey(groupId), appId);
            log.debug("Removing group table rule {}", groupId);
        }
    }
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) Group(org.onosproject.net.group.Group) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 59 with DefaultGroupDescription

use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.

the class DefaultOFSwitch method processGroupMod.

private void processGroupMod(OFGroupMod groupMod) {
    log.debug("processing GROUP_MOD {} message", groupMod.getCommand());
    ApplicationId appId = ofSwitchService.appId();
    GroupKey appCookie = new DefaultGroupKey(networkId.toString().getBytes());
    switch(groupMod.getCommand()) {
        case ADD:
            // TODO return OFGroupModFailedCode.GROUP_EXISTS if group already exists
            int groupId = groupMod.getGroup().getGroupNumber();
            OFGroupAdd groupAdd = (OFGroupAdd) groupMod;
            GroupBuckets groupAddBuckets = new OFAgentVirtualGroupBucketEntryBuilder(Dpid.dpid(Dpid.uri(dpid().getLong())), groupAdd.getBuckets(), groupAdd.getGroupType(), driverService).build();
            GroupDescription groupDescription = new DefaultGroupDescription(deviceId, getGroupType(groupAdd.getGroupType()), groupAddBuckets, appCookie, groupId, appId);
            groupService.addGroup(groupDescription);
            break;
        case MODIFY:
            // TODO return OFGroupModFailedCode.INVALID_GROUP if group does not exist
            OFGroupModify groupModify = (OFGroupModify) groupMod;
            GroupBuckets groupModifyBuckets = new OFAgentVirtualGroupBucketEntryBuilder(Dpid.dpid(Dpid.uri(dpid().getLong())), groupModify.getBuckets(), groupModify.getGroupType(), driverService).build();
            groupService.setBucketsForGroup(deviceId, appCookie, groupModifyBuckets, appCookie, appId);
            break;
        case DELETE:
            groupService.removeGroup(deviceId, appCookie, appId);
            break;
        default:
            // INSERT_BUCKET, REMOVE_BUCKET are effective OF 1.5.  OFAgent supports 1.3.
            log.warn("Unsupported GROUP_MOD {} message received for switch {}", groupMod.getCommand(), this);
    }
}
Also used : GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) OFGroupAdd(org.projectfloodlight.openflow.protocol.OFGroupAdd) OFGroupModify(org.projectfloodlight.openflow.protocol.OFGroupModify) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ApplicationId(org.onosproject.core.ApplicationId) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 60 with DefaultGroupDescription

use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.

the class OpenstackGroupRuleManager method setRule.

@Override
public void setRule(ApplicationId appId, DeviceId deviceId, int groupId, GroupDescription.Type type, List<GroupBucket> buckets, boolean install) {
    Group group = groupService.getGroup(deviceId, getGroupKey(groupId));
    if (install) {
        if (group == null) {
            GroupDescription groupDesc = new DefaultGroupDescription(deviceId, type, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId);
            groupService.addGroup(groupDesc);
            log.debug("Adding group table rule {}", groupId);
        }
    } else {
        if (group != null) {
            groupService.removeGroup(deviceId, getGroupKey(groupId), appId);
            log.debug("Removing group table rule {}", groupId);
        }
    }
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) Group(org.onosproject.net.group.Group) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Aggregations

DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)67 GroupBuckets (org.onosproject.net.group.GroupBuckets)61 GroupBucket (org.onosproject.net.group.GroupBucket)56 GroupDescription (org.onosproject.net.group.GroupDescription)54 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)47 GroupKey (org.onosproject.net.group.GroupKey)45 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)40 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)39 GroupId (org.onosproject.core.GroupId)21 Group (org.onosproject.net.group.Group)21 ArrayList (java.util.ArrayList)18 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)15 PortNumber (org.onosproject.net.PortNumber)14 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)14 ArrayDeque (java.util.ArrayDeque)13 Deque (java.util.Deque)13 TrafficSelector (org.onosproject.net.flow.TrafficSelector)13 DefaultGroup (org.onosproject.net.group.DefaultGroup)13 VlanId (org.onlab.packet.VlanId)10