p4lang / p4runtime

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

Update specification to clarify that server imposes restrictions on length of byte-strings. #420

Closed verios-google closed 1 year ago

verios-google commented 1 year ago

The Bytestring section of the specification states "Upon receiving a binary string, the P4Runtime receiver (whether the server or the client) does not impose any restrictions on the length of the string itself."

But also states: 1)"As a special case, define that the value $V=0$ requires at least $A=1$ bit to represent, regardless of whether it is signed or unsigned." 2)"If the string's byte length is zero, the server always rejects the string."

The previous 2 statements conflict with the first statement. The first statement should be removed or updated to be consistent.

verios-google commented 1 year ago

My suggested update to the relevant paragraph is:

Upon receiving a binary string, the P4Runtime server checks the length of the byte string. If the string's byte length is zero, the server always rejects the string. Clients are not required to perform this check. The receiver then verifies that the value encoded by the string fits within the expected type (signed or unsigned) and P4Info-specified bitwidth for the P4 object value.

chrispsommers commented 1 year ago

Thanks @verios-google would you be willing to submit a pull-request to make this change, assuming we can come to an agreement?

Another possible edit would be to insert the word maximum into the original description, as follows:

"Upon receiving a binary string, the P4Runtime receiver (whether the server or the client) does not impose any restrictions on the maximum length of the string itself."

verios-google commented 1 year ago

Ah, that's an even simpler change, and it provides useful explicit information. I'll do that