Commit Graph

563 Commits

Author SHA1 Message Date
Christian Brauner
cc73685dd0
lxc: switch to SPDX
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-12-04 13:48:46 +01:00
Claudio Kuenzler
63012bdd00 Add autodev.tmpfs.size config parameter
Signed-off-by: Claudio Kuenzler <ck@claudiokuenzler.com>
2019-10-04 09:47:23 -07:00
Christian Brauner
6453ba565e
tree-wide: initialize all auto-cleanup variables
Closes: #3101.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-07-23 16:41:46 +02:00
Thomas Parrott
3f0ed090d6 network: Adds mode param (bridge, router) to veth network setting
Defaulting to bridge mode.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2019-07-11 12:37:23 +01:00
Wolfgang Bumiller
84cf6d259b conf: add lxc.seccomp.notify.cookie
This is an arbitrary string to to be included in proxied
seccomp notification messages.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-09 12:25:10 +02:00
tomponline
a2f9a6706d network: Adds gateway device route mode
Adds ability to specify "dev" as the gateway value, which will cause a device route to be set as default gateway.

Signed-off-by: tomponline <thomas.parrott@canonical.com>
2019-05-03 15:08:49 +01:00
tomponline
6509154de1 network: Adds layer 2 (ARP/NDP) proxy mode
Adds the lxc.net.[i].l2proxy flag that can be either 0 or 1.

Defaults to 0.

This, when used with lxc.net.[i].link, will add IP neighbour proxy entries on the linked device
for any IPv4 and IPv6 addresses on the container's network device.

Additionally, for IPv6 addresses it will check the following sysctl values and fail with an error if not set:

	net.ipv6.conf.[link].proxy_ndp=1
	net.ipv6.conf.[link].forwarding=1

Signed-off-by: tomponline <thomas.parrott@canonical.com>
2019-05-02 14:07:28 +01:00
tomponline
c9f5238291 network: Adds IPVLAN support
Example usage:

	lxc.net[i].type=ipvlan
	lxc.net[i].ipvlan.mode=[l3|l3s|l2] (defaults to l3)
	lxc.net[i].ipvlan.flags=[bridge|private|vepa] (defaults to bridge)
	lxc.net[i].link=eth0
	lxc.net[i].flags=up

Signed-off-by: tomponline <thomas.parrott@canonical.com>
2019-05-01 10:10:44 +01:00
Christian Brauner
5efab6bf45
Merge pull request #2949 from tomponline/tp-veth-routes
network: Adds veth static routes feature
2019-04-29 17:15:38 +02:00
Christian Brauner
c3e3c21a10
seccomp: cleanup
Simplify and cleanup some of the seccomp code. This mainly focuses on removing
the open coding of various seccomp settings all over the code place in favor of
centralized helpers.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-04-29 15:17:31 +02:00
tomponline
d4a7da4632 network: Adds support host side veth device static routes
Adds the following new config keys:

	lxc.net.[i].veth.ipv4.route
	lxc.net.[i].veth.ipv6.route
E.g.

	lxc.net.0.veth.ipv4.route = 192.0.2.1/32
	lxc.net.0.veth.ipv4.route = 192.0.3.0/24
	lxc.net.0.veth.ipv6.route = 2001:db8::1/128
	lxc.net.0.veth.ipv6.route = 2001:db8:2::/64

Signed-off-by: tomponline <thomas.parrott@canonical.com>
2019-04-29 08:38:33 +01:00
Christian Brauner
86ce1da153
confile: add lxc.seccomp.notify.proxy
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-04-25 21:35:28 +02:00
Christian Brauner
f766251429
confile: make parse_limit_value() static
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-03-04 20:42:12 +01:00
Christian Brauner
5648fc191c
confile_utils: make update_hwaddr() static
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-03-04 20:42:11 +01:00
Christian Brauner
3db41a6cf0
confile_utils: lxc_config_net_is_hwaddr()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-03-04 20:42:11 +01:00
Christian Brauner
0cacddda88
confile: shut up gcc
Invalid warning but let's please the compiler.

Closes #2885.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-03-01 21:15:49 +01:00
Christian Brauner
f01d035800
confile: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
50d86993a7
confile: add lxc.seccomp.allow_nesting
This adds the lxc.seccomp.allow_nesting api extension. If
lxc.seccomp.allow_nesting is set to 1 then seccomp profiles will be
stacked. This way nested containers can load their own seccomp policy on
top of the policy that the outer container might have applied.

Cc: Simon Fels <simon.fels@canonical.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-07 15:34:08 +01:00
Christian Brauner
9395c7c215
confile: remove debug printf()s
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-11-01 22:50:18 +01:00
Christian Brauner
6437f1c173
conf: don't setup shared mountpoint for shmounts
Leave it up to the caller for now until we have a clear way to do
this without causing double mounts etc.

Needed-by: https://github.com/lxc/lxd/issues/5227

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-11-01 11:06:42 -04:00
Christian Brauner
594426ca1b
conf: expand shmounts lxc.mount.auto option
Allow users to specify a path in the container they want to use.
This will help LXD.

Needed-by: https://github.com/lxc/lxd/issues/5227

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-11-01 11:06:22 -04:00
Josh Soref
ae52f39643 spelling: unsigned
Signed-off-by: Josh Soref <jsoref@gmail.com>
2018-10-30 08:24:51 +00:00
Josh Soref
8d47350bea spelling: ambiguous
Signed-off-by: Josh Soref <jsoref@gmail.com>
2018-10-30 06:45:53 +00:00
Christian Brauner
637d38f246
coverity: #1440391
Dereference null return value

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-10-22 16:48:37 +02:00
Christian Brauner
33eb2ec186
confile: do not overwrite global variable
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-10-22 16:47:41 +02:00
2xsec
47903908f8
tree-wide: coding style fixes
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
[christian.brauner@ubuntu.com: cleanup if-branches in confile.c]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-10-19 11:21:36 +02:00
Christian Brauner
62a821f199
confile: fix append_unexp_config_line()
Reported-by: 2xsec dh48.jeong@samsung.com
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-10-18 15:56:29 +02:00
2xsec
8392708ef3
confile: remove unused variable
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
2018-10-10 14:50:32 +09:00
Stéphane Graber
cb2ce6d03e
Merge pull request #2674 from brauner/2018-10-07/protect_errno
parse: tweak config parsing
2018-10-07 16:22:08 -04:00
Christian Brauner
18740311c1
confile: s/MAXPATHLEN/PATH_MAX/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-10-07 09:59:16 +02:00
Christian Brauner
46ac8c5b35
parse: remove access() check
We can just fail on open() and not waste an additional syscall.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-10-07 00:42:44 +02:00
Christian Brauner
d38dd64a51
tree-wide: fix includes to fix bionic builds
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-27 01:01:33 +02:00
Christian Brauner
afeec9b739
compiler: add __hot attribute
This instructs the compiler to better optimize the config parsing code.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-26 14:52:27 +02:00
Christian Brauner
b1e44ed125
tree_wide: switch to netns_getifaddrs()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-23 21:19:35 +02:00
Christian Brauner
6333c91505
tree-wide: replace sizeof() with SIZEOF2STRLEN()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-23 12:56:13 +02:00
Christian Brauner
9caee129cd
confile: s/lxc.cgroup.keep/lxc.cgroup.relative/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-21 13:44:53 +02:00
2xsec
01c8b1cd9d
remove unused variables
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
2018-09-12 17:29:09 +09:00
Wolfgang Bumiller
6b28940591
Merge pull request #2435 from brauner/2018-06-27/storage_managed
[RFC] conf: introduce lxc.rootfs.managed
2018-08-30 08:28:08 +02:00
Christian Brauner
c77aee6475
confile: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:14:52 +02:00
Christian Brauner
76f0e2e739
confile: add lxc.cgroup.keep
This adds the new lxc.cgroup.keep config key. The key can be used to instruct
LXC to not escape to never escape to the root cgroup. This makes it easy for
users to adhere to restrictions enforced by cgroup2 and systemd. Specifically,
this makes it possible to run LXC containers as systemd services.

Note that cgroup v1 is considered legacy and will not see additional
controllers being added to it. This means that it is safe to use
lxc.cgroup.keep as config key since there is no "keep" controller. The only way
a conflict can be introduced is if the user is creating a named controller. I
think this case can be safely ignored since it is super rare and also the users
problem.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Felix Abecassis <fabecassis@nvidia.com>
Cc: Jonathan Calmels <jcalmels@nvidia.com>
2018-08-27 03:07:51 +02:00
Christian Brauner
6e54330c46
conf: introduce lxc.rootfs.managed
This introduces a new config key lxc.rootfs.managed which can be used to
indicate whether this LXC instance is managing the container storage. If LXC is
not managing the storage then LXC will not modify the container storage.
For example, an API call to c->destroy(c) will then run any destroy hooks but
will not destroy the actual rootfs (Unless, of course, the hook does so behind
LXC's back.).

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
CC: Wolfgang Bumiller <w.bumiller@proxmox.com>
CC: Stéphane Graber <stgraber@ubuntu.com>
CC: Serge Hallyn <serge@hallyn.com>
CC: 2xsec <dh48.jeong@samsung.com>
2018-07-31 22:09:34 +02:00
Christian Brauner
3437f95c47
confile: split mount options into flags and data
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-07-29 18:28:44 +02:00
Christian Brauner
62dd965e45
confile: s/strtok_r()/lxc_iterate_parts()/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-07-26 16:38:42 +02:00
Wolfgang Bumiller
1800f92473 apparmor: profile generation
This copies lxd's apparmor profile generation. This tries to
detect features such as cgroup namespaces, apparmor
namespaces and stacking support, and has profile parts
conditionally for unprivileged containers.

This introduces the following changes to the configuration:
  lxc.apparmor.profile = generated
    The fixed value 'generated' will cause this
    functionality to be used, otherwise there should be no
    functional changes happening unless specifically
    requested with the next key:
  lxc.apparmor.allow_nesting
    This is a boolean which, if enabled, causes the
    following changes: When generated apparmor profiles are
    used, they will contain the necessary changes to allow
    creating a nested container. In addition to the usual
    mount points, /dev/.lxc/proc and /dev/.lxc/sys will
    contain procfs and sysfs mount points without the lxcfs
    overlays, which, if generated apparmor profiles are
    being used, will not be read/writable directly.
  lxc.apparmor.raw
    A list of raw apparmor profile lines to append to the
    profile. Only valid when using generated profiles.

The following apparmor profile lines have not been copied
from lxd:

  mount /var/lib/lxd/shmounts/ -> /var/lib/lxd/shmounts/,
  mount none -> /var/lib/lxd/shmounts/,
  mount options=bind /var/lib/lxd/shmounts/** -> /var/lib/lxd/**,

They should be added via lxc.apparmor.raw entries by lxd.

In order for apparmor_parser's cache to be of use, this adds
a --with-apparmor-cache-dir ./configure option.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-25 14:37:32 +02:00
Liza Tretyakova
fd14fdb827
confile: add strdup failure check
Signed-off-by: Liza Tretyakova <elizabet.tretyakova@gmail.com>
[christian.brauner@ubuntu.com: coding style]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-07-22 15:50:29 +02:00
Liza Tretyakova
7a41e8578e
conf, confile, lxccontainer, start: nonfunctional changes
Signed-off-by: Liza Tretyakova <elizabet.tretyakova@gmail.com>
2018-07-22 15:35:21 +02:00
Liza Tretyakova
0d190408c2
conf, confile: add parsing of a shmounts config parameter
Signed-off-by: Liza Tretyakova <elizabet.tretyakova@gmail.com>
2018-07-22 15:25:15 +02:00
Liza Tretyakova
adf0ba1fc7
conf, confile: introduce basic structs for shared mount point
Signed-off-by: Liza Tretyakova <elizabet.tretyakova@gmail.com>
2018-07-22 15:25:13 +02:00
Christian Brauner
258f80519f
confile: add lxc.monitor.signal.pdeath
Set the signal to be sent to the container's init when the lxc monitor exits.
By default it is set to SIGKILL which will cause all container processes to be
killed when the lxc monitor process dies.
To ensure that containers stay alive even if lxc monitor dies set this to 0.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-07-16 12:50:57 +02:00
Christian Brauner
f6e32eb05b
confile: move signal helpers to confile utils
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-07-16 11:30:23 +02:00