Search in sources :

Example 21 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint 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 22 with FilteredConnectPoint

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

the class PeerConnectivityManagerTest method icmpPathintentConstructor.

/**
 * Constructs a BGP intent and put it into the intentList.
 * <p/>
 * The purpose of this method is too simplify the setUpBgpIntents() method,
 * and to make the setUpBgpIntents() easy to read.
 *
 * @param srcVlanId ingress VlanId
 * @param dstVlanId egress VlanId
 * @param srcPrefix source IP prefix to match
 * @param dstPrefix destination IP prefix to match
 * @param srcConnectPoint source connect point for PointToPointIntent
 * @param dstConnectPoint destination connect point for PointToPointIntent
 */
private void icmpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId, String srcPrefix, String dstPrefix, ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) {
    TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_ICMP).matchIPSrc(IpPrefix.valueOf(srcPrefix)).matchIPDst(IpPrefix.valueOf(dstPrefix));
    if (!srcVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(srcVlanId);
    }
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    if (!dstVlanId.equals(VlanId.NONE)) {
        treatment.setVlanId(dstVlanId);
    }
    Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] + "-" + "icmp", APPID);
    PointToPointIntent intent = PointToPointIntent.builder().appId(APPID).key(key).selector(builder.build()).treatment(treatment.build()).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).build();
    intentList.add(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 23 with FilteredConnectPoint

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

the class PeerConnectivityManagerTest method bgpPathintentConstructor.

/**
 * Constructs a BGP intent and put it into the intentList.
 * <p/>
 * The purpose of this method is too simplify the setUpBgpIntents() method,
 * and to make the setUpBgpIntents() easy to read.
 *
 * @param srcVlanId ingress VlanId
 * @param dstVlanId egress VlanId
 * @param srcPrefix source IP prefix to match
 * @param dstPrefix destination IP prefix to match
 * @param srcTcpPort source TCP port to match
 * @param dstTcpPort destination TCP port to match
 * @param srcConnectPoint source connect point for PointToPointIntent
 * @param dstConnectPoint destination connect point for PointToPointIntent
 */
private void bgpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId, String srcPrefix, String dstPrefix, Short srcTcpPort, Short dstTcpPort, ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) {
    TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_TCP).matchIPSrc(IpPrefix.valueOf(srcPrefix)).matchIPDst(IpPrefix.valueOf(dstPrefix));
    if (!srcVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(srcVlanId);
    }
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    if (!dstVlanId.equals(VlanId.NONE)) {
        treatment.setVlanId(dstVlanId);
    }
    if (srcTcpPort != null) {
        builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
    }
    if (dstTcpPort != null) {
        builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
    }
    Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] + "-" + ((srcTcpPort == null) ? "dst" : "src"), APPID);
    PointToPointIntent intent = PointToPointIntent.builder().appId(APPID).key(key).selector(builder.build()).treatment(treatment.build()).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).build();
    intentList.add(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 24 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint 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 25 with FilteredConnectPoint

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

the class TestProtectionEndpointIntentCommand method output.

private FilteredConnectPoint output(DeviceId did, String portNumberStr, String vlanStr) {
    ConnectPoint cp = new ConnectPoint(did, PortNumber.fromString(portNumberStr));
    if (deviceService.getPort(cp) == null) {
        print("Unknown port: %s", cp);
    }
    if (vlanStr == null) {
        return new FilteredConnectPoint(cp);
    } else {
        VlanId vlan = VlanId.vlanId(vlanStr);
        TrafficSelector sel = DefaultTrafficSelector.builder().matchVlanId(vlan).build();
        return new FilteredConnectPoint(cp, sel);
    }
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) VlanId(org.onlab.packet.VlanId) 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