Search in sources :

Example 46 with DeviceConfigNotFoundException

use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.

the class LinkHandler method isLinkValid.

/**
 * Checks validity of link. Examples of invalid links include
 * indirect-links, links between ports on the same switch, and more.
 *
 * @param link the link to be processed
 * @return true if valid link
 */
boolean isLinkValid(Link link) {
    if (link.type() != Link.Type.DIRECT) {
        // NOTE: A DIRECT link might be transiently marked as INDIRECT
        // if BDDP is received before LLDP. We can safely ignore that
        // until the LLDP is received and the link is marked as DIRECT.
        log.info("Ignore link {}->{}. Link type is {} instead of DIRECT.", link.src(), link.dst(), link.type());
        return false;
    }
    DeviceId srcId = link.src().deviceId();
    DeviceId dstId = link.dst().deviceId();
    if (srcId.equals(dstId)) {
        log.warn("Links between ports on the same switch are not " + "allowed .. ignoring link {}", link);
        return false;
    }
    DeviceConfiguration devConfig = srManager.deviceConfiguration;
    if (devConfig == null) {
        log.warn("Cannot check validity of link without device config");
        return true;
    }
    try {
        /*if (!devConfig.isEdgeDevice(srcId)
                    && !devConfig.isEdgeDevice(dstId)) {
                // ignore links between spines
                // XXX revisit when handling multi-stage fabrics
                log.warn("Links between spines not allowed...ignoring "
                        + "link {}", link);
                return false;
            }*/
        if (devConfig.isEdgeDevice(srcId) && devConfig.isEdgeDevice(dstId)) {
            // one pair-link
            if (devConfig.getPairDeviceId(srcId).equals(dstId) && devConfig.getPairLocalPort(srcId).equals(link.src().port()) && devConfig.getPairLocalPort(dstId).equals(link.dst().port())) {
                // found pair link - allow it
                return true;
            } else {
                log.warn("Links between leaves other than pair-links are " + "not allowed...ignoring link {}", link);
                return false;
            }
        }
    } catch (DeviceConfigNotFoundException e) {
        // We still want to count the links in seenLinks even though there
        // is no config. So we let it return true
        log.warn("Could not check validity of link {} as subtending devices " + "are not yet configured", link);
    }
    return true;
}
Also used : DeviceId(org.onosproject.net.DeviceId) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 47 with DeviceConfigNotFoundException

use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.

the class LinkHandler method checkUplinksForHost.

/**
 * Administratively disables the host location switchport if the edge device
 * has no viable uplinks. The caller needs to determine if such behavior is
 * desired for the single or dual-homed host.
 *
 * @param loc the host location
 */
void checkUplinksForHost(HostLocation loc) {
    // Topology has only a single pair of leaves
    if (srManager.getInfraDeviceIds().isEmpty()) {
        log.debug("No spine configured. Not disabling access port for {}", loc);
        return;
    }
    // If the device does not have a pair device - return
    if (getPairDeviceIdOrNull(loc.deviceId()) == null) {
        log.info("Device {} does not have pair device " + "not disabling access port", loc.deviceId());
        return;
    }
    // Verify link validity
    try {
        for (Link l : srManager.linkService.getDeviceLinks(loc.deviceId())) {
            if (srManager.deviceConfiguration.isEdgeDevice(l.dst().deviceId()) || l.state() == Link.State.INACTIVE) {
                continue;
            }
            // found valid uplink - so, nothing to do
            return;
        }
    } catch (DeviceConfigNotFoundException e) {
        log.warn("Could not check for valid uplinks due to missing device" + "config " + e.getMessage());
        return;
    }
    log.warn("Host location {} has no valid uplinks disabling port", loc);
    srManager.deviceAdminService.changePortState(loc.deviceId(), loc.port(), false);
    Set<PortNumber> p = downedPortStore.get(loc.deviceId());
    if (p == null) {
        p = Sets.newHashSet(loc.port());
    } else {
        p.add(loc.port());
    }
    downedPortStore.put(loc.deviceId(), p);
}
Also used : PortNumber(org.onosproject.net.PortNumber) Link(org.onosproject.net.Link) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 48 with DeviceConfigNotFoundException

use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.

the class ArpHandler method isArpForRouter.

private boolean isArpForRouter(NeighbourMessageContext pkt) {
    Ip4Address targetProtocolAddress = pkt.target().getIp4Address();
    Set<IpAddress> gatewayIpAddresses = null;
    try {
        if (targetProtocolAddress.equals(config.getRouterIpv4(pkt.inPort().deviceId()))) {
            return true;
        }
        gatewayIpAddresses = config.getPortIPs(pkt.inPort().deviceId());
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting check for router IP in processing arp");
    }
    if (gatewayIpAddresses != null && gatewayIpAddresses.contains(targetProtocolAddress)) {
        return true;
    }
    return false;
}
Also used : Ip4Address(org.onlab.packet.Ip4Address) IpAddress(org.onlab.packet.IpAddress) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Aggregations

DeviceConfigNotFoundException (org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)48 DeviceId (org.onosproject.net.DeviceId)24 ConnectPoint (org.onosproject.net.ConnectPoint)22 MacAddress (org.onlab.packet.MacAddress)18 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)18 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)18 PortNumber (org.onosproject.net.PortNumber)11 DefaultObjectiveContext (org.onosproject.net.flowobjective.DefaultObjectiveContext)11 Set (java.util.Set)10 IpAddress (org.onlab.packet.IpAddress)9 VlanId (org.onlab.packet.VlanId)9 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)9 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)9 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)9 Ip4Address (org.onlab.packet.Ip4Address)8 Ip6Address (org.onlab.packet.Ip6Address)8 Logger (org.slf4j.Logger)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7