As network namespaces tests (ltp/testcases/kernel/containers/netns) code is
a bit messy and it's hard to figure out how return values are passed in the code
I propose to remove all test cases and leave only the ones specified below.


netns structure:
================
* netns_helper.h

* netns_helper.sh - interface creation (each in a separate network NS)
                  - cleanup() function
                  - without IP setup (each test case will have its own)

* netns_isolation.sh
* netns_isolation_6.sh - the same as netns_isolation.sh but ipv6

* netns_devices.sh
* netns_devices_6.sh - the same as netns_devices.sh but ipv6

* netns_devices2.sh
* netns_devices2_6.sh - the same as netns_devices2.sh but ipv6

* netns_netlink.c

Above testcases covers all of the tests in the original code and everything else
in the original code doesn't exercise new code paths in the kernel. IPv6 
versions
of the three specified tests will be added if this proposal is approved.
Also test names may change to better reflect the purpose of the tests.


Implementation:
===============
As ip command cannot be used (because of older systems), we can use this generic
functions to create/delete namespace handle:

#!/bin/sh

# requirement: calling tst_tmpdir() before
# example: ns1=$(ns_create_handle net)
ns_create_handle()
{
        local handle

        if [ -z "$1" ]; then
                echo "first argument must be a namespace type"
                return 1
        fi

        handle=$(mktemp ns.XXX)

        case "$1" in
        ipc|mount|net|pid|uts|user);;
        *) rm -f $handle; return 1 ;;
        esac

        unshare "--$1" mount --bind "/proc/self/ns/$1" "$handle" || return 1
        echo $handle
        return 0
}

# then run COMMAND inside the namespace referred by the handle $ns1:
# nsenter "--net=$ns1" COMMAND [ARGUMENTS]

# example: ns_remove_handle $ns1
ns_remove_handle()
{
        if [ -z "$1" ]; then
                echo "first argument must be a name of a namespace"
                return 1
        fi

        umount $1
        rm -f $1
        return 0
}

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to