-
Notifications
You must be signed in to change notification settings - Fork 442
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
Spurious and misleading warning for overwriting extract (OverwritingHeader from ParsersUnroll) #4006
Comments
I agree that the behavior of extract'ing to the same header twice are well-defined in the P4 language specification. I also believe that MOST people would never want to write a parser that does so [1], and a warning that they have done so is a useful warning to have in a P4 compiler. What would you think if the warning message was instead something like this?
[1] Because unless you go to unusual lengths to save the data of the first extracted header into the header variable, that first extracted header will be deleted from the packet. There are other perfectly good ways to conditionally remove a header from a packet, e.g. use setInvalid() on the headers you want to remove, later after parsing is finished. |
I would add to the message something like: "If you do want that effect, replace the previous extract()s with lookahead()s instead". |
The loops unrolling pass has a long history and has various problems iirc. In this case, it is just calling into the interpreter code, which seems to throw that error. I am not sure how easy it is to fix that. @VolodymyrPeschanenko might know, he worked last on this particular compiler pass. |
I agree there should probably be a warning for this that suggests this might not be the best idea. @jafingerhut I think your formulation is good, and I think it is a good idea to add what @vgurevich suggested. I agree this is unusual and might be even wrong in most cases when the user writes it, but I have seen some that made some sense. In these cases we should make sure the warning reads as something in the sense of "this is not a great idea" rather than "this will be undefined" which is what the current warning suggests (although most likely not what the compiler does). Looking at the code a little bit, I am wondering if this could affect correctness of loop unrolling in the case when there is a header overwrite... And I have seen a code which has a loop in parser's control flow that could re-extract header. |
…ltiple times in a parse path (#4725) * Do not consider multiple header extractions as a symbolic exception * Update test outputs * Add back (better) warning message * appease cpplint * try again * warning is not emitted when loops are not unrolled
I'm getting the following warning in a quite simple program that just extracts ethernet and then two vlan tags.
The warning is coming from
ParsersUnroll
pass. Therefore, this affects any achitecture using this pass, not justdpdk
. It also affects p4testgen.This is quite confusing for many different reasons:
The code is here: parser-reextract.p4.txt (I had to change its extension for github to accept it).
The text was updated successfully, but these errors were encountered: