Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\syscall.c Create Date:2022-07-28 12:53:55
Last Modify:2022-05-19 18:06:12 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:bpf_prog_attach

Proto:static int bpf_prog_attach(const union bpf_attr *attr)

Type:int

Parameter:

TypeParameterName
const union bpf_attr *attr
2054  If Not Check operation authority Then Return -EPERM
2057  If helper macro to check that unused fields 'union bpf_attr' are zero (BPF_PROG_ATTACH) Then Return -EINVAL
2060  If attach_flags & ~BPF_F_ATTACH_MASK Then Return -EINVAL
2064  Case attach_type == BPF_CGROUP_INET_INGRESS
2065  Case attach_type == BPF_CGROUP_INET_EGRESS
2066  ptype = BPF_PROG_TYPE_CGROUP_SKB
2067  Break
2068  Case attach_type == BPF_CGROUP_INET_SOCK_CREATE
2069  Case attach_type == BPF_CGROUP_INET4_POST_BIND
2070  Case attach_type == BPF_CGROUP_INET6_POST_BIND
2071  ptype = BPF_PROG_TYPE_CGROUP_SOCK
2072  Break
2073  Case attach_type == BPF_CGROUP_INET4_BIND
2074  Case attach_type == BPF_CGROUP_INET6_BIND
2075  Case attach_type == BPF_CGROUP_INET4_CONNECT
2076  Case attach_type == BPF_CGROUP_INET6_CONNECT
2077  Case attach_type == BPF_CGROUP_UDP4_SENDMSG
2078  Case attach_type == BPF_CGROUP_UDP6_SENDMSG
2079  Case attach_type == BPF_CGROUP_UDP4_RECVMSG
2080  Case attach_type == BPF_CGROUP_UDP6_RECVMSG
2081  ptype = BPF_PROG_TYPE_CGROUP_SOCK_ADDR
2082  Break
2083  Case attach_type == BPF_CGROUP_SOCK_OPS
2084  ptype = BPF_PROG_TYPE_SOCK_OPS
2085  Break
2086  Case attach_type == BPF_CGROUP_DEVICE
2087  ptype = BPF_PROG_TYPE_CGROUP_DEVICE
2088  Break
2089  Case attach_type == BPF_SK_MSG_VERDICT
2090  ptype = BPF_PROG_TYPE_SK_MSG
2091  Break
2092  Case attach_type == BPF_SK_SKB_STREAM_PARSER
2093  Case attach_type == BPF_SK_SKB_STREAM_VERDICT
2094  ptype = BPF_PROG_TYPE_SK_SKB
2095  Break
2096  Case attach_type == BPF_LIRC_MODE2
2097  ptype = BPF_PROG_TYPE_LIRC_MODE2
2098  Break
2099  Case attach_type == BPF_FLOW_DISSECTOR
2100  ptype = BPF_PROG_TYPE_FLOW_DISSECTOR
2101  Break
2102  Case attach_type == BPF_CGROUP_SYSCTL
2103  ptype = BPF_PROG_TYPE_CGROUP_SYSCTL
2104  Break
2105  Case attach_type == BPF_CGROUP_GETSOCKOPT
2106  Case attach_type == BPF_CGROUP_SETSOCKOPT
2107  ptype = BPF_PROG_TYPE_CGROUP_SOCKOPT
2108  Break
2109  Default
2110  Return -EINVAL
2113  prog = bpf_prog_get_type( eBPF program to attach , ptype)
2114  If IS_ERR(prog) Then Return PTR_ERR(prog)
2117  If bpf_prog_attach_check_attach_type(prog, attach_type) Then
2118  bpf_prog_put(prog)
2119  Return -EINVAL
2123  Case ptype == BPF_PROG_TYPE_SK_SKB
2124  Case ptype == BPF_PROG_TYPE_SK_MSG
2126  Break
2129  Break
2132  Break
2133  Default
2137  If ret Then bpf_prog_put(prog)
2139  Return ret