linux_dsm_epyc7002/include/uapi/linux
Andrey Ignatov 7723628101 bpf: Introduce bpf_skb_ancestor_cgroup_id helper
== Problem description ==

It's useful to be able to identify cgroup associated with skb in TC so
that a policy can be applied to this skb, and existing bpf_skb_cgroup_id
helper can help with this.

Though in real life cgroup hierarchy and hierarchy to apply a policy to
don't map 1:1.

It's often the case that there is a container and corresponding cgroup,
but there are many more sub-cgroups inside container, e.g. because it's
delegated to containerized application to control resources for its
subsystems, or to separate application inside container from infra that
belongs to containerization system (e.g. sshd).

At the same time it may be useful to apply a policy to container as a
whole.

If multiple containers like this are run on a host (what is often the
case) and many of them have sub-cgroups, it may not be possible to apply
per-container policy in TC with existing helpers such as
bpf_skb_under_cgroup or bpf_skb_cgroup_id:

* bpf_skb_cgroup_id will return id of immediate cgroup associated with
  skb, i.e. if it's a sub-cgroup inside container, it can't be used to
  identify container's cgroup;

* bpf_skb_under_cgroup can work only with one cgroup and doesn't scale,
  i.e. if there are N containers on a host and a policy has to be
  applied to M of them (0 <= M <= N), it'd require M calls to
  bpf_skb_under_cgroup, and, if M changes, it'd require to rebuild &
  load new BPF program.

== Solution ==

The patch introduces new helper bpf_skb_ancestor_cgroup_id that can be
used to get id of cgroup v2 that is an ancestor of cgroup associated
with skb at specified level of cgroup hierarchy.

That way admin can place all containers on one level of cgroup hierarchy
(what is a good practice in general and already used in many
configurations) and identify specific cgroup on this level no matter
what sub-cgroup skb is associated with.

E.g. if there is a cgroup hierarchy:
  root/
  root/container1/
  root/container1/app11/
  root/container1/app11/sub-app-a/
  root/container1/app12/
  root/container2/
  root/container2/app21/
  root/container2/app22/
  root/container2/app22/sub-app-b/

, then having skb associated with root/container1/app11/sub-app-a/ it's
possible to get ancestor at level 1, what is container1 and apply policy
for this container, or apply another policy if it's container2.

Policies can be kept e.g. in a hash map where key is a container cgroup
id and value is an action.

Levels where container cgroups are created are usually known in advance
whether cgroup hierarchy inside container may be hard to predict
especially in case when its creation is delegated to containerized
application.

== Implementation details ==

The helper gets ancestor by walking parents up to specified level.

Another option would be to get different kind of "id" from
cgroup->ancestor_ids[level] and use it with idr_find() to get struct
cgroup for ancestor. But that would require radix lookup what doesn't
seem to be better (at least it's not obviously better).

Format of return value of the new helper is same as that of
bpf_skb_cgroup_id.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-08-13 01:02:39 +02:00
..
android
byteorder
caif
can
cifs
dvb
genwqe
hdlc
hsi
iio
isdn
mmc
netfilter netfilter: nf_tables: match on tunnel metadata 2018-08-03 21:12:19 +02:00
netfilter_arp
netfilter_bridge
netfilter_ipv4
netfilter_ipv6
nfsd
raid
sched
spi
sunrpc
tc_act net/sched: tunnel_key: Allow to set tos and ttl for tc based ip tunnels 2018-07-19 23:26:01 -07:00
tc_ematch
usb sound fixes for 4.18-rc1 2018-06-15 17:24:40 +09:00
wimax
a.out.h
acct.h
adb.h
adfs_fs.h
affs_hardblocks.h
agpgart.h
aio_abi.h Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2018-07-22 12:04:51 -07:00
am437x-vpfe.h
apm_bios.h
arcfb.h
arm_sdei.h
aspeed-lpc-ctrl.h
atalk.h
atm_eni.h
atm_he.h
atm_idt77105.h
atm_nicstar.h
atm_tcp.h
atm_zatm.h
atm.h
atmapi.h
atmarp.h
atmbr2684.h
atmclip.h
atmdev.h
atmioc.h
atmlec.h
atmmpc.h
atmppp.h
atmsap.h
atmsvc.h
audit.h Merge branch 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2018-06-07 15:40:37 -07:00
auto_dev-ioctl.h
auto_fs4.h autofs4: merge auto_fs.h and auto_fs4.h 2018-06-07 17:34:39 -07:00
auto_fs.h autofs4: merge auto_fs.h and auto_fs4.h 2018-06-07 17:34:39 -07:00
auxvec.h
ax25.h
b1lli.h
batadv_packet.h
batman_adv.h
baycom.h
bcache.h
bcm933xx_hcs.h
bfs_fs.h
binfmts.h
blkpg.h
blktrace_api.h
blkzoned.h
bpf_common.h
bpf_perf_event.h
bpf.h bpf: Introduce bpf_skb_ancestor_cgroup_id helper 2018-08-13 01:02:39 +02:00
bpfilter.h
bpqether.h
bsg.h
bt-bmc.h
btf.h bpf: btf: Clean up BTF_INT_BITS() in uapi btf.h 2018-07-20 10:25:48 +02:00
btrfs_tree.h
btrfs.h
can.h can: uapi: can.h: Fix can error class mask dir path 2018-07-27 10:40:16 +02:00
capability.h
capi.h
cciss_defs.h
cciss_ioctl.h
cdrom.h
cec-funcs.h
cec.h
cgroupstats.h
chio.h
cm4000_cs.h
cn_proc.h
coda_psdev.h
coda.h
coff.h
connector.h
const.h
coresight-stm.h
cramfs_fs.h
cryptouser.h
cuda.h
cyclades.h
cycx_cfm.h
dcbnl.h net: dcb: add DSCP to comment about priority selector types 2018-07-29 12:53:54 -07:00
dccp.h
devlink.h devlink: Add support for region snapshot read command 2018-07-12 17:37:13 -07:00
dlm_device.h
dlm_netlink.h
dlm_plock.h
dlm.h
dlmconstants.h
dm-ioctl.h
dm-log-userspace.h
dma-buf.h
dn.h
dqblk_xfs.h
edd.h
efs_fs_sb.h
elf-em.h
elf-fdpic.h
elf.h
elfcore.h
errno.h
errqueue.h net/sched: Make etf report drops on error_queue 2018-07-04 22:30:28 +09:00
erspan.h
ethtool.h ethtool: Add WAKE_FILTER and RX_CLS_FLOW_WAKE 2018-08-07 12:15:03 -07:00
eventpoll.h
fadvise.h
falloc.h
fanotify.h
fb.h
fcntl.h
fd.h
fdreg.h
fib_rules.h
fiemap.h
filter.h
firewire-cdev.h
firewire-constants.h
flat.h
fou.h
fs.h
fsl_hypervisor.h
fsmap.h
fuse.h
futex.h
gameport.h
gen_stats.h
genetlink.h
gfs2_ondisk.h
gigaset_dev.h
gpio.h
gsmmux.h
gtp.h
hash_info.h
hdlc.h
hdlcdrv.h
hdreg.h
hid.h
hiddev.h
hidraw.h
hpet.h
hsr_netlink.h
hw_breakpoint.h
hyperv.h
hysdn_if.h
i2c-dev.h
i2c.h
i2o-dev.h
i8k.h
icmp.h
icmpv6.h
if_addr.h
if_addrlabel.h
if_alg.h
if_arcnet.h
if_arp.h
if_bonding.h
if_bridge.h
if_cablemodem.h
if_eql.h
if_ether.h
if_fc.h
if_fddi.h
if_frad.h
if_hippi.h
if_infiniband.h
if_link.h net: report min and max mtu network device settings 2018-07-29 12:57:26 -07:00
if_ltalk.h
if_macsec.h
if_packet.h
if_phonet.h
if_plip.h
if_ppp.h
if_pppol2tp.h
if_pppox.h
if_slip.h
if_team.h
if_tun.h
if_tunnel.h
if_vlan.h
if_x25.h
if_xdp.h xsk: Fix umem fill/completion queue mmap on 32-bit 2018-06-08 00:18:02 +02:00
if.h
ife.h
igmp.h
ila.h ila: Flush netlink command to clear xlat table 2018-06-29 11:32:55 +09:00
in6.h
in_route.h
in.h
inet_diag.h
inotify.h
input-event-codes.h
input.h
ioctl.h
ip6_tunnel.h
ip_vs.h
ip.h route: add support for directed broadcast forwarding 2018-07-29 12:37:06 -07:00
ipc.h
ipmi_bmc.h
ipmi_msgdefs.h
ipmi.h
ipsec.h
ipv6_route.h
ipv6.h
ipx.h
irqnr.h
isdn_divertif.h
isdn_ppp.h
isdn.h
isdnif.h
iso_fs.h
ivtv.h
ivtvfb.h
jffs2.h
joystick.h
Kbuild
kcm.h
kcmp.h
kcov.h
kd.h
kdev_t.h
kernel-page-flags.h mm: mark pages in use for page tables 2018-06-07 17:34:37 -07:00
kernel.h
kernelcapi.h
kexec.h
keyboard.h
keyctl.h
kfd_ioctl.h
kvm_para.h
kvm.h kvm: fix typo in flag name 2018-06-12 15:06:35 +02:00
l2tp.h l2tp: ignore L2TP_ATTR_MTU 2018-08-03 10:03:57 -07:00
libc-compat.h
lightnvm.h
limits.h
lirc.h
llc.h
loop.h
lp.h
lwtunnel.h
magic.h
major.h
map_to_7segment.h
matroxfb.h
max2175.h
mdio.h
media-bus-format.h
media.h
mei.h
membarrier.h
memfd.h
mempolicy.h
meye.h
mic_common.h
mic_ioctl.h
mii.h net: phy: add GBit master / slave error detection 2018-07-24 14:41:08 -07:00
minix_fs.h
mman.h
mmtimer.h
module.h
mpls_iptunnel.h
mpls.h
mqueue.h
mroute6.h
mroute.h net: ipmr: add support for passing full packet on wrong vif 2018-07-13 14:21:16 -07:00
msdos_fs.h
msg.h
mtio.h
n_r3964.h
nbd-netlink.h
nbd.h nbd: Add the nbd NBD_DISCONNECT_ON_CLOSE config flag. 2018-06-20 19:10:06 -06:00
ncsi.h
ndctl.h
neighbour.h
net_dropmon.h
net_namespace.h
net_tstamp.h net: Use __u32 in uapi net_stamp.h 2018-07-09 16:31:28 -07:00
net.h
netconf.h route: add support for directed broadcast forwarding 2018-07-29 12:37:06 -07:00
netdevice.h
netfilter_arp.h
netfilter_bridge.h netfilter: bridge: Expose nf_tables bridge hook priorities through uapi 2018-08-03 21:15:09 +02:00
netfilter_decnet.h
netfilter_ipv4.h
netfilter_ipv6.h
netfilter.h
netlink_diag.h
netlink.h
netrom.h
nfc.h
nfs2.h
nfs3.h
nfs4_mount.h
nfs4.h
nfs_fs.h
nfs_idmap.h
nfs_mount.h
nfs.h
nfsacl.h
nilfs2_api.h
nilfs2_ondisk.h
nl80211.h This round's updates: 2018-06-30 21:08:12 +09:00
nsfs.h
nubus.h
nvme_ioctl.h
nvram.h
omap3isp.h
omapfb.h
oom.h
openvswitch.h openvswitch: kernel datapath clone action 2018-07-08 11:13:25 +09:00
packet_diag.h
param.h
parport.h
patchkey.h
pci_regs.h pci-v4.18-changes 2018-06-07 12:45:58 -07:00
pci.h
pcitest.h
perf_event.h perf/x86/intel: Fix unwind errors from PEBS entries (mk-II) 2018-07-25 11:46:21 +02:00
personality.h
pfkeyv2.h
pg.h
phantom.h
phonet.h
pkt_cls.h net/sched: allow flower to match tunnel options 2018-08-07 12:22:15 -07:00
pkt_sched.h net/sched: add skbprio scheduler 2018-07-24 14:44:00 -07:00
pktcdvd.h
pmu.h
poll.h
posix_acl_xattr.h
posix_acl.h
posix_types.h
ppdev.h
ppp_defs.h
ppp-comp.h
ppp-ioctl.h
pps.h
pr.h
prctl.h docs: Fix some broken references 2018-06-15 18:10:01 -03:00
psample.h
psci.h
psp-sev.h
ptp_clock.h
ptrace.h
qemu_fw_cfg.h
qnx4_fs.h
qnxtypes.h
qrtr.h
quota.h
radeonfb.h
random.h
raw.h
rds.h rds: Extend RDS API for IPv6 support 2018-07-23 21:17:44 -07:00
reboot.h
reiserfs_fs.h
reiserfs_xattr.h
resource.h
rfkill.h
rio_cm_cdev.h
rio_mport_cdev.h
romfs_fs.h
rose.h
route.h
rpmsg.h
rseq.h rseq: uapi: Declare rseq_cs field as union, update includes 2018-07-10 22:18:52 +02:00
rtc.h
rtnetlink.h net: sched: introduce chain object to uapi 2018-07-23 20:44:12 -07:00
rxrpc.h
scc.h
sched.h
scif_ioctl.h
screen_info.h
sctp.h sctp: add spp_ipv6_flowlabel and spp_dscp for sctp_paddrparams 2018-07-04 11:36:54 +09:00
sdla.h
seccomp.h
securebits.h
sed-opal.h
seg6_genl.h
seg6_hmac.h
seg6_iptunnel.h
seg6_local.h
seg6.h
selinux_netlink.h
sem.h
serial_core.h
serial_reg.h
serial.h
serio.h
shm.h
signal.h
signalfd.h
smc_diag.h net/smc: provide fallback reason code 2018-07-25 22:25:53 -07:00
smc.h
smiapp.h
snmp.h ip: discard IPv4 datagrams with overlapping segments. 2018-08-05 17:16:46 -07:00
sock_diag.h
socket.h
sockios.h
sonet.h
sonypi.h
sound.h
soundcard.h
stat.h
stddef.h
stm.h
string.h
suspend_ioctls.h
swab.h
switchtec_ioctl.h
sync_file.h
synclink.h
sysctl.h
sysinfo.h
target_core_user.h scsi: target: tcmu: add read length support 2018-06-18 21:02:52 -04:00
taskstats.h
tcp_metrics.h
tcp.h tcp: add stat of data packet reordering events 2018-08-01 09:56:10 -07:00
tee.h
termios.h
thermal.h
time.h
timerfd.h
times.h
timex.h
tiocl.h
tipc_config.h
tipc_netlink.h tipc: extend sock diag for group communication 2018-06-30 21:05:42 +09:00
tipc_sockets_diag.h
tipc.h
tls.h
toshiba.h
tty_flags.h
tty.h
types.h
udf_fs_i.h
udp.h
uhid.h
uinput.h
uio.h
uleds.h
ultrasound.h
un.h
unistd.h
unix_diag.h
usbdevice_fs.h
usbip.h
userfaultfd.h
userio.h
utime.h
utsname.h
uuid.h
uvcvideo.h
v4l2-common.h
v4l2-controls.h
v4l2-dv-timings.h
v4l2-mediabus.h
v4l2-subdev.h
vbox_err.h
vbox_vmmdev_types.h
vboxguest.h
veth.h
vfio_ccw.h
vfio.h
vhost.h vhost: switch to use new message format 2018-08-06 10:41:04 -07:00
videodev2.h
virtio_9p.h
virtio_balloon.h
virtio_blk.h
virtio_config.h virtio: update the comments for transport features 2018-06-12 04:59:29 +03:00
virtio_console.h
virtio_crypto.h
virtio_gpu.h
virtio_ids.h
virtio_input.h
virtio_mmio.h
virtio_net.h
virtio_pci.h
virtio_ring.h
virtio_rng.h
virtio_scsi.h
virtio_types.h
virtio_vsock.h
vm_sockets_diag.h
vm_sockets.h
vmcore.h
vsockmon.h
vt.h
vtpm_proxy.h
wait.h
wanrouter.h
watchdog.h
wimax.h
wireless.h
wmi.h
x25.h
xattr.h
xfrm.h xfrm: Add a new lookup key to match xfrm interfaces. 2018-06-23 16:07:15 +02:00
xilinx-v4l2-controls.h
zorro_ids.h
zorro.h