mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
bpf: Add new cgroup attach type to enable sock modifications
Add new cgroup based program type, BPF_PROG_TYPE_CGROUP_SOCK. Similar to
BPF_PROG_TYPE_CGROUP_SKB programs can be attached to a cgroup and run
any time a process in the cgroup opens an AF_INET or AF_INET6 socket.
Currently only sk_bound_dev_if is exported to userspace for modification
by a bpf program.
This allows a cgroup to be configured such that AF_INET{6} sockets opened
by processes are automatically bound to a specific device. In turn, this
enables the running of programs that do not support SO_BINDTODEVICE in a
specific VRF context / L3 domain.
Signed-off-by: David Ahern <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
b2cd12574a
commit
6102365876
7 changed files with 138 additions and 2 deletions
|
|
@ -374,8 +374,18 @@ lookup_protocol:
|
|||
|
||||
if (sk->sk_prot->init) {
|
||||
err = sk->sk_prot->init(sk);
|
||||
if (err)
|
||||
if (err) {
|
||||
sk_common_release(sk);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (!kern) {
|
||||
err = BPF_CGROUP_RUN_PROG_INET_SOCK(sk);
|
||||
if (err) {
|
||||
sk_common_release(sk);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
out:
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue