History log of /external/ltp/testcases/kernel/containers/share/ns_exec.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
0eb8985098758972c8e3fc2291b2f080be3b9f54 07-Oct-2015 Matus Marhefka <mmarhefk@redhat.com> containers/share: added namespaces types argument for ns_exec

In contrast with all other namespaces, joining the same user namespace
returns EINVAL. Because of that ns_exec now requires to specify the list
of types of namespaces in which to execute a program. The list of a comma
separated namespaces should be in the same order as list specified for
ns_create.

All testcases in containers/netns were modified to use namespaces types
argument when executing ns_create and ns_exec.

netns/netns_sysfs.sh:
* renamed "dummy0" to less common name "dummy_test0"
* /sys is now correctly mounted as private in a new namespace before
testing to not affect main mount namespace
* added test case which checks that only localhost and dummy interfaces
are seen in /sys/class/net/ after mounting sysfs in a new namespace

Signed-off-by: Matus Marhefka <mmarhefk@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/testcases/kernel/containers/share/ns_exec.c
433308eb5cdf376da630629363272aeac837b1e6 01-Sep-2015 Cyril Hrubis <chrubis@suse.cz> containers/share/ns_exec: Disable joining user ns

Disable joining user namespace for now, since it fails with EINVAL on
some kernels (as we attempt to join namespace we are allready in).

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/testcases/kernel/containers/share/ns_exec.c
39ef6df9cbe25279aded8ea3032b8f413267f8e1 18-Aug-2015 Matus Marhefka <mmarhefk@redhat.com> added helper tools for creating and working with namespaces

This patch introduces helper tools for creating and working
with namespaces (ltp/testcases/kernel/containers/share) and
also includes documentation (ltp/doc/namespaces-helper-tools.txt):

* ns_create:
Creates a child process in the new specified namespace(s),
child is then daemonized and is running in the background.
PID of the daemonized child process is printed on the stdout.
As the new namespace(s) is(are) maintained by the daemonized
child process it(they) can be removed by killing this process.
* ns_exec:
Enters the namespace(s) of a process specified by a PID and
then executes the indicated program inside that namespace(s).
* ns_ifmove:
Moves a network interface to the namespace of a process
specified by a PID.

Example usage:
==============
$ myns=$(ns_create net ipc)

$ ip link add veth0 type veth peer name veth1
$ ns_exec $myns ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

$ ns_ifmove veth1 $myns
$ ns_exec $myns ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
6: veth1: <BROADCAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 6a:0a:45:ed:6e:d0 brd ff:ff:ff:ff:ff:ff

$ ip link del veth0
$ kill -9 $myns
==============

The only requirement from kernel side is the support of "setns"
syscall. There is no need to have util-linux (unshare, nsenter)
installed. This way test cases utilizing namespaces can be
executed even on older kernels which do not provide required
tools for working with namespaces.

Signed-off-by: Matus Marhefka <mmarhefk@redhat.com>
/external/ltp/testcases/kernel/containers/share/ns_exec.c