Skip to content

Commit

Permalink
[SDFAB-1100] Leverage in-order FlowRuleService APIs (#512)
Browse files Browse the repository at this point in the history
* [SDFAB-1100] Leverage in-order FlowRuleService APIs

FabricUpfProgrammable leverages the new APIs to guarantee
in-order processing of the requests coming from the north.

If batch APIs are not used there is no guarantee about the
processing order in the FlowRuleService. Instead, the `striped`
API allow the apps to signal a preference in the requests
processing which is used by the FlowRuleService to serialize
all the requests, having equal key, on the same executor.

Depends on https://gerrit.onosproject.org/c/onos/+/25423

* Update snapshot version

Co-authored-by: Carmelo Cascone <[email protected]>
  • Loading branch information
pierventre and ccascone authored Mar 28, 2022
1 parent 2e63f6d commit 126aba9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ multiple targets:
To build and test this project you will need the following software:

* Barefoot SDE (a.k.a. Intel P4 Studio) = 9.7.0
* ONOS >= 2.5.7
* ONOS >= 2.5.8
* Docker (to run the build scripts without worrying about dependencies)
* cURL (to interact with the ONOS REST APIs)

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SPDX-License-Identifier: Apache-2.0
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-dependencies</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</parent>

<groupId>org.stratumproject</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public void enablePscEncap() {
FABRIC_EGRESS_UPF_GTPU_ENCAP, deviceId);
return;
}
flowRuleService.applyFlowRules(upfTranslator.buildGtpuWithPscEncapRule(
flowRuleService.applyFlowRules(deviceId.hashCode(), upfTranslator.buildGtpuWithPscEncapRule(
deviceId, appId));
}

Expand All @@ -312,7 +312,7 @@ public void disablePscEncap() {
FABRIC_EGRESS_UPF_GTPU_ENCAP, deviceId);
return;
}
flowRuleService.applyFlowRules(upfTranslator.buildGtpuOnlyEncapRule(
flowRuleService.applyFlowRules(deviceId.hashCode(), upfTranslator.buildGtpuOnlyEncapRule(
deviceId, appId));
}

Expand Down Expand Up @@ -407,7 +407,7 @@ public void deleteAll(UpfEntityType entityType) throws UpfProgrammableException
break;
}
}
flowRuleService.removeFlowRules(toBeRemoved.toArray(FlowRule[]::new));
flowRuleService.removeFlowRules(deviceId.hashCode(), toBeRemoved.toArray(FlowRule[]::new));
log.info("Cleared {} UPF entities of type {}", entitiesCleared, entityType.humanReadableName());
}

Expand Down Expand Up @@ -763,15 +763,15 @@ private void addUpfApplication(UpfApplication appFilter) throws UpfProgrammableE
assertSliceId(appFilter.sliceId());
FlowRule flowRule = upfTranslator.upfApplicationToFabricEntry(appFilter, deviceId, appId);
log.info("Installing {}", appFilter);
flowRuleService.applyFlowRules(flowRule);
flowRuleService.applyFlowRules(deviceId.hashCode(), flowRule);
log.debug("Application added with flowID {}", flowRule.id().value());
}

private void addInterface(UpfInterface upfInterface) throws UpfProgrammableException {
assertSliceId(upfInterface.sliceId());
FlowRule flowRule = upfTranslator.interfaceToFabricEntry(upfInterface, deviceId, appId, DEFAULT_PRIORITY);
log.info("Installing {}", upfInterface);
flowRuleService.applyFlowRules(flowRule);
flowRuleService.applyFlowRules(deviceId.hashCode(), flowRule);
log.debug("Interface added with flowID {}", flowRule.id().value());
// By default we enable UE-to-UE communication on the UE subnet identified by the CORE interface.
// TODO: allow enabling/disabling UE-to-UE via netcfg or other API.
Expand All @@ -785,7 +785,8 @@ private void addGtpTunnelPeer(UpfGtpTunnelPeer peer) throws UpfProgrammableExcep
peer, deviceId, appId, DEFAULT_PRIORITY);
log.info("Installing ingress and egress rules {}, {}",
fabricGtpTunnelPeers.getLeft().toString(), fabricGtpTunnelPeers.getRight().toString());
flowRuleService.applyFlowRules(fabricGtpTunnelPeers.getLeft(), fabricGtpTunnelPeers.getRight());
flowRuleService.applyFlowRules(deviceId.hashCode(), fabricGtpTunnelPeers.getLeft(),
fabricGtpTunnelPeers.getRight());
log.debug("GTP tunnel peer added with flowIDs ingress={}, egress={}",
fabricGtpTunnelPeers.getLeft().id().value(), fabricGtpTunnelPeers.getRight().id().value());
}
Expand All @@ -794,31 +795,31 @@ private void addUeSessionUplink(UpfSessionUplink ueSession) throws UpfProgrammab
FlowRule fabricUeSession = upfTranslator.sessionUplinkToFabricEntry(
ueSession, deviceId, appId, DEFAULT_PRIORITY);
log.info("Installing {}", ueSession.toString());
flowRuleService.applyFlowRules(fabricUeSession);
flowRuleService.applyFlowRules(deviceId.hashCode(), fabricUeSession);
log.debug("Uplink UE session added with flowID {}", fabricUeSession.id().value());
}

private void addUeSessionDownlink(UpfSessionDownlink ueSession) throws UpfProgrammableException {
FlowRule fabricUeSession = upfTranslator.sessionDownlinkToFabricEntry(
ueSession, deviceId, appId, DEFAULT_PRIORITY);
log.info("Installing {}", ueSession.toString());
flowRuleService.applyFlowRules(fabricUeSession);
flowRuleService.applyFlowRules(deviceId.hashCode(), fabricUeSession);
log.debug("Downlink UE session added with flowID {}", fabricUeSession.id().value());
}

private void addUpfTerminationUplink(UpfTerminationUplink upfTermination) throws UpfProgrammableException {
FlowRule fabricUpfTermination = upfTranslator.upfTerminationUplinkToFabricEntry(
upfTermination, deviceId, appId, DEFAULT_PRIORITY);
log.info("Installing {}", upfTermination.toString());
flowRuleService.applyFlowRules(fabricUpfTermination);
flowRuleService.applyFlowRules(deviceId.hashCode(), fabricUpfTermination);
log.debug("Uplink UPF termination added with flowID {}", fabricUpfTermination.id().value());
}

private void addUpfTerminationDownlink(UpfTerminationDownlink upfTermination) throws UpfProgrammableException {
FlowRule fabricUpfTermination = upfTranslator.upfTerminationDownlinkToFabricEntry(
upfTermination, deviceId, appId, DEFAULT_PRIORITY);
log.info("Installing {}", upfTermination.toString());
flowRuleService.applyFlowRules(fabricUpfTermination);
flowRuleService.applyFlowRules(deviceId.hashCode(), fabricUpfTermination);
log.debug("Downlink UPF termination added with flowID {}", fabricUpfTermination.id().value());
}

Expand Down Expand Up @@ -882,7 +883,7 @@ private boolean removeEntries(Collection<Pair<PiTableId, PiCriterion>> entriesTo
.collect(Collectors.toList());

try {
flowRuleService.removeFlowRules(entries.toArray(FlowRule[]::new));
flowRuleService.removeFlowRules(deviceId.hashCode(), entries.toArray(FlowRule[]::new));
// TODO in future we may need to send other notifications to the pfcp agent
//if (!failSilent) {
// throw new UpfProgrammableException("Match criterion " + match.toString() +
Expand Down Expand Up @@ -999,9 +1000,9 @@ private void applyUplinkRecirculation(Ip4Prefix subnet, boolean remove) {
FlowRule allowRule = upfTranslator.buildFabricUplinkRecircEntry(
deviceId, appId, subnet, subnet, true, DEFAULT_PRIORITY + 10);
if (!remove) {
flowRuleService.applyFlowRules(denyRule, allowRule);
flowRuleService.applyFlowRules(deviceId.hashCode(), denyRule, allowRule);
} else {
flowRuleService.removeFlowRules(denyRule, allowRule);
flowRuleService.removeFlowRules(deviceId.hashCode(), denyRule, allowRule);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public void apply(FlowRuleOperations ops) {
}
}

@Override
public void applyFlowRules(int key, FlowRule... flowRules) {
applyFlowRules(flowRules);
}

@Override
public void removeFlowRules(int key, FlowRule... flowRules) {
removeFlowRules(flowRules);
}

@Override
public int getFlowRuleCount() {
return flows.size();
Expand Down

0 comments on commit 126aba9

Please sign in to comment.