Search in sources :

Example 1 with PortNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class DefaultGroupHandler method getPortNextObjectiveId.

/**
 * Returns the next objective of type simple associated with the port on the
 * device, given the treatment. Different treatments to the same port result
 * in different next objectives. If no such objective exists, this method
 * creates one (if requested) and returns the id. Optionally metadata can be passed in for
 * the creation of the objective. Typically this is used for L2 and L3 forwarding
 * to compute nodes and containers/VMs on the compute nodes directly attached
 * to the switch.
 *
 * @param portNum the port number for the simple next objective
 * @param treatment the actions to apply on the packets (should include outport)
 * @param meta optional metadata passed into the creation of the next objective
 * @param createIfMissing true if a next object should be created if not found
 * @return int if found or created, -1 if there are errors during the
 *          creation of the next objective.
 */
public int getPortNextObjectiveId(PortNumber portNum, TrafficTreatment treatment, TrafficSelector meta, boolean createIfMissing) {
    Integer nextId = portNextObjStore.get(new PortNextObjectiveStoreKey(deviceId, portNum, treatment, meta));
    if (nextId != null) {
        return nextId;
    }
    log.debug("getPortNextObjectiveId in device {}: Next objective id " + "not found for port: {} .. {}", deviceId, portNum, (createIfMissing) ? "creating" : "aborting");
    if (!createIfMissing) {
        return -1;
    }
    // create missing next objective
    createGroupFromPort(portNum, treatment, meta);
    nextId = portNextObjStore.get(new PortNextObjectiveStoreKey(deviceId, portNum, treatment, meta));
    if (nextId == null) {
        log.warn("getPortNextObjectiveId: unable to create next obj" + "for dev:{} port:{}", deviceId, portNum);
        return -1;
    }
    return nextId;
}
Also used : PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey)

Example 2 with PortNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class DefaultGroupHandler method createGroupFromPort.

/**
 * Create simple next objective for a single port. The treatments can include
 * all outgoing actions that need to happen on the packet.
 *
 * @param portNum  the outgoing port on the device
 * @param treatment the actions to apply on the packets (should include outport)
 * @param meta optional data to pass to the driver
 */
public void createGroupFromPort(PortNumber portNum, TrafficTreatment treatment, TrafficSelector meta) {
    int nextId = flowObjectiveService.allocateNextId();
    PortNextObjectiveStoreKey key = new PortNextObjectiveStoreKey(deviceId, portNum, treatment, meta);
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder().withId(nextId).withType(NextObjective.Type.SIMPLE).addTreatment(treatment).fromApp(appId).withMeta(meta);
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("createGroupFromPort installed " + "NextObj {} on {}", nextId, deviceId), (objective, error) -> {
        log.warn("createGroupFromPort failed to install NextObj {} on {}: {}", nextId, deviceId, error);
        srManager.invalidateNextObj(objective.id());
    });
    NextObjective nextObj = nextObjBuilder.add(context);
    flowObjectiveService.next(deviceId, nextObj);
    log.debug("createGroupFromPort: Submited next objective {} in device {} " + "for port {}", nextId, deviceId, portNum);
    portNextObjStore.put(key, nextId);
}
Also used : PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 3 with PortNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class DefaultGroupHandler method updateL2InterfaceGroupBucket.

/**
 * Modifies L2IG bucket when the interface configuration is updated, especially
 * when the interface has same VLAN ID but the VLAN type is changed (e.g., from
 * vlan-tagged [10] to vlan-untagged 10), which requires changes on
 * TrafficTreatment in turn.
 *
 * @param portNumber the port on this device that needs to be updated
 * @param vlanId the vlan id corresponding to this port
 * @param pushVlan indicates if packets should be sent out untagged or not out
 *                 from the port. If true, updated TrafficTreatment involves
 *                 pop vlan tag action. If false, updated TrafficTreatment
 *                 does not involve pop vlan tag action.
 */
public void updateL2InterfaceGroupBucket(PortNumber portNumber, VlanId vlanId, boolean pushVlan) {
    TrafficTreatment.Builder oldTBuilder = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
    tBuilder.setOutput(portNumber);
    oldTBuilder.setOutput(portNumber);
    if (pushVlan) {
        tBuilder.popVlan();
    } else {
        oldTBuilder.popVlan();
    }
    TrafficSelector metadata = DefaultTrafficSelector.builder().matchVlanId(vlanId).build();
    // Update portNextObjStore with new L2IG
    int nextId = getPortNextObjectiveId(portNumber, oldTBuilder.build(), metadata, false);
    portNextObjStore.remove(new PortNextObjectiveStoreKey(deviceId, portNumber, oldTBuilder.build(), metadata));
    portNextObjStore.put(new PortNextObjectiveStoreKey(deviceId, portNumber, tBuilder.build(), metadata), nextId);
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder().withId(nextId).withType(NextObjective.Type.SIMPLE).fromApp(appId).addTreatment(tBuilder.build()).withMeta(metadata);
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("port {} successfully updated NextObj {} on {}", portNumber, nextId, deviceId), (objective, error) -> {
        log.warn("port {} failed to updated NextObj {} on {}: {}", portNumber, nextId, deviceId, error);
        srManager.invalidateNextObj(objective.id());
    });
    flowObjectiveService.next(deviceId, nextObjBuilder.modify(context));
}
Also used : PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 4 with PortNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class DefaultGroupHandler method removeGroupFromPort.

/**
 * Remove simple next objective for a single port. The treatments can include
 * all outgoing actions that need to happen on the packet.
 *
 * @param portNum  the outgoing port on the device
 * @param treatment the actions applied on the packets (should include outport)
 * @param meta optional data to pass to the driver
 * @return a completable future that completes when the port has been removed
 */
public CompletableFuture<Objective> removeGroupFromPort(PortNumber portNum, TrafficTreatment treatment, TrafficSelector meta) {
    PortNextObjectiveStoreKey key = new PortNextObjectiveStoreKey(deviceId, portNum, treatment, meta);
    Integer nextId = portNextObjStore.get(key);
    CompletableFuture<Objective> future = new CompletableFuture<>();
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder().withId(nextId).withType(NextObjective.Type.SIMPLE).addTreatment(treatment).fromApp(appId).withMeta(meta);
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> {
        log.info("removeGroupFromPort done " + "NextObj {} on {}", nextId, deviceId);
        future.complete(objective);
    }, (objective, error) -> {
        log.warn("removeGroupFromPort failed to install NextObj {} on {}: {}", nextId, deviceId, error);
        srManager.invalidateNextObj(objective.id());
        future.complete(null);
    });
    NextObjective nextObj = nextObjBuilder.remove(context);
    flowObjectiveService.next(deviceId, nextObj);
    log.info("removeGroupFromPort: Submitted next objective {} in device {} " + "for port {}", nextId, deviceId, portNum);
    portNextObjStore.remove(key);
    return future;
}
Also used : PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) Objective(org.onosproject.net.flowobjective.Objective) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext)

Example 5 with PortNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class DefaultGroupHandler method removePortNextObjective.

/**
 * Removes simple next objective for a single port.
 *
 * @param deviceId device id that has the port to deal with
 * @param portNum the outgoing port on the device
 * @param vlanId vlan id associated with the port
 * @param popVlan true if POP_VLAN action is applied on the packets, false otherwise
 */
public void removePortNextObjective(DeviceId deviceId, PortNumber portNum, VlanId vlanId, boolean popVlan) {
    TrafficSelector.Builder mbuilder = DefaultTrafficSelector.builder();
    mbuilder.matchVlanId(vlanId);
    TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder();
    tbuilder.immediate().setOutput(portNum);
    if (popVlan) {
        tbuilder.immediate().popVlan();
    }
    int portNextObjId = srManager.getPortNextObjectiveId(deviceId, portNum, tbuilder.build(), mbuilder.build(), false);
    PortNextObjectiveStoreKey key = new PortNextObjectiveStoreKey(deviceId, portNum, tbuilder.build(), mbuilder.build());
    if (portNextObjId != -1 && portNextObjStore.containsKey(key)) {
        NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder().withId(portNextObjId).withType(NextObjective.Type.SIMPLE).addTreatment(tbuilder.build()).fromApp(appId).withMeta(mbuilder.build());
        ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("removePortNextObjective removes NextObj {} on {}", portNextObjId, deviceId), (objective, error) -> {
            log.warn("removePortNextObjective failed to remove NextObj {} on {}: {}", portNextObjId, deviceId, error);
            srManager.invalidateNextObj(objective.id());
        });
        NextObjective nextObjective = nextObjBuilder.remove(context);
        log.info("**removePortNextObjective: Submitted " + "next objective {} in device {}", portNextObjId, deviceId);
        flowObjectiveService.next(deviceId, nextObjective);
        portNextObjStore.remove(key);
    }
}
Also used : PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

PortNextObjectiveStoreKey (org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey)6 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)4 DefaultObjectiveContext (org.onosproject.net.flowobjective.DefaultObjectiveContext)4 NextObjective (org.onosproject.net.flowobjective.NextObjective)4 ObjectiveContext (org.onosproject.net.flowobjective.ObjectiveContext)4 ConnectPoint (org.onosproject.net.ConnectPoint)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 CompletableFuture (java.util.concurrent.CompletableFuture)1 Objective (org.onosproject.net.flowobjective.Objective)1 NextNeighbors (org.onosproject.segmentrouting.grouphandler.NextNeighbors)1 McastHandler (org.onosproject.segmentrouting.mcast.McastHandler)1 DefaultL2Tunnel (org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel)1 DefaultL2TunnelHandler (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler)1 DefaultL2TunnelPolicy (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy)1 L2Tunnel (org.onosproject.segmentrouting.pwaas.L2Tunnel)1 L2TunnelPolicy (org.onosproject.segmentrouting.pwaas.L2TunnelPolicy)1 DestinationSetNextObjectiveStoreKey (org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey)1