Search in sources :

Example 46 with IpPrefix

use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.

the class SdnIpFib method removeInterface.

/*
     * Handles the case in which an existing interface gets removed.
     */
private void removeInterface(Interface intf) {
    synchronized (this) {
        for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) {
            // Retrieve the IP prefix and intent possibly affected
            IpPrefix prefix = entry.getKey();
            MultiPointToSinglePointIntent intent = entry.getValue();
            // The interface removed might be an ingress interface, so the
            // selector needs to match on the interface tagging params and
            // on the prefix
            TrafficSelector.Builder ingressSelector = buildIngressTrafficSelector(intf, prefix);
            FilteredConnectPoint removedIngressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), ingressSelector.build());
            // The interface removed might be an egress interface, so the
            // selector needs to match only on the interface tagging params
            TrafficSelector.Builder selector = buildTrafficSelector(intf);
            FilteredConnectPoint removedEgressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), selector.build());
            if (intent.filteredEgressPoint().equals(removedEgressFilteredCP)) {
                // The interface is an egress interface for the intent.
                // This intent just lost its head. Remove it and let higher
                // layer routing reroute
                intentSynchronizer.withdraw(routeIntents.remove(entry.getKey()));
            } else {
                if (intent.filteredIngressPoints().contains(removedIngressFilteredCP)) {
                    // The FilteredConnectPoint is an ingress
                    // FilteredConnectPoint for the intent
                    Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet(intent.filteredIngressPoints());
                    // Remove FilteredConnectPoint from the existing set
                    ingressFilteredCPs.remove(removedIngressFilteredCP);
                    if (!ingressFilteredCPs.isEmpty()) {
                        // There are still ingress points. Create a new
                        // intent and resubmit
                        MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder(intent).filteredIngressPoints(ingressFilteredCPs).build();
                        routeIntents.put(entry.getKey(), newIntent);
                        intentSynchronizer.submit(newIntent);
                    } else {
                        // No more ingress FilteredConnectPoint. Withdraw
                        // the intent
                        intentSynchronizer.withdraw(routeIntents.remove(entry.getKey()));
                    }
                }
            }
        }
    }
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 47 with IpPrefix

use of org.onlab.packet.IpPrefix 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 48 with IpPrefix

use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.

the class RouteRemoveCommand method doExecute.

@Override
protected void doExecute() {
    RouteAdminService service = AbstractShellCommand.get(RouteAdminService.class);
    IpPrefix prefix = IpPrefix.valueOf(prefixString);
    IpAddress nextHop = IpAddress.valueOf(nextHopString);
    // Routes through cli without mentioning source then it is created as STATIC,
    // otherwise routes are created with corresponding source.
    Route route = source == null ? new Route(Route.Source.STATIC, prefix, nextHop) : new Route(Route.Source.valueOf(source), prefix, nextHop);
    service.withdraw(Collections.singleton(route));
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) RouteAdminService(org.onosproject.routeservice.RouteAdminService) IpAddress(org.onlab.packet.IpAddress) Route(org.onosproject.routeservice.Route)

Example 49 with IpPrefix

use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.

the class ScaleTestManager method createRoutes.

// Creates the specified number of random routes. Such routes are generated
// using random IP prefices with next hop being an IP address of a randomly
// chosen hosts.
private void createRoutes(int routeCount) {
    List<Host> hosts = ImmutableList.copyOf(hostAdminService.getHosts());
    ImmutableSet.Builder<Route> routes = ImmutableSet.builder();
    for (int i = 0; i < routeCount; i++) {
        IpPrefix prefix = randomIp().toIpPrefix();
        IpAddress nextHop = randomIp(hosts);
        routes.add(new Route(Route.Source.STATIC, prefix, nextHop));
    }
    routeAdminService.update(routes.build());
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) ImmutableSet(com.google.common.collect.ImmutableSet) Host(org.onosproject.net.Host) IpAddress(org.onlab.packet.IpAddress) Route(org.onosproject.routeservice.Route)

Example 50 with IpPrefix

use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.

the class InterfaceIpAddressTest method testConstructorForDefaultBroadcastAddress.

/**
 * Tests valid class constructor for regular interface address with
 * default broadcast address.
 */
@Test
public void testConstructorForDefaultBroadcastAddress() {
    InterfaceIpAddress addr = new InterfaceIpAddress(IP_ADDRESS, SUBNET_ADDRESS);
    assertThat(addr.ipAddress(), is(IP_ADDRESS));
    assertThat(addr.subnetAddress(), is(SUBNET_ADDRESS));
    assertThat(addr.broadcastAddress(), is(DEF_BROADCAST_ADDRESS));
    assertThat(addr.peerAddress(), nullValue());
    IpPrefix subnetAddr = IpPrefix.valueOf("10.2.3.0/24");
    InterfaceIpAddress addr1 = new InterfaceIpAddress(IP_ADDRESS2, subnetAddr);
    assertThat(addr1.broadcastAddress().toString(), is("10.2.3.255"));
    IpAddress ipAddress = IpAddress.valueOf("2001::4");
    InterfaceIpAddress addr2 = new InterfaceIpAddress(ipAddress, V6_SUBNET_ADDRESS);
    assertThat(addr2.broadcastAddress(), is(nullValue()));
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) IpAddress(org.onlab.packet.IpAddress) Test(org.junit.Test)

Aggregations

IpPrefix (org.onlab.packet.IpPrefix)107 Test (org.junit.Test)37 IpAddress (org.onlab.packet.IpAddress)29 LinkedList (java.util.LinkedList)24 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)22 BgpHeader (org.onosproject.bgpio.types.BgpHeader)22 BgpPathAttributes (org.onosproject.bgpio.protocol.ver4.BgpPathAttributes)21 AsPath (org.onosproject.bgpio.types.AsPath)21 BgpValueType (org.onosproject.bgpio.types.BgpValueType)21 Origin (org.onosproject.bgpio.types.Origin)21 OriginType (org.onosproject.bgpio.types.Origin.OriginType)21 Med (org.onosproject.bgpio.types.Med)20 TrafficSelector (org.onosproject.net.flow.TrafficSelector)20 ProtocolType (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType)19 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)19 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)18 LinkStateAttributes (org.onosproject.bgpio.types.LinkStateAttributes)16 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)14 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)14 MacAddress (org.onlab.packet.MacAddress)12