198 Commits

Author SHA1 Message Date
Yi Tseng
0926513a15 [SDFAB-1147] Encode P4Runtime messages with canonical byte string
In ONOS, we still use non-canonical byte strings when sending P4Runtime
write requests.

Ref: https://p4.org/p4-spec/p4runtime/v1.3.0/P4Runtime-Spec.html#sec-bytestrings

Change-Id: I27d7977660bea462de82ebe2a4cb5d14500d3b69
(cherry picked from commit 3821399aee849c2a6a334fdb16bfa6b5f8f6dcc5)
2022-03-28 18:18:33 +00:00
pierventre
14a76e72a7 Improve Mastership logging
Logs only meaningful mastership changes

Change-Id: Ibbe4f85526df01b3c1b6eab317a2c15716098d80
2022-03-03 01:46:40 +00:00
pierventre
1c18ee5c26 [SDFAB-1015] Use gNOI to probe reachability and increase short timeouts
p4runtime probe reachability is based on GetPipelineConfig gRPC that
can timeout if we are setting in parallel the pipeline: the two requests
concur for the same lock. For our purposes it is enough to check if the
device is still there; for this reason stratum handshaker now relies
on gNOI reachability which is based on getTime RPC.

Additionally increase short timeouts: we have consistenly measured a
time of 14s to push the pipeline on the new QS devices.

Change-Id: I8837540241d8a68f648e47ae165ea53a2d0a865c
2022-02-25 06:27:00 +00:00
Yi Tseng
09347c11b5 Handle huge egress port number in PreReplicaCodec
When using logical port for replica such as SDN CPU port (0xfffffffd), the
PreReplicaCodec will throw an ArithmeticException since this value is too
big for an signed 32-bit integer.

In that example, we need to convert the value to -3

According to the protobuf document[1]:
"In Java, unsigned 32-bit and 64-bit integers are represented using their
signed counterparts, with the top bit simply being stored in the sign bit."

[1]: https://developers.google.com/protocol-buffers/docs/proto#scalar

Change-Id: Ie3bda828d499b7d26d7b790f9ed76bb687243e57
2022-02-04 08:14:27 +00:00
Wailok Shum
741d50de0a [SDFAB-820] Improve error logging in StreamClientImpl
Change-Id: I93a737f31432743f20917b8c85dd54d8b81eee62
2021-12-17 19:11:34 +00:00
Emanuele Gallone
b692a8240e Add architecture method to PiPipelineModel Interface.
The field `pkg_info:arch` is now parsed, when parsing a P4Info file.

Change-Id: Ia1b24b929fe4ed8ac2a2becfa0ce7678642e9037
(cherry picked from commit ce9942049825c51c0a0818ad4b89395321aa82b3)
2021-11-18 15:31:45 -08:00
Miguel Borges de Freitas
89e3d23d2b [P4Runtime] Make sure write requests contain the codec failure reason
The submit() method of p4 WriteRequestImpl is returning an empty
response if there are no update messages. However, one of the reasons
for updates to be empty is the fact the catch block in
appendToRequestMsg is reached due to some invalid usage of the p4runtime
contract. In such situations, not only the user doesn't know why the
request is failing (absence of logging in ONOS) but the responseBuilder
which contains the failure is also not propagated. As a result, a future
call to P4RuntimeWriteClient.WriteResponse.isSuccess() will return
true (as if the request actually succeeded) and .all() will also not
contain the failedResponse appended during the CodecException. Added a
test to illustrate the issue.

Change-Id: I0acfd3b34b3ed1db2d91f91fed08f9d00800dda4
2021-10-26 17:52:13 +00:00
pierventre
c0914ec586 [SDFAB-500][SDFAB-527] Meters cleanup and leftovers
- Improve ONOS cli enabling CRUD of p4rt trtcm
- Improve ONOS rest enabling CRUD of p4rt trtcm
- Improve MeterService with scope defined reads and integrate in cli/rest
- Add support along the stack for BYTE_PER_SEC unit
- Add support along the stack for COMMITTED and PEAK bands
- Fix several bugs in ONOS cli/rest interfaces
- Improve REST codecs
- Fix NPE in MeterDriverProvider
- Improve PiMeterTransalation by enforcing trtcm config
- Implement explicit translation of the bands
- Fix ONOS reconciliation by removing from the mirror the wrong configs
- Remove unnecessary checks in MeterEntryCodec
- Update unit tests

It will follow a 2nd patch to complete SDFAB-527

Change-Id: I855235b17f60cb1d39f5b9a042c1015105a8a269
2021-09-10 10:22:18 +00:00
Wailok Shum
221d70dc4e [SDFAB-453] Add a field check to MeterEntryCodec
Change-Id: I4c59c9d45f3128a7d75661fa432bfb33336965aa
2021-08-24 01:40:09 +08:00
Wailok Shum
6d42cff6bc [SDFAB-354] Improve P4RTMeterProgrammable
Change-Id: I65a325f90a49853c6c4a1cfb8212a016a8ec2b2d
2021-08-24 01:33:04 +08:00
Wailok Shum
9664209358 [SDFAB-356] Extend P4RuntimeMeterProgrammable and Codecs to support reset scenario
Change-Id: Ifad0b296568d3f78b2aa792fa63f2f81fa80ebae
2021-08-06 17:28:50 +08:00
Daniele Moro
d900fe4a87 Add support for one shot action profile programming in PI
A P4 table annotated with @oneshot annotation can be programmed
only with the action profile action set. For these kind of tables
we don't issue read request for action profile groups and members.

Change-Id: I7b6a743f4f4df4190f17d958ebb4807aca5feda5
2021-07-01 17:34:35 +00:00
Daniele Moro
53a3cdfb82 Ensure P4Runtime byte strings are padded to their bit width
The P4Runtime server may send canonical byte strings (i.e.,
non-padded byte strings).
In ONOS we ensure, in the codecs, that all byte strings are
padded to match the model (P4Info) bit width. In this way,
we provide read-write symmetry inside ONOS.
ONOS always pads byte strings when sending messages to the
P4Runtime server.
This patch doesn't enforce read-write symmetry between
P4Runtime client and server on the wire.

N.B.: the current padding implementation works ONLY when
using non-negative integer.

Change-Id: I9f8e43de015bd0929dd543d7688c8e71bf5fe98d
2021-05-18 15:58:44 +02:00
Daniele Moro
7aa13e6898 Allows to specify matches, action parameters as strings in PI
Some PI elements can encode in their value a string (e.g., when
a P4Runtime translation is used), for this reason we allow users
to specify matches and action parameters as strings.
From southbound, during decode, we interpret the elements as
string if the P4 model suggests that.

Change-Id: I5884de1500437ab647abc200d65de442e23bd1a8
2021-05-18 12:51:24 +00:00
pierventre
219dd8fedf [AETHER-1550] Add additional trace logs in P4RT SB
log:set TRACE org.onosproject.p4runtime.ctl.client.WriteRequestImpl
to have all the prints we need

Change-Id: Ie46e36145769ffc7a91485ee3f3791a94cf8b8a9
2021-04-30 04:33:42 +00:00
Daniele Moro
2375917830 Add support for arbitrary bitwidth packet metadata
This patch is related to #24172

Change-Id: I29fc82bd3944b7fc9f58021df56cadd209cac190
2021-03-01 17:57:36 +00:00
Daniele Moro
298d326e35 Fix bug when reading table entries
Check if table has counter only if not all tables wildcard read.

Change-Id: I1a15e578bb55eaaf0b1ce4e1c509a6ec0334292b
2021-02-17 23:00:07 +00:00
Daniele Moro
46b27630d4 Add support for all tables wildcard read in P4Runtime
This is required for targets that are not P4RT-compliant
and do not support table-specific wildcard reads.
The all tables wildcard read are activated via
tableWildcardReads driver property.

Change-Id: I675e6f876648ad7634ea0a13ecf44aa366739d3f
2021-02-11 16:52:57 +00:00
Daniele Moro
c6f2f7f3c5 Add Optional match fields support to PI subsystem
Change-Id: Ic458f59cab98340e40c04a0ad060d3c725ac5dbb
2021-02-05 19:03:05 +01:00
Carmelo Cascone
304b6644a1 Add digest to P4InfoBrowser
Change-Id: Ie79b61d2ecfc5a52c8b027a5384b86a555623db7
(cherry picked from commit 08be25533d09c3ba8023f4d34e07f4555d6013aa)
2021-02-05 18:02:04 +00:00
Daniele Moro
f178b0a5ad Add tests for codecs and P4Info parser when P4Runtime Translation is used
Change-Id: Ied0e83e81dad29f5b250548d2e26ec960b98f560
2021-02-05 18:00:09 +00:00
pierventre
69329170ad [AETHER-1104] Calculate PiPipeconf fingerprint in a deterministic way
New master after taking over a switch was pushing again the pipeline
and all the flows and groups. This was happening because DefaultPiPipeconf
fingerprint was not calculated in a deterministic way across the cluster.

This patch introduces the following changes:
- Implements toString method in each abstraction representing a pipeline
- Hashes the p4Info file to generate a consistent hash of the pipeline model
- Uses a sorted collection to generate a consistent hash of the extensions

Change-Id: I792283b0a9b821284add36b3aba52843f33527c3
2021-01-21 21:55:24 +01:00
pierventre
1a833d4c85 [AETHER-1074][AETHER-1088] Missing Kryo classes in several subsystems
This was leading to not proper replication of the state
and some EC maps being empty

Change-Id: Id39660c2ce3b5507e796801c0213c194f0a2009a
2021-01-19 16:47:27 -08:00
Charles Chan
730d546f05 Add debug log in P4RuntimePipelineConfigClient
Change-Id: Ie71af2f80b12b8ad99c8f597af1c3f026a532c4b
2021-01-19 16:47:21 -08:00
Daniele Moro
5c82b0fb37 Support arbitrary bit width action parameter and match field
This commit goes into the direction of supporting user-defined types in P4Runtime.
The modification is focusing on supporting fields and params with arbitrary bit width, that is the
case of using a String with the p4runtime_translation annotation on the user-defined type.

Change-Id: I7db7a6d97211378ff78ab4f1b3734a0bec4558e6
2020-12-15 17:50:10 +00:00
Carmelo Cascone
7981d09ab6 Extract and publish p4runtime protocol utils in separate artifact
For consumption by third-party apps built via mvn

Change-Id: Ic9c1eccb2519b2952cdb632e1f07ccefbba00396
2020-12-04 15:58:31 -08:00
Carmelo Cascone
df79459af1 AETHER-452 Read P4RT counters only if table supports them
Before, we were reading counters from all tables, even from those that
didn't have any. That was causing certain P4RT implementations to
return error.

Change-Id: I028ecaca46ddc0c9afc16b78ba7754f943a2717b
(cherry picked from commit d172435433e19b10eb6b320823428e67f6205e8a)
2020-07-17 19:13:29 +00:00
Carmelo Cascone
2254dcdcf0 Fix P4RuntimeClient not logging write errors
Change-Id: I07d9e3ecdc4bcd7178db2fe5356c984d8ae64d5b
2019-08-20 17:05:27 -07:00
Carmelo Cascone
d33d3b4838 Build ONOS exclusively with Bazel-provided remote JDK
This change make it possible to build ONOS in a host system without JDK
installed, or ignoring the one installed, instead relying exclusively on
the "remote" JDK provided by Bazel. The JDK version, along with the
toolchain configuration (language source and target values), are checked
in as part of the build files (tools/build/bazel/BUILD), thus enabling
deterministic builds that are less dependent of the host environment.

To allow this, this change replaces all references to JDK-related tools
expected to be on the host PATH, such as the jar command, with their
counterpart from the remote JDK (now a sandboxed relative path). This is
achieved by:

  * Creating a new "jdk_genrule" macro that exposes the remote JDK bin
    directory to the PATH visible by the genrule command. This is used
    for all genrule targets invoking for example `jar`;
  * Modifying custom Starlak rule implementations by replacing
    invocation to JDK tools with a path from the remote one.
  * Renaming the onos/lib directory to onos/deps as it clashes with
    the Bazel-provided JDK's lib directory (that for some strange reason
    is resolved on the ONOS workspace)

Finally, this change is reflected on the Dockerfile which now builds
ONOS from an Ubuntu image with no JDK installed.

Change-Id: Ie7d990cfce6fef00ddb4ffffe4c6205b8530fb47
2019-06-18 22:26:33 +00:00
Carmelo Cascone
b9536696f6 First attempt at supporting builds with Java 11
Includes:
- Bump protobuf to 3.8.0 and grpc-java to 1.21.0 (along with transitive
  dependencies such as Netty)
- Add jaxb_api at compile time when needed (removed in JDK 11)
- Bump Bnd to 4.1 (adds support for Java 11)

To build with JDK 11, uncomment lines in .bazelrc.
Tested with Bazel 0.26.0.

Change-Id: Ib8e0c7310eacf97328762606e57c01e4834e5565
2019-05-30 18:11:06 +00:00
Yi Tseng
b81121fc21
[ONOS-7982] Remove P4Config
Change-Id: Ie5cb39da2f5aad7b097b7e4819fc3a1ea7129ed2
2019-05-07 18:36:46 -07:00
Carmelo Cascone
c0b23a459f Allow building third-party apps based on gRPC
By publishing the repackaged grpc and protobuf artifacts

Change-Id: Ib3af7dba4f64948132aa70be31922de61d6f6ab2
2019-04-25 15:38:00 -07:00
Carmelo Cascone
75a9a8958e Trigger pipeconf deploy right after registration
Without waiting for the next pipeconf watchdog periodic probe.
To support this, this patch extends the PiPipeconfService to advertise
pipeconf registration events.

Change-Id: Ib44f1813bd37083c666a5e7980de320ce469c2d2
2019-04-23 19:39:56 +00:00
Carmelo Cascone
adb89058b4 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
2019-04-18 05:52:26 +00:00
Carmelo Cascone
9db4d5c644 Add support for P4Runtime clone sessions via Group API
Clone sessions can now be created by defining groups with new type CLONE

The PI framework has been refactored to abstract commonality between
multicast groups and clone sessions as both are managed as part of the
P4Runtime packet replication engine (PRE).

Change-Id: I2f23c629b7de1931d5cab96ec76aef26130ce418
2019-04-17 21:55:13 +00:00
Carmelo Cascone
4b616316d9 Further improvements to connection handling for gRPC-based devices
Force reset of gRPC connection backoff when probing for reachability.
This allows provider to attempt reconnection when needed, instead of
depending on the channel backoff timer.

Improved checkup task in GDP to better handle mastership
flapping observed when reconnecting devices.

Change-Id: I473fb14160b2eb744a483de431b91f9f6bcdab95
2019-04-17 21:54:42 +00:00
Carmelo Cascone
d51a555886 Minor fixes for P4Runtime devices
- Push ports before device is marked online
- Do not notify role NONE on device disconnection (otherwise the
DeviceManager won't mark the device as offline if there's not a master)
- Detect changes in the pipeconf extensions when reloading a pipeconf

Change-Id: I1779987da1269ec98c71b2ccda7bb579be5bf3f0
2019-04-15 20:34:12 +00:00
Carmelo Cascone
c2be50a804 Allow sharing the same gRPC channel between clients
This change introduces a refactoring of the gRPC protocol subsystem that
allows the creation of a gRPC chanel independently of the client, while
allowing multiple clients to share the same channel (e.g. as in Stratum
where we use 3 clients).

Moreover, we refactor the P4RuntimeClient API to support multiple
P4Runtime-internal device ID using the same client. While before the
client was associated to one of such ID.

Finally, we provide an abstract implementation for gRPC-based driver
behaviors, reducing code duplication in P4Runtime, gNMI and gNOI drivers.

Change-Id: I1a46352bbbef1e0d24042f169ae8ba580202944f
2019-04-11 23:14:41 +00:00
Carmelo Cascone
b8a2505d80 More robust deferring for P4Runtime MasterArbitrationUpdate messages
The P4RuntimeClient implements a deferring mechanism to avoid becoming
master when it shouldn't, i.e. when the requested election ID is bigger
than the master one on the device, but it was not asked to be master.
We rely on a distributed primitive to make sure all nodes are aware of
the latest master election ID on the device. In case we lose primitive
update events, this patch adds a maximum timeout after which the
MasterArbitrationUpdate message is always sent.

Change-Id: I98669dac3fc79173b9e98f41e11a4d08901c6cb1
2019-04-08 23:01:01 +00:00
Carmelo Cascone
c32976e7d5 Various fixes in preparation of Stratum demo at ONS 2019
- Do not read counters with table entries for Barefoot drivers
- If driver behavior setup fails, log which operation we are aborting
- Remove unnecessary setup steps in Stratum-related drivers
- Always get clients by their key in gRPC-based drivers
- Log when P4Runtime group operation fails because of missing group in
store
- Fix polling of table entry counters for P4Runtime driver

Change-Id: Ic9bf19b76d8cb5a191aec24852af4410fea8b998
2019-04-08 23:00:54 +00:00
Carmelo Cascone
a3635abf1d Parse action profile max group size from P4Info annotations
This is a temporary workaround to the inability of p4c to
correctly interpret P4Runtime-defined @max_group_size annotations.

Change-Id: If2799786c135b2eb5b6a3b4c6d6022350d37237e
2019-03-22 05:00:35 +00:00
Carmelo Cascone
ab5d41e8ab Add support for enabling/disabling ports for gNMI devices
This change also includes:
- Refactoring of gNMI protocol+driver to take advantage of the recent
changes to the gRPC protocol subsystem (e.g. no more locking, start RPC
with timeouts, etc.).
- Fixed Stratum driver to work after GeneralDeviceProvider refactoring
- Updated bmv2.py to generate ChassisConfig for stratum_bmv2
- Fixed portstate command to use the same port name as in the store

Change-Id: I0dad3bc73e4b6d907b5cf6b7b9a2852943226be7
2019-03-07 07:45:32 +00:00
Carmelo Cascone
6146946e16 Fix inconsistent update type during concurrent P4Runtime writes
This is achieved by optimistically updating the P4Runtime mirror using
the write request (instead of waiting for a response) and by serializing
building write requests for the same device.

This change requires updating the P4Runtime protocol classes to expose
the content of the write request.

It also includes:
- force member weight to 1 when reading groups (some server
implementation still fails to be compliant to the spec)
- remove unused operation timeout handling in GDP (now all RPCz have a
timeout)

Change-Id: Ib4f99a6085c1283f46a2797e0c883d96954e02e9
2019-03-06 19:28:42 +00:00
Carmelo Cascone
3977ea4d9e Refactor channel and mastership handling in P4Runtime
This (big) change aims at solving the issue observed with mastership flapping
and device connection/disconnection with P4Runtime.

Channel handling is now based on the underlying gRPC channel state. Before,
channel events (open/close/error) were generated as a consequence of P4Runtime
StreamChannel events, making device availability dependent on mastership. Now
Stream Channel events only affect mastership (MASTER/STANDBY or NONE when the
SteamChannel RPC is not active).

Mastership handling has been refactored to generate P4Runtime election IDs that
are compatible with the mastership preference decided by the MastershipService.

GeneralDeviceProvider has been re-implemented to support in-order
device event processing and to reduce implementation complexity. Stats polling
has been moved to a separate component, and netcfg handling updated to only
depend on BasicDeviceConfig, augmented with a pipeconf field, and re-using the
managementAddress field to set the gRPC server endpoints (e.g.
grpc://myswitch.local:50051). Before it was depending on 3 different config
classes, making hard to detect changes.

Finally, this change affects some core interfaces:
- Adds a method to DeviceProvider and DeviceHandshaker to check for device
availability, making the meaning of availability device-specific. This is needed
in cases where the device manager needs to change the availability state of a
device (as in change #20842)
- Support device providers not capable of reconciling mastership role responses
with requests (like P4Runtime).
- Clarify the meaning of "connection" in the DeviceConnect behavior.
- Allows driver-based providers to check devices for reachability and
availability without probing the device via the network.

Change-Id: I7ff30d29f5d02ad938e3171536e54ae2916629a2
2019-03-06 19:28:42 +00:00
Carmelo Cascone
a4dc3c12bc Update install-p4-tools.sh to use P4Runtime v1.0
Includes also various improvements to the p4vm scripts, such as:
- Choose to build VM with Ubuntu 16.04 or 18.04 (experimental)
- Allow users to specify version of protobuf and grpc to use
- Avoid building protobuf and grpc if already installed in the system
- Install Bazel 0.22

Also:
- Remove check for invalid group member weights (now PI always returns
members with weight 1)
- Re-compiled all P4 programs and fixed missing padding in controller
packet headers

Change-Id: I0e672fcebbaba63354c749f0c774af251f3cbc6c
2019-02-21 23:24:26 +00:00
Carmelo Cascone
bde9beba9c Re-package grpc and protobuf with the right group id and version
Change-Id: Ib1a17d917a061d3cce32eed3e72b18c596ccff69
2019-02-08 15:44:43 -08:00
Carmelo Cascone
b203b64818 Set all write responses as failed when P4Runtime server returns error
Change-Id: I1e3e1cd214b71b96c4abd10d8700a1fa11f73f0e
2019-02-07 18:45:48 +00:00
Carmelo Cascone
4c289b731d New P4RuntimeClient implementation that supports batching and error reporting
The new client API supports batching and provides detailed response for
write requests (e.g. if entity already exists when inserting), which was
not possible with the old one.

This patch includes:
- New more efficient implementation of P4RuntimeClient (no more locking,
use native gRPC executor, use stub deadlines)
- Ported all codecs to new AbstractCodec-based implementation (needed to
implement codec cache in the future)
- Uses batching in P4RuntimeFlowRuleProgrammable and
P4RuntimeGroupActionProgrammable
- Minor changes to PI framework runtime classes

Change-Id: I3fac42057bb4e1389d761006a32600c786598683
2019-02-04 23:12:46 -08:00
Carmelo Cascone
e45902b280 Bumped P4Runtime to v1.0.0
Change-Id: Ie6419e45980a0394ce1e0439831f4b011a4d7487
2019-02-05 00:44:37 +00:00
Carmelo Cascone
0f8b7bea74 Fix build of protobuf-related components to support Bazel 0.22
- Bumped version of protobuf to 3.6.1.3 (includes fix for Bazel 0.22)
- Removed all protobuf and grpc dependencies from deps.json. Instead,
  depends solely on what's provided by the external grpc and protobuf
  workspaces.
- Use OSGi-wrapped protobuf and grpc JARs built with Bazel for runtime
- Add missing netty-related bundles to onos-thirdparty-base (required
by grpc)

Note, build with Bazel 0.22 is still broken because of
osgi_java_library.bzl, unless the following build arg is used:
build --incompatible_string_is_not_iterable=false

It seems the error is caused by dead code in osgi_java_library.bzl
that should be removed.

Change-Id: I749f1de25902bf9df5242444380f7224bc99b4b5
2019-01-29 16:11:08 -08:00