]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Add new cgroup attach type to enable sock modifications
authorDavid Ahern <dsa@cumulusnetworks.com>
Thu, 1 Dec 2016 16:48:04 +0000 (08:48 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Dec 2016 18:46:08 +0000 (13:46 -0500)
commitcf020472530874844ed3ee7bc3d0d9e6317d780c
tree9b10a9d2a8b5820450298f9bda8f3c23fbf66b57
parent11e275c15cda2a61d94acbcbb6ddcb3b6896b9dd
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 <dsa@cumulusnetworks.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf-cgroup.h
include/uapi/linux/bpf.h
kernel/bpf/cgroup.c
kernel/bpf/syscall.c
net/core/filter.c
net/ipv4/af_inet.c
net/ipv6/af_inet6.c