-
Notifications
You must be signed in to change notification settings - Fork 98
Description
Spawning off an issue based on @antoninbas's comment on a BMv2 PR and my subsequent response.
Basically, at the moment, I believe that the Wildcard Reads section suggests that a wildcard read like this should be supported:
device_id: <ID>
entities {
extern_entry { } # read all extern instances for all supported extern types
table_entry { } # read all table entries for all tables
action_profile_member { } # read all members for all action profiles
action_profile_group { } # read all groups for all action profiles
...
packet_replication_engine_entry { } # read all packet replication engine entries
}
And return, among other things, all packet replication engine entries. This is based on the simplest extrapolation from the example, which looks identical, but without the packet_replication_engine_entry
line.
However, @antoninbas brought up the great point that packet_replication_engine_entry { some_as_of_yet_undefined_field_that_is_NOT_part_of_the_type_one_of }
is an indistinguishable message from packet_replication_engine_entry { some_as_of_yet_undefined_field_that_is_part_of_the_type_one_of }
(as per https://protobuf.dev/programming-guides/proto3/#backward), which is also what we mention as the reason why a full wildcard read can't just be:
device_id: <ID>
entities { }
So, I think we need to clarify this in some direction. Here are 3 possible ways to deal with this:
- Disallow reads with unknown fields. This would also allow for the simpler wildcard read request, but means that clients need to know what version of P4Runtime their server is using.
- Allow unknown fields, but ignore them AND treat oneofs as being unset if no known field belongs to the oneof. This would also allow the simpler wildcard read requests, and would allow clients to send any reads they want, but if they fill in a oneof within an entity type A, they now need to expect getting ONLY that returned as a result (for entities of type A) or all other entities of type A.
- Disallow unset oneofs in reads unless they are a submessage of another unset message (e.g. if I don't have a
packet_replication_engine_entry
at all, then I don't need to fill in its oneof). This seems to be what BMv2 does now (at least for the situation above). Probably here we would still allow unknown fields, but ignore them? This is consistent with the current semantics for entity reads, and clients can expect the result of their reads to include EXACTLY what they requested (since presumably the switch doesn't contain any entities of a type it is unaware of). It's a little complicated though.
Note: Presumably for writes, we'd expect servers to not accept anything containing unknown fields, and therefore this is a non-issue?