Search in sources :

Example 16 with InterfaceIpAddress

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

the class InterfaceConfig method getInterfaces.

/**
 * Retrieves all interfaces configured on this port.
 *
 * @return set of interfaces
 * @throws ConfigException if there is any error in the JSON config
 */
public Set<Interface> getInterfaces() throws ConfigException {
    Set<Interface> interfaces = Sets.newHashSet();
    try {
        for (JsonNode intfNode : array) {
            String name = intfNode.path(NAME).asText(null);
            List<InterfaceIpAddress> ips = getIps(intfNode);
            String mac = intfNode.path(MAC).asText();
            MacAddress macAddr = mac.isEmpty() ? null : MacAddress.valueOf(mac);
            VlanId vlan = getVlan(intfNode, VLAN);
            VlanId vlanUntagged = getVlan(intfNode, VLAN_UNTAGGED);
            Set<VlanId> vlanTagged = getVlans(intfNode, VLAN_TAGGED);
            VlanId vlanNative = getVlan(intfNode, VLAN_NATIVE);
            interfaces.add(new Interface(name, subject, ips, macAddr, vlan, vlanUntagged, vlanTagged, vlanNative));
        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }
    return interfaces;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ConfigException(org.onosproject.net.config.ConfigException) MacAddress(org.onlab.packet.MacAddress) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId)

Example 17 with InterfaceIpAddress

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

the class InterfaceManagerTest method createInterface.

private Interface createInterface(int i) {
    ConnectPoint cp = createConnectPoint(i);
    InterfaceIpAddress ia = InterfaceIpAddress.valueOf("192.168." + i + ".1/24");
    Interface intf = new Interface(Interface.NO_INTERFACE_NAME, cp, Collections.singletonList(ia), MacAddress.valueOf(i), VlanId.vlanId((short) i));
    return intf;
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface)

Example 18 with InterfaceIpAddress

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

the class InterfaceCodec method decode.

@Override
public Interface decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    String name = nullIsIllegal(json.findValue(NAME), NAME + MISSING_NAME_MESSAGE).asText();
    ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(nullIsIllegal(json.findValue(CONNECT_POINT), CONNECT_POINT + MISSING_CONNECT_POINT_MESSAGE).asText());
    List<InterfaceIpAddress> ipAddresses = Lists.newArrayList();
    if (json.findValue(IPS) != null) {
        json.findValue(IPS).forEach(ip -> {
            ipAddresses.add(InterfaceIpAddress.valueOf(ip.asText()));
        });
    }
    MacAddress macAddr = json.findValue(MAC) == null ? null : MacAddress.valueOf(json.findValue(MAC).asText());
    VlanId vlanId = json.findValue(VLAN) == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(json.findValue(VLAN).asText()));
    Interface inter = new Interface(name, connectPoint, ipAddresses, macAddr, vlanId);
    return inter;
}
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)

Example 19 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress 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 20 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress 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)

Aggregations

InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)28 Interface (org.onosproject.net.intf.Interface)21 ConnectPoint (org.onosproject.net.ConnectPoint)16 ArrayList (java.util.ArrayList)11 IpAddress (org.onlab.packet.IpAddress)9 MacAddress (org.onlab.packet.MacAddress)9 VlanId (org.onlab.packet.VlanId)9 DeviceId (org.onosproject.net.DeviceId)9 Ethernet (org.onlab.packet.Ethernet)5 IPv4 (org.onlab.packet.IPv4)5 PortNumber (org.onosproject.net.PortNumber)5 TrafficSelector (org.onosproject.net.flow.TrafficSelector)5 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 HashMultimap (com.google.common.collect.HashMultimap)4 Lists (com.google.common.collect.Lists)4 Sets (com.google.common.collect.Sets)4 Collections (java.util.Collections)4 List (java.util.List)4 Set (java.util.Set)4