iovisor / iovisor/bcc

Reading from unaligned structs (class) is causing invalid values.

Open
#2,017 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
10d 4h
Merged PRs (30d)
3

Description

When the below structure is used in the BPF Code, packet_num works fine, but if the same is retrieved using python it doesn't work.
struct reorder_info {
u16 seq_num;
u32 packet_num;
}__packed;

In the above structs, even though its packed, python inserts "holes" to try and align the struct because BCC doesn't understand the "__packed" macro as its from Linux Kernel. While accessing "packet_num" the python code starts at the hole offset causing invalid values.

BPF should understand packed from and refrain from aligning the struct.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.