@@ -52,8 +52,8 @@ enum libbpf_errno {
52
52
int libbpf_strerror (int err , char * buf , size_t size );
53
53
54
54
/*
55
- * In include/linux/compiler-gcc.h, __printf is defined . However
56
- * it should be better if libbpf.h doesn 't depend on Linux header file .
55
+ * __printf is defined in include/linux/compiler-gcc.h. However,
56
+ * it would be better if libbpf.h didn 't depend on Linux header files .
57
57
* So instead of __printf, here we use gcc attribute directly.
58
58
*/
59
59
typedef int (* libbpf_print_fn_t )(const char * , ...)
@@ -92,7 +92,7 @@ int bpf_object__set_priv(struct bpf_object *obj, void *priv,
92
92
bpf_object_clear_priv_t clear_priv );
93
93
void * bpf_object__priv (struct bpf_object * prog );
94
94
95
- /* Accessors of bpf_program. */
95
+ /* Accessors of bpf_program */
96
96
struct bpf_program ;
97
97
struct bpf_program * bpf_program__next (struct bpf_program * prog ,
98
98
struct bpf_object * obj );
@@ -121,28 +121,28 @@ struct bpf_insn;
121
121
122
122
/*
123
123
* Libbpf allows callers to adjust BPF programs before being loaded
124
- * into kernel. One program in an object file can be transform into
125
- * multiple variants to be attached to different code .
124
+ * into kernel. One program in an object file can be transformed into
125
+ * multiple variants to be attached to different hooks .
126
126
*
127
127
* bpf_program_prep_t, bpf_program__set_prep and bpf_program__nth_fd
128
- * are APIs for this propose .
128
+ * form an API for this purpose .
129
129
*
130
130
* - bpf_program_prep_t:
131
- * It defines 'preprocessor', which is a caller defined function
131
+ * Defines a 'preprocessor', which is a caller defined function
132
132
* passed to libbpf through bpf_program__set_prep(), and will be
133
133
* called before program is loaded. The processor should adjust
134
- * the program one time for each instances according to the number
134
+ * the program one time for each instance according to the instance id
135
135
* passed to it.
136
136
*
137
137
* - bpf_program__set_prep:
138
- * Attachs a preprocessor to a BPF program. The number of instances
139
- * whould be created is also passed through this function.
138
+ * Attaches a preprocessor to a BPF program. The number of instances
139
+ * that should be created is also passed through this function.
140
140
*
141
141
* - bpf_program__nth_fd:
142
- * After the program is loaded, get resuling fds from bpf program for
143
- * each instances .
142
+ * After the program is loaded, get resulting FD of a given instance
143
+ * of the BPF program .
144
144
*
145
- * If bpf_program__set_prep() is not used, the program whould be loaded
145
+ * If bpf_program__set_prep() is not used, the program would be loaded
146
146
* without adjustment during bpf_object__load(). The program has only
147
147
* one instance. In this case bpf_program__fd(prog) is equal to
148
148
* bpf_program__nth_fd(prog, 0).
@@ -156,7 +156,7 @@ struct bpf_prog_prep_result {
156
156
struct bpf_insn * new_insn_ptr ;
157
157
int new_insn_cnt ;
158
158
159
- /* If not NULL, result fd is set to it */
159
+ /* If not NULL, result FD is written to it. */
160
160
int * pfd ;
161
161
};
162
162
@@ -169,8 +169,8 @@ struct bpf_prog_prep_result {
169
169
* - res: Output parameter, result of transformation.
170
170
*
171
171
* Return value:
172
- * - Zero: pre-processing success.
173
- * - Non-zero: pre-processing, stop loading.
172
+ * - Zero: pre-processing success.
173
+ * - Non-zero: pre-processing error , stop loading.
174
174
*/
175
175
typedef int (* bpf_program_prep_t )(struct bpf_program * prog , int n ,
176
176
struct bpf_insn * insns , int insns_cnt ,
@@ -182,7 +182,7 @@ int bpf_program__set_prep(struct bpf_program *prog, int nr_instance,
182
182
int bpf_program__nth_fd (struct bpf_program * prog , int n );
183
183
184
184
/*
185
- * Adjust type of bpf program. Default is kprobe.
185
+ * Adjust type of BPF program. Default is kprobe.
186
186
*/
187
187
int bpf_program__set_socket_filter (struct bpf_program * prog );
188
188
int bpf_program__set_tracepoint (struct bpf_program * prog );
@@ -206,10 +206,10 @@ bool bpf_program__is_xdp(struct bpf_program *prog);
206
206
bool bpf_program__is_perf_event (struct bpf_program * prog );
207
207
208
208
/*
209
- * We don't need __attribute__((packed)) now since it is
210
- * unnecessary for 'bpf_map_def' because they are all aligned.
211
- * In addition, using it will trigger -Wpacked warning message,
212
- * and will be treated as an error due to -Werror.
209
+ * No need for __attribute__((packed)), all members of 'bpf_map_def'
210
+ * are all aligned. In addition, using __attribute__((packed))
211
+ * would trigger a -Wpacked warning message, and lead to an error
212
+ * if -Werror is set .
213
213
*/
214
214
struct bpf_map_def {
215
215
unsigned int type ;
@@ -220,16 +220,16 @@ struct bpf_map_def {
220
220
};
221
221
222
222
/*
223
- * There is another 'struct bpf_map' in include/linux/map.h. However ,
224
- * it is not a uapi header so no need to consider name clash.
223
+ * The 'struct bpf_map' in include/linux/bpf.h is internal to the kernel ,
224
+ * so no need to worry about a name clash.
225
225
*/
226
226
struct bpf_map ;
227
227
struct bpf_map *
228
228
bpf_object__find_map_by_name (struct bpf_object * obj , const char * name );
229
229
230
230
/*
231
231
* Get bpf_map through the offset of corresponding struct bpf_map_def
232
- * in the bpf object file.
232
+ * in the BPF object file.
233
233
*/
234
234
struct bpf_map *
235
235
bpf_object__find_map_by_offset (struct bpf_object * obj , size_t offset );
0 commit comments