Search in sources :

Example 1 with UpfInterface

use of org.onosproject.net.behaviour.upf.UpfInterface in project up4 by omec-project.

the class ResetEntriesCommand method doExecute.

@Override
protected void doExecute() throws UpfProgrammableException {
    Up4AdminService app = get(Up4AdminService.class);
    print("Clearing all UP4 dataplane table entries.");
    app.adminDeleteAll(UpfEntityType.SESSION_UPLINK);
    app.adminDeleteAll(UpfEntityType.SESSION_DOWNLINK);
    app.adminDeleteAll(UpfEntityType.TERMINATION_UPLINK);
    app.adminDeleteAll(UpfEntityType.TERMINATION_DOWNLINK);
    app.adminDeleteAll(UpfEntityType.TUNNEL_PEER);
    app.adminReadAll(UpfEntityType.INTERFACE);
    Collection<UpfInterface> configInterfaces = app.configInterfaces();
    // Remove only the interfaces from UP4 config
    for (UpfInterface upfInterface : configInterfaces) {
        app.adminDelete(upfInterface);
    }
    app.resetAllSessionMeters();
    app.resetAllApplicationMeters();
    print("Reinstalling UP4 interfaces and DBUF GTP Tunnel from app configuration.");
    app.installUpfEntities();
}
Also used : UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) Up4AdminService(org.omecproject.up4.impl.Up4AdminService)

Example 2 with UpfInterface

use of org.onosproject.net.behaviour.upf.UpfInterface in project up4 by omec-project.

the class Up4DeviceManager method apply.

@Override
public void apply(UpfEntity entity) throws UpfProgrammableException {
    switch(entity.type()) {
        case SESSION_DOWNLINK:
            UpfSessionDownlink sessDl = (UpfSessionDownlink) entity;
            if (sessDl.needsBuffering()) {
                // Override tunnel peer id with the DBUF
                entity = convertToBuffering(sessDl);
                up4Store.learnBufferingUe(sessDl.ueAddress());
            }
            break;
        case TERMINATION_UPLINK:
            UpfTerminationUplink termUl = (UpfTerminationUplink) entity;
            if (isMaxUeSet() && termUl.counterId() >= getMaxUe() * 2) {
                throw new UpfProgrammableException("Counter cell index referenced by uplink UPF termination " + "rule above max supported UE value.", UpfProgrammableException.Type.ENTITY_OUT_OF_RANGE, UpfEntityType.TERMINATION_UPLINK);
            }
            break;
        case TERMINATION_DOWNLINK:
            UpfTerminationDownlink termDl = (UpfTerminationDownlink) entity;
            if (isMaxUeSet() && termDl.counterId() >= getMaxUe() * 2) {
                throw new UpfProgrammableException("Counter cell index referenced by downlink UPF termination " + "rule above max supported UE value.", UpfProgrammableException.Type.ENTITY_OUT_OF_RANGE, UpfEntityType.TERMINATION_DOWNLINK);
            }
            break;
        case INTERFACE:
            UpfInterface intf = (UpfInterface) entity;
            if (intf.isDbufReceiver()) {
                throw new UpfProgrammableException("Cannot apply the DBUF interface entry!");
            }
            break;
        case TUNNEL_PEER:
            UpfGtpTunnelPeer tunnelPeer = (UpfGtpTunnelPeer) entity;
            if (tunnelPeer.tunPeerId() == DBUF_TUNNEL_ID) {
                throw new UpfProgrammableException("Cannot apply the DBUF GTP Tunnel Peer");
            }
            break;
        default:
            break;
    }
    getLeaderUpfProgrammable().apply(entity);
    // Drain from DBUF if necessary
    if (entity.type().equals(SESSION_DOWNLINK)) {
        UpfSessionDownlink sess = (UpfSessionDownlink) entity;
        if (!sess.needsBuffering() && up4Store.forgetBufferingUe(sess.ueAddress())) {
            // TODO: Should we wait for rules to be installed on all devices before
            // triggering drain?
            // When a fwd FAR is changed to buff FAR,
            // both session_downlink & downlink_termination rules are updated.
            // If the drain action starts immediately right after applying session_downlink,
            // the downlink_termination rule may not be updated,
            // thus, the TEID may wrong in such case.
            // Run the outbound rpc in a forked context so it doesn't cancel if it was called
            // by an inbound rpc that completes faster than the drain call
            Ip4Address ueAddr = sess.ueAddress();
            Context ctx = Context.current().fork();
            ctx.run(() -> {
                if (dbufClient == null) {
                    log.error("Cannot start dbuf drain for {}, dbufClient is null", ueAddr);
                    return;
                }
                if (config == null || config.dbufDrainAddr() == null) {
                    log.error("Cannot start dbuf drain for {}, dbufDrainAddr is null", ueAddr);
                    return;
                }
                log.info("Started dbuf drain for {}", ueAddr);
                dbufClient.drain(ueAddr, config.dbufDrainAddr(), GTP_PORT).whenComplete((result, ex) -> {
                    if (ex != null) {
                        log.error("Exception while draining dbuf for {}: {}", ueAddr, ex);
                    } else if (result) {
                        log.info("Dbuf drain completed for {}", ueAddr);
                    } else {
                        log.warn("Unknown error while draining dbuf for {}", ueAddr);
                    }
                });
            });
        }
    }
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext) Context(io.grpc.Context) UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) UpfTerminationDownlink(org.onosproject.net.behaviour.upf.UpfTerminationDownlink) Ip4Address(org.onlab.packet.Ip4Address) UpfSessionDownlink(org.onosproject.net.behaviour.upf.UpfSessionDownlink) UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) UpfGtpTunnelPeer(org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer) UpfTerminationUplink(org.onosproject.net.behaviour.upf.UpfTerminationUplink)

Example 3 with UpfInterface

use of org.onosproject.net.behaviour.upf.UpfInterface in project up4 by omec-project.

the class Up4DeviceManager method ensureInterfacesInstalled.

/**
 * Ensure that all interfaces present in the UP4 config file are installed in the UPF leader device.
 */
private void ensureInterfacesInstalled() {
    log.info("Ensuring all interfaces present in app config are present on the leader device.");
    Collection<? extends UpfEntity> installedInterfaces;
    UpfProgrammable leader = getLeaderUpfProgrammable();
    try {
        installedInterfaces = leader.readAll(UpfEntityType.INTERFACE);
    } catch (UpfProgrammableException e) {
        log.warn("Failed to read interface: {}", e.getMessage());
        return;
    }
    for (UpfInterface iface : configInterfaces()) {
        if (!installedInterfaces.contains(iface)) {
            log.warn("{} is missing from leader device! Installing", iface);
            try {
                leader.apply(iface);
            } catch (UpfProgrammableException e) {
                log.warn("Failed to insert interface: {}", e.getMessage());
            }
        }
    }
}
Also used : UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) UpfProgrammable(org.onosproject.net.behaviour.upf.UpfProgrammable)

Example 4 with UpfInterface

use of org.onosproject.net.behaviour.upf.UpfInterface in project up4 by omec-project.

the class Up4DeviceManager method deleteAll.

@Override
public void deleteAll(UpfEntityType entityType) throws UpfProgrammableException {
    switch(entityType) {
        case TERMINATION_DOWNLINK:
            getLeaderUpfProgrammable().deleteAll(entityType);
            up4Store.reset();
            break;
        case INTERFACE:
            Collection<? extends UpfEntity> intfs = getLeaderUpfProgrammable().readAll(UpfEntityType.INTERFACE).stream().filter(t -> !((UpfInterface) t).isDbufReceiver()).collect(Collectors.toList());
            for (UpfEntity i : intfs) {
                getLeaderUpfProgrammable().delete(i);
            }
            break;
        case TUNNEL_PEER:
            Collection<? extends UpfEntity> tunnels = getLeaderUpfProgrammable().readAll(UpfEntityType.TUNNEL_PEER).stream().filter(t -> ((UpfGtpTunnelPeer) t).tunPeerId() != DBUF_TUNNEL_ID).collect(Collectors.toList());
            for (UpfEntity tun : tunnels) {
                getLeaderUpfProgrammable().delete(tun);
            }
            break;
        default:
            getLeaderUpfProgrammable().deleteAll(entityType);
    }
}
Also used : Up4Config(org.omecproject.up4.config.Up4Config) UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) FlowEntryState(org.onosproject.net.flow.FlowEntry.FlowEntryState) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) DeviceService(org.onosproject.net.device.DeviceService) APP_SUBJECT_FACTORY(org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY) Future(java.util.concurrent.Future) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) FlowRuleService(org.onosproject.net.flow.FlowRuleService) Pair(org.apache.commons.lang3.tuple.Pair) MeterCellId(org.onosproject.net.meter.MeterCellId) MeterService(org.onosproject.net.meter.MeterService) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) MastershipService(org.onosproject.mastership.MastershipService) APPLICATION_METER(org.onosproject.net.behaviour.upf.UpfEntityType.APPLICATION_METER) Up4DbufConfig(org.omecproject.up4.config.Up4DbufConfig) Ip4Address(org.onlab.packet.Ip4Address) UpfDevice(org.onosproject.net.behaviour.upf.UpfDevice) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) ConfigFactory(org.onosproject.net.config.ConfigFactory) DeviceEvent(org.onosproject.net.device.DeviceEvent) SESSION_DOWNLINK(org.onosproject.net.behaviour.upf.UpfEntityType.SESSION_DOWNLINK) TERMINATION_UPLINK(org.onosproject.net.behaviour.upf.UpfEntityType.TERMINATION_UPLINK) Tools.getLongProperty(org.onlab.util.Tools.getLongProperty) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) DbufClient(org.omecproject.dbuf.client.DbufClient) MeterRequest(org.onosproject.net.meter.MeterRequest) TUNNEL_PEER(org.onosproject.net.behaviour.upf.UpfEntityType.TUNNEL_PEER) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) FlowRuleEvent(org.onosproject.net.flow.FlowRuleEvent) ComponentContext(org.osgi.service.component.ComponentContext) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) Up4Service(org.omecproject.up4.Up4Service) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) UpfCounter(org.onosproject.net.behaviour.upf.UpfCounter) StreamSupport(java.util.stream.StreamSupport) UpfEntityType(org.onosproject.net.behaviour.upf.UpfEntityType) FlowRuleListener(org.onosproject.net.flow.FlowRuleListener) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) UPF_RECONCILE_INTERVAL(org.omecproject.up4.impl.OsgiPropertyConstants.UPF_RECONCILE_INTERVAL) DeviceListener(org.onosproject.net.device.DeviceListener) Meter(org.onosproject.net.meter.Meter) Properties(java.util.Properties) TERMINATION_DOWNLINK(org.onosproject.net.behaviour.upf.UpfEntityType.TERMINATION_DOWNLINK) UpfTerminationUplink(org.onosproject.net.behaviour.upf.UpfTerminationUplink) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) UpfProgrammable(org.onosproject.net.behaviour.upf.UpfProgrammable) DefaultMeter(org.onosproject.net.meter.DefaultMeter) Context(io.grpc.Context) UpfTerminationDownlink(org.onosproject.net.behaviour.upf.UpfTerminationDownlink) CoreService(org.onosproject.core.CoreService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Up4EventListener(org.omecproject.up4.Up4EventListener) ByteBuffer(java.nio.ByteBuffer) PiPipeconfEvent(org.onosproject.net.pi.service.PiPipeconfEvent) UpfGtpTunnelPeer(org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) DEFAULT_SLICE_ID(org.omecproject.up4.impl.AppConstants.DEFAULT_SLICE_ID) DefaultDbufClient(org.omecproject.dbuf.client.DefaultDbufClient) Ip4Prefix(org.onlab.packet.Ip4Prefix) MeterEvent(org.onosproject.net.meter.MeterEvent) MeterScope(org.onosproject.net.meter.MeterScope) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Device(org.onosproject.net.Device) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) PiPipeconfListener(org.onosproject.net.pi.service.PiPipeconfListener) UPF_RECONCILE_INTERVAL_DEFAULT(org.omecproject.up4.impl.OsgiPropertyConstants.UPF_RECONCILE_INTERVAL_DEFAULT) SESSION_METER(org.onosproject.net.behaviour.upf.UpfEntityType.SESSION_METER) PiPipeconfService(org.onosproject.net.pi.service.PiPipeconfService) PiMeterCellId(org.onosproject.net.pi.runtime.PiMeterCellId) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MeterListener(org.onosproject.net.meter.MeterListener) Activate(org.osgi.service.component.annotations.Activate) ExecutorService(java.util.concurrent.ExecutorService) UpfSessionDownlink(org.onosproject.net.behaviour.upf.UpfSessionDownlink) UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) Logger(org.slf4j.Logger) Up4Event(org.omecproject.up4.Up4Event) Maps(com.google.common.collect.Maps) MeterState(org.onosproject.net.meter.MeterState) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) DefaultMeterRequest(org.onosproject.net.meter.DefaultMeterRequest) Modified(org.osgi.service.component.annotations.Modified) Reference(org.osgi.service.component.annotations.Reference) COUNTER(org.onosproject.net.behaviour.upf.UpfEntityType.COUNTER) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity)

Example 5 with UpfInterface

use of org.onosproject.net.behaviour.upf.UpfInterface in project up4 by omec-project.

the class Up4DeviceManager method delete.

@Override
public void delete(UpfEntity entity) throws UpfProgrammableException {
    switch(entity.type()) {
        case SESSION_DOWNLINK:
            UpfSessionDownlink sess = (UpfSessionDownlink) entity;
            if (sess.needsBuffering()) {
                entity = convertToBuffering(sess);
            }
            break;
        case INTERFACE:
            UpfInterface intf = (UpfInterface) entity;
            if (intf.isDbufReceiver()) {
                throw new UpfProgrammableException("Cannot delete the DBUF interface rule!");
            }
            break;
        case TUNNEL_PEER:
            UpfGtpTunnelPeer tunnel = (UpfGtpTunnelPeer) entity;
            if (tunnel.tunPeerId() == DBUF_TUNNEL_ID) {
                throw new UpfProgrammableException("Cannot delete the DBUF GTP tunnel peer");
            }
            break;
        default:
            break;
    }
    getLeaderUpfProgrammable().delete(entity);
    forgetBufferingUeIfRequired(entity);
}
Also used : UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) UpfSessionDownlink(org.onosproject.net.behaviour.upf.UpfSessionDownlink) UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) UpfGtpTunnelPeer(org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer)

Aggregations

UpfInterface (org.onosproject.net.behaviour.upf.UpfInterface)7 UpfGtpTunnelPeer (org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer)4 UpfProgrammableException (org.onosproject.net.behaviour.upf.UpfProgrammableException)4 UpfSessionDownlink (org.onosproject.net.behaviour.upf.UpfSessionDownlink)4 Ip4Address (org.onlab.packet.Ip4Address)3 Ip4Prefix (org.onlab.packet.Ip4Prefix)3 UpfTerminationDownlink (org.onosproject.net.behaviour.upf.UpfTerminationDownlink)3 UpfTerminationUplink (org.onosproject.net.behaviour.upf.UpfTerminationUplink)3 Context (io.grpc.Context)2 ArrayList (java.util.ArrayList)2 UpfProgrammable (org.onosproject.net.behaviour.upf.UpfProgrammable)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 ByteBuffer (java.nio.ByteBuffer)1 Collection (java.util.Collection)1 Dictionary (java.util.Dictionary)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1