Skip to content

Commit 8fb575c

Browse files
Alexei Starovoitovdavem330
authored andcommitted
net: filter: rename sk_convert_filter() -> bpf_convert_filter()
to indicate that this function is converting classic BPF into eBPF and not related to sockets Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4df95ff commit 8fb575c

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎arch/x86/net/bpf_jit_comp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int do_jit(struct sk_filter *bpf_prog, int *addrs, u8 *image,
235235
/* mov qword ptr [rbp-X],rbx */
236236
EMIT3_off32(0x48, 0x89, 0x9D, -stacksize);
237237

238-
/* sk_convert_filter() maps classic BPF register X to R7 and uses R8
238+
/* bpf_convert_filter() maps classic BPF register X to R7 and uses R8
239239
* as temporary, so all tcpdump filters need to spill/fill R7(r13) and
240240
* R8(r14). R9(r15) spill could be made conditional, but there is only
241241
* one 'bpf_error' return path out of helper functions inside bpf_jit.S

‎include/linux/filter.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ int sk_filter(struct sock *sk, struct sk_buff *skb);
351351
void sk_filter_select_runtime(struct sk_filter *fp);
352352
void sk_filter_free(struct sk_filter *fp);
353353

354-
int sk_convert_filter(struct sock_filter *prog, int len,
355-
struct bpf_insn *new_prog, int *new_len);
354+
int bpf_convert_filter(struct sock_filter *prog, int len,
355+
struct bpf_insn *new_prog, int *new_len);
356356

357357
int sk_unattached_filter_create(struct sk_filter **pfp,
358358
struct sock_fprog_kern *fprog);

‎kernel/bpf/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ static unsigned int __sk_run_filter(void *ctx, const struct bpf_insn *insn)
446446
/* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are
447447
* only appearing in the programs where ctx ==
448448
* skb. All programs keep 'ctx' in regs[BPF_REG_CTX]
449-
* == BPF_R6, sk_convert_filter() saves it in BPF_R6,
449+
* == BPF_R6, bpf_convert_filter() saves it in BPF_R6,
450450
* internal BPF verifier will check that BPF_R6 ==
451451
* ctx.
452452
*

‎kernel/seccomp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static long seccomp_attach_filter(struct sock_fprog *fprog)
249249
goto free_prog;
250250

251251
/* Convert 'sock_filter' insns to 'bpf_insn' insns */
252-
ret = sk_convert_filter(fp, fprog->len, NULL, &new_len);
252+
ret = bpf_convert_filter(fp, fprog->len, NULL, &new_len);
253253
if (ret)
254254
goto free_prog;
255255

@@ -265,7 +265,7 @@ static long seccomp_attach_filter(struct sock_fprog *fprog)
265265
if (!filter->prog)
266266
goto free_filter;
267267

268-
ret = sk_convert_filter(fp, fprog->len, filter->prog->insnsi, &new_len);
268+
ret = bpf_convert_filter(fp, fprog->len, filter->prog->insnsi, &new_len);
269269
if (ret)
270270
goto free_filter_prog;
271271
kfree(fp);

‎net/core/filter.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static bool convert_bpf_extensions(struct sock_filter *fp,
312312
}
313313

314314
/**
315-
* sk_convert_filter - convert filter program
315+
* bpf_convert_filter - convert filter program
316316
* @prog: the user passed filter program
317317
* @len: the length of the user passed filter program
318318
* @new_prog: buffer where converted program will be stored
@@ -322,21 +322,21 @@ static bool convert_bpf_extensions(struct sock_filter *fp,
322322
* Conversion workflow:
323323
*
324324
* 1) First pass for calculating the new program length:
325-
* sk_convert_filter(old_prog, old_len, NULL, &new_len)
325+
* bpf_convert_filter(old_prog, old_len, NULL, &new_len)
326326
*
327327
* 2) 2nd pass to remap in two passes: 1st pass finds new
328328
* jump offsets, 2nd pass remapping:
329329
* new_prog = kmalloc(sizeof(struct bpf_insn) * new_len);
330-
* sk_convert_filter(old_prog, old_len, new_prog, &new_len);
330+
* bpf_convert_filter(old_prog, old_len, new_prog, &new_len);
331331
*
332332
* User BPF's register A is mapped to our BPF register 6, user BPF
333333
* register X is mapped to BPF register 7; frame pointer is always
334334
* register 10; Context 'void *ctx' is stored in register 1, that is,
335335
* for socket filters: ctx == 'struct sk_buff *', for seccomp:
336336
* ctx == 'struct seccomp_data *'.
337337
*/
338-
int sk_convert_filter(struct sock_filter *prog, int len,
339-
struct bpf_insn *new_prog, int *new_len)
338+
int bpf_convert_filter(struct sock_filter *prog, int len,
339+
struct bpf_insn *new_prog, int *new_len)
340340
{
341341
int new_flen = 0, pass = 0, target, i;
342342
struct bpf_insn *new_insn;
@@ -921,7 +921,7 @@ static struct sk_filter *__sk_migrate_filter(struct sk_filter *fp)
921921
}
922922

923923
/* 1st pass: calculate the new program length. */
924-
err = sk_convert_filter(old_prog, old_len, NULL, &new_len);
924+
err = bpf_convert_filter(old_prog, old_len, NULL, &new_len);
925925
if (err)
926926
goto out_err_free;
927927

@@ -940,9 +940,9 @@ static struct sk_filter *__sk_migrate_filter(struct sk_filter *fp)
940940
fp->len = new_len;
941941

942942
/* 2nd pass: remap sock_filter insns into bpf_insn insns. */
943-
err = sk_convert_filter(old_prog, old_len, fp->insnsi, &new_len);
943+
err = bpf_convert_filter(old_prog, old_len, fp->insnsi, &new_len);
944944
if (err)
945-
/* 2nd sk_convert_filter() can fail only if it fails
945+
/* 2nd bpf_convert_filter() can fail only if it fails
946946
* to allocate memory, remapping must succeed. Note,
947947
* that at this time old_fp has already been released
948948
* by krealloc().

0 commit comments

Comments
 (0)