diff options
author | Martin KaFai Lau <kafai@fb.com> | 2017-06-05 12:15:46 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-06 15:41:22 -0400 |
commit | dc4bb0e2356149aee4cdae061936f3bbdd45595c (patch) | |
tree | 519cc48437a65eade73ab7cb150e32076cbbc17e /kernel/async.c | |
parent | 8ea4fae926afd81f4d7fd43444562afc8629f77c (diff) |
bpf: Introduce bpf_prog ID
This patch generates an unique ID for each BPF_PROG_LOAD-ed prog.
It is worth to note that each BPF_PROG_LOAD-ed prog will have
a different ID even they have the same bpf instructions.
The ID is generated by the existing idr_alloc_cyclic().
The ID is ranged from [1, INT_MAX). It is allocated in cyclic manner,
so an ID will get reused every 2 billion BPF_PROG_LOAD.
The bpf_prog_alloc_id() is done after bpf_prog_select_runtime()
because the jit process may have allocated a new prog. Hence,
we need to ensure the value of pointer 'prog' will not be changed
any more before storing the prog to the prog_idr.
After bpf_prog_select_runtime(), the prog is read-only. Hence,
the id is stored in 'struct bpf_prog_aux'.
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/async.c')
0 files changed, 0 insertions, 0 deletions