Search in sources :

Example 6 with Interface

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

the class ControlPlaneRedirectManager method updateOspfForwarding.

/**
 * Installs or removes OSPF forwarding rules.
 *
 * @param request provisioning request containing router and interface
 * @param install true to create an add objective, false to create a remove
 *            objective
 */
private void updateOspfForwarding(InterfaceProvisionRequest request, boolean install) {
    // TODO IPv6 support has not been implemented yet
    Interface intf = request.intf();
    log.debug("{} OSPF flows for {}", operation(install), intf);
    // OSPF to router
    TrafficSelector toSelector = DefaultTrafficSelector.builder().matchInPort(intf.connectPoint().port()).matchEthType(EthType.EtherType.IPV4.ethType().toShort()).matchVlanId(intf.vlan()).matchIPProtocol((byte) OSPF_IP_PROTO).build();
    // create nextObjectives for forwarding to the controlPlaneConnectPoint
    DeviceId deviceId = intf.connectPoint().deviceId();
    PortNumber controlPlanePort = request.controlPlaneConnectPoint().port();
    int cpNextId;
    if (intf.vlan() == VlanId.NONE) {
        cpNextId = modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId(ASSIGNED_VLAN), true, install);
    } else {
        cpNextId = modifyNextObjective(deviceId, controlPlanePort, intf.vlan(), false, install);
    }
    flowObjectiveService.forward(intf.connectPoint().deviceId(), buildForwardingObjective(toSelector, null, cpNextId, install ? request.info().ospfEnabled() : install, ACL_PRIORITY));
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PortNumber(org.onosproject.net.PortNumber) Interface(org.onosproject.net.intf.Interface)

Example 7 with Interface

use of org.onosproject.net.intf.Interface 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 8 with Interface

use of org.onosproject.net.intf.Interface 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 9 with Interface

use of org.onosproject.net.intf.Interface 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)

Example 10 with Interface

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

the class FibInstaller method updateMcastFilteringObjective.

/**
 * Installs or removes multicast filtering objectives relating to an interface.
 *
 * @param routerIntf interface to update objectives for
 * @param install true to install the objectives, false to remove them
 */
private void updateMcastFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) {
    Interface intf = routerIntf.intf();
    VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ? VlanId.vlanId(ASSIGNED_VLAN) : egressVlan();
    FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
    // first add filter for the interface
    fob.withKey(Criteria.matchInPort(intf.connectPoint().port())).addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST, MacAddress.IPV4_MULTICAST_MASK)).addCondition(Criteria.matchVlanId(ingressVlan()));
    fob.withPriority(PRIORITY_OFFSET);
    TrafficTreatment tt = DefaultTrafficTreatment.builder().pushVlan().setVlanId(assignedVlan).build();
    fob.withMeta(tt);
    fob.permit().fromApp(fibAppId);
    sendFilteringObjective(install, fob, intf);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Interface(org.onosproject.net.intf.Interface) VlanId(org.onlab.packet.VlanId)

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