Commit 468e2f64d220 ("bpf: introduce BPF_PROG_QUERY command") originally introduced this, but there have been several additions since then. Unlike BPF_PROG_ATTACH, it appears that the sockmap progs are not able to be queried so far.
Showing the changes to include/uapi (1 of 1 file). Show all
Unified · Split
| @@ -389,6 +389,43 @@ union bpf_iter_link_info { · 388 unmodified lines | |||
| 389 | * Obtain information about eBPF programs associated with the | 389 | * Obtain information about eBPF programs associated with the |
| 390 | * specified *attach_type* hook. | 390 | * specified *attach_type* hook. |
| 391 | * | 391 | * |
| 392 | * The *target_fd* must be a valid file descriptor for a kernel | ||
| 393 | * object which depends on the attach type of *attach_bpf_fd*: | ||
| 394 | * | ||
| 395 | * **BPF_PROG_TYPE_CGROUP_DEVICE**, | ||
| 396 | * **BPF_PROG_TYPE_CGROUP_SKB**, | ||
| 397 | * **BPF_PROG_TYPE_CGROUP_SOCK**, | ||
| 398 | * **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**, | ||
| 399 | * **BPF_PROG_TYPE_CGROUP_SOCKOPT**, | ||
| 400 | * **BPF_PROG_TYPE_CGROUP_SYSCTL**, | ||
| 401 | * **BPF_PROG_TYPE_SOCK_OPS** | ||
| 402 | * | ||
| 403 | * Control Group v2 hierarchy with the eBPF controller | ||
| 404 | * enabled. Requires the kernel to be compiled with | ||
| 405 | * **CONFIG_CGROUP_BPF**. | ||
| 406 | * | ||
| 407 | * **BPF_PROG_TYPE_FLOW_DISSECTOR** | ||
| 408 | * | ||
| 409 | * Network namespace (eg /proc/self/ns/net). | ||
| 410 | * | ||
| 411 | * **BPF_PROG_TYPE_LIRC_MODE2** | ||
| 412 | * | ||
| 413 | * LIRC device path (eg /dev/lircN). Requires the kernel | ||
| 414 | * to be compiled with **CONFIG_BPF_LIRC_MODE2**. | ||
| 415 | * | ||
| 416 | * **BPF_PROG_QUERY** always fetches the number of programs | ||
| 417 | * attached and the *attach_flags* which were used to attach those | ||
| 418 | * programs. Additionally, if *prog_ids* is nonzero and the number | ||
| 419 | * of attached programs is less than *prog_cnt*, populates | ||
| 420 | * *prog_ids* with the eBPF program ids of the programs attached | ||
| 421 | * at *target_fd*. | ||
| 422 | * | ||
| 423 | * The following flags may alter the result: | ||
| 424 | * | ||
| 425 | * **BPF_F_QUERY_EFFECTIVE** | ||
| 426 | * Only return information regarding programs which are | ||
| 427 | * currently effective at the specified *target_fd*. | ||
| 428 | * | ||
| 392 | * Return | 429 | * Return |
| 393 | * Returns zero on success. On error, -1 is returned and *errno* | 430 | * Returns zero on success. On error, -1 is returned and *errno* |
| 394 | * is set appropriately. | 431 | * is set appropriately. |