In the initial sockmap API we provided strparser and verdict programs using a single attach command by extending the attach API with a the attach_bpf_fd2 field. However, if we add other programs in the future we will be adding a field for every new possible type, attach_bpf_fd(3,4,..). This seems a bit clumsy for an API. So lets push the programs using two new type fields. BPF_SK_SKB_STREAM_PARSER BPF_SK_SKB_STREAM_VERDICT This has the advantage of having a readable name and can easily be extended in the future. Updates to samples and sockmap included here also generalize tests slightly to support upcoming patch for multiple map support.
Showing the changes to include/uapi/linux (1 of 13 files). Show all
Unified · Split
| @@ -136,7 +136,8 @@ enum bpf_attach_type { · 135 unmodified lines | |||
| 136 | BPF_CGROUP_INET_EGRESS, | 136 | BPF_CGROUP_INET_EGRESS, |
| 137 | BPF_CGROUP_INET_SOCK_CREATE, | 137 | BPF_CGROUP_INET_SOCK_CREATE, |
| 138 | BPF_CGROUP_SOCK_OPS, | 138 | BPF_CGROUP_SOCK_OPS, |
| 139 | BPF_CGROUP_SMAP_INGRESS, | 139 | BPF_SK_SKB_STREAM_PARSER, |
| 140 | BPF_SK_SKB_STREAM_VERDICT, | ||
| 140 | __MAX_BPF_ATTACH_TYPE | 141 | __MAX_BPF_ATTACH_TYPE |
| 141 | }; | 142 | }; |
| 142 | 143 | ||
| @@ -224,7 +225,6 @@ union bpf_attr { · 81 unmodified lines | |||
| 224 | __u32 attach_bpf_fd; /* eBPF program to attach */ | 225 | __u32 attach_bpf_fd; /* eBPF program to attach */ |
| 225 | __u32 attach_type; | 226 | __u32 attach_type; |
| 226 | __u32 attach_flags; | 227 | __u32 attach_flags; |
| 227 | __u32 attach_bpf_fd2; | ||
| 228 | }; | 228 | }; |
| 229 | 229 | ||
| 230 | struct { /* anonymous struct used by BPF_PROG_TEST_RUN command */ | 230 | struct { /* anonymous struct used by BPF_PROG_TEST_RUN command */ |
| @@ -580,14 +580,11 @@ union bpf_attr { · 349 unmodified lines | |||
| 580 | * @flags: reserved for future use | 580 | * @flags: reserved for future use |
| 581 | * Return: SK_REDIRECT | 581 | * Return: SK_REDIRECT |
| 582 | * | 582 | * |
| 583 | * int bpf_sock_map_update(skops, map, key, flags, map_flags) | 583 | * int bpf_sock_map_update(skops, map, key, flags) |
| 584 | * @skops: pointer to bpf_sock_ops | 584 | * @skops: pointer to bpf_sock_ops |
| 585 | * @map: pointer to sockmap to update | 585 | * @map: pointer to sockmap to update |
| 586 | * @key: key to insert/update sock in map | 586 | * @key: key to insert/update sock in map |
| 587 | * @flags: same flags as map update elem | 587 | * @flags: same flags as map update elem |
| 588 | * @map_flags: sock map specific flags | ||
| 589 | * bit 1: Enable strparser | ||
| 590 | * other bits: reserved | ||
| 591 | */ | 588 | */ |
| 592 | #define __BPF_FUNC_MAPPER(FN) \ | 589 | #define __BPF_FUNC_MAPPER(FN) \ |
| 593 | FN(unspec), \ | 590 | FN(unspec), \ |