Search in sources :

Example 6 with EncapsulationType

use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.

the class SdnIpFib method update.

private void update(ResolvedRoute route) {
    synchronized (this) {
        IpPrefix prefix = route.prefix();
        EncapsulationType encap = encap();
        MultiPointToSinglePointIntent intent = generateRouteIntent(prefix, route.nextHop(), route.nextHopMac(), encap);
        if (intent == null) {
            log.debug("No interface found for route {}", route);
            return;
        }
        routeIntents.put(prefix, intent);
        intentSynchronizer.submit(intent);
    }
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) EncapsulationType(org.onosproject.net.EncapsulationType) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent)

Example 7 with EncapsulationType

use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.

the class SdnIpFib method encapUpdate.

/*
     * Triggered when the network configuration configuration is modified.
     * It checks if the encapsulation type has changed from last time, and in
     * case modifies all intents.
     */
private void encapUpdate() {
    synchronized (this) {
        // Get the encapsulation type just set from the configuration
        EncapsulationType encap = encap();
        for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) {
            // Get each intent currently registered by SDN-IP
            MultiPointToSinglePointIntent intent = entry.getValue();
            // Make sure the same constraint is not already part of the
            // intent constraints
            List<Constraint> constraints = intent.constraints();
            if (!constraints.stream().filter(c -> c instanceof EncapsulationConstraint && new EncapsulationConstraint(encap).equals(c)).findAny().isPresent()) {
                MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder(intent);
                // Set the new encapsulation constraint
                setEncap(intentBuilder, constraints, encap);
                // Build and submit the new intent
                MultiPointToSinglePointIntent newIntent = intentBuilder.build();
                routeIntents.put(entry.getKey(), newIntent);
                intentSynchronizer.submit(newIntent);
            }
        }
    }
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) NONE(org.onosproject.net.EncapsulationType.NONE) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) LoggerFactory(org.slf4j.LoggerFactory) RouteEvent(org.onosproject.routeservice.RouteEvent) InterfaceService(org.onosproject.net.intf.InterfaceService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) Ethernet(org.onlab.packet.Ethernet) InterfaceListener(org.onosproject.net.intf.InterfaceListener) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) IntentSynchronizationService(org.onosproject.intentsync.IntentSynchronizationService) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) RouteService(org.onosproject.routeservice.RouteService) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) VlanId(org.onlab.packet.VlanId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) RouteListener(org.onosproject.routeservice.RouteListener) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) IpPrefix(org.onlab.packet.IpPrefix) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) EncapsulationType(org.onosproject.net.EncapsulationType) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent)

Example 8 with EncapsulationType

use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.

the class VplsIntentTest method generateVplsUni.

/**
 * Generates a list of expected mp2sp intents for a given VPLS.
 *
 * @param fcPoints the filtered connect point
 * @param hosts the hosts
 * @param name the name of the VPLS
 * @param encap the encapsulation type
 * @return the list of expected mp2sp intents for the given VPLS
 */
private List<MultiPointToSinglePointIntent> generateVplsUni(Set<FilteredConnectPoint> fcPoints, Set<Host> hosts, String name, EncapsulationType encap) {
    List<MultiPointToSinglePointIntent> intents = Lists.newArrayList();
    hosts.forEach(host -> {
        FilteredConnectPoint hostPoint = getHostPoint(host, fcPoints);
        Set<FilteredConnectPoint> otherPoints = fcPoints.stream().filter(fcp -> !fcp.equals(hostPoint)).collect(Collectors.toSet());
        Key uniKey = buildKey(VplsIntentUtility.PREFIX_UNICAST, host.location(), name, host.mac());
        intents.add(buildUniIntent(uniKey, otherPoints, hostPoint, host, encap));
    });
    return intents;
}
Also used : IntentServiceAdapter(org.onosproject.net.intent.IntentServiceAdapter) MockIdGenerator(org.onosproject.net.intent.MockIdGenerator) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) NONE(org.onosproject.net.EncapsulationType.NONE) VplsData(org.onosproject.vpls.api.VplsData) InterfaceService(org.onosproject.net.intf.InterfaceService) IntentUtils(org.onosproject.net.intent.IntentUtils) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceListener(org.onosproject.net.intf.InterfaceListener) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) After(org.junit.After) Map(java.util.Map) Intent(org.onosproject.net.intent.Intent) EasyMock.replay(org.easymock.EasyMock.replay) EasyMock.createMock(org.easymock.EasyMock.createMock) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) Before(org.junit.Before) EasyMock.anyObject(org.easymock.EasyMock.anyObject) ImmutableSet(com.google.common.collect.ImmutableSet) VLAN(org.onosproject.net.EncapsulationType.VLAN) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) VplsIntentUtility(org.onosproject.vpls.intent.VplsIntentUtility) EasyMock.expect(org.easymock.EasyMock.expect) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) EasyMock.expectLastCall(org.easymock.EasyMock.expectLastCall) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) MacAddress(org.onlab.packet.MacAddress) Assert.assertEquals(org.junit.Assert.assertEquals) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 9 with EncapsulationType

use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.

the class VplsIntentUtility method setEncap.

/**
 * Sets one or more encapsulation constraints on the intent builder given.
 *
 * @param builder the intent builder
 * @param constraints the existing intent constraints
 * @param encap the encapsulation type to be set
 */
public static void setEncap(ConnectivityIntent.Builder builder, List<Constraint> constraints, EncapsulationType encap) {
    // Constraints might be an immutable list, so a new modifiable list
    // is created
    List<Constraint> newConstraints = new ArrayList<>(constraints);
    // Remove any encapsulation constraint if already in the list
    constraints.stream().filter(c -> c instanceof EncapsulationConstraint).forEach(newConstraints::remove);
    // constraint should be added to the list
    if (!encap.equals(NONE)) {
        newConstraints.add(new EncapsulationConstraint(encap));
    }
    // Submit new constraint list as immutable list
    builder.constraints(ImmutableList.copyOf(newConstraints));
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) LoggerFactory(org.slf4j.LoggerFactory) VplsData(org.onosproject.vpls.api.VplsData) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) MacAddress(org.onlab.packet.MacAddress) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) ArrayList(java.util.ArrayList)

Example 10 with EncapsulationType

use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.

the class SimpleFabricRouting method buildConstraints.

// constraints generator
private List<Constraint> buildConstraints(List<Constraint> constraints, EncapsulationType encap) {
    if (!encap.equals(EncapsulationType.NONE)) {
        List<Constraint> newConstraints = new ArrayList<>(constraints);
        constraints.stream().filter(c -> c instanceof EncapsulationConstraint).forEach(newConstraints::remove);
        newConstraints.add(new EncapsulationConstraint(encap));
        return ImmutableList.copyOf(newConstraints);
    }
    return constraints;
}
Also used : HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) REACTIVE_MATCH_IP_PROTO(org.onosproject.simplefabric.api.Constants.REACTIVE_MATCH_IP_PROTO) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) Interface(org.onosproject.net.intf.Interface) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) ALLOW_ETH_ADDRESS_SELECTOR(org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR) ROUTING_APP_ID(org.onosproject.simplefabric.api.Constants.ROUTING_APP_ID) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) FlowRuleService(org.onosproject.net.flow.FlowRuleService) SimpleFabricEvent(org.onosproject.simplefabric.api.SimpleFabricEvent) ApplicationId(org.onosproject.core.ApplicationId) Ip4Prefix(org.onlab.packet.Ip4Prefix) PRI_REACTIVE_BORDER_STEP(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_STEP) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) ALLOW_IPV6(org.onosproject.simplefabric.api.Constants.ALLOW_IPV6) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) ICMP(org.onlab.packet.ICMP) PacketService(org.onosproject.net.packet.PacketService) Constraint(org.onosproject.net.intent.Constraint) EthType(org.onlab.packet.EthType) Key(org.onosproject.net.intent.Key) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) EncapsulationType(org.onosproject.net.EncapsulationType) REACTIVE_SINGLE_TO_SINGLE(org.onosproject.simplefabric.api.Constants.REACTIVE_SINGLE_TO_SINGLE) FlowRule(org.onosproject.net.flow.FlowRule) PacketContext(org.onosproject.net.packet.PacketContext) LinkService(org.onosproject.net.link.LinkService) PRI_REACTIVE_BORDER_INTERCEPT(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_INTERCEPT) DeviceId(org.onosproject.net.DeviceId) PRI_REACTIVE_LOCAL_FORWARD(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_FORWARD) IpPrefix(org.onlab.packet.IpPrefix) REACTIVE_HASHED_PATH_SELECTION(org.onosproject.simplefabric.api.Constants.REACTIVE_HASHED_PATH_SELECTION) ICMP6(org.onlab.packet.ICMP6) Host(org.onosproject.net.Host) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SimpleFabricListener(org.onosproject.simplefabric.api.SimpleFabricListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) FabricRoute(org.onosproject.simplefabric.api.FabricRoute) PRI_REACTIVE_BORDER_FORWARD(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_FORWARD) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IpAddress(org.onlab.packet.IpAddress) SimpleFabricService(org.onosproject.simplefabric.api.SimpleFabricService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PrintStream(java.io.PrintStream) PRI_REACTIVE_BORDER_BASE(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_BASE) Logger(org.slf4j.Logger) PRI_REACTIVE_LOCAL_INTERCEPT(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_INTERCEPT) VlanId(org.onlab.packet.VlanId) FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) Ip6Prefix(org.onlab.packet.Ip6Prefix) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) REACTIVE_ALLOW_LINK_CP(org.onosproject.simplefabric.api.Constants.REACTIVE_ALLOW_LINK_CP) MacAddress(org.onlab.packet.MacAddress) PacketPriority(org.onosproject.net.packet.PacketPriority) Reference(org.osgi.service.component.annotations.Reference) Comparator(java.util.Comparator) Collections(java.util.Collections) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) Constraint(org.onosproject.net.intent.Constraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) ArrayList(java.util.ArrayList)

Aggregations

EncapsulationType (org.onosproject.net.EncapsulationType)24 ConnectPoint (org.onosproject.net.ConnectPoint)16 List (java.util.List)15 Set (java.util.Set)15 VlanId (org.onlab.packet.VlanId)15 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)15 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 EncapsulationConstraint (org.onosproject.net.intent.constraint.EncapsulationConstraint)15 ImmutableList (com.google.common.collect.ImmutableList)13 ApplicationId (org.onosproject.core.ApplicationId)13 Intent (org.onosproject.net.intent.Intent)13 Collectors (java.util.stream.Collectors)12 CoreService (org.onosproject.core.CoreService)12 Ethernet (org.onlab.packet.Ethernet)11 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)11 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)11 Collection (java.util.Collection)10 Assert.assertTrue (org.junit.Assert.assertTrue)9 Before (org.junit.Before)9 Test (org.junit.Test)9