Commit ac9f060
bpf: Introduce bpf_obj_drop
Introduce bpf_obj_drop, which is the kfunc used to free allocated
objects (allocated using bpf_obj_new). Pairing with bpf_obj_new, it
implicitly destructs the fields part of object automatically without
user intervention.
Just like the previous patch, btf_struct_meta that is needed to free up
the special fields is passed as a hidden argument to the kfunc.
For the user, a convenience macro hides over the kernel side kfunc which
is named bpf_obj_drop_impl.
Continuing the previous example:
void prog(void) {
struct foo *f;
f = bpf_obj_new(typeof(*f));
if (!f)
return;
bpf_obj_drop(f);
}
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20221118015614.2013203-15-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent 958cf2e commit ac9f060
File tree
3 files changed
+79
-11
lines changed- kernel/bpf
- tools/testing/selftests/bpf
3 files changed
+79
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1770 | 1770 | | |
1771 | 1771 | | |
1772 | 1772 | | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
1773 | 1783 | | |
1774 | 1784 | | |
1775 | 1785 | | |
1776 | 1786 | | |
1777 | 1787 | | |
1778 | 1788 | | |
1779 | 1789 | | |
| 1790 | + | |
1780 | 1791 | | |
1781 | 1792 | | |
1782 | 1793 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7879 | 7879 | | |
7880 | 7880 | | |
7881 | 7881 | | |
| 7882 | + | |
| 7883 | + | |
| 7884 | + | |
| 7885 | + | |
7882 | 7886 | | |
7883 | 7887 | | |
7884 | 7888 | | |
| |||
7957 | 7961 | | |
7958 | 7962 | | |
7959 | 7963 | | |
| 7964 | + | |
| 7965 | + | |
| 7966 | + | |
| 7967 | + | |
| 7968 | + | |
7960 | 7969 | | |
7961 | 7970 | | |
7962 | 7971 | | |
| |||
8051 | 8060 | | |
8052 | 8061 | | |
8053 | 8062 | | |
| 8063 | + | |
8054 | 8064 | | |
8055 | 8065 | | |
8056 | 8066 | | |
8057 | 8067 | | |
8058 | 8068 | | |
8059 | 8069 | | |
8060 | 8070 | | |
| 8071 | + | |
| 8072 | + | |
| 8073 | + | |
| 8074 | + | |
| 8075 | + | |
| 8076 | + | |
| 8077 | + | |
| 8078 | + | |
| 8079 | + | |
| 8080 | + | |
| 8081 | + | |
| 8082 | + | |
| 8083 | + | |
| 8084 | + | |
8061 | 8085 | | |
8062 | 8086 | | |
8063 | 8087 | | |
| |||
8078 | 8102 | | |
8079 | 8103 | | |
8080 | 8104 | | |
| 8105 | + | |
| 8106 | + | |
| 8107 | + | |
8081 | 8108 | | |
8082 | 8109 | | |
8083 | 8110 | | |
| |||
8294 | 8321 | | |
8295 | 8322 | | |
8296 | 8323 | | |
| 8324 | + | |
8297 | 8325 | | |
8298 | 8326 | | |
8299 | 8327 | | |
| |||
8330 | 8358 | | |
8331 | 8359 | | |
8332 | 8360 | | |
| 8361 | + | |
| 8362 | + | |
| 8363 | + | |
| 8364 | + | |
| 8365 | + | |
| 8366 | + | |
| 8367 | + | |
| 8368 | + | |
| 8369 | + | |
| 8370 | + | |
| 8371 | + | |
| 8372 | + | |
| 8373 | + | |
| 8374 | + | |
| 8375 | + | |
8333 | 8376 | | |
8334 | 8377 | | |
8335 | 8378 | | |
| |||
8400 | 8443 | | |
8401 | 8444 | | |
8402 | 8445 | | |
8403 | | - | |
8404 | | - | |
8405 | | - | |
8406 | | - | |
8407 | | - | |
8408 | | - | |
8409 | | - | |
8410 | | - | |
8411 | | - | |
8412 | | - | |
8413 | | - | |
8414 | 8446 | | |
8415 | 8447 | | |
8416 | 8448 | | |
| |||
8532 | 8564 | | |
8533 | 8565 | | |
8534 | 8566 | | |
| 8567 | + | |
| 8568 | + | |
| 8569 | + | |
| 8570 | + | |
8535 | 8571 | | |
8536 | 8572 | | |
8537 | 8573 | | |
| |||
14768 | 14804 | | |
14769 | 14805 | | |
14770 | 14806 | | |
| 14807 | + | |
| 14808 | + | |
| 14809 | + | |
| 14810 | + | |
| 14811 | + | |
| 14812 | + | |
| 14813 | + | |
| 14814 | + | |
14771 | 14815 | | |
14772 | 14816 | | |
14773 | 14817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
25 | 38 | | |
0 commit comments