add padding to the end of structure #1484
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.
Commit 538a84e ("provide padded structure for
table_{key|leaf}_desc API") added explicit padding, if needed,
before every structure member.
This is not enough as if an array of elements are returned
from C++ to python side, the size of structure must be correct.
This patch also adds padding after the last structure field
to make structure size in python side consistent with C++
side. With this patch, I experimented with the pull request
for tcpretrans.py by Matthias Tafelmeier, the type
struct ipv6_flow_key_t {
unsigned __int128 saddr;
unsigned __int128 daddr;
u64 lport;
u64 dport;
}
can be replaced with
struct ipv6_flow_key_t {
unsigned __int128 saddr;
unsigned __int128 daddr;
u16 lport;
u16 dport;
}
where the original type of lport/dport is u16.
Some other ipv6 related data structures can also be simplified.
Signed-off-by: Yonghong Song [email protected]