Search in sources :

Example 31 with Interface

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

the class SimpleFabricForwarding method buildUniIntents.

// Builds unicast Intents for a L2 Network.
private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork, Set<Host> hosts) {
    Set<Interface> interfaces = fabricNetwork.interfaces();
    if (!fabricNetwork.isForward() || interfaces.size() < 2) {
        return ImmutableSet.of();
    }
    Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
    hosts.forEach(host -> {
        FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
        Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(this::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
        Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
        MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcFcps).filteredEgressPoint(hostFcp).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_UNICAST).resourceGroup(resourceGroup);
        uniIntents.add(intentBuilder.build());
    });
    return uniIntents;
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) CoreService(org.onosproject.core.CoreService) LoggerFactory(org.slf4j.LoggerFactory) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SimpleFabricListener(org.onosproject.simplefabric.api.SimpleFabricListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) SimpleFabricEvent(org.onosproject.simplefabric.api.SimpleFabricEvent) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) PRI_L2NETWORK_BROADCAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_BROADCAST) SimpleFabricService(org.onosproject.simplefabric.api.SimpleFabricService) PrintStream(java.io.PrintStream) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) FORWARDING_APP_ID(org.onosproject.simplefabric.api.Constants.FORWARDING_APP_ID) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) PRI_L2NETWORK_UNICAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 32 with Interface

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

the class SimpleFabricNeighbour method handleRequest.

/**
 * Handles request messages.
 *
 * @param context the message context
 */
protected void handleRequest(NeighbourMessageContext context) {
    MacAddress mac = simpleFabric.vMacForIp(context.target());
    if (mac != null) {
        log.trace("simple fabric neightbour request on virtualGatewayAddress {}; response to {} {} mac={}", context.target(), context.inPort(), context.vlan(), mac);
        context.reply(mac);
        return;
    }
    // else forward to corresponding host
    FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(context.inPort(), context.vlan());
    if (fabricNetwork != null) {
        int numForwards = 0;
        if (!context.dstMac().isBroadcast() && !context.dstMac().isMulticast()) {
            for (Host host : hostService.getHostsByMac(context.dstMac())) {
                log.trace("simple fabric neightbour request forward unicast to {}", host.location());
                // ASSUME: vlan is same
                context.forward(host.location());
                // TODO: may need to check host.location().time()
                numForwards++;
            }
            if (numForwards > 0) {
                return;
            }
        }
        // else do broadcast to all host in the same l2 network
        log.trace("simple fabric neightbour request forward broadcast: {} {}", context.inPort(), context.vlan());
        for (Interface iface : fabricNetwork.interfaces()) {
            if (!context.inPort().equals(iface.connectPoint())) {
                log.trace("simple fabric forward neighbour request broadcast to {}", iface);
                context.forward(iface);
            }
        }
    } else {
        log.warn("simple fabric neightbour request drop: {} {}", context.inPort(), context.vlan());
        context.drop();
    }
}
Also used : Host(org.onosproject.net.Host) MacAddress(org.onlab.packet.MacAddress) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) Interface(org.onosproject.net.intf.Interface)

Example 33 with Interface

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

the class PeerConnectivityManagerTest method setUpInterfaces.

/**
 * Sets up logical interfaces, which emulate the configured interfaces
 * in the SDN-IP application.
 *
 * @return configured interfaces as a map from interface name to Interface
 */
private Map<String, Interface> setUpInterfaces() {
    Map<String, Interface> configuredInterfaces = new HashMap<>();
    String interfaceSw1Eth1 = "s1-eth1";
    InterfaceIpAddress ia1 = new InterfaceIpAddress(IpAddress.valueOf("192.168.10.101"), IpPrefix.valueOf("192.168.10.0/24"));
    Interface intfsw1eth1 = new Interface(interfaceSw1Eth1, s1Eth1, Collections.singletonList(ia1), MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE);
    configuredInterfaces.put(interfaceSw1Eth1, intfsw1eth1);
    String interfaceSw2Eth1 = "s2-eth1";
    InterfaceIpAddress ia2 = new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"), IpPrefix.valueOf("192.168.20.0/24"));
    Interface intfsw2eth1 = new Interface(interfaceSw2Eth1, s2Eth1, Collections.singletonList(ia2), MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE);
    configuredInterfaces.put(interfaceSw2Eth1, intfsw2eth1);
    String interfaceSw2Eth1intf2 = "s2-eth1_2";
    InterfaceIpAddress ia3 = new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"), IpPrefix.valueOf("192.168.30.0/24"));
    Interface intfsw2eth1intf2 = new Interface(interfaceSw2Eth1intf2, s2Eth1, Collections.singletonList(ia3), MacAddress.valueOf("00:00:00:00:00:03"), VlanId.NONE);
    configuredInterfaces.put(interfaceSw2Eth1intf2, intfsw2eth1intf2);
    String interfaceSw3Eth1 = "s3-eth1";
    InterfaceIpAddress ia4 = new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24"));
    Interface intfsw3eth1 = new Interface(Interface.NO_INTERFACE_NAME, s3Eth1, ImmutableList.of(ia4), MacAddress.valueOf("00:00:00:00:00:04"), VLAN10);
    configuredInterfaces.put(interfaceSw3Eth1, intfsw3eth1);
    String interfaceSw3Eth1intf2 = "s3-eth1_2";
    InterfaceIpAddress ia5 = new InterfaceIpAddress(IpAddress.valueOf("192.168.50.101"), IpPrefix.valueOf("192.168.50.0/24"));
    Interface intfsw3eth1intf2 = new Interface(Interface.NO_INTERFACE_NAME, s3Eth1, ImmutableList.of(ia5), MacAddress.valueOf("00:00:00:00:00:05"), VLAN20);
    configuredInterfaces.put(interfaceSw3Eth1intf2, intfsw3eth1intf2);
    expect(interfaceService.getInterfacesByPort(s1Eth1)).andReturn(Collections.singleton(intfsw1eth1)).anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.10.101"))).andReturn(Collections.singleton(intfsw1eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.10.1"))).andReturn(intfsw1eth1).anyTimes();
    expect(interfaceService.getInterfacesByPort(s2Eth1)).andReturn(Collections.singleton(intfsw2eth1)).anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.20.101"))).andReturn(Collections.singleton(intfsw2eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.20.1"))).andReturn(intfsw2eth1).anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.30.101"))).andReturn(Collections.singleton(intfsw2eth1intf2)).anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.30.1"))).andReturn(intfsw2eth1intf2).anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.40.101"))).andReturn(Collections.singleton(intfsw3eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.40.1"))).andReturn(intfsw3eth1).anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.50.101"))).andReturn(Collections.singleton(intfsw3eth1intf2)).anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.50.1"))).andReturn(intfsw3eth1intf2).anyTimes();
    // Non-existent interface used during one of the tests
    expect(interfaceService.getInterfacesByPort(new ConnectPoint(DeviceId.deviceId("of:0000000000000100"), PortNumber.portNumber(1)))).andReturn(null).anyTimes();
    expect(interfaceService.getInterfaces()).andReturn(Sets.newHashSet(configuredInterfaces.values())).anyTimes();
    return configuredInterfaces;
}
Also used : HashMap(java.util.HashMap) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 34 with Interface

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

the class SdnIpFibTest method setUpInterfaceService.

/**
 * Sets up the interface service.
 */
private void setUpInterfaceService() {
    List<InterfaceIpAddress> iIps1 = Lists.newArrayList();
    iIps1.add(IIP1);
    Interface sw1Eth1 = new Interface("sw1-eth1", SW1_ETH1, iIps1, MAC1, VLAN10);
    interfaces.add(sw1Eth1);
    List<InterfaceIpAddress> iIps2 = Lists.newArrayList();
    iIps2.add(IIP2);
    Interface sw2Eth1 = new Interface("sw2-eth1", SW2_ETH1, iIps2, MAC2, VLAN20);
    interfaces.add(sw2Eth1);
    List<InterfaceIpAddress> iIps3 = Lists.newArrayList();
    iIps3.add(IIP3);
    Interface sw3Eth1 = new Interface("sw3-eth1", SW3_ETH1, iIps3, MAC3, NO_VLAN);
    interfaces.add(sw3Eth1);
    expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(Collections.singleton(sw1Eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IP1)).andReturn(sw1Eth1).anyTimes();
    expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(Collections.singleton(sw2Eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IP2)).andReturn(sw2Eth1).anyTimes();
    expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(Collections.singleton(sw3Eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IP3)).andReturn(sw3Eth1).anyTimes();
    expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
}
Also used : InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface)

Example 35 with Interface

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

the class SdnIpFibTest method testRemoveIngressInterface.

/**
 * Tests removing an existing interface.
 *
 * We first push an intent with destination sw3 and source sw1 and sw2. We
 * then remove the ingress interface on sw1.
 *
 * We verify that the synchronizer records the correct state and that the
 * correct intent is withdrawn from the IntentService.
 */
@Test
public void testRemoveIngressInterface() {
    // Add a route first
    testRouteAddToNoVlan();
    // Create the new expected intent
    MultiPointToSinglePointIntent remainingIntent = createIntentToThreeSrcTwo(PREFIX1);
    reset(intentSynchronizer);
    intentSynchronizer.submit(eqExceptId(remainingIntent));
    expectLastCall().once();
    replay(intentSynchronizer);
    // Define the existing ingress interface and remove it
    Interface intf = new Interface("sw1-eth1", SW1_ETH1, Collections.singletonList(IIP1), MAC1, VLAN10);
    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)

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