Search in sources :

Example 11 with DefaultGroupHandler

use of org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler in project trellis-control by opennetworkinglab.

the class LinkHandler method processLinkRemoved.

/**
 * Preprocessing of removed link before being sent for route-path handling.
 * Also performs post processing of link.
 *
 * @param link the link to be processed
 */
void processLinkRemoved(Link link) {
    log.info("** LINK REMOVED {}", link.toString());
    if (!isLinkValid(link)) {
        return;
    }
    // after a DEVICE DOWN event.
    if (isSeenLink(link)) {
        updateSeenLink(link, false);
    } else {
        // Exiting here may not be needed since other checks later should fail
        log.warn("received a link down for the link {} which is not in the store", link);
    }
    // handle edge-ports for dual-homed hosts
    if (srManager.shouldProgram(link.src().deviceId())) {
        updateHostPorts(link, false);
    }
    // when switch comes back.
    if (link.src().elementId() instanceof DeviceId && !srManager.deviceService.isAvailable(link.src().deviceId())) {
        purgeSeenLink(link);
        return;
    }
    if (link.dst().elementId() instanceof DeviceId && !srManager.deviceService.isAvailable(link.dst().deviceId())) {
        purgeSeenLink(link);
        return;
    }
    // process link only if it is bidirectional
    if (!isBidirectionalLinkDown(link)) {
        log.debug("Link not bidirectional.. waiting for other direction " + "src {} --> dst {} ", link.dst(), link.src());
        return;
    }
    log.info("processing bidi links {} <--> {} DOWN", link.src(), link.dst());
    for (Link ulink : getBidiComponentLinks(link)) {
        log.info("-- Starting optimized route-path processing for component " + "unidirectional link {} --> {} DOWN", ulink.src(), ulink.dst());
        srManager.defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(ulink, null, null, true);
        // attempt rehashing for parallel links
        DefaultGroupHandler groupHandler = srManager.groupHandlerMap.get(ulink.src().deviceId());
        if (groupHandler != null) {
            if (srManager.shouldProgram(ulink.src().deviceId()) && isParallelLink(ulink)) {
                log.debug("* retrying hash for parallel link removed:{}", ulink);
                groupHandler.retryHash(ulink, true, false);
            } else {
                log.debug("Not attempting retry-hash for link removed: {} .. {}", ulink, (srManager.shouldProgram(ulink.src().deviceId())) ? "not parallel" : "not handling programming");
            }
            // ensure local stores are updated after all rerouting or rehashing
            groupHandler.portDownForLink(ulink);
        } else {
            log.warn("group handler not found for dev:{} when removing link: {}", ulink.src().deviceId(), ulink);
        }
    }
}
Also used : DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) DeviceId(org.onosproject.net.DeviceId) Link(org.onosproject.net.Link)

Example 12 with DefaultGroupHandler

use of org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler in project trellis-control by opennetworkinglab.

the class LinkHandler method processLinkAdded.

/**
 * Preprocessing of added link before being sent for route-path handling.
 * Also performs post processing of link.
 *
 * @param link the link to be processed
 */
void processLinkAdded(Link link) {
    log.info("** LINK ADDED {}", link.toString());
    if (!isLinkValid(link)) {
        return;
    }
    // Irrespective of whether the local is a MASTER or not for this device,
    // create group handler instance and push default TTP flow rules if needed,
    // as in a multi-instance setup, instances can initiate groups for any
    // device. Also update local groupHandler stores.
    DefaultGroupHandler groupHandler = srManager.groupHandlerMap.get(link.src().deviceId());
    if (groupHandler == null) {
        Device device = srManager.deviceService.getDevice(link.src().deviceId());
        if (device != null) {
            log.warn("processLinkAdded: Link Added notification without " + "Device Added event, still handling it");
            srManager.processDeviceAdded(device);
        }
    }
    if (isSeenLink(link)) {
        // temp store retains previous state, just before the state is updated in
        // seenLinks; previous state is necessary when processing the
        // linkupdate in defaultRoutingHandler
        seenBefore.add(link);
    }
    updateSeenLink(link, true);
    if (srManager.deviceConfiguration == null || !srManager.deviceConfiguration.isConfigured(link.src().deviceId())) {
        log.warn("Source device of this link is not configured.. " + "not processing further");
        return;
    }
    // process link only if it is bidirectional
    if (!isBidirectionalLinkUp(link)) {
        log.debug("Link not bidirectional.. waiting for other direction " + "src {} --> dst {} ", link.dst(), link.src());
        return;
    }
    log.info("processing bidi links {} <--> {} UP", link.src(), link.dst());
    // update groupHandler internal port state for both directions
    List<Link> ulinks = getBidiComponentLinks(link);
    for (Link ulink : ulinks) {
        DefaultGroupHandler gh = srManager.groupHandlerMap.get(ulink.src().deviceId());
        if (gh != null) {
            gh.portUpForLink(ulink);
        }
    }
    for (Link ulink : ulinks) {
        log.info("-- Starting optimized route-path processing for component " + "unidirectional link {} --> {} UP", ulink.src(), ulink.dst());
        // Performs the seenBefore optimization iff we have seen before both links in that case
        // we have programmed the group (unless there were major issues in the system)
        srManager.defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(null, ulink, null, (seenBefore.contains(ulink) && seenBefore.contains(getReverseLink(ulink))));
        if (srManager.shouldProgram(ulink.src().deviceId())) {
            // handle edge-ports for dual-homed hosts
            updateHostPorts(ulink, true);
            // It's possible that linkUp causes no route-path change as ECMP graph does
            // not change if the link is a parallel link (same src-dst as
            // another link). However we still need to update ECMP hash
            // groups to include new buckets for the link that has come up.
            DefaultGroupHandler gh = srManager.groupHandlerMap.get(ulink.src().deviceId());
            if (gh != null) {
                if (!seenBefore.contains(ulink) && isParallelLink(ulink)) {
                    // if link seen first time, we need to ensure hash-groups have
                    // all ports
                    log.debug("Attempting retryHash for paralled first-time link {}", ulink);
                    gh.retryHash(ulink, false, true);
                } else {
                    // seen before-link
                    if (isParallelLink(ulink)) {
                        log.debug("Attempting retryHash for paralled seen-before " + "link {}", ulink);
                        gh.retryHash(ulink, false, false);
                    }
                }
            }
        }
        // clean up temp state
        seenBefore.remove(ulink);
    }
}
Also used : DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) Device(org.onosproject.net.Device) Link(org.onosproject.net.Link)

Aggregations

DefaultGroupHandler (org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler)12 ConnectPoint (org.onosproject.net.ConnectPoint)7 DeviceId (org.onosproject.net.DeviceId)5 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)5 DeviceConfigNotFoundException (org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)5 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)4 TrafficSelector (org.onosproject.net.flow.TrafficSelector)4 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)4 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)4 Builder (org.onosproject.net.flowobjective.ForwardingObjective.Builder)4 ExecutionException (java.util.concurrent.ExecutionException)3 Link (org.onosproject.net.Link)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 DefaultObjectiveContext (org.onosproject.net.flowobjective.DefaultObjectiveContext)3 DestinationSet (org.onosproject.segmentrouting.grouphandler.DestinationSet)3 HashSet (java.util.HashSet)2 Set (java.util.Set)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 IpPrefix (org.onlab.packet.IpPrefix)2 MacAddress (org.onlab.packet.MacAddress)2