Skip to content
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

Dpdk Backend: Fix incorrect field extraction arithmetic #4301

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

usha1830
Copy link
Contributor

when multiple non-byte aligned header fields are combined into single byte aligned field. The references of these fields are updated with incorrect slice operation.

For ex: when

 header ipv4_t {
                            ...
                            bit<3>  flags;
                            bit<13> fragOffset;
                            ...
                        }

is converted into

                  header ipv4_t {
                           ...
                           bit<16>  flags_fragOffset;
                           ...
                       }

flags field should be converted to flags_fragOffset[15:13]
fragOffset should be converted to flags_fragOffset[12:0]

But currently the conversion happens like this
flags field is converted to flags_fragOffset[2:0]
fragOffset is converted to flags_fragOffset[15:3]

Fixes #4077

@@ -122,38 +122,38 @@ action encap_one_tunnel_layer_ipv4 args instanceof encap_one_tunnel_layer_ipv4_a
mov h.mac.type 0x800
validate h.ipv4_0
mov m.MainControlT_tmp h.ipv4_0.version_ihl
and m.MainControlT_tmp 0xF0
and m.MainControlT_tmp 0xF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come this bug wasn't caught?

Copy link
Contributor

@jafingerhut jafingerhut Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was caught. That is why there was a bug report about it.

Do you mean, why wasn't it caught earlier than Jul 2023 when I reported it?

Probably at least in part because there are no automated CI tests that pass data packets through the P4 DPDK that would have caught this. Fabian Ruffy has tried to create some such tests, but he has had difficulty making them work consistently enough to use for CI purposes on this repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And Perhaps no user tried accessing the individual header fields of the combined fields. Some of the early users may be combining these fields by themselves in the P4 program and thereby handling these extractions also in the program itself.
Thanks to Andy who caught this!!

…ned header fields are combined into single byte aligned field
@usha1830 usha1830 merged commit 9bad3cb into p4lang:main Dec 20, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DPDK back end can produce incorrect field extraction arithmetic in parser
3 participants