mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
Reading a context field narrower than a register was hardcoded to struct_xdp_md's i32 fields in three places that had to agree with each other: the destination alloca in allocation_pass, the zext in load_ctx_field, and the store in assign_pass. struct pt_regs' cs and ss are 2 bytes, so a second special case would have been needed. Replace all three with the general rule: a context field is loaded at its natural width and zero-extended to i64, so its destination is i64. allocation_pass gains the same context discriminator load_ctx_field uses (a context argument has no alloca of its own), so non-context field reads, which go through load_struct_field and bpf_probe_read_kernel, keep their natural width and are untouched. struct_xdp_md's generated IR is byte-identical, as is every other vmlinux/xdp test program's; the only diff in the whole corpus remains the four new globals from the previous commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>