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;
}
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);
}
}
}
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);
}
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);
}
}
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;
}
Aggregations