-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What does BMv2 do with a header object in a calculation? #739
Comments
Following up on my own question, it appears that the P4_14 language spec says that if a header is in a field list, it should be treated as if it is expanded into all of its fields. If that is true, then probably my last bullet item is the correct answer here, at least for P4_14, and it is up to the P4 programmer to set the conditions for using any calculation result only when its inputs are well-defined. |
The implementation is here: https://github.com/p4lang/behavioral-model/blob/master/src/bm_sim/calculations.cpp#L95. It is fairly straightforward since it only supports 3 cases: field, header and constant. We iterate over the members of the "field" list and build a buffer over which the hash is eventually computed. For headers and fields, the buffer is built using the same underlying methods as for the
|
In your answer "if a header is not valid, it is skipped", I understand that can be useful behavior. Do you agree that it is a bit different then the P4_14 language specification behavior from Section 2.4 "Field Lists", where it claims the following for a field_list that contains the name of a header variable: "Each entry may be a specific field instance reference, a header instance (which is equivalent to listing all the header’s fields in order) or a fixed value." If so, it wouldn't be the first time the implementation diverged a bit from the P4_14 language spec. I am just digging for a few details here when thinking about how to document the behavior of P4_16 v1model and PSA functions like checksum and hash that are passed lists of "things", if those things happen to be headers. It is not supported to have header values in such lists for v1model, according to the documentation in v1model.p4 comments, and perhaps it shouldn't be supported for PSA, either. If they are supported, it seems good to nail down these kinds of behavior details, so thanks for the info. |
@jafingerhut any follow-up needed on this year-old issue? Or can we close it? |
From these lines of BMv2 code, it appears that at least when the code was written, it was expected that a checksum verification and/or update calculation could include not only constants and fields, but also entire headers: https://github.com/p4lang/behavioral-model/blob/master/src/bm_sim/P4Objects.cpp#L1391-L1394
I got a little lost in the implementation of how BMv2 actually does the calculation, and had the following questions:
The text was updated successfully, but these errors were encountered: