Search in sources :

Example 71 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class PeerConnectivityManager method buildSpeakerIntents.

private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker, EncapsulationType encap) {
    List<PointToPointIntent> intents = new ArrayList<>();
    // Get the BGP Speaker VLAN Id
    VlanId bgpSpeakerVlanId = speaker.vlan();
    for (IpAddress peerAddress : speaker.peers()) {
        Interface peeringInterface = interfaceService.getMatchingInterface(peerAddress);
        if (peeringInterface == null) {
            log.debug("No peering interface found for peer {} on speaker {}", peerAddress, speaker);
            continue;
        }
        IpAddress bgpSpeakerAddress = null;
        for (InterfaceIpAddress address : peeringInterface.ipAddressesList()) {
            if (address.subnetAddress().contains(peerAddress)) {
                bgpSpeakerAddress = address.ipAddress();
                break;
            }
        }
        checkNotNull(bgpSpeakerAddress);
        VlanId peerVlanId = peeringInterface.vlan();
        intents.addAll(buildIntents(speaker.connectPoint(), bgpSpeakerVlanId, bgpSpeakerAddress, peeringInterface.connectPoint(), peerVlanId, peerAddress, encap));
    }
    return intents;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) IpAddress(org.onlab.packet.IpAddress) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 72 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class SdnIpFib method generateRouteIntent.

/**
 * Generates a route intent for a prefix, the next hop IP address, and
 * the next hop MAC address.
 * <p/>
 * This method will find the egress interface for the intent.
 * Intent will match dst IP prefix and rewrite dst MAC address at all other
 * border switches, then forward packets according to dst MAC address.
 *
 * @param prefix            the IP prefix of the route to add
 * @param nextHopIpAddress  the IP address of the next hop
 * @param nextHopMacAddress the MAC address of the next hop
 * @param encap             the encapsulation type in use
 * @return the generated intent, or null if no intent should be submitted
 */
private MultiPointToSinglePointIntent generateRouteIntent(IpPrefix prefix, IpAddress nextHopIpAddress, MacAddress nextHopMacAddress, EncapsulationType encap) {
    // Find the attachment point (egress interface) of the next hop
    Interface egressInterface = interfaceService.getMatchingInterface(nextHopIpAddress);
    if (egressInterface == null) {
        log.warn("No outgoing interface found for {}", nextHopIpAddress);
        return null;
    }
    ConnectPoint egressPort = egressInterface.connectPoint();
    log.debug("Generating intent for prefix {}, next hop mac {}", prefix, nextHopMacAddress);
    Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
    // TODO this should be only peering interfaces
    interfaceService.getInterfaces().forEach(intf -> {
        // Get ony ingress interfaces with IPs configured
        if (validIngressIntf(intf, egressInterface)) {
            TrafficSelector.Builder selector = buildIngressTrafficSelector(intf, prefix);
            FilteredConnectPoint ingressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), selector.build());
            ingressFilteredCPs.add(ingressFilteredCP);
        }
    });
    // Build treatment: rewrite the destination MAC address
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setEthDst(nextHopMacAddress);
    // Build the egress selector for VLAN Id
    TrafficSelector.Builder selector = buildTrafficSelector(egressInterface);
    FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(egressPort, selector.build());
    // Set priority
    int priority = prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
    // Set key
    Key key = Key.of(prefix.toString(), appId);
    MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).filteredIngressPoints(ingressFilteredCPs).filteredEgressPoint(egressFilteredCP).treatment(treatment.build()).priority(priority).constraints(CONSTRAINTS);
    setEncap(intentBuilder, CONSTRAINTS, encap);
    return intentBuilder.build();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 73 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class SdnIpFibTest method testAddInterface.

/**
 * Tests adding a new interface.
 *
 * We verify that the synchronizer records the correct state and that the
 * correct intent is withdrawn from the IntentService.
 */
@Test
public void testAddInterface() {
    // Add a route first
    testRouteAddToNoVlan();
    // Create the new expected intent
    MultiPointToSinglePointIntent addedIntent = createIntentToThreeSrcOneTwoFour(PREFIX1);
    reset(intentSynchronizer);
    intentSynchronizer.submit(eqExceptId(addedIntent));
    expectLastCall().once();
    replay(intentSynchronizer);
    // Create the new interface and add notify it
    Interface intf = new Interface("sw4-eth1", SW4_ETH1, Collections.singletonList(IIP4), MAC4, NO_VLAN);
    InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_ADDED, intf);
    interfaceListener.event(intfEvent);
    verify(intentSynchronizer);
}
Also used : InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 74 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class SdnIpFibTest method testRemoveEgressInterface.

/**
 * Tests removing an existing egress interface.
 *
 * We first push an intent with destination sw3 and source sw1 and sw2. We
 * then remove the egress interface on sw3.
 *
 * We verify that the synchronizer records the correct state and that the
 * correct intent is withdrawn from the IntentService.
 */
@Test
public void testRemoveEgressInterface() {
    // Add a route first
    testRouteAddToNoVlan();
    // Create existing intent
    MultiPointToSinglePointIntent removedIntent = createIntentToThreeSrcOneTwo(PREFIX1);
    // Set up expectation
    reset(intentSynchronizer);
    // Setup the expected intents
    intentSynchronizer.withdraw(eqExceptId(removedIntent));
    replay(intentSynchronizer);
    // Define the existing egress interface and remove it
    Interface intf = new Interface("sw3-eth1", SW3_ETH1, Collections.singletonList(IIP3), MAC3, VlanId.NONE);
    InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
    interfaceListener.event(intfEvent);
    verify(intentSynchronizer);
}
Also used : InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 75 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class DefaultFabricNetworkTest method createInterface.

private static Interface createInterface(int index) {
    String name = "INTF_NAME_" + index;
    ConnectPoint cp = ConnectPoint.fromString("of:0011223344556677/" + index);
    InterfaceIpAddress intfIp1 = InterfaceIpAddress.valueOf("10.10.10." + index + "/32");
    InterfaceIpAddress intfIp2 = InterfaceIpAddress.valueOf("20.20.20." + index + "/32");
    List<InterfaceIpAddress> intfIps = ImmutableList.of(intfIp1, intfIp2);
    MacAddress mac = MacAddress.valueOf("00:00:00:00:00:00");
    VlanId vlanId = VlanId.NONE;
    return new Interface(name, cp, intfIps, mac, vlanId);
}
Also used : MacAddress(org.onlab.packet.MacAddress) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface)

Aggregations

Interface (org.onosproject.net.intf.Interface)92 ConnectPoint (org.onosproject.net.ConnectPoint)51 MacAddress (org.onlab.packet.MacAddress)35 VlanId (org.onlab.packet.VlanId)34 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)32 Ethernet (org.onlab.packet.Ethernet)28 IpAddress (org.onlab.packet.IpAddress)28 ArrayList (java.util.ArrayList)26 DeviceId (org.onosproject.net.DeviceId)26 Host (org.onosproject.net.Host)25 InterfaceService (org.onosproject.net.intf.InterfaceService)25 Logger (org.slf4j.Logger)25 Set (java.util.Set)23 TrafficSelector (org.onosproject.net.flow.TrafficSelector)23 LoggerFactory (org.slf4j.LoggerFactory)23 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)22 Test (org.junit.Test)21 ApplicationId (org.onosproject.core.ApplicationId)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)20