Search in sources :

Example 6 with DeviceConfigNotFoundException

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

the class RoutingRulePopulator method revokeRoute.

/**
 * Removes IP rules for a route when the next hop is gone.
 * This method should not be invoked directly without going through DefaultRoutingHandler.
 *
 * @param deviceId device ID of the device that next hop attaches to
 * @param prefix IP prefix of the route
 * @param hostMac MAC address of the next hop
 * @param hostVlanId Vlan ID of the nexthop
 * @param outPort port that next hop attaches to
 * @param directHost host is of type direct or indirect
 * @return future that carries the flow objective if succeeded, null if otherwise
 */
CompletableFuture<Objective> revokeRoute(DeviceId deviceId, IpPrefix prefix, MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, boolean directHost) {
    log.debug("Revoke IP table entry for route {} at {}:{}", prefix, deviceId, outPort);
    ForwardingObjective.Builder fwdBuilder;
    try {
        fwdBuilder = routingFwdObjBuilder(deviceId, prefix, hostMac, hostVlanId, outPort, null, null, directHost, true);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting revokeIpRuleForHost.");
        return CompletableFuture.completedFuture(null);
    }
    if (fwdBuilder == null) {
        log.warn("Aborting host routing table entries due " + "to error for dev:{} route:{}", deviceId, prefix);
        return CompletableFuture.completedFuture(null);
    }
    CompletableFuture<Objective> future = new CompletableFuture<>();
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> {
        log.debug("IP rule for route {} revoked", prefix);
        future.complete(objective);
    }, (objective, error) -> {
        log.warn("Failed to revoke IP rule for route {}: {}", prefix, error);
        future.complete(null);
    });
    srManager.flowObjectiveService.forward(deviceId, fwdBuilder.remove(context));
    return future;
}
Also used : ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) Builder(org.onosproject.net.flowobjective.ForwardingObjective.Builder) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 7 with DeviceConfigNotFoundException

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

the class RoutingRulePopulator method populateMplsRule.

/**
 * Populates MPLS flow rules in the target device to point towards the
 * destination device.
 *
 * @param targetSwId target device ID of the switch to set the rules
 * @param destSwId destination switch device ID
 * @param nextHops next hops switch ID list
 * @param routerIp the router ip of the destination switch
 * @return true if all rules are set successfully, false otherwise
 */
boolean populateMplsRule(DeviceId targetSwId, DeviceId destSwId, Set<DeviceId> nextHops, IpAddress routerIp) {
    int segmentId;
    try {
        if (routerIp.isIp4()) {
            segmentId = config.getIPv4SegmentId(destSwId);
        } else {
            segmentId = config.getIPv6SegmentId(destSwId);
        }
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting populateMplsRule.");
        return false;
    }
    List<ForwardingObjective> fwdObjs = new ArrayList<>();
    Collection<ForwardingObjective> fwdObjsMpls;
    // Generates the transit rules used by the standard "routing".
    fwdObjsMpls = handleMpls(targetSwId, destSwId, nextHops, segmentId, routerIp, true);
    if (fwdObjsMpls.isEmpty()) {
        return false;
    }
    fwdObjs.addAll(fwdObjsMpls);
    // Generates the transit rules used by the MPLS Pwaas.
    int pwSrLabel;
    try {
        pwSrLabel = config.getPWRoutingLabel(destSwId);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting populateMplsRule. No label for PseudoWire traffic.");
        return false;
    }
    fwdObjsMpls = handleMpls(targetSwId, destSwId, nextHops, pwSrLabel, routerIp, false);
    if (fwdObjsMpls.isEmpty()) {
        return false;
    }
    fwdObjs.addAll(fwdObjsMpls);
    for (ForwardingObjective fwdObj : fwdObjs) {
        log.debug("Sending MPLS fwd obj {} for SID {}-> next {} in sw: {}", fwdObj.id(), segmentId, fwdObj.nextId(), targetSwId);
        srManager.flowObjectiveService.forward(targetSwId, fwdObj);
        rulePopulationCounter.incrementAndGet();
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ConnectPoint(org.onosproject.net.ConnectPoint) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 8 with DeviceConfigNotFoundException

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

the class RoutingRulePopulator method populateRoute.

/**
 * Populates IP rules for a route that has direct connection to the switch.
 * This method should not be invoked directly without going through DefaultRoutingHandler.
 *
 * @param deviceId device ID of the device that next hop attaches to
 * @param prefix IP prefix of the route
 * @param hostMac MAC address of the next hop
 * @param hostVlanId Vlan ID of the nexthop
 * @param outPort port where the next hop attaches to
 * @param directHost host is of type direct or indirect
 * @return future that carries the flow objective if succeeded, null if otherwise
 */
CompletableFuture<Objective> populateRoute(DeviceId deviceId, IpPrefix prefix, MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, boolean directHost) {
    log.debug("Populate direct routing entry for route {} at {}:{}", prefix, deviceId, outPort);
    ForwardingObjective.Builder fwdBuilder;
    try {
        fwdBuilder = routingFwdObjBuilder(deviceId, prefix, hostMac, hostVlanId, outPort, null, null, directHost, false);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting direct populateRoute");
        return CompletableFuture.completedFuture(null);
    }
    if (fwdBuilder == null) {
        log.warn("Aborting host routing table entry due " + "to error for dev:{} route:{}", deviceId, prefix);
        return CompletableFuture.completedFuture(null);
    }
    int nextId = fwdBuilder.add().nextId();
    CompletableFuture<Objective> future = new CompletableFuture<>();
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> {
        log.debug("Direct routing rule for route {} populated. nextId={}", prefix, nextId);
        future.complete(objective);
    }, (objective, error) -> {
        log.warn("Failed to populate direct routing rule for route {}: {}", prefix, error);
        future.complete(null);
    });
    srManager.flowObjectiveService.forward(deviceId, fwdBuilder.add(context));
    rulePopulationCounter.incrementAndGet();
    return future;
}
Also used : ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) Builder(org.onosproject.net.flowobjective.ForwardingObjective.Builder) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 9 with DeviceConfigNotFoundException

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

the class SegmentRoutingManager method processDeviceAddedInternal.

private void processDeviceAddedInternal(DeviceId deviceId) {
    // Irrespective of whether the local is leading the programming or not for this device,
    // we need to create a SR-group-handler instance. This is because in a
    // multi-instance setup, any instance can initiate forwarding/next-objectives
    // for any switch (even if this instance is a SLAVE or not even connected
    // to the switch). To handle this, a default-group-handler instance is necessary
    // per switch.
    log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet());
    if (groupHandlerMap.get(deviceId) == null) {
        DefaultGroupHandler groupHandler;
        try {
            groupHandler = DefaultGroupHandler.createGroupHandler(deviceId, appId, deviceConfiguration, linkService, flowObjectiveService, this);
        } catch (DeviceConfigNotFoundException e) {
            log.warn(e.getMessage() + " Aborting processDeviceAdded.");
            return;
        }
        log.debug("updating groupHandlerMap with new grpHdlr for device: {}", deviceId);
        groupHandlerMap.put(deviceId, groupHandler);
    }
    if (shouldProgram(deviceId)) {
        defaultRoutingHandler.populatePortAddressingRules(deviceId);
        DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
        groupHandler.createGroupsFromVlanConfig();
        routingRulePopulator.populateSubnetBroadcastRule(deviceId);
    }
    appCfgHandler.init(deviceId);
}
Also used : DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 10 with DeviceConfigNotFoundException

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

the class SegmentRoutingNeighbourHandler method getSenderInfo.

/**
 * Retrieve router (device) info.
 *
 * @param mac where to copy the mac
 * @param ip where to copy the ip
 * @param deviceId the device id
 * @param targetAddress the target address
 * @return true if it was possible to get the necessary info.
 * False for errors
 */
protected boolean getSenderInfo(byte[] mac, byte[] ip, DeviceId deviceId, IpAddress targetAddress) {
    byte[] senderMacAddress;
    byte[] senderIpAddress;
    IpAddress sender;
    try {
        senderMacAddress = config.getDeviceMac(deviceId).toBytes();
        if (targetAddress.isIp4()) {
            sender = config.getRouterIpAddressForASubnetHost(targetAddress.getIp4Address());
        } else {
            sender = config.getRouterIpAddressForASubnetHost(targetAddress.getIp6Address());
        }
        // If sender is null we abort.
        if (sender == null) {
            log.warn("Sender ip is null. Aborting getSenderInfo");
            return false;
        }
        senderIpAddress = sender.toOctets();
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting getSenderInfo");
        return false;
    }
    System.arraycopy(senderMacAddress, 0, mac, 0, senderMacAddress.length);
    System.arraycopy(senderIpAddress, 0, ip, 0, senderIpAddress.length);
    return true;
}
Also used : 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