]> git.proxmox.com Git - mirror_lxc.git/blame - doc/api-extensions.md
Merge pull request #4125 from stgraber/master
[mirror_lxc.git] / doc / api-extensions.md
CommitLineData
aafa5f96
CB
1# API extensions
2
3The changes below were introduced to the LXC API after the 3.0 API was finalized.
4
5They are all backward compatible and can be detected by client tools by
6called the `lxc_has_api_extension` function.
7
8## lxc\_log
9
10This introduces a way to initialize a logging instance from the API for a given
11container.
12
13## lxc\_config\_item\_is\_supported
14
15This introduces the `lxc_config_item_is_supported` function. It allows users to
16check whether their LXC instance supports a given configuration key.
17
18## console\_log
19
20This adds support to container's console log. The console log is implemented as
21an efficient ringbuffer.
22
23## reboot2
24
25This adds `reboot2()` as a new API extension. This function properly waits
26until a reboot succeeded. It takes a timeout argument. When set to `> 0`
27`reboot2()` will block until the timeout is reached, if timeout is set to zero
a8b46a6b 28`reboot2()` will not block, if set to -1 `reboot2()` will block indefinitely.
aafa5f96
CB
29
30## mount\_injection
31
32This adds support for injecting and removing mounts into/from a running
33containers. Two new API functions `mount()` and `umount()` are added. They
34mirror the current mount and umount API of the kernel.
d4a7da46 35
7b766ddc 36## seccomp\_allow\_nesting
37
51c9ca2c 38This adds support for seccomp filters to be stacked regardless of whether a seccomp profile is already loaded. This allows nested containers to load their own seccomp profile.
7b766ddc 39
40## seccomp\_notify
41
b3883456 42This adds "notify" as seccomp action that will cause LXC to register a seccomp listener and retrieve a listener file descriptor from the kernel. When a syscall is made that is registered as "notify" the kernel will generate a poll event and send a message over the file descriptor.
7b766ddc 43
44The caller can read this message, inspect the syscalls including its arguments. Based on this information the caller is expected to send back a message informing the kernel which action to take. Until that message is sent the kernel will block the calling process. The format of the messages to read and sent is documented in seccomp itself.
45
890ecf08
CB
46A new API function `seccomp_notify_fd()` has been added which allows callers to retrieve the notifier fd for the container's seccomp filter.
47
d4a7da46 48## network\_veth\_routes
49
50This introduces the `lxc.net.[i].veth.ipv4.route` and `lxc.net.[i].veth.ipv6.route` properties
51on `veth` type network interfaces. This allows adding static routes on host to the container's
52network interface.
c9f52382 53
54## network\_ipvlan
55
56This introduces the `ipvlan` network type.
57
58Example usage:
59
60```
61lxc.net[i].type=ipvlan
62lxc.net[i].ipvlan.mode=[l3|l3s|l2] (defaults to l3)
63lxc.net[i].ipvlan.isolation=[bridge|private|vepa] (defaults to bridge)
64lxc.net[i].link=eth0
65lxc.net[i].flags=up
66```
6509154d 67
68## network\_l2proxy
69
70This introduces the `lxc.net.[i].l2proxy` that can be either `0` or `1`. Defaults to `0`.
71This, when used with `lxc.net.[i].link`, will add IP neighbour proxy entries on the linked device
72for any IPv4 and IPv6 addresses on the container's network device.
73
74For IPv4 addresses it will check the following sysctl values and fail with an error if not set:
75
76```
77net.ipv4.conf.[link].forwarding=1
78```
79
80For IPv6 addresses it will check the following sysctl values and fail with an error if not set:
81
82```
83net.ipv6.conf.[link].proxy_ndp=1
84net.ipv6.conf.[link].forwarding=1
85```
a2f9a670 86
87## network\_gateway\_device\_route
88
89This introduces the ability to specify `lxc.net.[i].ipv4.gateway` and/or
90`lxc.net.[i].ipv6.gateway` with a value of `dev` which will cause the default gateway
91inside the container to be created as a device route without destination gateway IP needed.
92This is primarily intended for use with layer 3 networking devices, such as IPVLAN.
bc999107
TP
93
94## network\_phys\_macvlan\_mtu
95
96This introduces the ability to specify a custom MTU for `phys` and `macvlan` devices using the
97`lxc.net.[i].mtu` property.
3e5c2e69 98
f3741b92 99## network\_veth\_router
3e5c2e69 100
712ff18d 101This introduces the ability to specify a `lxc.net.[i].veth.mode` setting, which takes a value of "bridge" or "router". This defaults to "bridge".
3e5c2e69 102
712ff18d 103In "router" mode static routes are created on the host for the container's IP addresses pointing to the host side veth interface. In addition to the routes, a static IP neighbour proxy is added to the host side veth interface for the IPv4 and IPv6 gateway IPs.
c60ee0a9
CB
104
105
f3741b92 106## cgroup2\_devices
c60ee0a9 107
cc08c0f3 108This enables `LXC` to make use of the new devices controller in the unified cgroup hierarchy. `LXC` will now create, load, and attach bpf program to the cgroup of the container when the controller is available.
c60ee0a9 109
f3741b92 110## cgroup2
c60ee0a9 111
15ba80d5 112This enables `LXC` to make complete use of the unified cgroup hierarchy. With this extension it is possible to run `LXC` containers on systems that use a pure unified cgroup layout.
fa3621ea 113
f3741b92 114## init\_pidfd
fa3621ea 115
58795066 116This adds a new API function `init_pidfd()` which allows one to retrieve a pidfd for the container's init process allowing process management interactions such as sending signals to be completely reliable and race free.
77f5bdc2 117
f3741b92 118## pidfd
77f5bdc2
CB
119
120When running on kernels that support pidfds LXC will rely on them for most operations. This makes interacting with containers not just more reliable it also makes it significantly safer and eliminates various races inherent to PID-based kernel APIs. LXC will require that the running kernel at least support `pidfd_send_signal()`, `CLONE_PIDFD`, `P_PIDFD`, and pidfd polling support. Any kernel starting with `Linux 5.4` should have full support for pidfds.
e9619d75
CB
121
122## cgroup\_advanced\_isolation
123
124Privileged containers will usually be able to override the cgroup limits given to them. This introduces three new configuration keys `lxc.cgroup.dir.monitor`, `lxc.cgroup.dir.container`, and `lxc.cgroup.dir.container.inner`. The `lxc.cgroup.dir.monitor` and `lxc.cgroup.dir.container` keys can be used to set to place the `monitor` and the `container` into different cgroups. The `lxc.cgroup.dir.container.inner` key can be set to a cgroup that is concatenated with `lxc.cgroup.dir.container`. When `lxc.cgroup.dir.container.inner` is set the container will be placed into the `lxc.cgroup.dir.container.inner` cgroup but the limits will be set in the `lxc.cgroup.dir.container` cgroup. This way privileged containers cannot escape their cgroup limits.
b1248e47
CB
125
126
127## time\_namespace
128
129This adds time namespace support to LXC.
c312db11
CB
130
131## seccomp\_allow\_deny\_syntax
132
133This adds the ability to use "denylist" and "allowlist" in seccomp v2 policies.
f797f05e
CB
134
135## devpts\_fd
136
137This adds the ability to allocate a file descriptor for the devpts instance of
138the container.
21405769
CB
139
140## seccomp\_notify\_fd\_active
141
142Retrieve the seccomp notifier fd from a running container.
0dd2e321
CB
143
144## seccomp\_proxy\_send\_notify\_fd
145
146Whether the seccomp notify proxy sends a long a notify fd file descriptor.
fa3a0034
CB
147
148## idmapped\_mounts
149
3df13023
CB
150Whether this LXC instance can handle idmapped mounts for the rootfs.
151
152## idmapped\_mounts\_v2
153
154Whether this LXC instance can handle idmapped mounts for lxc.mount.entry
155entries.
d90d3007
CB
156
157## cgroup2\_auto_mounting
158
159This adds the new options `cgroup2`, `cgroup2:ro`, `cgroup2:force`,
160`cgroup2:ro:force` for the `lxc.mount.auto` configuration key. For example, if
161a user specifies `cgroup2:force` LXC will pre-mount a pure `cgroup2` layout for
162the container even if the host is running with a hybrid layout.