p4lang / p4runtime

Specification documents for the P4Runtime control-plane API
Apache License 2.0
147 stars 89 forks source link

Wildcard reads / deletes for MulticastGroupEntry and CloneSessionEntry? #205

Open antoninbas opened 5 years ago

antoninbas commented 5 years ago

This is currently not supported by P4Runtime (to the best of my knowledge), which could be quite inconvenient. I don't see a nice way to support this without changing the corresponding Protobuf message definitions. For MulticastGroupEntry, we may be able to get away with using multicast_group_id 0 as the wildcard, but for CloneSessionEntry, the spec states that 0 is a valid session id (of course we could consider changing that).

jafingerhut commented 5 years ago

Note from 2019-Jun-19 P4 API working group meeting:

One possible way that might work is for the PacketReplicationEngineEntry message to be unset, i.e. neither of its oneof values (if Protobuf allows that -- needs to be verified). If it can be unset, the P4Runtime API spec could specify that when it is unset, the server treats it as a wildcard read of all multicast groups and all clone sessions.

stefanheule commented 5 years ago

Just wanted to follow-up here saying that you can indeed check for the absence of a oneof field in protobuf 3. You can check the "case" of the oneof field, which will be 0 for unset oneof fields.

For instance, in C++ you could check it as follows: entry.type_case() == ::p4::v1::PacketReplicationEngineEntry::TypeCase::TYPE_NOT_SET.