History

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

Alexei Starovoitov committed 12 years ago

Commit 8fb575c1 parent 4df95ff5 files · +14 −14Browse files

Unified · Split

5 files
  1. arch/x86/net/bpf_jit_comp.c +1 −1
  2. include/linux/filter.h +2 −2
  3. kernel/bpf/core.c +1 −1
  4. kernel/seccomp.c +2 −2
  5. net/core/filter.c +8 −8
arch/x86/net/bpf_jit_comp.c+1−1
@@ -235,7 +235,7 @@ static int do_jit(struct sk_filter *bpf_prog, int *addrs, u8 *image, · 234 unmodified lines
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+2−2
@@ -351,8 +351,8 @@ int sk_filter(struct sock *sk, struct sk_buff *skb); · 350 unmodified lines
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+1−1
@@ -446,7 +446,7 @@ load_word: · 445 unmodified lines
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+2−2
@@ -249,7 +249,7 @@ static long seccomp_attach_filter(struct sock_fprog *fprog) · 248 unmodified lines
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) · 9 unmodified lines
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+8−8
@@ -312,7 +312,7 @@ static bool convert_bpf_extensions(struct sock_filter *fp, · 311 unmodified lines
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,12 +322,12 @@ static bool convert_bpf_extensions(struct sock_filter *fp, · 3 unmodified lines
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
@@ -335,8 +335,8 @@ static bool convert_bpf_extensions(struct sock_filter *fp, · 1 unmodified line
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) · 578 unmodified lines
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) · 12 unmodified lines
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().

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t