Search in sources :

Example 21 with InterfaceIpAddress

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

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

the class RouterAdvertisementManager method loadGlobalPrefixConfig.

@SuppressWarnings("GuardedBy")
private synchronized // Loading global prefixes for devices from network configuration
void loadGlobalPrefixConfig() {
    globalPrefixes.clear();
    Set<DeviceId> deviceSubjects = networkConfigRegistry.getSubjects(DeviceId.class, RouterAdvertisementDeviceConfig.class);
    deviceSubjects.forEach(subject -> {
        RouterAdvertisementDeviceConfig config = networkConfigRegistry.getConfig(subject, RouterAdvertisementDeviceConfig.class);
        if (config != null) {
            List<InterfaceIpAddress> ips = config.prefixes();
            globalPrefixes.put(subject, ips);
        }
    });
}
Also used : DeviceId(org.onosproject.net.DeviceId) RouterAdvertisementDeviceConfig(org.onosproject.ra.config.RouterAdvertisementDeviceConfig) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 23 with InterfaceIpAddress

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

the class RouterAdvertisementDeviceConfig method prefixes.

/**
 * Gets global router advertisement prefixes for device.
 *
 * @return global prefixes. Or null if not configured.
 */
public List<InterfaceIpAddress> prefixes() {
    if (!object.has(PREFIXES)) {
        return null;
    }
    List<InterfaceIpAddress> ips = Lists.newArrayList();
    ArrayNode prefixes = (ArrayNode) object.path(PREFIXES);
    prefixes.forEach(i -> ips.add(InterfaceIpAddress.valueOf(i.asText())));
    return ips;
}
Also used : ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 24 with InterfaceIpAddress

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

the class FpmManager method modified.

@Modified
protected void modified(ComponentContext context) {
    Ip4Address rurIPv4Address;
    Ip6Address rurIPv6Address;
    Dictionary<?, ?> properties = context.getProperties();
    if (properties == null) {
        return;
    }
    String strClearRoutes = Tools.get(properties, CLEAR_ROUTES);
    if (strClearRoutes != null) {
        clearRoutes = Boolean.parseBoolean(strClearRoutes);
        log.info("clearRoutes is {}", clearRoutes);
    }
    String strPdPushEnabled = Tools.get(properties, PD_PUSH_ENABLED);
    if (strPdPushEnabled != null) {
        boolean oldValue = pdPushEnabled;
        pdPushEnabled = Boolean.parseBoolean(strPdPushEnabled);
        if (pdPushEnabled) {
            pdPushNextHopIPv4 = new ArrayList<Ip4Address>();
            pdPushNextHopIPv6 = new ArrayList<Ip6Address>();
            String strPdPushNextHopIPv4 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV4);
            if (strPdPushNextHopIPv4 != null) {
                List<String> strPdPushNextHopIPv4List = Arrays.asList(strPdPushNextHopIPv4.split(","));
                for (String nextHop : strPdPushNextHopIPv4List) {
                    log.trace("IPv4 next hop added is:" + nextHop);
                    pdPushNextHopIPv4.add(Ip4Address.valueOf(nextHop));
                }
            }
            String strPdPushNextHopIPv6 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV6);
            if (strPdPushNextHopIPv6 != null) {
                List<String> strPdPushNextHopIPv6List = Arrays.asList(strPdPushNextHopIPv6.split(","));
                for (String nextHop : strPdPushNextHopIPv6List) {
                    log.trace("IPv6 next hop added is:" + nextHop);
                    pdPushNextHopIPv6.add(Ip6Address.valueOf(nextHop));
                }
            }
            if (pdPushNextHopIPv4.size() == 0) {
                rurIPv4Address = interfaceService.getInterfaces().stream().filter(iface -> iface.name().contains("RUR")).map(Interface::ipAddressesList).flatMap(Collection::stream).map(InterfaceIpAddress::ipAddress).filter(IpAddress::isIp4).map(IpAddress::getIp4Address).findFirst().orElse(null);
                log.debug("RUR IPv4 address extracted from netcfg is: {}", rurIPv4Address);
                if (rurIPv4Address != null) {
                    pdPushNextHopIPv4.add(rurIPv4Address);
                } else {
                    log.debug("Unable to extract RUR IPv4 address from netcfg");
                }
            }
            if (pdPushNextHopIPv6 == null || pdPushNextHopIPv6.size() == 0) {
                rurIPv6Address = interfaceService.getInterfaces().stream().filter(iface -> iface.name().contains("RUR")).map(Interface::ipAddressesList).flatMap(Collection::stream).map(InterfaceIpAddress::ipAddress).filter(IpAddress::isIp6).map(IpAddress::getIp6Address).findFirst().orElse(null);
                log.debug("RUR IPv6 address extracted from netcfg is: {}", rurIPv6Address);
                if (rurIPv6Address != null) {
                    pdPushNextHopIPv6.add(rurIPv6Address);
                } else {
                    log.debug("Unable to extract RUR IPv6 address from netcfg");
                }
            }
            log.info("PD pushing is enabled.");
            if (pdPushNextHopIPv4.size() != 0) {
                log.info("ipv4 next-hop {} with {} items", pdPushNextHopIPv4.toString(), pdPushNextHopIPv4.size());
            } else {
                log.info("ipv4 next-hop is null");
            }
            if (pdPushNextHopIPv6.size() != 0) {
                log.info("ipv6 next-hop={} with {} items", pdPushNextHopIPv6.toString(), pdPushNextHopIPv6.size());
            } else {
                log.info("ipv6 next-hop is null");
            }
            processStaticRoutes();
        } else {
            log.info("PD pushing is disabled.");
        }
    }
}
Also used : Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) Collection(java.util.Collection) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) IpAddress(org.onlab.packet.IpAddress) Modified(org.osgi.service.component.annotations.Modified)

Example 25 with InterfaceIpAddress

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

the class PeerConnectivityManager method buildSpeakerIntents.

private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker, EncapsulationType encap) {
    List<PointToPointIntent> intents = new ArrayList<>();
    // Get the BGP Speaker VLAN Id
    VlanId bgpSpeakerVlanId = speaker.vlan();
    for (IpAddress peerAddress : speaker.peers()) {
        Interface peeringInterface = interfaceService.getMatchingInterface(peerAddress);
        if (peeringInterface == null) {
            log.debug("No peering interface found for peer {} on speaker {}", peerAddress, speaker);
            continue;
        }
        IpAddress bgpSpeakerAddress = null;
        for (InterfaceIpAddress address : peeringInterface.ipAddressesList()) {
            if (address.subnetAddress().contains(peerAddress)) {
                bgpSpeakerAddress = address.ipAddress();
                break;
            }
        }
        checkNotNull(bgpSpeakerAddress);
        VlanId peerVlanId = peeringInterface.vlan();
        intents.addAll(buildIntents(speaker.connectPoint(), bgpSpeakerVlanId, bgpSpeakerAddress, peeringInterface.connectPoint(), peerVlanId, peerAddress, encap));
    }
    return intents;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) IpAddress(org.onlab.packet.IpAddress) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

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