Search in sources :

Example 1 with EncapsulationType

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

the class SdnIpCommand method setEncap.

/**
 * Sets the encapsulation type for SDN-IP.
 *
 * @param encap the encapsulation type
 */
private void setEncap(String encap) {
    EncapsulationType encapType = EncapsulationType.enumFromString(encap);
    if (encapType.equals(EncapsulationType.NONE) && !encapType.toString().equals(encap)) {
        print(ENCAP_NOT_FOUND, encap);
        return;
    }
    NetworkConfigService configService = get(NetworkConfigService.class);
    CoreService coreService = get(CoreService.class);
    ApplicationId appId = coreService.getAppId(SdnIp.SDN_IP_APP);
    SdnIpConfig config = configService.addConfig(appId, SdnIpConfig.class);
    config.setEncap(encapType);
    config.apply();
// configService.applyConfig(appId, SdnIpConfig.class, config.node());
}
Also used : EncapsulationType(org.onosproject.net.EncapsulationType) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 2 with EncapsulationType

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

the class PeerConnectivityManager method setUpConnectivity.

/**
 * Sets up paths to establish connectivity between all internal
 * BGP speakers and external BGP peers.
 */
private void setUpConnectivity() {
    BgpConfig bgpConfig = configService.getConfig(routerAppId, RoutingService.CONFIG_CLASS);
    SdnIpConfig sdnIpConfig = configService.getConfig(appId, SdnIpConfig.class);
    Set<BgpConfig.BgpSpeakerConfig> bgpSpeakers;
    EncapsulationType encap;
    if (bgpConfig == null) {
        log.debug("No BGP config available");
        bgpSpeakers = Collections.emptySet();
    } else {
        bgpSpeakers = bgpConfig.bgpSpeakers();
    }
    if (sdnIpConfig == null) {
        log.debug("No SDN-IP config available");
        encap = EncapsulationType.NONE;
    } else {
        encap = sdnIpConfig.encap();
    }
    Map<Key, PointToPointIntent> existingIntents = new HashMap<>(peerIntents);
    for (BgpConfig.BgpSpeakerConfig bgpSpeaker : bgpSpeakers) {
        log.debug("Start to set up BGP paths for BGP speaker: {}", bgpSpeaker);
        buildSpeakerIntents(bgpSpeaker, encap).forEach(i -> {
            PointToPointIntent intent = existingIntents.remove(i.key());
            if (intent == null || !IntentUtils.intentsAreEqual(i, intent)) {
                peerIntents.put(i.key(), i);
                intentSynchronizer.submit(i);
            }
        });
    }
    // Remove any remaining intents that we used to have that we don't need
    // anymore
    existingIntents.values().forEach(i -> {
        peerIntents.remove(i.key());
        intentSynchronizer.withdraw(i);
    });
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) EncapsulationType(org.onosproject.net.EncapsulationType) HashMap(java.util.HashMap) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Key(org.onosproject.net.intent.Key)

Example 3 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 4 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 5 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