Add coverage to the verifier tests and tests for reading bpf_sock fields to ensure that 32-bit, 16-bit, and 8-bit loads from dst_port field are allowed only at intended offsets and produce expected values. While 16-bit and 8-bit access to dst_port field is straight-forward, 32-bit wide loads need be allowed and produce a zero-padded 16-bit value for backward compatibility.
Showing the changes to tools/include/uapi (1 of 4 files). Show all
Unified · Split
| @@ -5574,7 +5574,8 @@ struct bpf_sock { · 5573 unmodified lines | ||
| 5574 | 5574 | __u32 src_ip4; |
| 5575 | 5575 | __u32 src_ip6[4]; |
| 5576 | 5576 | __u32 src_port; /* host byte order */ |
| 5577 | − __u32 dst_port; /* network byte order */ | |
| 5577 | + __be16 dst_port; /* network byte order */ | |
| 5578 | + __u16 :16; /* zero padding */ | |
| 5578 | 5579 | __u32 dst_ip4; |
| 5579 | 5580 | __u32 dst_ip6[4]; |
| 5580 | 5581 | __u32 state; |