Search in sources :

Example 21 with PortNumber

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

the class PortAuthTracker method logPortsNoLongerBlocked.

private void logPortsNoLongerBlocked() {
    for (Map.Entry<DeviceId, Map<PortNumber, BlockState>> entry : oldMap.entrySet()) {
        DeviceId d = entry.getKey();
        Map<PortNumber, BlockState> portMap = entry.getValue();
        for (PortNumber p : portMap.keySet()) {
            if (notInMap(d, p)) {
                clearBlockingFlow(d, p);
                log.info("De-configuring port {}/{} (UNCHECKED)", d, p);
            }
        }
    }
}
Also used : DeviceId(org.onosproject.net.DeviceId) PortNumber(org.onosproject.net.PortNumber) HashMap(java.util.HashMap) Map(java.util.Map)

Example 22 with PortNumber

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

the class RouteHandler method processSingleLeafPairIfNeeded.

protected boolean processSingleLeafPairIfNeeded(Set<ConnectPoint> locations, ConnectPoint location, IpPrefix prefix, VlanId nextHopVlan) {
    // Special handling for single leaf pair
    if (!srManager.getInfraDeviceIds().isEmpty()) {
        log.debug("Spine found. Skip single leaf pair handling");
        return false;
    }
    Optional<DeviceId> pairDeviceId = srManager.getPairDeviceId(location.deviceId());
    if (pairDeviceId.isEmpty()) {
        log.debug("Pair device of {} not found", location.deviceId());
        return false;
    }
    if (locations.stream().anyMatch(l -> l.deviceId().equals(pairDeviceId.get()))) {
        log.debug("Pair device has a next hop available. Leave it as is.");
        return false;
    }
    Optional<PortNumber> pairRemotePort = srManager.getPairLocalPort(pairDeviceId.get());
    if (pairRemotePort.isEmpty()) {
        log.debug("Pair remote port of {} not found", pairDeviceId.get());
        return false;
    }
    // Use routerMac of the pair device as the next hop
    MacAddress effectiveMac;
    try {
        effectiveMac = srManager.getDeviceMacAddress(location.deviceId());
    } catch (DeviceConfigNotFoundException e) {
        log.warn("Abort populateRoute on pair device {}. routerMac not found", pairDeviceId);
        return false;
    }
    // Since the pairLocalPort is trunk port, use assigned vlan of original port
    // when the host is untagged
    VlanId effectiveVlan = Optional.ofNullable(srManager.getInternalVlanId(location)).orElse(nextHopVlan);
    log.debug("Single leaf pair. populateRoute {}/{}, {}, {}, {}", pairDeviceId, pairRemotePort, prefix, effectiveMac, effectiveVlan);
    srManager.defaultRoutingHandler.populateRoute(pairDeviceId.get(), prefix, effectiveMac, effectiveVlan, pairRemotePort.get(), false);
    return true;
}
Also used : DeviceId(org.onosproject.net.DeviceId) PortNumber(org.onosproject.net.PortNumber) MacAddress(org.onlab.packet.MacAddress) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) VlanId(org.onlab.packet.VlanId)

Example 23 with PortNumber

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

the class PortsCommand method doExecute.

@Override
protected void doExecute() {
    PhasedRecoveryService prService = get(PhasedRecoveryService.class);
    DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
    boolean enabled;
    switch(actionStr.toUpperCase()) {
        case "ENABLE":
            enabled = true;
            break;
        case "DISABLE":
            enabled = false;
            break;
        default:
            print("Action should be either ENABLE or DISABLE");
            return;
    }
    Set<PortNumber> portsChanged;
    switch(portsStr.toUpperCase()) {
        case "ALL":
            portsChanged = prService.changeAllPorts(deviceId, enabled);
            break;
        case "PAIR":
            portsChanged = prService.changePairPort(deviceId, enabled);
            break;
        case "INFRA":
            portsChanged = prService.changeInfraPorts(deviceId, enabled);
            break;
        case "EDGE":
            portsChanged = prService.changeEdgePorts(deviceId, enabled);
            break;
        default:
            print("Ports should be ALL, PAIR, INFRA, EDGE");
            return;
    }
    print("Ports set to %s: %s", enabled ? "enabled" : "disabled", portsChanged.stream().map(PortNumber::toLong).collect(Collectors.toSet()));
}
Also used : PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) DeviceId(org.onosproject.net.DeviceId) PortNumber(org.onosproject.net.PortNumber)

Example 24 with PortNumber

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

the class XconnectManager method getPhysicalPorts.

private Set<PortNumber> getPhysicalPorts(DeviceId deviceId, XconnectEndpoint endpoint) {
    if (endpoint.type() == XconnectEndpoint.Type.PORT) {
        PortNumber port = ((XconnectPortEndpoint) endpoint).port();
        return Sets.newHashSet(port);
    }
    if (endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER) {
        PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, ((XconnectLoadBalancerEndpoint) endpoint).key());
        Set<PortNumber> ports = portLoadBalancerService.getPortLoadBalancer(portLoadBalancerId).ports();
        return Sets.newHashSet(ports);
    }
    return Sets.newHashSet();
}
Also used : XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint) PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) PortNumber(org.onosproject.net.PortNumber)

Example 25 with PortNumber

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

the class MockFlowObjectiveService method forward.

@Override
public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
    TrafficSelector selector = forwardingObjective.selector();
    TrafficTreatment treatment = nextTable.get(forwardingObjective.nextId());
    MacAddress macAddress = ((EthCriterion) selector.getCriterion(Criterion.Type.ETH_DST)).mac();
    VlanId vlanId = ((VlanIdCriterion) selector.getCriterion(Criterion.Type.VLAN_VID)).vlanId();
    boolean popVlan = treatment.allInstructions().stream().filter(instruction -> instruction.type().equals(Instruction.Type.L2MODIFICATION)).anyMatch(instruction -> ((L2ModificationInstruction) instruction).subtype().equals(L2ModificationInstruction.L2SubType.VLAN_POP));
    PortNumber portNumber = treatment.allInstructions().stream().filter(instruction -> instruction.type().equals(Instruction.Type.OUTPUT)).map(instruction -> ((Instructions.OutputInstruction) instruction).port()).findFirst().orElse(null);
    if (portNumber == null) {
        throw new IllegalArgumentException();
    }
    Objective.Operation op = forwardingObjective.op();
    MockBridgingTableKey btKey = new MockBridgingTableKey(deviceId, macAddress, vlanId);
    MockBridgingTableValue btValue = new MockBridgingTableValue(popVlan, portNumber);
    if (op.equals(Objective.Operation.ADD)) {
        bridgingTable.put(btKey, btValue);
        forwardingObjective.context().ifPresent(context -> context.onSuccess(forwardingObjective));
    } else if (op.equals(Objective.Operation.REMOVE)) {
        bridgingTable.remove(btKey, btValue);
        forwardingObjective.context().ifPresent(context -> context.onSuccess(forwardingObjective));
    } else {
        forwardingObjective.context().ifPresent(context -> context.onError(forwardingObjective, ObjectiveError.UNKNOWN));
        throw new IllegalArgumentException();
    }
}
Also used : TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Instructions(org.onosproject.net.flow.instructions.Instructions) Instruction(org.onosproject.net.flow.instructions.Instruction) VlanId(org.onlab.packet.VlanId) PortNumber(org.onosproject.net.PortNumber) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) TrafficSelector(org.onosproject.net.flow.TrafficSelector) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) Map(java.util.Map) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) FlowObjectiveServiceAdapter(org.onosproject.net.flowobjective.FlowObjectiveServiceAdapter) Criterion(org.onosproject.net.flow.criteria.Criterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instructions(org.onosproject.net.flow.instructions.Instructions) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MacAddress(org.onlab.packet.MacAddress) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

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