10000 Make struct used by digest in p4tc packed by vbnogueira · Pull Request #5329 · p4lang/p4c · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make struct used by digest in p4tc packed #5329

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vbnogueira
Copy link
Contributor
@vbnogueira vbnogueira commented Jun 26, 2025

The p4tc control path expects the digest message to be packed
For example, in testdata/p4tc_samples/digest.p4 we have the following
struct being sent throught digest pack:

struct mac_learn_digest_t {
    @tc_type("macaddr") bit<48> srcAddr;
    @tc_type("dev") PortId_t ingress_port;
};

As an eBPF C struct, this will be:

struct mac_learn_digest_t {
    u8 srcAddr[6]; /* bit<48> */
    u32 ingress_port; /* PortId_t */
};

Notice that this will create padding between srcAddr
and ingress_port. To avoid this we are making structs associated with
digest messages packed. So the previous struct will become:

struct __attribute__((__packed__)) mac_learn_digest_t {
    u8 srcAddr[6]; /* bit<48> */
    u32 ingress_port; /* PortId_t */
};

The p4tc control path expects the digest message to be packed
For example, in testdata/p4tc_samples/digest.p4 we have the following
struct being sent throught digest pack:

struct mac_learn_digest_t {
    @tc_type("macaddr") bit<48> srcAddr;
    @tc_type("dev") PortId_t ingress_port;
};

As an eBPF C struct, this will be:

struct mac_learn_digest_t {
    u8 srcAddr[6]; /* bit<48> */
    u32 ingress_port; /* PortId_t */
};

Notice that this will create padding between srcAddr
and ingress_port. To avoid this we are making structs associated with
digest messages packed. So the previous struct will become:

struct __attribute__((__packed__)) mac_learn_digest_t {
    u8 srcAddr[6]; /* bit<48> */
    u32 ingress_port; /* PortId_t */
};

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
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 cl 3698 ose these issues.

1 participant
0