Do not require device data blob when checking pipeconf on device
This prevents loading potentially large amount of data in memory when
doing pipeconf reconciliation, as well as unregistering a pipeconf while
devices are using it (since we no longer need to access the
target-specific extensions to generate the device data blob)
Change-Id: Ib54123ce49a931ff88d93c991244d4086e5d7de0
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimePipelineProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimePipelineProgrammable.java
index 9b700ca..bc162b2 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimePipelineProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimePipelineProgrammable.java
@@ -65,13 +65,7 @@
return completedFuture(false);
}
- final ByteBuffer deviceDataBuffer = createDeviceDataBuffer(pipeconf);
- if (deviceDataBuffer == null) {
- // Hopefully the child class logged the problem.
- return completedFuture(false);
- }
-
- return client.isPipelineConfigSet(p4DeviceId, pipeconf, deviceDataBuffer);
+ return client.isPipelineConfigSet(p4DeviceId, pipeconf);
}
@Override
diff --git a/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimePipelineConfigClient.java b/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimePipelineConfigClient.java
index 2d9cb94..cc4b9e1 100644
--- a/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimePipelineConfigClient.java
+++ b/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimePipelineConfigClient.java
@@ -74,26 +74,24 @@
*
* @param p4DeviceId P4Runtime-internal device ID
* @param pipeconf pipeconf
- * @param deviceData target-specific data
* @return completable future, true if the device has the given pipeconf
* set, false otherwise.
*/
CompletableFuture<Boolean> isPipelineConfigSet(
- long p4DeviceId, PiPipeconf pipeconf, ByteBuffer deviceData);
+ long p4DeviceId, PiPipeconf pipeconf);
/**
- * Same as {@link #isPipelineConfigSet(long, PiPipeconf, ByteBuffer)} but
- * blocks execution.
+ * Same as {@link #isPipelineConfigSet(long, PiPipeconf)} but blocks
+ * execution.
*
* @param p4DeviceId P4Runtime-internal device ID
* @param pipeconf pipeconf
- * @param deviceData target-specific data
* @return true if the device has the given pipeconf set, false otherwise.
*/
default boolean isPipelineConfigSetSync(
- long p4DeviceId, PiPipeconf pipeconf, ByteBuffer deviceData) {
+ long p4DeviceId, PiPipeconf pipeconf) {
return Futures.getUnchecked(isPipelineConfigSet(
- p4DeviceId, pipeconf, deviceData));
+ p4DeviceId, pipeconf));
}
/**
diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/P4RuntimeClientImpl.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/P4RuntimeClientImpl.java
index 653fcfd..fdf5a94 100644
--- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/P4RuntimeClientImpl.java
+++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/P4RuntimeClientImpl.java
@@ -113,8 +113,8 @@
@Override
public CompletableFuture<Boolean> isPipelineConfigSet(
- long p4DeviceId, PiPipeconf pipeconf, ByteBuffer deviceData) {
- return pipelineConfigClient.isPipelineConfigSet(p4DeviceId, pipeconf, deviceData);
+ long p4DeviceId, PiPipeconf pipeconf) {
+ return pipelineConfigClient.isPipelineConfigSet(p4DeviceId, pipeconf);
}
@Override
diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/PipelineConfigClientImpl.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/PipelineConfigClientImpl.java
index 1dffc9c..f9aa5e7 100644
--- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/PipelineConfigClientImpl.java
+++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/client/PipelineConfigClientImpl.java
@@ -146,7 +146,9 @@
.newBuilder()
.setExtras(P4Config.P4DeviceConfig.Extras.getDefaultInstance())
.setReassign(true)
- .setDeviceData(ByteString.copyFrom(deviceData))
+ .setDeviceData(deviceData != null
+ ? ByteString.copyFrom(deviceData)
+ : ByteString.EMPTY)
.build();
return ForwardingPipelineConfig
.newBuilder()
@@ -159,10 +161,10 @@
@Override
public CompletableFuture<Boolean> isPipelineConfigSet(
- long p4DeviceId, PiPipeconf pipeconf, ByteBuffer expectedDeviceData) {
+ long p4DeviceId, PiPipeconf pipeconf) {
return getPipelineCookieFromServer(p4DeviceId)
.thenApply(cfgFromDevice -> comparePipelineConfig(
- pipeconf, expectedDeviceData, cfgFromDevice));
+ pipeconf, cfgFromDevice));
}
@Override
@@ -171,14 +173,13 @@
}
private boolean comparePipelineConfig(
- PiPipeconf pipeconf, ByteBuffer expectedDeviceData,
- ForwardingPipelineConfig cfgFromDevice) {
+ PiPipeconf pipeconf, ForwardingPipelineConfig cfgFromDevice) {
if (cfgFromDevice == null) {
return false;
}
final ForwardingPipelineConfig expectedCfg = buildForwardingPipelineConfigMsg(
- pipeconf, expectedDeviceData);
+ pipeconf, null);
if (expectedCfg == null) {
return false;
}
@@ -190,25 +191,11 @@
// No cookie.
log.warn("{} returned GetForwardingPipelineConfigResponse " +
"with 'cookie' field unset. " +
- "Will try by comparing 'device_data' and 'p4_info'...",
+ "Will try by comparing 'p4_info'...",
client.deviceId());
- if (cfgFromDevice.getP4DeviceConfig().isEmpty()
- && !expectedCfg.getP4DeviceConfig().isEmpty()) {
- // Don't bother with a warn or error since we don't really allow
- // updating the P4 blob to a different one without changing the
- // P4Info. I.e, comparing just the P4Info should be enough for us.
- log.debug("{} returned GetForwardingPipelineConfigResponse " +
- "with empty 'p4_device_config' field, " +
- "equality will be based only on P4Info",
- client.deviceId());
- return cfgFromDevice.getP4Info().equals(expectedCfg.getP4Info());
- }
-
- return cfgFromDevice.getP4DeviceConfig()
- .equals(expectedCfg.getP4DeviceConfig())
- && cfgFromDevice.getP4Info()
- .equals(expectedCfg.getP4Info());
+ return cfgFromDevice.hasP4Info() && expectedCfg.hasP4Info() &&
+ cfgFromDevice.getP4Info().equals(expectedCfg.getP4Info());
}
private CompletableFuture<ForwardingPipelineConfig> getPipelineCookieFromServer(