This patch adds "state", "dst_ip4", "dst_ip6" and "dst_port" to the bpf_sock. The userspace has already been using "state", e.g. inet_diag (ss -t) and getsockopt(TCP_INFO). This patch also allows narrow load on the following existing fields: "family", "type", "protocol" and "src_port". Unlike IP address, the load offset is resticted to the first byte for them but it can be relaxed later if there is a use case. This patch also folds __sock_filter_check_size() into bpf_sock_is_valid_access() since it is not called by any where else. All bpf_sock checking is in one place.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -2606,15 +2606,14 @@ struct bpf_sock { · 2605 unmodified lines | |||
| 2606 | __u32 protocol; | 2606 | __u32 protocol; |
| 2607 | __u32 mark; | 2607 | __u32 mark; |
| 2608 | __u32 priority; | 2608 | __u32 priority; |
| 2609 | __u32 src_ip4; /* Allows 1,2,4-byte read. | 2609 | /* IP address also allows 1 and 2 bytes access */ |
| 2610 | * Stored in network byte order. | 2610 | __u32 src_ip4; |
| 2611 | */ | 2611 | __u32 src_ip6[4]; |
| 2612 | __u32 src_ip6[4]; /* Allows 1,2,4-byte read. | 2612 | __u32 src_port; /* host byte order */ |
| 2613 | * Stored in network byte order. | 2613 | __u32 dst_port; /* network byte order */ |
| 2614 | */ | 2614 | __u32 dst_ip4; |
| 2615 | __u32 src_port; /* Allows 4-byte read. | 2615 | __u32 dst_ip6[4]; |
| 2616 | * Stored in host byte order | 2616 | __u32 state; |
| 2617 | */ | ||
| 2618 | }; | 2617 | }; |
| 2619 | 2618 | ||
| 2620 | struct bpf_sock_tuple { | 2619 | struct bpf_sock_tuple { |