Skip to content

Support for libbpf_probe_bpf_prog_type / libbpf_probe_bpf_map_type / libbpf_probe_bpf_helper #2745

Open
@saxena-anurag

Description

@saxena-anurag

Describe the feature you'd like supported

This issue is track adding support for the following libbpf functions:

  • libbpf_probe_bpf_helper
  • libbpf_probe_bpf_prog_type
  • libbpf_probe_bpf_map_type

These helper functions will be useful for any user mode application to determine which program types, maps and helper functions are supported by a specific version of eBPF running on a system.


/**
* @brief **libbpf_probe_bpf_prog_type()** detects if host kernel supports
* BPF programs of a given type.
* @param prog_type BPF program type to detect kernel support for
* @param opts reserved for future extensibility, should be NULL
* @return 1, if given program type is supported; 0, if given program type is
* not supported; negative error code if feature detection failed or can't be
* performed
*
* Make sure the process has required set of CAP_* permissions (or runs as
* root) when performing feature checking.
*/
LIBBPF_API int libbpf_probe_bpf_prog_type(enum bpf_prog_type prog_type, const void *opts);
/**
* @brief **libbpf_probe_bpf_map_type()** detects if host kernel supports
* BPF maps of a given type.
* @param map_type BPF map type to detect kernel support for
* @param opts reserved for future extensibility, should be NULL
* @return 1, if given map type is supported; 0, if given map type is
* not supported; negative error code if feature detection failed or can't be
* performed
*
* Make sure the process has required set of CAP_* permissions (or runs as
* root) when performing feature checking.
*/
LIBBPF_API int libbpf_probe_bpf_map_type(enum bpf_map_type map_type, const void *opts);
/**
* @brief **libbpf_probe_bpf_helper()** detects if host kernel supports the
* use of a given BPF helper from specified BPF program type.
* @param prog_type BPF program type used to check the support of BPF helper
* @param helper_id BPF helper ID (enum bpf_func_id) to check support for
* @param opts reserved for future extensibility, should be NULL
* @return 1, if given combination of program type and helper is supported; 0,
* if the combination is not supported; negative error code if feature
* detection for provided input arguments failed or can't be performed
*
* Make sure the process has required set of CAP_* permissions (or runs as
* root) when performing feature checking.
*/
LIBBPF_API int libbpf_probe_bpf_helper(enum bpf_prog_type prog_type,
				       enum bpf_func_id helper_id, const void *opts);

Proposed solution

Implement these libbpf APIs

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededtriagedDiscussed in a triage meeting

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions