Search in sources :

Example 1 with INITIATION

use of org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Pipeline.INITIATION in project trellis-control by opennetworkinglab.

the class DefaultL2TunnelHandler method deployPseudoWireTerm.

/**
 * Handles the tunnel termination, which consists in the creation
 * of a forwarding objective and a next objective.
 *
 * @param l2Tunnel   the tunnel to terminate
 * @param egress     the egress point
 * @param egressVlan the expected vlan at egress
 * @param direction  the direction
 * @return the result of the operation
 */
private Result deployPseudoWireTerm(L2Tunnel l2Tunnel, ConnectPoint egress, VlanId egressVlan, Direction direction, boolean oneHop) {
    log.debug("Started deploying termination objectives for pseudowire {} , direction {}.", l2Tunnel.tunnelId(), direction == FWD ? "forward" : "reverse");
    // We create the group relative to the termination.
    NextObjective.Builder nextObjectiveBuilder = createNextObjective(TERMINATION, egress, null, l2Tunnel, egress.deviceId(), oneHop, egressVlan);
    if (nextObjectiveBuilder == null) {
        return INTERNAL_ERROR;
    }
    TrafficSelector metadata = DefaultTrafficSelector.builder().matchVlanId(egressVlan).build();
    nextObjectiveBuilder.withMeta(metadata);
    int nextId = srManager.flowObjectiveService.allocateNextId();
    if (nextId < 0) {
        log.warn("Not able to allocate a next id for initiation");
        return INTERNAL_ERROR;
    }
    nextObjectiveBuilder.withId(nextId);
    String key = generateKey(l2Tunnel.tunnelId(), direction);
    l2TerminationNextObjStore.put(key, nextObjectiveBuilder.add());
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("Termination l2 tunnel rule for {} populated", l2Tunnel.tunnelId()), (objective, error) -> {
        log.warn("Failed to populate termination l2 tunnel rule for {}: {}", l2Tunnel.tunnelId(), error);
        srManager.invalidateNextObj(objective.id());
    });
    NextObjective nextObjective = nextObjectiveBuilder.add(context);
    srManager.flowObjectiveService.next(egress.deviceId(), nextObjective);
    log.debug("Termination next objective for {} not found. Creating new NextObj with id={}", l2Tunnel.tunnelId(), nextObjective.id());
    // We create the flow relative to the termination.
    ForwardingObjective.Builder fwdBuilder = createTermFwdObjective(l2Tunnel.pwLabel(), l2Tunnel.tunnelId(), egress.port(), nextObjective.id());
    context = new DefaultObjectiveContext((objective) -> log.debug("FwdObj for tunnel termination {} populated", l2Tunnel.tunnelId()), (objective, error) -> log.warn("Failed to populate fwdrObj" + " for tunnel termination {} : {}", l2Tunnel.tunnelId(), error));
    srManager.flowObjectiveService.forward(egress.deviceId(), fwdBuilder.add(context));
    log.debug("Creating new FwdObj for termination NextObj with id={} for tunnel {}", nextId, l2Tunnel.tunnelId());
    return SUCCESS;
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) ConsistentMap(org.onosproject.store.service.ConsistentMap) REV(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Direction.REV) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) PwaasUtil(org.onosproject.segmentrouting.pwaas.PwaasUtil) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) FWD(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Direction.FWD) NextObjective(org.onosproject.net.flowobjective.NextObjective) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) Result(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Result) DefaultLink(org.onosproject.net.DefaultLink) Serializer(org.onosproject.store.service.Serializer) ImmutableMap(com.google.common.collect.ImmutableMap) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) SRLinkWeigher(org.onosproject.segmentrouting.SRLinkWeigher) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Set(java.util.Set) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Collectors(java.util.stream.Collectors) Versioned(org.onosproject.store.service.Versioned) List(java.util.List) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) Path(org.onosproject.net.Path) TERMINATION(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Pipeline.TERMINATION) DeviceId(org.onosproject.net.DeviceId) DistributedLock(org.onosproject.store.service.DistributedLock) RandomUtils(org.apache.commons.lang3.RandomUtils) Iterables(com.google.common.collect.Iterables) StorageException(org.onosproject.store.service.StorageException) CompletableFuture(java.util.concurrent.CompletableFuture) KryoNamespace(org.onlab.util.KryoNamespace) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) VERSATILE(org.onosproject.net.flowobjective.ForwardingObjective.Flag.VERSATILE) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) SegmentRoutingManager(org.onosproject.segmentrouting.SegmentRoutingManager) Logger(org.slf4j.Logger) MplsLabel(org.onlab.packet.MplsLabel) INITIATION(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Pipeline.INITIATION) VlanId(org.onlab.packet.VlanId) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) LinkWeigher(org.onosproject.net.topology.LinkWeigher) 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) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 2 with INITIATION

use of org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Pipeline.INITIATION in project trellis-control by opennetworkinglab.

the class DefaultL2TunnelHandler method deployPolicy.

/**
 * Handles the policy establishment which consists in
 * create the filtering and forwarding objectives related
 * to the initiation and termination.
 *
 * @param tunnelId     the tunnel id
 * @param ingress      the ingress point
 * @param ingressInner the ingress inner tag
 * @param ingressOuter the ingress outer tag
 * @param egressVlan   Vlan-id to set, depends on ingress vlan
 *                     combinations. For example, if pw is double tagged
 *                     then this is the value of the outer vlan, if single
 *                     tagged then it is the new value of the single tag.
 *                     Should be None for untagged traffic.
 * @param nextId       the next objective id
 * @return the result of the operation
 */
private Result deployPolicy(long tunnelId, ConnectPoint ingress, VlanId ingressInner, VlanId ingressOuter, VlanId egressVlan, int nextId) {
    log.debug("Starting deploying policy for pseudowire {}.", tunnelId);
    List<Objective> objectives = Lists.newArrayList();
    // We create the forwarding objective for supporting
    // the l2 tunnel.
    ForwardingObjective.Builder fwdBuilder = createInitFwdObjective(tunnelId, ingress.port(), nextId);
    // We create and add objective context.
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("FwdObj for tunnel {} populated", tunnelId), (objective, error) -> log.warn("Failed to populate fwdObj " + "for tunnel {} : {}", tunnelId, error));
    objectives.add(fwdBuilder.add(context));
    // We create the filtering objective to define the
    // permit traffic in the switch
    FilteringObjective.Builder filtBuilder = createFiltObjective(ingress.port(), ingressInner, ingressOuter);
    // We add the metadata.
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setTunnelId(tunnelId).setVlanId(egressVlan);
    filtBuilder.withMeta(treatment.build());
    // We create and add objective context.
    context = new DefaultObjectiveContext((objective) -> log.debug("FilterObj for tunnel {} populated", tunnelId), (objective, error) -> log.warn("Failed to populate filterObj for " + "tunnel {} : {}", tunnelId, error));
    objectives.add(filtBuilder.add(context));
    for (Objective objective : objectives) {
        if (objective instanceof ForwardingObjective) {
            srManager.flowObjectiveService.forward(ingress.deviceId(), (ForwardingObjective) objective);
            log.debug("Creating new FwdObj for initiation NextObj with id={} for tunnel {}", nextId, tunnelId);
        } else {
            srManager.flowObjectiveService.filter(ingress.deviceId(), (FilteringObjective) objective);
            log.debug("Creating new FiltObj for tunnel {}", tunnelId);
        }
    }
    return SUCCESS;
}
Also used : DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) ConsistentMap(org.onosproject.store.service.ConsistentMap) REV(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Direction.REV) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) PwaasUtil(org.onosproject.segmentrouting.pwaas.PwaasUtil) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) FWD(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Direction.FWD) NextObjective(org.onosproject.net.flowobjective.NextObjective) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) Result(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Result) DefaultLink(org.onosproject.net.DefaultLink) Serializer(org.onosproject.store.service.Serializer) ImmutableMap(com.google.common.collect.ImmutableMap) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) SRLinkWeigher(org.onosproject.segmentrouting.SRLinkWeigher) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Set(java.util.Set) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Collectors(java.util.stream.Collectors) Versioned(org.onosproject.store.service.Versioned) List(java.util.List) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) Path(org.onosproject.net.Path) TERMINATION(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Pipeline.TERMINATION) DeviceId(org.onosproject.net.DeviceId) DistributedLock(org.onosproject.store.service.DistributedLock) RandomUtils(org.apache.commons.lang3.RandomUtils) Iterables(com.google.common.collect.Iterables) StorageException(org.onosproject.store.service.StorageException) CompletableFuture(java.util.concurrent.CompletableFuture) KryoNamespace(org.onlab.util.KryoNamespace) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) VERSATILE(org.onosproject.net.flowobjective.ForwardingObjective.Flag.VERSATILE) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) SegmentRoutingManager(org.onosproject.segmentrouting.SegmentRoutingManager) Logger(org.slf4j.Logger) MplsLabel(org.onlab.packet.MplsLabel) INITIATION(org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Pipeline.INITIATION) VlanId(org.onlab.packet.VlanId) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) LinkWeigher(org.onosproject.net.topology.LinkWeigher) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)2 Iterables (com.google.common.collect.Iterables)2 Lists (com.google.common.collect.Lists)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Collectors (java.util.stream.Collectors)2 RandomUtils (org.apache.commons.lang3.RandomUtils)2 Ethernet (org.onlab.packet.Ethernet)2 MacAddress (org.onlab.packet.MacAddress)2 MplsLabel (org.onlab.packet.MplsLabel)2 VlanId (org.onlab.packet.VlanId)2 KryoNamespace (org.onlab.util.KryoNamespace)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 DefaultLink (org.onosproject.net.DefaultLink)2 DeviceId (org.onosproject.net.DeviceId)2 Link (org.onosproject.net.Link)2 Path (org.onosproject.net.Path)2