Search in sources :

Example 76 with IpPrefix

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

the class OpenstackVtapManager method updateHostbyType.

/**
 * Updates device list of vtaps with respect to the host changes.
 *
 * @param newHost   new host instance
 * @param oldHost   old host instance
 */
private void updateHostbyType(Type type, Host newHost, Host oldHost) {
    getVtaps(type).forEach(vtap -> {
        IpPrefix prefix = (type == Type.VTAP_TX) ? vtap.vtapCriterion().srcIpPrefix() : vtap.vtapCriterion().dstIpPrefix();
        int hostDiff = hostCompareIp(newHost, oldHost, prefix);
        if (hostDiff < 0) {
            oldHost.locations().stream().map(HostLocation::deviceId).forEach(deviceId -> store.removeDeviceFromVtap(vtap.id(), type, deviceId));
        } else if (hostDiff > 0) {
            newHost.locations().stream().map(HostLocation::deviceId).filter(deviceId -> Objects.nonNull(osNodeService.node(deviceId))).forEach(deviceId -> store.addDeviceToVtap(vtap.id(), type, deviceId));
        }
    });
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) OpenstackVtapUtil.getTunnelName(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getTunnelName) COMPLETE(org.onosproject.openstacknode.api.NodeState.COMPLETE) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) VTAP_INBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_MIRROR_TABLE) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) FlowRuleService(org.onosproject.net.flow.FlowRuleService) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) PROTOCOL_UDP(org.onlab.packet.IPv4.PROTOCOL_UDP) OpenstackVtapUtil.isValidHost(org.onosproject.openstackvtap.util.OpenstackVtapUtil.isValidHost) VTAP_INBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_GROUP_TABLE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackVtapUtil.getGroupKey(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getGroupKey) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Type(org.onosproject.openstackvtap.api.OpenstackVtap.Type) VTAP_OUTBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_MIRROR_TABLE) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) GroupDescription(org.onosproject.net.group.GroupDescription) Dictionary(java.util.Dictionary) VTAP_OUTBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_GROUP_TABLE) FlowRuleOperationsContext(org.onosproject.net.flow.FlowRuleOperationsContext) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) OpenstackVtap(org.onosproject.openstackvtap.api.OpenstackVtap) ComponentContext(org.osgi.service.component.ComponentContext) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) HostListener(org.onosproject.net.host.HostListener) TUNNEL_NICIRA(org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICIRA) HostService(org.onosproject.net.host.HostService) VTAP_INBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_TABLE) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackVtapEvent(org.onosproject.openstackvtap.api.OpenstackVtapEvent) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OpenstackVtapStore(org.onosproject.openstackvtap.api.OpenstackVtapStore) StreamSupport(java.util.stream.StreamSupport) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) DeviceListener(org.onosproject.net.device.DeviceListener) PROTOCOL_ICMP(org.onlab.packet.IPv4.PROTOCOL_ICMP) GroupService(org.onosproject.net.group.GroupService) GroupId(org.onosproject.core.GroupId) LeadershipService(org.onosproject.cluster.LeadershipService) OpenstackVtapUtil.hostCompareIp(org.onosproject.openstackvtap.util.OpenstackVtapUtil.hostCompareIp) HostLocation(org.onosproject.net.HostLocation) CoreService(org.onosproject.core.CoreService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) VTAP_FLAT_OUTBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_GROUP_TABLE) INTEGRATION_BRIDGE(org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Mode(org.onosproject.openstackvtap.api.OpenstackVtapNetwork.Mode) OpenstackVtapUtil.dumpStackTrace(org.onosproject.openstackvtap.util.OpenstackVtapUtil.dumpStackTrace) TYPE_IPV4(org.onlab.packet.Ethernet.TYPE_IPV4) TUNNEL_NICRA_DEFAULT(org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICRA_DEFAULT) NodeId(org.onosproject.cluster.NodeId) ImmutableSet(com.google.common.collect.ImmutableSet) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Device(org.onosproject.net.Device) DHCP_TABLE(org.onosproject.openstacknetworking.api.Constants.DHCP_TABLE) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) NICIRA_RESUBMIT_TABLE(org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE) VTAP_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_TABLE) Objects(java.util.Objects) NICIRA_SET_TUNNEL_DST(org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) OpenstackVtapUtil.containsIp(org.onosproject.openstackvtap.util.OpenstackVtapUtil.containsIp) FLAT_TABLE(org.onosproject.openstacknetworking.api.Constants.FLAT_TABLE) FlowRule(org.onosproject.net.flow.FlowRule) ClusterService(org.onosproject.cluster.ClusterService) OpenstackVtapId(org.onosproject.openstackvtap.api.OpenstackVtapId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) IpPrefix(org.onlab.packet.IpPrefix) InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) OpenstackVtapListener(org.onosproject.openstackvtap.api.OpenstackVtapListener) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) TunnelKey(org.onosproject.net.behaviour.TunnelKey) GroupBucket(org.onosproject.net.group.GroupBucket) VTAP_FLAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_TABLE) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) OpenstackVtapStoreDelegate(org.onosproject.openstackvtap.api.OpenstackVtapStoreDelegate) ImmutableList(com.google.common.collect.ImmutableList) OpenstackVtapAdminService(org.onosproject.openstackvtap.api.OpenstackVtapAdminService) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) VTAP_FLAT_OUTBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_MIRROR_TABLE) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FORWARDING_TABLE(org.onosproject.openstacknetworking.api.Constants.FORWARDING_TABLE) Logger(org.slf4j.Logger) OpenstackVtapService(org.onosproject.openstackvtap.api.OpenstackVtapService) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackVtapCriterion(org.onosproject.openstackvtap.api.OpenstackVtapCriterion) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) PROTOCOL_TCP(org.onlab.packet.IPv4.PROTOCOL_TCP) Reference(org.osgi.service.component.annotations.Reference) OpenstackVtapUtil.getTunnelType(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getTunnelType)

Example 77 with IpPrefix

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

the class PimInterface method processJoinPrune.

/**
 * Process an incoming PIM JoinPrune message.
 *
 * @param ethPkt the Ethernet packet header.
 */
public void processJoinPrune(Ethernet ethPkt) {
    IPv4 ip = (IPv4) ethPkt.getPayload();
    checkNotNull(ip);
    PIM pim = (PIM) ip.getPayload();
    checkNotNull(pim);
    PIMJoinPrune jpHdr = (PIMJoinPrune) pim.getPayload();
    checkNotNull(jpHdr);
    /*
         * The Join/Prune messages are grouped by Group address. We'll walk each group address
         * where we will possibly have to walk a list of source address for the joins and prunes.
         */
    Collection<PIMJoinPruneGroup> jpgs = jpHdr.getJoinPrunes();
    for (PIMJoinPruneGroup jpg : jpgs) {
        IpPrefix gpfx = jpg.getGroup();
        // Walk the joins first.
        for (IpPrefix spfx : jpg.getJoins().values()) {
        // We may need
        }
        for (IpPrefix spfx : jpg.getPrunes().values()) {
        // TODO: this is where we many need to remove multi-cast state and possibly intents.
        }
    }
}
Also used : PIMJoinPrune(org.onlab.packet.pim.PIMJoinPrune) IpPrefix(org.onlab.packet.IpPrefix) PIM(org.onlab.packet.PIM) PIMJoinPruneGroup(org.onlab.packet.pim.PIMJoinPruneGroup) IPv4(org.onlab.packet.IPv4)

Example 78 with IpPrefix

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

the class SdnIpReactiveRouting method packetReactiveProcessor.

/**
 * Routes packet reactively.
 *
 * @param dstIpAddress the destination IP address of a packet
 * @param srcIpAddress the source IP address of a packet
 * @param srcConnectPoint the connect point where a packet comes from
 * @param srcMacAddress the source MAC address of a packet
 */
private void packetReactiveProcessor(IpAddress dstIpAddress, IpAddress srcIpAddress, ConnectPoint srcConnectPoint, MacAddress srcMacAddress) {
    checkNotNull(dstIpAddress);
    checkNotNull(srcIpAddress);
    checkNotNull(srcConnectPoint);
    checkNotNull(srcMacAddress);
    // 
    // Step1: Try to update the existing intent first if it exists.
    // 
    IpPrefix ipPrefix = null;
    Route route = null;
    if (config.isIpAddressLocal(dstIpAddress)) {
        if (dstIpAddress.isIp4()) {
            ipPrefix = IpPrefix.valueOf(dstIpAddress, Ip4Address.BIT_LENGTH);
        } else {
            ipPrefix = IpPrefix.valueOf(dstIpAddress, Ip6Address.BIT_LENGTH);
        }
    } else {
        // Get IP prefix from BGP route table
        route = routeService.longestPrefixMatch(dstIpAddress);
        if (route != null) {
            ipPrefix = route.prefix();
        }
    }
    if (ipPrefix != null && intentRequestListener.mp2pIntentExists(ipPrefix)) {
        intentRequestListener.updateExistingMp2pIntent(ipPrefix, srcConnectPoint);
        return;
    }
    // 
    // Step2: There is no existing intent for the destination IP address.
    // Check whether it is necessary to create a new one. If necessary then
    // create a new one.
    // 
    TrafficType trafficType = trafficTypeClassifier(srcConnectPoint, dstIpAddress);
    switch(trafficType) {
        case HOST_TO_INTERNET:
            // The Step 1 has already handled it. We do not need to do anything here.
            if (route != null) {
                intentRequestListener.setUpConnectivityHostToInternet(srcIpAddress, ipPrefix, route.nextHop());
            }
            break;
        case INTERNET_TO_HOST:
            intentRequestListener.setUpConnectivityInternetToHost(dstIpAddress);
            break;
        case HOST_TO_HOST:
            intentRequestListener.setUpConnectivityHostToHost(dstIpAddress, srcIpAddress, srcMacAddress, srcConnectPoint);
            break;
        case INTERNET_TO_INTERNET:
            log.trace("This is transit traffic, " + "the intent should be preinstalled already");
            break;
        case DROP:
            // We need a new type of intent here.
            break;
        case UNKNOWN:
            log.trace("This is unknown traffic, so we do nothing");
            break;
        default:
            break;
    }
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) Route(org.onosproject.routeservice.Route)

Example 79 with IpPrefix

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

the class RouteConfig method getRoutes.

/**
 * Returns all routes in this configuration.
 *
 * @return A set of route.
 */
public Set<Route> getRoutes() {
    ImmutableSet.Builder<Route> routes = ImmutableSet.builder();
    array.forEach(route -> {
        try {
            IpPrefix prefix = IpPrefix.valueOf(route.path(PREFIX).asText());
            IpAddress nextHop = IpAddress.valueOf(route.path(NEXTHOP).asText());
            routes.add(new Route(Route.Source.STATIC, prefix, nextHop));
        } catch (IllegalArgumentException e) {
        // Ignores routes that cannot be parsed correctly
        }
    });
    return routes.build();
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) ImmutableSet(com.google.common.collect.ImmutableSet) IpAddress(org.onlab.packet.IpAddress)

Example 80 with IpPrefix

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

the class FpmManager method updateAcceptRouteFlag.

@Override
public void updateAcceptRouteFlag(Collection<FpmPeerAcceptRoutes> modifiedPeers) {
    modifiedPeers.forEach(modifiedPeer -> {
        log.debug("FPM connection to {} is disabled", modifiedPeer);
        NodeId localNode = clusterService.getLocalNode().id();
        log.debug("Peer Flag {}", modifiedPeer.isAcceptRoutes());
        peers.compute(modifiedPeer.peer(), (p, infos) -> {
            if (infos == null) {
                return null;
            }
            Iterator<FpmConnectionInfo> iterator = infos.iterator();
            if (iterator.hasNext()) {
                FpmConnectionInfo connectionInfo = iterator.next();
                if (connectionInfo.isAcceptRoutes() == modifiedPeer.isAcceptRoutes()) {
                    return null;
                }
                localPeers.remove(modifiedPeer.peer());
                infos.remove(connectionInfo);
                infos.add(new FpmConnectionInfo(localNode, modifiedPeer.peer(), System.currentTimeMillis(), modifiedPeer.isAcceptRoutes()));
                localPeers.put(modifiedPeer.peer(), infos);
            }
            Map<IpPrefix, Route> routes = fpmRoutes.get(modifiedPeer.peer());
            if (routes != null && !modifiedPeer.isAcceptRoutes()) {
                updateRouteStore(Lists.newArrayList(), routes.values());
            } else {
                updateRouteStore(routes.values(), Lists.newArrayList());
            }
            return infos;
        });
    });
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) NodeId(org.onosproject.cluster.NodeId) Route(org.onosproject.routeservice.Route)

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