Function report |
Source Code:kernel\bpf\syscall.c |
Create Date:2022-07-28 12:53:37 |
| Last Modify:2022-05-19 18:06:12 | Copyright©Brick |
| home page | Tree |
| Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:bpf_prog_load
Proto:static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)
Type:int
Parameter:
| Type | Parameter | Name |
|---|---|---|
| union bpf_attr * | attr | |
| union bpf_attr __user * | uattr |
| 1704 | type = one of enum bpf_prog_type |
| 1710 | If helper macro to check that unused fields 'union bpf_attr' are zero (BPF_PROG_LOAD) Then Return -EINVAL |
| 1725 | If Copy a NUL terminated string from userspace < 0 Then Return -EFAULT |
| 1731 | is_gpl = license_is_gpl_compatible(license) |
| 1733 | If insn_cnt == 0 || insn_cnt > If Check operation authority Then yes. 1M insns Else BPF_MAXINSNS Then Return -E2BIG |
| 1736 | If type != BPF_PROG_TYPE_SOCKET_FILTER && type != BPF_PROG_TYPE_CGROUP_SKB && Not Check operation authority Then Return -EPERM |
| 1748 | prog = bpf_prog_alloc(bpf_prog_size(insn_cnt), GFP_USER) |
| 1752 | For some prog types = For some prog types expected attach type must be known at * load time to verify attach type specific parts of prog * (context accesses, allowed helpers, etc). |
| 1754 | If 0 to attach to vmlinux Then |
| 1757 | tgt_prog = bpf_prog_get( 0 to attach to vmlinux ) |
| 1760 | Go to free_prog_nouncharge |
| 1762 | linked_prog = tgt_prog |
| 1765 | offload_requested = Not Not ifindex of netdev to prep for |
| 1767 | err = security_bpf_prog_alloc( Auxiliary fields ) |
| 1768 | If err Then Go to free_prog_nouncharge |
| 1771 | err = bpf_prog_charge_memlock(prog) |
| 1772 | If err Then Go to free_prog_sec |
| 1775 | Number of filter blocks = insn_cnt |
| 1778 | If copy_from_user(insns, u64_to_user_ptr(insns), bpf_prog_insn_size(prog)) != 0 Then Go to free_prog |
| 1782 | Original BPF program = NULL |
| 1783 | Is our filter JIT'ed? = 0 |
| 1785 | atomic64_set( & refcnt, 1) |
| 1786 | Is filter GPL compatible? = If is_gpl Then 1 Else 0 |
| 1788 | If bpf_prog_is_dev_bound( Auxiliary fields ) Then |
| 1795 | err = find_prog_type(type, prog) |
| 1799 | ns since boottime = ktime_get_boottime_ns() |
| 1800 | err = dst and src must have at least BPF_OBJ_NAME_LEN number of bytes.* Return 0 on success and < 0 on error. |
| 1806 | If err < 0 Then Go to free_used_maps |
| 1810 | If err < 0 Then Go to free_used_maps |
| 1813 | err = bpf_prog_alloc_id(prog) |
| 1814 | If err Then Go to free_used_maps |
| 1831 | bpf_prog_kallsyms_add(prog) |
| 1832 | perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0) |
| 1834 | err = bpf_prog_new_fd(prog) |
| 1835 | If err < 0 Then bpf_prog_put(prog) |
| 1837 | Return err |
| 1839 | free_used_maps : |
| 1845 | Return err |
| 1846 | free_prog : |
| 1848 | free_prog_sec : |
| 1850 | free_prog_nouncharge : |
| 1852 | Return err |
| Source code conversion tool public plug-in interface | X |
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |