Search in sources :

Example 16 with PortNumber

use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.

the class PolicyGroupParams method hashCode.

@Override
public int hashCode() {
    int result = 17;
    int combinedHash = 0;
    for (PortNumber port : ports) {
        combinedHash = combinedHash + port.hashCode();
    }
    combinedHash = combinedHash + Objects.hash(labelStack);
    result = 31 * result + combinedHash;
    return result;
}
Also used : PortNumber(org.onosproject.net.PortNumber)

Example 17 with PortNumber

use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.

the class LinkHandler method updateHostPorts.

/**
 * Administratively enables or disables edge ports if the link that was
 * added or removed was the only uplink port from an edge device. Edge ports
 * that belong to dual-homed hosts are always processed. In addition,
 * single-homed host ports are optionally processed depending on the
 * singleHomedDown property.
 *
 * @param link the link to be processed
 * @param added true if link was added, false if link was removed
 */
private void updateHostPorts(Link link, boolean added) {
    // Topology has only a single pair of leaves
    if (srManager.getInfraDeviceIds().isEmpty()) {
        log.debug("No spine configured. Not updating edge port for {} {}", link, added ? "add" : "remove");
        return;
    }
    DeviceConfiguration devConfig = srManager.deviceConfiguration;
    if (added) {
        try {
            if (!devConfig.isEdgeDevice(link.src().deviceId()) || devConfig.isEdgeDevice(link.dst().deviceId())) {
                return;
            }
        } catch (DeviceConfigNotFoundException e) {
            log.warn("Unable to determine if link is a valid uplink" + e.getMessage());
        }
        // re-enable previously disabled ports on this edge-device if any
        Set<PortNumber> p = downedPortStore.remove(link.src().deviceId());
        if (p != null) {
            log.warn("Link src {} --> dst {} added is an edge-device uplink, " + "enabling dual homed ports if any: {}", link.src().deviceId(), link.dst().deviceId(), (p.isEmpty()) ? "no ports" : p);
            p.forEach(pnum -> srManager.deviceAdminService.changePortState(link.src().deviceId(), pnum, true));
        }
    } else {
        // If the device does not have a pair device - skip
        DeviceId dev = link.src().deviceId();
        if (getPairDeviceIdOrNull(dev) == null) {
            log.info("Device {} does not have pair device " + "not disabling access port", dev);
            return;
        }
        // Verify if last uplink
        if (!lastUplink(link)) {
            return;
        }
        // find dual homed hosts on this dev to disable
        Set<PortNumber> dp = srManager.hostHandler.getDualHomedHostPorts(dev);
        log.warn("Link src {} --> dst {} removed was the last uplink, " + "disabling  dual homed ports:  {}", dev, link.dst().deviceId(), (dp.isEmpty()) ? "no ports" : dp);
        dp.forEach(pnum -> srManager.deviceAdminService.changePortState(dev, pnum, false));
        if (srManager.singleHomedDown) {
            // get all configured ports and down them if they haven't already
            // been downed
            srManager.deviceService.getPorts(dev).stream().filter(p -> p.isEnabled() && !dp.contains(p.number())).filter(p -> srManager.interfaceService.isConfigured(new ConnectPoint(dev, p.number()))).filter(p -> !srManager.deviceConfiguration.isPairLocalPort(dev, p.number())).forEach(p -> {
                log.warn("Last uplink gone src {} -> dst {} .. removing " + "configured port {}", p.number());
                srManager.deviceAdminService.changePortState(dev, p.number(), false);
                dp.add(p.number());
            });
        }
        if (!dp.isEmpty()) {
            // update global store
            Set<PortNumber> p = downedPortStore.get(dev);
            if (p == null) {
                p = dp;
            } else {
                p.addAll(dp);
            }
            downedPortStore.put(link.src().deviceId(), p);
        }
    }
}
Also used : DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) Logger(org.slf4j.Logger) HostLocation(org.onosproject.net.HostLocation) Device(org.onosproject.net.Device) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) Collectors(java.util.stream.Collectors) Link(org.onosproject.net.Link) Sets(com.google.common.collect.Sets) ConnectPoint(org.onosproject.net.ConnectPoint) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) Map(java.util.Map) Entry(java.util.Map.Entry) LinkService(org.onosproject.net.link.LinkService) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) DeviceId(org.onosproject.net.DeviceId) DeviceId(org.onosproject.net.DeviceId) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 18 with PortNumber

use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.

the class LinkHandler method avoidLink.

/**
 * Determines if the given link should be avoided in routing calculations by
 * policy or design.
 *
 * @param link the infrastructure link being queried
 * @return true if link should be avoided
 */
boolean avoidLink(Link link) {
    // XXX currently only avoids all pair-links. In the future can be
    // extended to avoid any generic link
    DeviceId src = link.src().deviceId();
    PortNumber srcPort = link.src().port();
    DeviceConfiguration devConfig = srManager.deviceConfiguration;
    if (devConfig == null || !devConfig.isConfigured(src)) {
        log.warn("Device {} not configured..cannot avoid link {}", src, link);
        return false;
    }
    DeviceId pairDev;
    PortNumber pairLocalPort, pairRemotePort = null;
    try {
        pairDev = devConfig.getPairDeviceId(src);
        pairLocalPort = devConfig.getPairLocalPort(src);
        if (pairDev != null) {
            pairRemotePort = devConfig.getPairLocalPort(pairDev);
        }
    } catch (DeviceConfigNotFoundException e) {
        log.warn("Pair dev for dev {} not configured..cannot avoid link {}", src, link);
        return false;
    }
    return srcPort.equals(pairLocalPort) && link.dst().deviceId().equals(pairDev) && link.dst().port().equals(pairRemotePort);
}
Also used : DeviceId(org.onosproject.net.DeviceId) PortNumber(org.onosproject.net.PortNumber) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 19 with PortNumber

use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.

the class PortAuthTracker method radiusAuthorize.

/**
 * Radius has authorized the supplicant at this connect point. If
 * we are tracking this port, clear the blocking flow and mark the
 * port as authorized.
 *
 * @param connectPoint supplicant connect point
 */
void radiusAuthorize(ConnectPoint connectPoint) {
    DeviceId d = connectPoint.deviceId();
    PortNumber p = connectPoint.port();
    if (configured(d, p)) {
        clearBlockingFlow(d, p);
        markAsAuthenticated(d, p);
    }
}
Also used : DeviceId(org.onosproject.net.DeviceId) PortNumber(org.onosproject.net.PortNumber)

Example 20 with PortNumber

use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.

the class PortAuthTracker method reportPortsAuthState.

private List<PortAuthState> reportPortsAuthState() {
    List<PortAuthState> result = new ArrayList<>();
    for (Map.Entry<DeviceId, Map<PortNumber, BlockState>> entry : blockedPorts.entrySet()) {
        DeviceId d = entry.getKey();
        Map<PortNumber, BlockState> portMap = entry.getValue();
        for (PortNumber p : portMap.keySet()) {
            result.add(new PortAuthState(d, p, portMap.get(p)));
        }
    }
    Collections.sort(result);
    return result;
}
Also used : DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) PortNumber(org.onosproject.net.PortNumber) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

PortNumber (org.onosproject.net.PortNumber)336 DeviceId (org.onosproject.net.DeviceId)136 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)109 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)103 ConnectPoint (org.onosproject.net.ConnectPoint)82 TrafficSelector (org.onosproject.net.flow.TrafficSelector)80 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)74 Port (org.onosproject.net.Port)67 ArrayList (java.util.ArrayList)64 Set (java.util.Set)64 List (java.util.List)59 Logger (org.slf4j.Logger)58 Collectors (java.util.stream.Collectors)51 DeviceService (org.onosproject.net.device.DeviceService)49 VlanId (org.onlab.packet.VlanId)42 MacAddress (org.onlab.packet.MacAddress)41 Device (org.onosproject.net.Device)40 FlowRule (org.onosproject.net.flow.FlowRule)40 Optional (java.util.Optional)39 Sets (com.google.common.collect.Sets)35