fix map a type parsing issue for export/extern types #1563
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix issue #1562.
Currently, bcc allows a map defined in one module and
used in the same or a different module. At tests/python directory,
test_clang.py and test_shared_table.py have such an example.
...
b1 = BPF(text="""BPF_TABLE_PUBLIC("hash", int, int, table1, 10);""")
b2 = BPF(text="""BPF_TABLE("extern", int, int, table1, 10);""")
t = b2["table"]
...
With current implementation, the map key/value types are parsed
twice, resulting a type "int int" instead of "int". When type
is retrieved through
t = b2["table"]
, python decoding errorwill appear.
The issue is fixed by preventing the second map key/value type
parsing if the map is
extern
. Also addt = b2["table"]
so the issue will be triggered if bcc clang frontend fix is not there.
Signed-off-by: Yonghong Song yhs@fb.com