Search in sources :

Example 1 with MacVlanNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class DefaultGroupHandler method createGroupFromMacVlan.

/**
 * Create simple next objective for an indirect host mac/vlan. The treatments can include
 * all outgoing actions that need to happen on the packet.
 *
 * @param macAddr the mac address of the host
 * @param vlanId the vlan of the host
 * @param treatment the actions to apply on the packets (should include outport)
 * @param meta optional data to pass to the driver
 * @return next objective ID
 */
public int createGroupFromMacVlan(MacAddress macAddr, VlanId vlanId, TrafficTreatment treatment, TrafficSelector meta) {
    int nextId = flowObjectiveService.allocateNextId();
    MacVlanNextObjectiveStoreKey key = new MacVlanNextObjectiveStoreKey(deviceId, macAddr, vlanId);
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder().withId(nextId).withType(NextObjective.Type.SIMPLE).addTreatment(treatment).fromApp(appId).withMeta(meta);
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("createGroupFromMacVlan installed " + "NextObj {} on {}", nextId, deviceId), (objective, error) -> {
        log.warn("createGroupFromMacVlan failed to install NextObj {} on {}: {}", nextId, deviceId, error);
        srManager.invalidateNextObj(objective.id());
    });
    NextObjective nextObj = nextObjBuilder.add(context);
    flowObjectiveService.next(deviceId, nextObj);
    log.debug("createGroupFromMacVlan: Submited next objective {} in device {} " + "for host {}/{}", nextId, deviceId, macAddr, vlanId);
    macVlanNextObjStore.put(key, nextId);
    return nextId;
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 2 with MacVlanNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class DefaultGroupHandler method getMacVlanNextObjectiveId.

/**
 * Returns the next objective of type simple associated with the mac/vlan on the
 * device, given the treatment. Different treatments to the same mac/vlan result
 * in different next objectives. If no such objective exists, this method
 * creates one (if requested) and returns the id. Optionally metadata can be passed in for
 * the creation of the objective. Typically this is used for L2 and L3 forwarding
 * to compute nodes and containers/VMs on the compute nodes directly attached
 * to the switch.
 *
 * @param macAddr the mac addr for the simple next objective
 * @param vlanId the vlan for the simple next objective
 * @param port port with which to create the Next Obj.
 * @param createIfMissing true if a next object should be created if not found
 * @return int if found or created, -1 if there are errors during the
 *          creation of the next objective.
 */
public int getMacVlanNextObjectiveId(MacAddress macAddr, VlanId vlanId, PortNumber port, boolean createIfMissing) {
    Integer nextId = macVlanNextObjStore.get(new MacVlanNextObjectiveStoreKey(deviceId, macAddr, vlanId));
    if (nextId != null) {
        return nextId;
    }
    log.debug("getMacVlanNextObjectiveId in device {}: Next objective id " + "not found for host : {}/{} .. {}", deviceId, macAddr, vlanId, (createIfMissing) ? "creating" : "aborting");
    if (!createIfMissing) {
        return -1;
    }
    MacAddress deviceMac;
    try {
        deviceMac = deviceConfig.getDeviceMac(deviceId);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " in getMacVlanNextObjectiveId");
        return -1;
    }
    // since we are creating now, port cannot be null
    if (port == null) {
        log.debug("getMacVlanNextObjectiveId : port information cannot be null " + "for device {}, host {}/{}", deviceId, macAddr, vlanId);
        return -1;
    }
    TrafficSelector.Builder meta = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.deferred().setEthDst(macAddr).setEthSrc(deviceMac).setOutput(port);
    ConnectPoint connectPoint = new ConnectPoint(deviceId, port);
    VlanId untaggedVlan = srManager.interfaceService.getUntaggedVlanId(connectPoint);
    Set<VlanId> taggedVlans = srManager.interfaceService.getTaggedVlanId(connectPoint);
    VlanId nativeVlan = srManager.interfaceService.getNativeVlanId(connectPoint);
    // Adjust the meta according to VLAN configuration
    if (taggedVlans.contains(vlanId)) {
        meta.matchVlanId(vlanId);
        treatment.setVlanId(vlanId);
    } else if (vlanId.equals(VlanId.NONE)) {
        if (untaggedVlan != null) {
            meta.matchVlanId(untaggedVlan);
            treatment.popVlan();
        } else if (nativeVlan != null) {
            meta.matchVlanId(nativeVlan);
            treatment.popVlan();
        } else {
            log.warn("Untagged nexthop {}/{} is not allowed on {} without untagged or native vlan", macAddr, vlanId, connectPoint);
            return -1;
        }
    } else {
        log.warn("Tagged nexthop {}/{} is not allowed on {} without VLAN listed" + " in tagged vlan", macAddr, vlanId, connectPoint);
        return -1;
    }
    /* create missing next objective */
    nextId = createGroupFromMacVlan(macAddr, vlanId, treatment.build(), meta.build());
    if (nextId == null) {
        log.warn("getMacVlanNextObjectiveId: unable to create next obj" + "for dev:{} host:{}/{}", deviceId, macAddr, vlanId);
        return -1;
    }
    return nextId;
}
Also used : MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MacAddress(org.onlab.packet.MacAddress) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) VlanId(org.onlab.packet.VlanId)

Example 3 with MacVlanNextObjectiveStoreKey

use of org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey in project trellis-control by opennetworkinglab.

the class SegmentRoutingManager method activate.

@Activate
protected void activate(ComponentContext context) {
    appId = coreService.registerApplication(APP_NAME);
    mainEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("onos/sr", "event-main-%d", log));
    hostEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("onos/sr", "event-host-%d", log));
    routeEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("onos/sr", "event-route-%d", log));
    mcastEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("onos/sr", "event-mcast-%d", log));
    packetExecutor = Executors.newSingleThreadExecutor(groupedThreads("onos/sr", "packet-%d", log));
    neighborExecutor = Executors.newFixedThreadPool(DEFAULT_POOL_SIZE, groupedThreads("onos/sr", "neighbor-%d", log));
    log.debug("Creating EC map nsnextobjectivestore");
    EventuallyConsistentMapBuilder<DestinationSetNextObjectiveStoreKey, NextNeighbors> nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
    dsNextObjStore = nsNextObjMapBuilder.withName("nsnextobjectivestore").withSerializer(createSerializer()).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    log.trace("Current size {}", dsNextObjStore.size());
    log.debug("Creating EC map vlannextobjectivestore");
    EventuallyConsistentMapBuilder<VlanNextObjectiveStoreKey, Integer> vlanNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
    vlanNextObjStore = vlanNextObjMapBuilder.withName("vlannextobjectivestore").withSerializer(createSerializer()).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    log.debug("Creating EC map macvlannextobjectivestore");
    EventuallyConsistentMapBuilder<MacVlanNextObjectiveStoreKey, Integer> macVlanNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
    macVlanNextObjStore = macVlanNextObjMapBuilder.withName("macvlannextobjectivestore").withSerializer(createSerializer()).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    log.debug("Creating EC map subnetnextobjectivestore");
    EventuallyConsistentMapBuilder<PortNextObjectiveStoreKey, Integer> portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
    portNextObjStore = portNextObjMapBuilder.withName("portnextobjectivestore").withSerializer(createSerializer()).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    EventuallyConsistentMapBuilder<String, Tunnel> tunnelMapBuilder = storageService.eventuallyConsistentMapBuilder();
    tunnelStore = tunnelMapBuilder.withName("tunnelstore").withSerializer(createSerializer()).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    EventuallyConsistentMapBuilder<String, Policy> policyMapBuilder = storageService.eventuallyConsistentMapBuilder();
    policyStore = policyMapBuilder.withName("policystore").withSerializer(createSerializer()).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    processor = new InternalPacketProcessor();
    linkListener = new InternalLinkListener();
    deviceListener = new InternalDeviceListener();
    appCfgHandler = new AppConfigHandler(this);
    mcastHandler = new McastHandler(this);
    hostHandler = new HostHandler(this);
    linkHandler = new LinkHandler(this);
    routeHandler = new RouteHandler(this);
    neighbourHandler = new SegmentRoutingNeighbourDispatcher(this);
    l2TunnelHandler = new DefaultL2TunnelHandler(this);
    topologyHandler = new TopologyHandler(this);
    compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider", "requestInterceptsEnabled", "false", false);
    compCfgService.preSetProperty("org.onosproject.net.neighbour.impl.NeighbourResolutionManager", "requestInterceptsEnabled", "false", false);
    compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelayManager", "arpEnabled", "false", false);
    compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager", "greedyLearningIpv6", "true", false);
    compCfgService.preSetProperty("org.onosproject.routing.cpr.ControlPlaneRedirectManager", "forceUnprovision", "true", false);
    compCfgService.preSetProperty("org.onosproject.routeservice.store.RouteStoreImpl", "distributed", "true", false);
    compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider", "multihomingEnabled", "true", false);
    compCfgService.preSetProperty("org.onosproject.provider.lldp.impl.LldpLinkProvider", "staleLinkAge", "15000", false);
    compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager", "allowDuplicateIps", "false", false);
    // For P4 switches
    compCfgService.preSetProperty("org.onosproject.net.flow.impl.FlowRuleManager", "fallbackFlowPollFrequency", "4", false);
    compCfgService.preSetProperty("org.onosproject.net.group.impl.GroupManager", "fallbackGroupPollFrequency", "3", false);
    compCfgService.preSetProperty("org.onosproject.net.meter.impl.MeterManager", "fallbackMeterPollFrequency", "3", false);
    compCfgService.registerProperties(getClass());
    modified(context);
    cfgService.addListener(cfgListener);
    cfgService.registerConfigFactory(deviceConfigFactory);
    cfgService.registerConfigFactory(appConfigFactory);
    cfgService.registerConfigFactory(mcastConfigFactory);
    log.info("Configuring network before adding listeners");
    cfgListener.configureNetwork();
    hostService.addListener(hostListener);
    packetService.addProcessor(processor, PacketProcessor.director(2));
    linkService.addListener(linkListener);
    deviceService.addListener(deviceListener);
    multicastRouteService.addListener(mcastListener);
    routeService.addListener(routeListener);
    topologyService.addListener(topologyListener);
    mastershipService.addListener(mastershipListener);
    clusterService.addListener(clusterListener);
    linkHandler.init();
    l2TunnelHandler.init();
    drainEvents();
    log.info("Started");
}
Also used : PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) ReferencePolicy(org.osgi.service.component.annotations.ReferencePolicy) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) L2TunnelPolicy(org.onosproject.segmentrouting.pwaas.L2TunnelPolicy) MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) McastHandler(org.onosproject.segmentrouting.mcast.McastHandler) NextNeighbors(org.onosproject.segmentrouting.grouphandler.NextNeighbors) DefaultL2TunnelHandler(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler) DestinationSetNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) L2Tunnel(org.onosproject.segmentrouting.pwaas.L2Tunnel) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

MacVlanNextObjectiveStoreKey (org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey)3 ConnectPoint (org.onosproject.net.ConnectPoint)2 MacAddress (org.onlab.packet.MacAddress)1 VlanId (org.onlab.packet.VlanId)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)1 DefaultObjectiveContext (org.onosproject.net.flowobjective.DefaultObjectiveContext)1 NextObjective (org.onosproject.net.flowobjective.NextObjective)1 ObjectiveContext (org.onosproject.net.flowobjective.ObjectiveContext)1 DeviceConfigNotFoundException (org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)1 NextNeighbors (org.onosproject.segmentrouting.grouphandler.NextNeighbors)1 McastHandler (org.onosproject.segmentrouting.mcast.McastHandler)1 DefaultL2Tunnel (org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel)1 DefaultL2TunnelHandler (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler)1 DefaultL2TunnelPolicy (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy)1 L2Tunnel (org.onosproject.segmentrouting.pwaas.L2Tunnel)1 L2TunnelPolicy (org.onosproject.segmentrouting.pwaas.L2TunnelPolicy)1