Search in sources :

Example 61 with Interface

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

the class ControlPlaneRedirectManager method updateInterfaceForwarding.

/**
 * Installs or removes the basic forwarding flows for each interface.
 *
 * @param request provisioning request containing router and interface
 * @param install true to install the objectives, false to remove them
 */
private void updateInterfaceForwarding(InterfaceProvisionRequest request, boolean install) {
    Interface intf = request.intf();
    log.debug("{} interface objectives for {}", operation(install), intf);
    DeviceId deviceId = intf.connectPoint().deviceId();
    PortNumber controlPlanePort = request.controlPlaneConnectPoint().port();
    for (InterfaceIpAddress ip : intf.ipAddressesList()) {
        // create nextObjectives for forwarding to this interface and the
        // controlPlaneConnectPoint
        int cpNextId, intfNextId;
        if (intf.vlan() == VlanId.NONE) {
            cpNextId = modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId(ASSIGNED_VLAN), true, install);
            intfNextId = modifyNextObjective(deviceId, intf.connectPoint().port(), VlanId.vlanId(ASSIGNED_VLAN), true, install);
        } else {
            cpNextId = modifyNextObjective(deviceId, controlPlanePort, intf.vlan(), false, install);
            intfNextId = modifyNextObjective(deviceId, intf.connectPoint().port(), intf.vlan(), false, install);
        }
        List<ForwardingObjective> fwdToSend = Lists.newArrayList();
        TrafficSelector selector;
        // IP traffic toward the router.
        selector = buildIPDstSelector(ip.ipAddress().toIpPrefix(), intf.connectPoint().port(), null, intf.mac(), intf.vlan());
        fwdToSend.add(buildForwardingObjective(selector, null, cpNextId, install, ACL_PRIORITY));
        // IP traffic from the router.
        selector = buildIPSrcSelector(ip.ipAddress().toIpPrefix(), controlPlanePort, intf.mac(), null, intf.vlan());
        fwdToSend.add(buildForwardingObjective(selector, null, intfNextId, install, ACL_PRIORITY));
        // We build the punt treatment.
        TrafficTreatment treatment = DefaultTrafficTreatment.builder().punt().build();
        // IPv6 traffic - we have to deal with the NDP protocol.
        if (ip.ipAddress().isIp4()) {
            // ARP traffic towards the router.
            selector = buildArpSelector(intf.connectPoint().port(), intf.vlan(), null, null);
            fwdToSend.add(buildForwardingObjective(selector, treatment, cpNextId, install, ACL_PRIORITY + 1));
            // ARP traffic from the router.
            selector = buildArpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().getIp4Address(), intf.mac());
            fwdToSend.add(buildForwardingObjective(selector, treatment, intfNextId, install, ACL_PRIORITY + 1));
        } else {
            // Neighbour solicitation traffic towards the router.
            // This flow is for the global unicast address.
            selector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            fwdToSend.add(buildForwardingObjective(selector, treatment, cpNextId, install, ACL_PRIORITY + 1));
            // Neighbour solicitation traffic towards the router.
            // This flow is for the link local address.
            selector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            fwdToSend.add(buildForwardingObjective(selector, treatment, cpNextId, install, ACL_PRIORITY + 1));
            // Neighbour solicitation traffic towards the router.
            // This flow is for the solicitation node address of
            // the global unicast address.
            selector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(ip.ipAddress().toOctets())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            fwdToSend.add(buildForwardingObjective(selector, treatment, cpNextId, install, ACL_PRIORITY + 1));
            // Neighbour solicitation traffic towards the router.
            // This flow is for the solicitation node address of
            // the link local address.
            selector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(getLinkLocalAddress(intf.mac().toBytes()))).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            fwdToSend.add(buildForwardingObjective(selector, treatment, cpNextId, install, ACL_PRIORITY + 1));
            // Neighbour solicitation traffic from the router.
            // This flow is for the global unicast address.
            selector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            fwdToSend.add(buildForwardingObjective(selector, treatment, intfNextId, install, ACL_PRIORITY + 1));
            // Neighbour solicitation traffic from the router.
            // This flow is for the link local address.
            selector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            fwdToSend.add(buildForwardingObjective(selector, treatment, intfNextId, install, ACL_PRIORITY + 1));
            // Neighbour advertisement traffic towards the router.
            // This flow is for the global unicast address
            selector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            fwdToSend.add(buildForwardingObjective(selector, treatment, cpNextId, install, ACL_PRIORITY + 1));
            // Neighbour advertisement traffic towards the router.
            // This flow is for the link local address
            selector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            fwdToSend.add(buildForwardingObjective(selector, treatment, cpNextId, install, ACL_PRIORITY + 1));
            // Neighbour advertisement traffic from the router.
            // This flow is for the global unicast address
            selector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, intf.mac());
            fwdToSend.add(buildForwardingObjective(selector, treatment, intfNextId, install, ACL_PRIORITY + 1));
            // Neighbour advertisement traffic from the router.
            // This flow is for the link local address
            selector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, intf.mac());
            fwdToSend.add(buildForwardingObjective(selector, treatment, intfNextId, install, ACL_PRIORITY + 1));
        }
        // Finally we push the fwd objectives through the flow objective service.
        fwdToSend.stream().forEach(forwardingObjective -> flowObjectiveService.forward(deviceId, forwardingObjective));
    }
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 62 with Interface

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

the class ControlPlaneRedirectManagerTest method setUpInterfaceService.

/**
 * Setup Interface expectation for all Testcases.
 */
private void setUpInterfaceService() {
    List<InterfaceIpAddress> interfaceIpAddresses1 = new ArrayList<>();
    interfaceIpAddresses1.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.10.101"), IpPrefix.valueOf("192.168.10.0/24")));
    Interface sw1Eth1 = new Interface(SW1_ETH1.deviceId().toString(), SW1_ETH1, interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE);
    interfaces.add(sw1Eth1);
    List<InterfaceIpAddress> interfaceIpAddresses2 = new ArrayList<>();
    interfaceIpAddresses2.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"), IpPrefix.valueOf("192.168.20.0/24")));
    Interface sw1Eth2 = new Interface(SW1_ETH1.deviceId().toString(), SW1_ETH2, interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE);
    interfaces.add(sw1Eth2);
    List<InterfaceIpAddress> interfaceIpAddresses3 = new ArrayList<>();
    interfaceIpAddresses3.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"), IpPrefix.valueOf("192.168.30.0/24")));
    Interface sw1Eth3 = new Interface(SW1_ETH1.deviceId().toString(), SW1_ETH3, interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"), VlanId.NONE);
    interfaces.add(sw1Eth3);
}
Also used : ArrayList(java.util.ArrayList) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface)

Example 63 with Interface

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

the class ControlPlaneRedirectManagerTest method testRemoveInterface.

@Test
public void testRemoveInterface() {
    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);
    EasyMock.reset(flowObjectiveService);
    expect(flowObjectiveService.allocateNextId()).andReturn(1).anyTimes();
    setUpInterfaceConfiguration(sw1Eth4, false);
    replay(flowObjectiveService);
    interfaceListener.event(new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, 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 64 with Interface

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

the class ControlPlaneRedirectManagerTest method setUpFlowObjectiveService.

/**
 * Setup flow Configuration for all configured Interfaces.
 */
private void setUpFlowObjectiveService() {
    expect(flowObjectiveService.allocateNextId()).andReturn(1).anyTimes();
    for (Interface intf : interfaceService.getInterfaces()) {
        setUpInterfaceConfiguration(intf, true);
    }
    replay(flowObjectiveService);
}
Also used : Interface(org.onosproject.net.intf.Interface)

Example 65 with Interface

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

the class FibInstaller method addNextHop.

private synchronized void addNextHop(ResolvedRoute route) {
    prefixToNextHop.put(route.prefix(), route.nextHop());
    if (nextHopsCount.count(route.nextHop()) == 0) {
        // There was no next hop in the multiset
        Interface egressIntf = interfaceService.getMatchingInterface(route.nextHop());
        if (egressIntf == null) {
            log.warn("no egress interface found for {}", route);
            return;
        }
        NextHopGroupKey groupKey = new NextHopGroupKey(route.nextHop());
        NextHop nextHop = new NextHop(route.nextHop(), route.nextHopMac(), groupKey);
        TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setEthSrc(egressIntf.mac()).setEthDst(nextHop.mac());
        TrafficSelector.Builder metabuilder = null;
        if (!egressIntf.vlan().equals(VlanId.NONE)) {
            treatment.pushVlan().setVlanId(egressIntf.vlan()).setVlanPcp((byte) 0);
        } else {
            // untagged outgoing port may require internal vlan in some pipelines
            metabuilder = DefaultTrafficSelector.builder();
            metabuilder.matchVlanId(VlanId.vlanId(ASSIGNED_VLAN));
        }
        treatment.setOutput(egressIntf.connectPoint().port());
        int nextId = flowObjectiveService.allocateNextId();
        NextObjective.Builder nextBuilder = DefaultNextObjective.builder().withId(nextId).addTreatment(treatment.build()).withType(NextObjective.Type.SIMPLE).fromApp(fibAppId);
        if (metabuilder != null) {
            nextBuilder.withMeta(metabuilder.build());
        }
        // TODO add callbacks
        NextObjective nextObjective = nextBuilder.add();
        flowObjectiveService.next(deviceId, nextObjective);
        nextHops.put(nextHop.ip(), nextId);
        if (routeToNextHop) {
            // Install route to next hop
            ForwardingObjective fob = generateRibForwardingObj(IpPrefix.valueOf(route.nextHop(), 32), nextId).add();
            flowObjectiveService.forward(deviceId, fob);
        }
    }
    nextHopsCount.add(route.nextHop());
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) NextHop(org.onosproject.routing.NextHop) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Interface(org.onosproject.net.intf.Interface) NextHopGroupKey(org.onosproject.routing.NextHopGroupKey)

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