Search in sources :

Example 1 with FWD

use of org.onosproject.segmentrouting.pwaas.L2TunnelHandler.Direction.FWD 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)

Aggregations

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