Git Product home page Git Product logo

Comments (6)

dhankook avatar dhankook commented on July 20, 2024

Sorry, I was sloppy with the versions of the modify_field_test and commands files; some incorrect table and action names are in the versions I supplied earlier. Here are the corrected versions:
modify_field_test.txt
commands.txt

from behavioral-model.

antoninbas avatar antoninbas commented on July 20, 2024

Hi David,
This is what I wrote on p4-dev: it is likely that a bunch of P4 capable switches won't be able to enforce these semantics for modify_field. Therefore, it is likely that the next iteration of the P4 spec will change these semantics to "undefined behavior".
Regarding bmv2, it would be in theory be possible to add an action primitive modify_field_with_check, which would only perform the assignment if a condition is valid. It could be used like this: modify_field_with_check(hA.f1, hB.f1, valid(hA) and valid(hB)). I am not sure it is worth the trouble though, as this would probably be only valid on bmv2. Note that the following is supported (and will be supported by the future spec): modify_field(hA.f1, valid(hB) ? hB.f1 : 0). It does not do what you want though.
I think the bottom line is that a "conditional write" is not something you can get right now.

from behavioral-model.

dhankook avatar dhankook commented on July 20, 2024

Thanks for your response. I would be the last one to argue for anything that will only be valid on bmv2, since one of the foundational points of my research is to provide a vehicle for P4 code portability across different switches.
I will adjust.

from behavioral-model.

antoninbas avatar antoninbas commented on July 20, 2024

cool, let's hope that the new version of the spec comes out soon and addresses this issue

from behavioral-model.

antoninbas avatar antoninbas commented on July 20, 2024

The proposed P4_16 spec states that this is undefined behavior (http://p4.org/wp-content/uploads/2016/12/P4_16-prerelease-Dec_16.html#sec-ops-on-hdrs): "The result of reading or writing a field in an invalid header is undefined. The result of reading an uninitialized header field is undefined — even if the header itself is valid.".
However, since bmv2 is meant first and foremost as a P4 debugging tool, we could consider having a "strict" mode that would print a warning when this happens, which is why I'm leaving this issue open for now.

from behavioral-model.

jafingerhut avatar jafingerhut commented on July 20, 2024

There is now an updated version 1.0.4 of the P4-14 spec published: https://p4lang.github.io/p4-spec/

It defines that if the source field of modify_field is part of an invalid header, then the read value is undefined.

Like v1.0.3 did, v1.0.4 still says that if the dest field is part of an invalid header, the modify_field operation has no effect.

There is a current discussion for exactly what is the meaning of the line that was quoted in the P4-16 spec, here: p4lang/p4-spec#285

from behavioral-model.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.