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();
}
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);
}
});
});
}
}
}
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());
}
}
}
}
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);
}
}
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);
}
Aggregations