Search in sources :

Example 1 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class RouterAdvertisementDeviceConfigTest method setUp.

@Before
public void setUp() throws Exception {
    InputStream jsonStream = RouterAdvertisementDeviceConfigTest.class.getResourceAsStream("/device.json");
    prefixes = new ArrayList<InterfaceIpAddress>();
    prefixes.add(InterfaceIpAddress.valueOf("2001:0558:FF10:04C9::6:100/120"));
    prefixes.add(InterfaceIpAddress.valueOf("2001:0558:FF10:04C9::7:100/120"));
    DeviceId subject = DeviceId.deviceId("of:0000000000000001");
    String key = "routeradvertisement";
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();
    config = new RouterAdvertisementDeviceConfig();
    config.init(subject, key, jsonNode, mapper, delegate);
}
Also used : InputStream(java.io.InputStream) DeviceId(org.onosproject.net.DeviceId) JsonNode(com.fasterxml.jackson.databind.JsonNode) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Example 2 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class ControlPlaneRedirectManagerTest method testUpdateNetworkConfig.

/**
 * Tests adding while updating the networkConfig.
 */
@Test
public void testUpdateNetworkConfig() {
    ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
    List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>();
    interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")));
    interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120")));
    Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses, MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
    interfaces.add(sw1Eth4);
    EasyMock.reset(flowObjectiveService);
    setUpFlowObjectiveService();
    networkConfigListener.event(new NetworkConfigEvent(Type.CONFIG_UPDATED, dev3, RoutingService.ROUTER_CONFIG_CLASS));
    networkConfigService.addListener(networkConfigListener);
    verify(flowObjectiveService);
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) ArrayList(java.util.ArrayList) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 3 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class ControlPlaneRedirectManagerTest method setUpInterfaceConfiguration.

/**
 * Setting up flowobjective expectations for basic forwarding and ospf.
 */
private void setUpInterfaceConfiguration(Interface intf, boolean install) {
    DeviceId deviceId = controlPlaneConnectPoint.deviceId();
    PortNumber controlPlanePort = controlPlaneConnectPoint.port();
    for (InterfaceIpAddress ip : intf.ipAddressesList()) {
        int cpNextId, intfNextId;
        cpNextId = modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId(ControlPlaneRedirectManager.ASSIGNED_VLAN), true, install);
        intfNextId = modifyNextObjective(deviceId, intf.connectPoint().port(), VlanId.vlanId(ControlPlaneRedirectManager.ASSIGNED_VLAN), true, install);
        // IP to router
        TrafficSelector toSelector = buildIPDstSelector(ip.ipAddress().toIpPrefix(), intf.connectPoint().port(), null, intf.mac(), intf.vlan());
        flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, null, cpNextId, install, ACL_PRIORITY));
        expectLastCall().once();
        // IP from router
        TrafficSelector fromSelector = buildIPSrcSelector(ip.ipAddress().toIpPrefix(), controlPlanePort, intf.mac(), null, intf.vlan());
        flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, null, intfNextId, install, ACL_PRIORITY));
        expectLastCall().once();
        TrafficTreatment puntTreatment = DefaultTrafficTreatment.builder().punt().build();
        if (ip.ipAddress().isIp4()) {
            // ARP to router
            toSelector = buildArpSelector(intf.connectPoint().port(), intf.vlan(), null, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // ARP from router
            fromSelector = buildArpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().getIp4Address(), intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
        } else {
            // NDP solicitation to router
            // Global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // Link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // solicitated global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(ip.ipAddress().toOctets())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // solicitated link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(getLinkLocalAddress(intf.mac().toBytes()))).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation from router
            // Global unicast address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation from router
            // Link local address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement to router
            // Global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement to router
            // Link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement from the router
            // Global unicast address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement from router
            // Link local address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
        }
    }
    // setting expectations for ospf forwarding.
    TrafficSelector toSelector = DefaultTrafficSelector.builder().matchInPort(intf.connectPoint().port()).matchEthType(EthType.EtherType.IPV4.ethType().toShort()).matchVlanId(intf.vlan()).matchIPProtocol((byte) OSPF_IP_PROTO).build();
    modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId((short) 4094), true, install);
    flowObjectiveService.forward(controlPlaneConnectPoint.deviceId(), buildForwardingObjective(toSelector, null, 1, install, 40001));
    expectLastCall().once();
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 4 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class ControlPlaneRedirectManagerTest method testAddDevice.

/**
 * Tests adding new Device to a openflow router.
 */
@Test
public void testAddDevice() {
    ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
    List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>();
    interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")));
    interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120")));
    Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses, MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
    interfaces.add(sw1Eth4);
    EasyMock.reset(flowObjectiveService);
    setUpFlowObjectiveService();
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED, dev3));
    verify(flowObjectiveService);
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) ArrayList(java.util.ArrayList) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 5 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class ControlPlaneRedirectManagerTest method testAddInterface.

/**
 * Tests adding while updating the networkConfig.
 */
@Test
public void testAddInterface() {
    ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
    List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>();
    interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")));
    interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120")));
    Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses, MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
    interfaces.add(sw1Eth4);
    EasyMock.reset(flowObjectiveService);
    expect(flowObjectiveService.allocateNextId()).andReturn(1).anyTimes();
    setUpInterfaceConfiguration(sw1Eth4, true);
    replay(flowObjectiveService);
    interfaceListener.event(new InterfaceEvent(InterfaceEvent.Type.INTERFACE_ADDED, sw1Eth4, 500L));
    verify(flowObjectiveService);
}
Also used : InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) ArrayList(java.util.ArrayList) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Aggregations

InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)25 Interface (org.onosproject.net.intf.Interface)18 ConnectPoint (org.onosproject.net.ConnectPoint)13 ArrayList (java.util.ArrayList)8 IpAddress (org.onlab.packet.IpAddress)6 DeviceId (org.onosproject.net.DeviceId)6 Test (org.junit.Test)5 MacAddress (org.onlab.packet.MacAddress)5 VlanId (org.onlab.packet.VlanId)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 Ethernet (org.onlab.packet.Ethernet)3 IPv4 (org.onlab.packet.IPv4)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 TrafficSelector (org.onosproject.net.flow.TrafficSelector)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 Collection (java.util.Collection)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Ip4Address (org.onlab.packet.Ip4Address)2 NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)2