]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
7 years agotests: remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:06:26 +0000 (08:06 +0200)] 
tests: remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc_usernsexec: remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:03:06 +0000 (08:03 +0200)] 
lxc_usernsexec: remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-unshare: do not pass NULL pointer
Christian Brauner [Sun, 10 Sep 2017 06:01:31 +0000 (08:01 +0200)] 
lxc-unshare: do not pass NULL pointer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: parse_idmaps() remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:00:50 +0000 (08:00 +0200)] 
confile: parse_idmaps() remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: do not write to 0 sized buffer
Christian Brauner [Sun, 10 Sep 2017 04:42:10 +0000 (06:42 +0200)] 
utils: do not write to 0 sized buffer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocriu: use correct check initialization check
Christian Brauner [Sat, 9 Sep 2017 16:45:47 +0000 (18:45 +0200)] 
criu: use correct check initialization check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: remove dead variable
Christian Brauner [Sat, 9 Sep 2017 09:23:55 +0000 (11:23 +0200)] 
start: remove dead variable

non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agomonitor: remove dead assignment
Christian Brauner [Sat, 9 Sep 2017 09:23:34 +0000 (11:23 +0200)] 
monitor: remove dead assignment

non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: remove dead assignments
Christian Brauner [Sat, 9 Sep 2017 09:23:14 +0000 (11:23 +0200)] 
console: remove dead assignments

non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: userns_exec_full()
Christian Brauner [Sat, 9 Sep 2017 09:21:51 +0000 (11:21 +0200)] 
start: userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxccontainer: use userns_exec_full()
Christian Brauner [Sat, 9 Sep 2017 09:21:16 +0000 (11:21 +0200)] 
lxccontainer: use userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: add userns_exec_full()
Christian Brauner [Sat, 9 Sep 2017 09:20:57 +0000 (11:20 +0200)] 
conf: add userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: add missing checks for empty links
Wolfgang Bumiller [Wed, 6 Sep 2017 09:51:03 +0000 (11:51 +0200)] 
network: add missing checks for empty links

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 years agoconf: fix tty creation
Christian Brauner [Tue, 5 Sep 2017 10:41:30 +0000 (12:41 +0200)] 
conf: fix tty creation

We allocate pty {master,slave} file descriptors in the childs namespaces after
we have setup devpts. After we have sent the pty file descriptors to the parent
and set up the pty file descriptors under /dev/tty* and before we exec the init
binary we need to delete these file descriptors in the child. However, one of
my commits made the deletion occur before setting up the file descriptors under
/dev/tty*. This caused a failures when trying to attach to the container's ttys
since they werent actually configured although the file descriptors were
available in the in-memory configuration of the parent.
This commit reworks setting up tty such that deletion occurs after all setup
has been performed. The commit is actually minimal but needs to also move all
the functions into one place since they well now be called from
"lxc_create_ttys()".

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: clean tty state + return 0 on peer exit
LiFeng [Tue, 5 Sep 2017 15:16:50 +0000 (23:16 +0800)] 
console: clean tty state + return 0 on peer exit

In the past, if the console client exited, lxc_console_cb_con return 1. And
the lxc_poll will exit, the process will wait at waitpid. At this moment, the
process could not handle any command (For example get the container state
LXC_CMD_GET_STATE or stop the container LXC_CMD_STOP.).

I think we should clean the tty_state and return 0 in this case. So, we can use
the lxc-console to connect the console of the container. And we will not exit
the function lxc_polland we can handle the commands by lxc_cmd_process

Reproducer prior to this commit:
- open a new terminal, get the tty device name by command tty /dev/pts/6
- set lxc.console.path = /dev/pts/6
- start the container and the ouptut will print to /dev/pts/6
- close /dev/pts/6
- try an operation e.g. getting state with lxc-ls and lxc-ls will hang

Closes #1787.

Signed-off-by: LiFeng <lifeng68@huawei.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: fix userns_exec_1()
Christian Brauner [Tue, 5 Sep 2017 15:43:31 +0000 (17:43 +0200)] 
conf: fix userns_exec_1()

A bit of context:
userns_exec_1() is only used to operate based on privileges for the user's own
{g,u}id on the host and for the container root's unmapped {g,u}id. This means
we require only to establish a mapping from:
- the container root {g,u}id as seen from the host -> user's host {g,u}id
- the container root -> some sub{g,u}id

This function however was buggy. It relied on some pointer pointing to the same
memory, namely specific idmap entries in the idmap list in the container's
in-memory configuration. However, due to a stupid mistake of mine, the pointers
to be compared pointed to freshly allocated memory. They were never pointing to
the intended memory locations. To reproduce what I'm talking about prior to
this commit simply place:

    chb:999:1000000000
    chb:999:1
    chb:1000:1

in /etc/sub{g,u}id then create a container which requests the following
idmappings:

    lxc.idmap = u 0 999 999
    lxc.idmap = g 0 999 1000000000

and start the container. What we *would expect* is for liblxc to establish the
following mapping:

    newuidmap <pid> 0 999 999
    newgidmap <pid> 0 999 1000000000

since all required mappings are present. Due to the buggy pointer comparisons
what happened was:

    newuidmap <pid> 0 999 999 0 999 999
    newgidmap <pid> 0 999 1000000000 0 999 1000000000

Let's fix this.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: do not log uninitialized memory
Christian Brauner [Tue, 5 Sep 2017 11:46:53 +0000 (13:46 +0200)] 
conf: do not log uninitialized memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: non-functional changes
Christian Brauner [Tue, 5 Sep 2017 10:19:28 +0000 (12:19 +0200)] 
conf: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: non-functional change
Christian Brauner [Wed, 30 Aug 2017 14:37:22 +0000 (16:37 +0200)] 
console: non-functional change

Remove executable bit.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1781 from brauner/stable-2.0
Stéphane Graber [Sun, 10 Sep 2017 17:59:55 +0000 (13:59 -0400)] 
Merge pull request #1781 from brauner/stable-2.0

stable 2.0: cherry-picks + delta reduction between master and stable 2.0

7 years agoconf: record idmap that gets written 1781/head
Christian Brauner [Tue, 5 Sep 2017 00:00:29 +0000 (02:00 +0200)] 
conf: record idmap that gets written

This will serve us well in the future!

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: document all handler fields
Christian Brauner [Mon, 4 Sep 2017 22:29:01 +0000 (00:29 +0200)] 
start: document all handler fields

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocriu: add cmp_version()
Federico Briata [Mon, 4 Sep 2017 10:16:35 +0000 (12:16 +0200)] 
criu: add cmp_version()

We cannot use strcmp(). Otherwise we incorrectly report e.g. that criu 2.12.1
is less than 2.8.

Signed-off-by: Federico Briata <federico-pietro.briata@cnhind.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: don't let data_sock users close the fd
Christian Brauner [Mon, 4 Sep 2017 12:48:37 +0000 (14:48 +0200)] 
start: don't let data_sock users close the fd

It is bad style to close an fd inside a function which didn't create it. Let's
rather close it transparently in start.c.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: don't send ttys when none are configured
Christian Brauner [Mon, 4 Sep 2017 12:35:02 +0000 (14:35 +0200)] 
conf: don't send ttys when none are configured

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: do not free static memory
Christian Brauner [Mon, 4 Sep 2017 11:26:40 +0000 (13:26 +0200)] 
conf: do not free static memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: switch from SOCK_DGRAM to SOCK_STREAM
Christian Brauner [Sun, 3 Sep 2017 23:27:30 +0000 (01:27 +0200)] 
start: switch from SOCK_DGRAM to SOCK_STREAM

Writes < PIPE_BUF will be atomic. PIPE_BUF is guaranteed to be 512 by POSIX and
Linux guarantess 4096. Nothing we send around goes over this limit.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: send ttys in batches of 2
Christian Brauner [Sun, 3 Sep 2017 23:27:04 +0000 (01:27 +0200)] 
conf: send ttys in batches of 2

I thought we could send all ttys at once but this limits the number of ttys
users can use because of iovec_len restrictions. So let's sent them in batches
of 2.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: simplify
Christian Brauner [Sun, 3 Sep 2017 18:49:54 +0000 (20:49 +0200)] 
lxc-user-nic: simplify

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: remove allocation from lxc_mkifname()
Christian Brauner [Sun, 3 Sep 2017 18:37:21 +0000 (20:37 +0200)] 
network: remove allocation from lxc_mkifname()

lxc_mkifname() really doesn't need to allocate any memory.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: fix grammar
Christian Brauner [Sun, 3 Sep 2017 15:08:23 +0000 (17:08 +0200)] 
network: fix grammar

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: user send()/recv()
Christian Brauner [Sun, 3 Sep 2017 14:51:54 +0000 (16:51 +0200)] 
network: user send()/recv()

Also move all functions to network.{c,h}.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agohandler: root -> am_root
Christian Brauner [Sun, 3 Sep 2017 14:44:41 +0000 (16:44 +0200)] 
handler: root -> am_root

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: bugfixes
Christian Brauner [Sun, 3 Sep 2017 14:40:11 +0000 (16:40 +0200)] 
lxc-user-nic: bugfixes

Since find_line() was changed before count_entries() started counting lines
wrong. It would report maximum reached before you actually reached your alloted
maximum.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: add lxc_nic_exists()
Christian Brauner [Sun, 3 Sep 2017 14:35:48 +0000 (16:35 +0200)] 
utils: add lxc_nic_exists()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: keep lines from other {users,links}
Christian Brauner [Sat, 2 Sep 2017 17:44:10 +0000 (19:44 +0200)] 
lxc-user-nic: keep lines from other {users,links}

Assume the db contained the following entries:

    chb veth lxcbr0 veth1
    chb veth lxcbr0 veth2
    chb veth lxdbr0 veth3
    chb veth lxdbr0 veth2
    didi veth lxcbr0 veth4

And you request

    cull_entries("chb", "veth", "lxdbr0", "veth3");

lxc-user-nic would wipe any entries that did not match irrespective of whether
they existed or not. Let's fix that.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: fix adding database entries
Christian Brauner [Sat, 2 Sep 2017 00:26:28 +0000 (02:26 +0200)] 
lxc-user-nic: fix adding database entries

The code before inserted \0-bytes after every new line which made the db
basically unusable.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: remove netpipe
Christian Brauner [Fri, 1 Sep 2017 20:33:21 +0000 (22:33 +0200)] 
network: remove netpipe

We use data_sock for all things we need to send around between parent and child
now. It doesn't make sense to have so many different pipes and sockets if one
will do just fine.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoCheck that there is netplan binary, rather than just just a config directory.
Dimitri John Ledkov [Thu, 31 Aug 2017 11:40:58 +0000 (12:40 +0100)] 
Check that there is netplan binary, rather than just just a config directory.

Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotemplates/ubuntu: support netplan in newer releases by default
Dimitri John Ledkov [Wed, 30 Aug 2017 12:45:27 +0000 (13:45 +0100)] 
templates/ubuntu: support netplan in newer releases by default

If netplan is present in the container, configure default networking
with neplan instead of ifupdown. Also, do not install ifupdown when
boostrapping minbase variant, unless using currently support
non-netplan releases (trusty, zenial, zesty).

Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agonetwork: use correct network device name
Christian Brauner [Fri, 1 Sep 2017 17:34:43 +0000 (19:34 +0200)] 
network: use correct network device name

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: stop recording saved physical net devices
Christian Brauner [Fri, 1 Sep 2017 14:44:46 +0000 (16:44 +0200)] 
network: stop recording saved physical net devices

liblxc will now correctly log any network device names and ifindeces in their
respective network namespaces. So there's no need to record physical network
devices any more. This spares us heap allocations and memory we need to have
lying around til the container is shutdown.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: retrieve correct names and ifindices
Christian Brauner [Fri, 1 Sep 2017 13:30:28 +0000 (15:30 +0200)] 
network: retrieve correct names and ifindices

On privileged network creation we only retrieved the names and ifindeces of
network devices in the host's network namespace. This meant that the monitor
process was acting on possibly incorrect information. With this commit we have
the child send back the correct device names and ifindeces in the container's
network namespace.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: non-functional changes
Christian Brauner [Fri, 1 Sep 2017 11:04:00 +0000 (13:04 +0200)] 
start: non-functional changes

This renames the socketpair() variable "ttysock" to "data_sock" since we will
use it to send arbitrary data around, not just ttys anymore.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: non-functional changes
Christian Brauner [Fri, 1 Sep 2017 10:54:43 +0000 (12:54 +0200)] 
network: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: use static memory for net device names
Christian Brauner [Thu, 31 Aug 2017 22:23:30 +0000 (00:23 +0200)] 
network: use static memory for net device names

All network devices can only be of size < IFNAMSIZ. So let's spare the useless
heap allocations and use static memory.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: initialize vars to silence gcc-7
Christian Brauner [Thu, 31 Aug 2017 21:13:44 +0000 (23:13 +0200)] 
lxc-user-nic: initialize vars to silence gcc-7

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: free memory and check for error
Christian Brauner [Thu, 31 Aug 2017 21:08:28 +0000 (23:08 +0200)] 
lxc-user-nic: free memory and check for error

- check for error on ifindex retrieval
- free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: non-functional changes
Christian Brauner [Thu, 31 Aug 2017 21:01:46 +0000 (23:01 +0200)] 
start: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: retrieve the host's veth device ifindex
Christian Brauner [Thu, 31 Aug 2017 20:58:30 +0000 (22:58 +0200)] 
network: retrieve the host's veth device ifindex

- Retrieve the host's veth device ifindex in the host's network namespace.
- Add a note why we retrieve the container's veth device ifindex in the host's
  network namespace.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: rework network creation
Christian Brauner [Thu, 31 Aug 2017 13:30:39 +0000 (15:30 +0200)] 
network: rework network creation

- On unprivileged veth network creation have lxc-user-nic send the names of the
  veth devices and their respective ifindeces. The advantage of retrieving this
  information from lxc-user-nic is that we spare us sending around more stuff
  via the netpipe in start.c. Also, lxc-user-nic operates in both namespaces
  (the container's namespace and the hosts's namespace) via setns and so is
  guaranteed to retrieve the correct ifindex via if_nametoindex() which is an
  network namespace aware ioctl() call. While I'm pretty sure the ifindeces for
  veth devices are identical across network namespaces I'm weary to rely on
  this. We need the ifindexes to guarantee safe deletion of unprivileged
  network devices via lxc-user-nic later on since we use them to identify the
  network devices in their corresponding network namespaces.
- Move the network device logging from the child to the parent. The child does
  not have all of the information about the network devices available only the
  few bits it actually needs to now. The monitor process is the only process
  that needs all this information.
- The network creation code for privileged and unprivileged networks was
  previously mangled into one single function but at the same time some of the
  privileged code had additional functions that were called in other places in
  start.c. Let's divide and conquer and split out the privileged and
  unprivileged network creation into completely separate functions. This makes
  what's happening way more clear. This will also have no performance impact
  since either you are privileged and only execute the privileged network
  creation functions or you are unprivileged and only execute the unprivileged
  network creation functions.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: log ifindex for host side veth device
Christian Brauner [Thu, 31 Aug 2017 13:25:16 +0000 (15:25 +0200)] 
network: log ifindex for host side veth device

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: document all fields in struct lxc_netdev
Christian Brauner [Thu, 31 Aug 2017 11:23:18 +0000 (13:23 +0200)] 
network: document all fields in struct lxc_netdev

This is menial work but I'll thank myself later... a lot.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: add ifindex field for host veth device
Christian Brauner [Thu, 31 Aug 2017 11:19:33 +0000 (13:19 +0200)] 
network: add ifindex field for host veth device

We should not just record the ifindex for the container's veth device but also
for the host's veth device. This is useful when {configuring,deconfiguring}
veth devices and becomes crucial when calling our lxc-user-nic setuid helper
where we rely on the ifindex to make decisions about whether we are licensed to
perform certain operations on the veth device in question.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: log veth_attr.pair and veth_attr.veth1
Christian Brauner [Thu, 31 Aug 2017 11:17:11 +0000 (13:17 +0200)] 
network: log veth_attr.pair and veth_attr.veth1

If the user specified lxc.net.[i].veth.pair attribute to request that the host
side of a veth pair be given a specific name let's log it at the trace level.
Otherwise, if the user didn't not specify lxc.net.[i].veth.pair veth_attr.veth1
will contain the name of the host side veth device.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: test privilege over netns on delete
Christian Brauner [Wed, 30 Aug 2017 23:32:39 +0000 (01:32 +0200)] 
lxc-user-nic: test privilege over netns on delete

When lxc-user-nic is called with the "delete" subcommand we need to make sure
that we are actually privileged over the network namespace for which we are
supposed to delete devices on the host. To this end we require that path to the
affected network namespace is passed. We then setns() to the network namespace
and drop privilege to the caller's real user id. Then we try to delete the
loopback interface which is not possible. If we are privileged over the network
namespace this operation will fail with ENOTSUP. If we are not privileged over
the network namespace we will get EPERM.

This is the first part of the commit. As of now nothing guarantees that the
caller does not just give us a random path to a network namespace it is
privileged over.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: remove delta between master + stable
Christian Brauner [Mon, 4 Sep 2017 10:49:52 +0000 (12:49 +0200)] 
lxc-user-nic: remove delta between master + stable

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1768 from brauner/2017-08-29/stable_2.0_cherry_picks
Stéphane Graber [Tue, 29 Aug 2017 21:22:31 +0000 (17:22 -0400)] 
Merge pull request #1768 from brauner/2017-08-29/stable_2.0_cherry_picks

stable 2.0: cherry picks

7 years agonetwork: non-functional changes 1768/head
Christian Brauner [Mon, 28 Aug 2017 10:23:29 +0000 (12:23 +0200)] 
network: non-functional changes

This moves all of the network handling code into network.{c,h}. This makes what
is going on much clearer. Also it's easier to find relevant code if it is all
in one place.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: increase lxc-user-nic buffer
Christian Brauner [Sun, 27 Aug 2017 12:48:52 +0000 (14:48 +0200)] 
conf: increase lxc-user-nic buffer

This will allow us log more detailed failures.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: check db before trying to delete
Christian Brauner [Sun, 27 Aug 2017 07:17:10 +0000 (09:17 +0200)] 
lxc-user-nic: check db before trying to delete

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: non-functional changes
Christian Brauner [Sun, 27 Aug 2017 13:03:16 +0000 (15:03 +0200)] 
lxc-user-nic: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: delete ovs for unprivileged networks
Christian Brauner [Sun, 27 Aug 2017 03:02:23 +0000 (05:02 +0200)] 
network: delete ovs for unprivileged networks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: log ifindex
Christian Brauner [Sun, 27 Aug 2017 03:01:14 +0000 (05:01 +0200)] 
network: log ifindex

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: send ifindex for unpriv networks
Christian Brauner [Sun, 27 Aug 2017 02:59:57 +0000 (04:59 +0200)] 
network: send ifindex for unpriv networks

We use the ifindex as an indicator that liblxc created the network so let's
record it for the unprivileged case as well.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: rework renaming net devices
Christian Brauner [Sat, 26 Aug 2017 22:39:17 +0000 (00:39 +0200)] 
lxc-user-nic: rework renaming net devices

This should make things a little less convoluted.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: adapt to lxc-user-nic usage
Christian Brauner [Sat, 26 Aug 2017 21:04:01 +0000 (23:04 +0200)] 
conf: adapt to lxc-user-nic usage

- lxc-user-nic gains the subcommands {create,delete}
- dup2() STDERR_FILENO as well so that we can show helpful messages in our logs
  on failure
- initialize output buffer so that we don't print garbage

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotests: adapt lxc-user-nic tests to new syntax
Christian Brauner [Sat, 26 Aug 2017 22:00:58 +0000 (00:00 +0200)] 
tests: adapt lxc-user-nic tests to new syntax

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: add new {create,delete} subcommands
Christian Brauner [Sat, 26 Aug 2017 21:16:03 +0000 (23:16 +0200)] 
lxc-user-nic: add new {create,delete} subcommands

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: fix memleak
Christian Brauner [Sat, 26 Aug 2017 21:10:18 +0000 (23:10 +0200)] 
lxc-user-nic: fix memleak

get_new_nicname() calls lxc_mkifname() which allocates memory and returns it to
the caller. The way get_new_nicname() and get_nic_if_avail() were implemented
they hid that fact by returning a boolean. That doesn't make sense. Let's
rather have them return a pointer to the allocated nic name which the caller
needs to free.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-user-nic: non-functional changes
Christian Brauner [Sat, 26 Aug 2017 16:53:29 +0000 (18:53 +0200)] 
lxc-user-nic: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgfsng: non-functional changes
Christian Brauner [Fri, 25 Aug 2017 07:52:14 +0000 (09:52 +0200)] 
cgfsng: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: do not deref null pointer
Christian Brauner [Sat, 26 Aug 2017 22:48:34 +0000 (00:48 +0200)] 
conf: do not deref null pointer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: non-functional changes
Christian Brauner [Sat, 26 Aug 2017 22:36:40 +0000 (00:36 +0200)] 
conf: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoattach: non-functional changes
Christian Brauner [Fri, 25 Aug 2017 05:35:02 +0000 (07:35 +0200)] 
attach: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: do not check union on wrong net type
Christian Brauner [Thu, 24 Aug 2017 22:02:47 +0000 (00:02 +0200)] 
conf: do not check union on wrong net type

This will obviously not work.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: refactor network deletion
Christian Brauner [Thu, 24 Aug 2017 14:10:30 +0000 (16:10 +0200)] 
conf: refactor network deletion

I'm ashamed at how aweful my previous code was.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoopenvswitch: delete ports intelligently
Christian Brauner [Thu, 24 Aug 2017 13:31:38 +0000 (15:31 +0200)] 
openvswitch: delete ports intelligently

So far, when creating veth devices attached to openvswitch bridges we used to
fork() off a thread on container startup. This thread was kept around until the
container shut down. I have no good explanation why we did it that why but it's
certainly not necessary. Instead, let's fork() off the thread on container
shutdown to delete the veth.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotemplates/ubuntu: conditionally move upstart ssh job, as it is now optional.
Dimitri John Ledkov [Tue, 29 Aug 2017 14:11:55 +0000 (15:11 +0100)] 
templates/ubuntu: conditionally move upstart ssh job, as it is now optional.

Mimic the code from the debian template.

Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
7 years agoarguments: non-functional changes
Christian Brauner [Fri, 25 Aug 2017 05:17:20 +0000 (07:17 +0200)] 
arguments: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoaf_unix: non-functional changes
Christian Brauner [Fri, 25 Aug 2017 05:11:26 +0000 (07:11 +0200)] 
af_unix: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agortnl: non-functional changes
Christian Brauner [Fri, 25 Aug 2017 05:07:43 +0000 (07:07 +0200)] 
rtnl: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: log lxc-user-nic output
Christian Brauner [Thu, 24 Aug 2017 11:43:15 +0000 (13:43 +0200)] 
conf: log lxc-user-nic output

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: non-functional changes
Christian Brauner [Thu, 24 Aug 2017 11:26:10 +0000 (13:26 +0200)] 
conf: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: log cleanup thread pid for openswitch
Christian Brauner [Wed, 23 Aug 2017 20:10:21 +0000 (22:10 +0200)] 
network: log cleanup thread pid for openswitch

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoUse deb.debian.org as the default Debian mirror
Salvatore Bonaccorso [Thu, 24 Aug 2017 07:24:29 +0000 (09:24 +0200)] 
Use deb.debian.org as the default Debian mirror

The httpredir.debian.org service has been discontinued in favour of
deb.debian.org and httpredir.debian.org now redirects to deb.debian.org.

https://lists.debian.org/debian-mirrors/2017/02/msg00000.html
https://wiki.debian.org/DebianGeoMirror#httpredir.debian.org_.2F_http.debian.net

Cf. https://bugs.debian.org/872719

Signed-off-by: Salvatore Bonaccorso <carnil@debian.org>
7 years agocgroups: non-functional changes
Christian Brauner [Wed, 23 Aug 2017 23:32:32 +0000 (01:32 +0200)] 
cgroups: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: non-functional fixup
Christian Brauner [Wed, 23 Aug 2017 11:08:02 +0000 (13:08 +0200)] 
conf: non-functional fixup

Surfaced while building lxc-2.0.8 on e2k architecture with lcc,
looks like its -Wall is more pedantic than gcc's:

lcc: "conf.c", line 1514: error: unrecognized character escape sequence
          [-Werror]
        DEBUG("created directory for console and tty devices at \%s\"", path);
                                                                ^
 in expansion of macro "DEBUG" at line 1514

Another byte is a leading whitespace fix while at that.

Signed-off-by: Michael Shigorin <mike@altlinux.org>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotools: add additional cgroup checks
Christian Brauner [Tue, 22 Aug 2017 12:22:21 +0000 (14:22 +0200)] 
tools: add additional cgroup checks

- list all cgroup v1 mountpoints
- list all cgroup v2 mountpoints
- report "missing" when no mountpoint for the systemd controller was found
- report "missing" when no mountpoint for the freezer controller was found

Closes https://github.com/lxc/lxd/issues/3687.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotools: use "which"
Christian Brauner [Mon, 21 Aug 2017 15:33:30 +0000 (17:33 +0200)] 
tools: use "which"

Somehow "type" doesn't really work.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoAdd CONFIG_NETFILTER_XT_MATCH_COMMENT to lxc-checkconfig
Stéphane Graber [Sat, 19 Aug 2017 16:28:46 +0000 (12:28 -0400)] 
Add CONFIG_NETFILTER_XT_MATCH_COMMENT to lxc-checkconfig

Closes https://github.com/lxc/lxd/issues/3685

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agoconfile: lxc_listconfigs -> lxc_list_config_items
Christian Brauner [Thu, 10 Aug 2017 22:19:10 +0000 (00:19 +0200)] 
confile: lxc_listconfigs -> lxc_list_config_items

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: non-functional changes
Christian Brauner [Thu, 10 Aug 2017 22:13:25 +0000 (00:13 +0200)] 
confile: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoRevert "debian: jessie and stretch keyring support"
Stéphane Graber [Fri, 11 Aug 2017 19:06:02 +0000 (15:06 -0400)] 
Revert "debian: jessie and stretch keyring support"

This reverts commit 87eacd4d49033d38d7e3257046079a77fd60e588.

While that commit looks right, the actual signing key doesn't match and
debootstrap therefore fails to bootstrap, as can be seen here:

https://jenkins.linuxcontainers.org/view/All/job/lxc-template-debian/

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agoFix mem leak with realpath
Shukui Yang [Fri, 11 Aug 2017 09:12:24 +0000 (17:12 +0800)] 
Fix mem leak with realpath

Signed-off-by: Shukui Yang <yangshukui@huawei.com>
7 years agoandroid: fix includes
Christian Brauner [Thu, 10 Aug 2017 21:00:12 +0000 (23:00 +0200)] 
android: fix includes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxccontainer: remove 5s timeout
Christian Brauner [Tue, 8 Aug 2017 19:48:48 +0000 (21:48 +0200)] 
lxccontainer: remove 5s timeout

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agodebian: jessie and stretch keyring support
有张纸 [Tue, 8 Aug 2017 10:06:38 +0000 (18:06 +0800)] 
debian: jessie and stretch keyring support

Signed-off-by: feng xiahou xiahoufeng@yahoo.com
7 years agodebian: Add buster as a valid release
Stéphane Graber [Mon, 7 Aug 2017 21:49:40 +0000 (17:49 -0400)] 
debian: Add buster as a valid release

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agostart: ensure cgroups are cleaned up
Christian Brauner [Thu, 3 Aug 2017 21:55:23 +0000 (23:55 +0200)] 
start: ensure cgroups are cleaned up

When a container is marked as being in STOPPED state it is possible for another
thread to start it again even though not all cleanup operations for that
container have finished. This is not a problem for most things like sockets and
friends which are unique to the container. It is however a problem for cgroups
which are named after that container in that we cause our cgroup driver to
waste cpu cycles finding a new cgroup name.

Closes  #1726.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>