Search in sources :

Example 96 with FilteredConnectPoint

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

the class SimpleFabricRouting method setUpConnectivity.

/**
 * Update intents for connectivity.
 *
 * ToHost: dstPrefix = dstHostIp.toIpPrefix(), nextHopIp = destHostIp
 * ToInternet: dstPrefix = route.prefix(), nextHopIp = route.nextHopIp
 * returns intent submitted or not
 */
private boolean setUpConnectivity(ConnectPoint srcCp, byte ipProto, IpPrefix srcPrefix, IpPrefix dstPrefix, IpAddress nextHopIp, MacAddress treatmentSrcMac, EncapsulationType encap, boolean updateMac, boolean isDstLocalSubnet, int borderRoutePrefixLength) {
    if (!(simpleFabric.fabricNetwork(srcCp, VlanId.NONE) != null || (REACTIVE_ALLOW_LINK_CP && !linkService.getIngressLinks(srcCp).isEmpty()))) {
        log.warn("NO REGI for srcCp not in DefaultFabricNetwork; srcCp={} srcPrefix={} dstPrefix={} nextHopIp={}", srcCp, srcPrefix, dstPrefix, nextHopIp);
        return false;
    }
    MacAddress nextHopMac = null;
    ConnectPoint egressPoint = null;
    for (Host host : hostService.getHostsByIp(nextHopIp)) {
        if (host.mac() != null) {
            nextHopMac = host.mac();
            egressPoint = host.location();
            break;
        }
    }
    if (nextHopMac == null || egressPoint == null) {
        log.info("NO REGI for unknown nextHop Cp and Mac: srcPrefix={} dstPrefix={} nextHopIp={}", srcPrefix, dstPrefix, nextHopIp);
        hostService.startMonitoringIp(nextHopIp);
        simpleFabric.requestMac(nextHopIp);
        return false;
    }
    TrafficTreatment treatment;
    if (updateMac && ALLOW_ETH_ADDRESS_SELECTOR) {
        treatment = generateSetMacTreatment(nextHopMac, treatmentSrcMac);
    } else {
        treatment = DefaultTrafficTreatment.builder().build();
    }
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    if (dstPrefix.isIp4()) {
        selector.matchEthType(Ethernet.TYPE_IPV4);
        if (REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
            selector.matchIPSrc(srcPrefix);
        }
        if (dstPrefix.prefixLength() > 0) {
            selector.matchIPDst(dstPrefix);
        }
        if (ipProto != 0 && REACTIVE_MATCH_IP_PROTO) {
            selector.matchIPProtocol(ipProto);
        }
    } else {
        selector.matchEthType(Ethernet.TYPE_IPV6);
        if (REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
            selector.matchIPv6Src(srcPrefix);
        }
        if (dstPrefix.prefixLength() > 0) {
            selector.matchIPv6Dst(dstPrefix);
        }
        if (ipProto != 0 && REACTIVE_MATCH_IP_PROTO) {
            selector.matchIPProtocol(ipProto);
        }
    }
    Key key;
    String keyProtoTag = "";
    if (REACTIVE_MATCH_IP_PROTO) {
        keyProtoTag = "-p" + ipProto;
    }
    if (REACTIVE_SINGLE_TO_SINGLE) {
        // allocate intent per (srcPrefix, dstPrefix)
        key = Key.of(srcPrefix.toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
    } else {
        // allocate intent per (srcDeviceId, dstPrefix)
        key = Key.of(srcCp.deviceId().toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
    }
    // check and merge already existing ingress points
    Set<FilteredConnectPoint> ingressPoints = new HashSet<>();
    MultiPointToSinglePointIntent existingIntent = (MultiPointToSinglePointIntent) intentService.getIntent(key);
    if (existingIntent != null) {
        ingressPoints.addAll(existingIntent.filteredIngressPoints());
        if (// alread exists and dst not changed
        !ingressPoints.add(new FilteredConnectPoint(srcCp)) && egressPoint.equals(existingIntent.egressPoint()) && treatment.equals(existingIntent.treatment())) {
            log.warn("srcCP is already in mp2p intent: srcPrefix={} dstPrefix={} srcCp={}", srcPrefix, dstPrefix, srcCp);
            return false;
        }
        log.info("update mp2p intent: srcPrefix={} dstPrefix={} srcCp={}", srcPrefix, dstPrefix, srcCp);
    } else {
        log.info("create mp2p intent: srcPrefix={} dstPrefix={} srcCp={}", srcPrefix, dstPrefix, srcCp);
        ingressPoints.add(new FilteredConnectPoint(srcCp));
    }
    // priority for forwarding case
    int priority = reactivePriority(true, isDstLocalSubnet, borderRoutePrefixLength);
    MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder().key(key).appId(appId).selector(selector.build()).treatment(treatment).filteredIngressPoints(ingressPoints).filteredEgressPoint(new FilteredConnectPoint(egressPoint)).priority(priority).constraints(buildConstraints(reactiveConstraints, encap)).build();
    log.info("submit mp2p intent: srcPrefix={} dstPrefix={} srcCp={} " + "newIntent={} nextHopIp={} nextHopMac={} priority={}", srcPrefix, dstPrefix, ingressPoints, newIntent, nextHopIp, nextHopMac, priority);
    toBePurgedIntentKeys.remove(newIntent.key());
    intentService.submit(newIntent);
    return true;
}
Also used : Host(org.onosproject.net.Host) MacAddress(org.onlab.packet.MacAddress) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) ConnectPoint(org.onosproject.net.ConnectPoint) Constraint(org.onosproject.net.intent.Constraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Example 97 with FilteredConnectPoint

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

the class VbngManager method srcMatchIntentGenerator.

/**
 * PointToPointIntent Generator.
 * <p>
 * The intent will match the source IP address in packet, rewrite the
 * source IP address, and rewrite the destination MAC address.
 * </p>
 *
 * @param srcIpAddress the source IP address in packet to match
 * @param newSrcIpAddress the new source IP address to set
 * @param dstMacAddress the destination MAC address to set
 * @param dstConnectPoint the egress point
 * @param srcConnectPoint the ingress point
 * @return a PointToPointIntent
 */
private PointToPointIntent srcMatchIntentGenerator(IpAddress srcIpAddress, IpAddress newSrcIpAddress, MacAddress dstMacAddress, ConnectPoint dstConnectPoint, ConnectPoint srcConnectPoint) {
    checkNotNull(srcIpAddress);
    checkNotNull(newSrcIpAddress);
    checkNotNull(dstMacAddress);
    checkNotNull(dstConnectPoint);
    checkNotNull(srcConnectPoint);
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchEthType(Ethernet.TYPE_IPV4);
    selector.matchIPSrc(IpPrefix.valueOf(srcIpAddress, IpPrefix.MAX_INET_MASK_LENGTH));
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.setEthDst(dstMacAddress);
    treatment.setIpSrc(newSrcIpAddress);
    Key key = Key.of(srcIpAddress.toString() + "MatchSrc", appId);
    PointToPointIntent intent = PointToPointIntent.builder().appId(appId).key(key).selector(selector.build()).treatment(treatment.build()).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).build();
    log.info("Generated a PointToPointIntent for traffic from local host " + ": {}", intent);
    return intent;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 98 with FilteredConnectPoint

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

the class VbngManager method dstMatchIntentGenerator.

/**
 * PointToPointIntent Generator.
 * <p>
 * The intent will match the destination IP address in packet, rewrite the
 * destination IP address, and rewrite the destination MAC address.
 * </p>
 *
 * @param dstIpAddress the destination IP address in packet to match
 * @param newDstIpAddress the new destination IP address to set
 * @param dstMacAddress the destination MAC address to set
 * @param dstConnectPoint the egress point
 * @param srcConnectPoint the ingress point
 * @return a PointToPointIntent
 */
private PointToPointIntent dstMatchIntentGenerator(IpAddress dstIpAddress, IpAddress newDstIpAddress, MacAddress dstMacAddress, ConnectPoint dstConnectPoint, ConnectPoint srcConnectPoint) {
    checkNotNull(dstIpAddress);
    checkNotNull(newDstIpAddress);
    checkNotNull(dstMacAddress);
    checkNotNull(dstConnectPoint);
    checkNotNull(srcConnectPoint);
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchEthType(Ethernet.TYPE_IPV4);
    selector.matchIPDst(IpPrefix.valueOf(dstIpAddress, IpPrefix.MAX_INET_MASK_LENGTH));
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.setEthDst(dstMacAddress);
    treatment.setIpDst(newDstIpAddress);
    Key key = Key.of(newDstIpAddress.toString() + "MatchDst", appId);
    PointToPointIntent intent = PointToPointIntent.builder().appId(appId).key(key).selector(selector.build()).treatment(treatment.build()).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).build();
    log.info("Generated a PointToPointIntent for traffic to local host " + ": {}", intent);
    return intent;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 99 with FilteredConnectPoint

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

the class VplsIntentUtility method buildBrcIntents.

/**
 * Builds broadcast Intents for a VPLS.
 *
 * @param vplsData the VPLS
 * @param appId the application id for Intents
 * @return broadcast Intents for the VPLS
 */
public static Set<Intent> buildBrcIntents(VplsData vplsData, ApplicationId appId) {
    Set<Interface> interfaces = vplsData.interfaces();
    // At least two or more network interfaces to build broadcast Intents
    if (interfaces.size() < 2) {
        return ImmutableSet.of();
    }
    Set<Intent> brcIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
    // Generates broadcast Intents from any network interface to other
    // network interface from the VPLS.
    interfaces.forEach(src -> {
        FilteredConnectPoint srcFcp = VplsIntentUtility.buildFilteredConnectedPoint(src);
        Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(VplsIntentUtility::buildFilteredConnectedPoint).collect(Collectors.toSet());
        Key key = VplsIntentUtility.buildKey(PREFIX_BROADCAST, srcFcp.connectPoint(), vplsData.name(), MacAddress.BROADCAST, appId);
        Intent brcIntent = buildBrcIntent(key, appId, srcFcp, dstFcps, vplsData.encapsulationType(), resourceGroup);
        brcIntents.add(brcIntent);
    });
    return brcIntents;
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 100 with FilteredConnectPoint

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

the class VplsIntentUtility method buildUniIntents.

/**
 * Builds unicast Intents for a VPLS.
 *
 * @param vplsData the VPLS
 * @param hosts the hosts of the VPLS
 * @param appId application ID for Intents
 * @return unicast Intents for the VPLS
 */
public static Set<Intent> buildUniIntents(VplsData vplsData, Set<Host> hosts, ApplicationId appId) {
    Set<Interface> interfaces = vplsData.interfaces();
    if (interfaces.size() < 2) {
        return ImmutableSet.of();
    }
    Set<Intent> uniIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
    hosts.forEach(host -> {
        FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
        Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(VplsIntentUtility::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
        Key key = buildKey(PREFIX_UNICAST, hostFcp.connectPoint(), vplsData.name(), host.mac(), appId);
        Intent uniIntent = buildUniIntent(key, appId, srcFcps, hostFcp, host, vplsData.encapsulationType(), resourceGroup);
        uniIntents.add(uniIntent);
    });
    return uniIntents;
}
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) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)161 Test (org.junit.Test)101 Intent (org.onosproject.net.intent.Intent)101 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)92 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)80 TrafficSelector (org.onosproject.net.flow.TrafficSelector)65 ConnectPoint (org.onosproject.net.ConnectPoint)64 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)53 List (java.util.List)52 Collectors (java.util.stream.Collectors)52 VlanId (org.onlab.packet.VlanId)52 DeviceId (org.onosproject.net.DeviceId)50 FlowRule (org.onosproject.net.flow.FlowRule)50 DomainService (org.onosproject.net.domain.DomainService)48 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)48 ImmutableSet (com.google.common.collect.ImmutableSet)47 LOCAL (org.onosproject.net.domain.DomainId.LOCAL)47 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)47 Before (org.junit.Before)46