~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/lib/bpf/libbpf_legacy.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/lib/bpf/libbpf_legacy.h (Architecture alpha) and /tools/lib/bpf/libbpf_legacy.h (Architecture sparc64)


  1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2      1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
  2                                                     2 
  3 /*                                                  3 /*
  4  * Libbpf legacy APIs (either discouraged or d      4  * Libbpf legacy APIs (either discouraged or deprecated, as mentioned in [0])
  5  *                                                  5  *
  6  *   [0] https://docs.google.com/document/d/1U      6  *   [0] https://docs.google.com/document/d/1UyjTZuPFWiPFyKk1tV5an11_iaRuec6U-ZESZ54nNTY
  7  *                                                  7  *
  8  * Copyright (C) 2021 Facebook                      8  * Copyright (C) 2021 Facebook
  9  */                                                 9  */
 10 #ifndef __LIBBPF_LEGACY_BPF_H                      10 #ifndef __LIBBPF_LEGACY_BPF_H
 11 #define __LIBBPF_LEGACY_BPF_H                      11 #define __LIBBPF_LEGACY_BPF_H
 12                                                    12 
 13 #include <linux/bpf.h>                             13 #include <linux/bpf.h>
 14 #include <stdbool.h>                               14 #include <stdbool.h>
 15 #include <stddef.h>                                15 #include <stddef.h>
 16 #include <stdint.h>                                16 #include <stdint.h>
 17 #include "libbpf_common.h"                         17 #include "libbpf_common.h"
 18                                                    18 
 19 #ifdef __cplusplus                                 19 #ifdef __cplusplus
 20 extern "C" {                                       20 extern "C" {
 21 #endif                                             21 #endif
 22                                                    22 
 23 /* As of libbpf 1.0 libbpf_set_strict_mode() a     23 /* As of libbpf 1.0 libbpf_set_strict_mode() and enum libbpf_struct_mode have
 24  * no effect. But they are left in libbpf_lega     24  * no effect. But they are left in libbpf_legacy.h so that applications that
 25  * prepared for libbpf 1.0 before final releas     25  * prepared for libbpf 1.0 before final release by using
 26  * libbpf_set_strict_mode() still work with li     26  * libbpf_set_strict_mode() still work with libbpf 1.0+ without any changes.
 27  */                                                27  */
 28 enum libbpf_strict_mode {                          28 enum libbpf_strict_mode {
 29         /* Turn on all supported strict featur     29         /* Turn on all supported strict features of libbpf to simulate libbpf
 30          * v1.0 behavior.                          30          * v1.0 behavior.
 31          * This will be the default behavior i     31          * This will be the default behavior in libbpf v1.0.
 32          */                                        32          */
 33         LIBBPF_STRICT_ALL = 0xffffffff,            33         LIBBPF_STRICT_ALL = 0xffffffff,
 34                                                    34 
 35         /*                                         35         /*
 36          * Disable any libbpf 1.0 behaviors. T     36          * Disable any libbpf 1.0 behaviors. This is the default before libbpf
 37          * v1.0. It won't be supported anymore     37          * v1.0. It won't be supported anymore in v1.0, please update your
 38          * code so that it handles LIBBPF_STRI     38          * code so that it handles LIBBPF_STRICT_ALL mode before libbpf v1.0.
 39          */                                        39          */
 40         LIBBPF_STRICT_NONE = 0x00,                 40         LIBBPF_STRICT_NONE = 0x00,
 41         /*                                         41         /*
 42          * Return NULL pointers on error, not      42          * Return NULL pointers on error, not ERR_PTR(err).
 43          * Additionally, libbpf also always se     43          * Additionally, libbpf also always sets errno to corresponding Exx
 44          * (positive) error code.                  44          * (positive) error code.
 45          */                                        45          */
 46         LIBBPF_STRICT_CLEAN_PTRS = 0x01,           46         LIBBPF_STRICT_CLEAN_PTRS = 0x01,
 47         /*                                         47         /*
 48          * Return actual error codes from low-     48          * Return actual error codes from low-level APIs directly, not just -1.
 49          * Additionally, libbpf also always se     49          * Additionally, libbpf also always sets errno to corresponding Exx
 50          * (positive) error code.                  50          * (positive) error code.
 51          */                                        51          */
 52         LIBBPF_STRICT_DIRECT_ERRS = 0x02,          52         LIBBPF_STRICT_DIRECT_ERRS = 0x02,
 53         /*                                         53         /*
 54          * Enforce strict BPF program section      54          * Enforce strict BPF program section (SEC()) names.
 55          * E.g., while prefiously SEC("xdp_wha     55          * E.g., while prefiously SEC("xdp_whatever") or SEC("perf_event_blah") were
 56          * allowed, with LIBBPF_STRICT_SEC_PRE     56          * allowed, with LIBBPF_STRICT_SEC_PREFIX this will become
 57          * unrecognized by libbpf and would ha     57          * unrecognized by libbpf and would have to be just SEC("xdp") and
 58          * SEC("xdp") and SEC("perf_event").       58          * SEC("xdp") and SEC("perf_event").
 59          *                                         59          *
 60          * Note, in this mode the program pin      60          * Note, in this mode the program pin path will be based on the
 61          * function name instead of section na     61          * function name instead of section name.
 62          *                                         62          *
 63          * Additionally, routines in the .text     63          * Additionally, routines in the .text section are always considered
 64          * sub-programs. Legacy behavior allow     64          * sub-programs. Legacy behavior allows for a single routine in .text
 65          * to be a program.                        65          * to be a program.
 66          */                                        66          */
 67         LIBBPF_STRICT_SEC_NAME = 0x04,             67         LIBBPF_STRICT_SEC_NAME = 0x04,
 68         /*                                         68         /*
 69          * Disable the global 'bpf_objects_lis     69          * Disable the global 'bpf_objects_list'. Maintaining this list adds
 70          * a race condition to bpf_object__ope     70          * a race condition to bpf_object__open() and bpf_object__close().
 71          * Clients can maintain it on their ow     71          * Clients can maintain it on their own if it is valuable for them.
 72          */                                        72          */
 73         LIBBPF_STRICT_NO_OBJECT_LIST = 0x08,       73         LIBBPF_STRICT_NO_OBJECT_LIST = 0x08,
 74         /*                                         74         /*
 75          * Automatically bump RLIMIT_MEMLOCK u     75          * Automatically bump RLIMIT_MEMLOCK using setrlimit() before the
 76          * first BPF program or map creation o     76          * first BPF program or map creation operation. This is done only if
 77          * kernel is too old to support memcg-     77          * kernel is too old to support memcg-based memory accounting for BPF
 78          * subsystem. By default, RLIMIT_MEMLO     78          * subsystem. By default, RLIMIT_MEMLOCK limit is set to RLIM_INFINITY,
 79          * but it can be overridden with libbp     79          * but it can be overridden with libbpf_set_memlock_rlim() API.
 80          * Note that libbpf_set_memlock_rlim()     80          * Note that libbpf_set_memlock_rlim() needs to be called before
 81          * the very first bpf_prog_load(), bpf     81          * the very first bpf_prog_load(), bpf_map_create() or bpf_object__load()
 82          * operation.                              82          * operation.
 83          */                                        83          */
 84         LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK = 0x     84         LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK = 0x10,
 85         /*                                         85         /*
 86          * Error out on any SEC("maps") map de     86          * Error out on any SEC("maps") map definition, which are deprecated
 87          * in favor of BTF-defined map definit     87          * in favor of BTF-defined map definitions in SEC(".maps").
 88          */                                        88          */
 89         LIBBPF_STRICT_MAP_DEFINITIONS = 0x20,      89         LIBBPF_STRICT_MAP_DEFINITIONS = 0x20,
 90                                                    90 
 91         __LIBBPF_STRICT_LAST,                      91         __LIBBPF_STRICT_LAST,
 92 };                                                 92 };
 93                                                    93 
 94 LIBBPF_API int libbpf_set_strict_mode(enum lib     94 LIBBPF_API int libbpf_set_strict_mode(enum libbpf_strict_mode mode);
 95                                                    95 
 96 /**                                                96 /**
 97  * @brief **libbpf_get_error()** extracts the      97  * @brief **libbpf_get_error()** extracts the error code from the passed
 98  * pointer                                         98  * pointer
 99  * @param ptr pointer returned from libbpf API     99  * @param ptr pointer returned from libbpf API function
100  * @return error code; or 0 if no error occurr    100  * @return error code; or 0 if no error occurred
101  *                                                101  *
102  * Note, as of libbpf 1.0 this function is not    102  * Note, as of libbpf 1.0 this function is not necessary and not recommended
103  * to be used. Libbpf doesn't return error cod    103  * to be used. Libbpf doesn't return error code embedded into the pointer
104  * itself. Instead, NULL is returned on error     104  * itself. Instead, NULL is returned on error and error code is passed through
105  * thread-local errno variable. **libbpf_get_e    105  * thread-local errno variable. **libbpf_get_error()** is just returning -errno
106  * value if it receives NULL, which is correct    106  * value if it receives NULL, which is correct only if errno hasn't been
107  * modified between libbpf API call and corres    107  * modified between libbpf API call and corresponding **libbpf_get_error()**
108  * call. Prefer to check return for NULL and u    108  * call. Prefer to check return for NULL and use errno directly.
109  *                                                109  *
110  * This API is left in libbpf 1.0 to allow app    110  * This API is left in libbpf 1.0 to allow applications that were 1.0-ready
111  * before final libbpf 1.0 without needing to     111  * before final libbpf 1.0 without needing to change them.
112  */                                               112  */
113 LIBBPF_API long libbpf_get_error(const void *p    113 LIBBPF_API long libbpf_get_error(const void *ptr);
114                                                   114 
115 #define DECLARE_LIBBPF_OPTS LIBBPF_OPTS           115 #define DECLARE_LIBBPF_OPTS LIBBPF_OPTS
116                                                   116 
117 /* "Discouraged" APIs which don't follow consi    117 /* "Discouraged" APIs which don't follow consistent libbpf naming patterns.
118  * They are normally a trivial aliases or wrap    118  * They are normally a trivial aliases or wrappers for proper APIs and are
119  * left to minimize unnecessary disruption for    119  * left to minimize unnecessary disruption for users of libbpf. But they
120  * shouldn't be used going forward.               120  * shouldn't be used going forward.
121  */                                               121  */
122                                                   122 
123 struct bpf_program;                               123 struct bpf_program;
124 struct bpf_map;                                   124 struct bpf_map;
125 struct btf;                                       125 struct btf;
126 struct btf_ext;                                   126 struct btf_ext;
127                                                   127 
128 LIBBPF_API struct btf *libbpf_find_kernel_btf(    128 LIBBPF_API struct btf *libbpf_find_kernel_btf(void);
129                                                   129 
130 LIBBPF_API enum bpf_prog_type bpf_program__get    130 LIBBPF_API enum bpf_prog_type bpf_program__get_type(const struct bpf_program *prog);
131 LIBBPF_API enum bpf_attach_type bpf_program__g    131 LIBBPF_API enum bpf_attach_type bpf_program__get_expected_attach_type(const struct bpf_program *prog);
132 LIBBPF_API const char *bpf_map__get_pin_path(c    132 LIBBPF_API const char *bpf_map__get_pin_path(const struct bpf_map *map);
133 LIBBPF_API const void *btf__get_raw_data(const    133 LIBBPF_API const void *btf__get_raw_data(const struct btf *btf, __u32 *size);
134 LIBBPF_API const void *btf_ext__get_raw_data(c    134 LIBBPF_API const void *btf_ext__get_raw_data(const struct btf_ext *btf_ext, __u32 *size);
135                                                   135 
136 #ifdef __cplusplus                                136 #ifdef __cplusplus
137 } /* extern "C" */                                137 } /* extern "C" */
138 #endif                                            138 #endif
139                                                   139 
140 #endif /* __LIBBPF_LEGACY_BPF_H */                140 #endif /* __LIBBPF_LEGACY_BPF_H */
141                                                   141 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php