mirror of
https://github.com/torvalds/linux.git
synced 2025-01-01 15:51:46 +00:00
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>
This commit is contained in:
parent
4df95ff488
commit
8fb575ca39
@ -235,7 +235,7 @@ static int do_jit(struct sk_filter *bpf_prog, int *addrs, u8 *image,
|
|||||||
/* mov qword ptr [rbp-X],rbx */
|
/* mov qword ptr [rbp-X],rbx */
|
||||||
EMIT3_off32(0x48, 0x89, 0x9D, -stacksize);
|
EMIT3_off32(0x48, 0x89, 0x9D, -stacksize);
|
||||||
|
|
||||||
/* sk_convert_filter() maps classic BPF register X to R7 and uses R8
|
/* bpf_convert_filter() maps classic BPF register X to R7 and uses R8
|
||||||
* as temporary, so all tcpdump filters need to spill/fill R7(r13) and
|
* as temporary, so all tcpdump filters need to spill/fill R7(r13) and
|
||||||
* R8(r14). R9(r15) spill could be made conditional, but there is only
|
* R8(r14). R9(r15) spill could be made conditional, but there is only
|
||||||
* one 'bpf_error' return path out of helper functions inside bpf_jit.S
|
* one 'bpf_error' return path out of helper functions inside bpf_jit.S
|
||||||
|
@ -351,8 +351,8 @@ int sk_filter(struct sock *sk, struct sk_buff *skb);
|
|||||||
void sk_filter_select_runtime(struct sk_filter *fp);
|
void sk_filter_select_runtime(struct sk_filter *fp);
|
||||||
void sk_filter_free(struct sk_filter *fp);
|
void sk_filter_free(struct sk_filter *fp);
|
||||||
|
|
||||||
int sk_convert_filter(struct sock_filter *prog, int len,
|
int bpf_convert_filter(struct sock_filter *prog, int len,
|
||||||
struct bpf_insn *new_prog, int *new_len);
|
struct bpf_insn *new_prog, int *new_len);
|
||||||
|
|
||||||
int sk_unattached_filter_create(struct sk_filter **pfp,
|
int sk_unattached_filter_create(struct sk_filter **pfp,
|
||||||
struct sock_fprog_kern *fprog);
|
struct sock_fprog_kern *fprog);
|
||||||
|
@ -446,7 +446,7 @@ load_word:
|
|||||||
/* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are
|
/* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are
|
||||||
* only appearing in the programs where ctx ==
|
* only appearing in the programs where ctx ==
|
||||||
* skb. All programs keep 'ctx' in regs[BPF_REG_CTX]
|
* skb. All programs keep 'ctx' in regs[BPF_REG_CTX]
|
||||||
* == BPF_R6, sk_convert_filter() saves it in BPF_R6,
|
* == BPF_R6, bpf_convert_filter() saves it in BPF_R6,
|
||||||
* internal BPF verifier will check that BPF_R6 ==
|
* internal BPF verifier will check that BPF_R6 ==
|
||||||
* ctx.
|
* ctx.
|
||||||
*
|
*
|
||||||
|
@ -249,7 +249,7 @@ static long seccomp_attach_filter(struct sock_fprog *fprog)
|
|||||||
goto free_prog;
|
goto free_prog;
|
||||||
|
|
||||||
/* Convert 'sock_filter' insns to 'bpf_insn' insns */
|
/* Convert 'sock_filter' insns to 'bpf_insn' insns */
|
||||||
ret = sk_convert_filter(fp, fprog->len, NULL, &new_len);
|
ret = bpf_convert_filter(fp, fprog->len, NULL, &new_len);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_prog;
|
goto free_prog;
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ static long seccomp_attach_filter(struct sock_fprog *fprog)
|
|||||||
if (!filter->prog)
|
if (!filter->prog)
|
||||||
goto free_filter;
|
goto free_filter;
|
||||||
|
|
||||||
ret = sk_convert_filter(fp, fprog->len, filter->prog->insnsi, &new_len);
|
ret = bpf_convert_filter(fp, fprog->len, filter->prog->insnsi, &new_len);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_filter_prog;
|
goto free_filter_prog;
|
||||||
kfree(fp);
|
kfree(fp);
|
||||||
|
@ -312,7 +312,7 @@ static bool convert_bpf_extensions(struct sock_filter *fp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sk_convert_filter - convert filter program
|
* bpf_convert_filter - convert filter program
|
||||||
* @prog: the user passed filter program
|
* @prog: the user passed filter program
|
||||||
* @len: the length of the user passed filter program
|
* @len: the length of the user passed filter program
|
||||||
* @new_prog: buffer where converted program will be stored
|
* @new_prog: buffer where converted program will be stored
|
||||||
@ -322,12 +322,12 @@ static bool convert_bpf_extensions(struct sock_filter *fp,
|
|||||||
* Conversion workflow:
|
* Conversion workflow:
|
||||||
*
|
*
|
||||||
* 1) First pass for calculating the new program length:
|
* 1) First pass for calculating the new program length:
|
||||||
* sk_convert_filter(old_prog, old_len, NULL, &new_len)
|
* bpf_convert_filter(old_prog, old_len, NULL, &new_len)
|
||||||
*
|
*
|
||||||
* 2) 2nd pass to remap in two passes: 1st pass finds new
|
* 2) 2nd pass to remap in two passes: 1st pass finds new
|
||||||
* jump offsets, 2nd pass remapping:
|
* jump offsets, 2nd pass remapping:
|
||||||
* new_prog = kmalloc(sizeof(struct bpf_insn) * new_len);
|
* new_prog = kmalloc(sizeof(struct bpf_insn) * new_len);
|
||||||
* sk_convert_filter(old_prog, old_len, new_prog, &new_len);
|
* bpf_convert_filter(old_prog, old_len, new_prog, &new_len);
|
||||||
*
|
*
|
||||||
* User BPF's register A is mapped to our BPF register 6, user BPF
|
* User BPF's register A is mapped to our BPF register 6, user BPF
|
||||||
* register X is mapped to BPF register 7; frame pointer is always
|
* register X is mapped to BPF register 7; frame pointer is always
|
||||||
@ -335,8 +335,8 @@ static bool convert_bpf_extensions(struct sock_filter *fp,
|
|||||||
* for socket filters: ctx == 'struct sk_buff *', for seccomp:
|
* for socket filters: ctx == 'struct sk_buff *', for seccomp:
|
||||||
* ctx == 'struct seccomp_data *'.
|
* ctx == 'struct seccomp_data *'.
|
||||||
*/
|
*/
|
||||||
int sk_convert_filter(struct sock_filter *prog, int len,
|
int bpf_convert_filter(struct sock_filter *prog, int len,
|
||||||
struct bpf_insn *new_prog, int *new_len)
|
struct bpf_insn *new_prog, int *new_len)
|
||||||
{
|
{
|
||||||
int new_flen = 0, pass = 0, target, i;
|
int new_flen = 0, pass = 0, target, i;
|
||||||
struct bpf_insn *new_insn;
|
struct bpf_insn *new_insn;
|
||||||
@ -921,7 +921,7 @@ static struct sk_filter *__sk_migrate_filter(struct sk_filter *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 1st pass: calculate the new program length. */
|
/* 1st pass: calculate the new program length. */
|
||||||
err = sk_convert_filter(old_prog, old_len, NULL, &new_len);
|
err = bpf_convert_filter(old_prog, old_len, NULL, &new_len);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_err_free;
|
goto out_err_free;
|
||||||
|
|
||||||
@ -940,9 +940,9 @@ static struct sk_filter *__sk_migrate_filter(struct sk_filter *fp)
|
|||||||
fp->len = new_len;
|
fp->len = new_len;
|
||||||
|
|
||||||
/* 2nd pass: remap sock_filter insns into bpf_insn insns. */
|
/* 2nd pass: remap sock_filter insns into bpf_insn insns. */
|
||||||
err = sk_convert_filter(old_prog, old_len, fp->insnsi, &new_len);
|
err = bpf_convert_filter(old_prog, old_len, fp->insnsi, &new_len);
|
||||||
if (err)
|
if (err)
|
||||||
/* 2nd sk_convert_filter() can fail only if it fails
|
/* 2nd bpf_convert_filter() can fail only if it fails
|
||||||
* to allocate memory, remapping must succeed. Note,
|
* to allocate memory, remapping must succeed. Note,
|
||||||
* that at this time old_fp has already been released
|
* that at this time old_fp has already been released
|
||||||
* by krealloc().
|
* by krealloc().
|
||||||
|
Loading…
Reference in New Issue
Block a user