NetTestSlave: remount sysfs in new net namespace

Creating a new network namespace does not change the contents of the
sysfs filesystem which makes it unusable for network configuration
purposes. This patch fixes that by creating a new mount namespace and
remounting the sysfs filesystem.

This also means that we don't need to use iproute2 to create Bonding
interfaces anymore.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
ConnectionHandler: check specific connections

This patch extends the ConnectionHandler class with functionality to
check specific connections for new messages instead of always checking
all of them.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
schema-recipe: add support for veth interfaces

This patch adds recipe XML support for veth interfaces. Since veth
devices are created in pairs, XML specification reflects this by
encapsulating two <veth> tags in a single <veth_pair> tag. Both of these
tags are mandatory. At the moment there are no <options> supported - you
can specify them, but they will be ignored.

Example interface specification would look something like this:

<interfaces>
    <eth id="out_if" label="tnet"/>
    <veth_pair>
        <veth id="testifc1" netns="xyz">
            <addresses>
                <address value="192.168.200.2/24"/>
            </addresses>
        </veth>
        <veth id="testifc2"/>
    </veth_pair>
    <bridge id="br">
        <slaves>
            <slave id="out_if"/>
            <slave id="testifc2"/>
        </slaves>
    </bridge>
</interfaces>

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
RecipeParser: support parsing veth interfaces

The _process_interface method now returns a list of parsed interfaces.
This is because when parsing the veth_pair tag the method parses both
child veth tags and returns 2 interfaces at once. Both interfaces
contain a reference (by id) to their peer.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestSlave: extend communication options between namespaces

The ServerHandler class now supports retrieving messages from a
specified connection. And the NetTestSlave class now supports waiting
for a response from a specified connection using the ServerHandler
method.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestSlave: make return_if_netns method recursive

This patch makes the 'return_if_netns' slave method recursive - the
controller always calls it in the root namespace which will reroute the
method to the specific namespace that the device was moved into. In
addition the InterfaceManager class will not remove Device objects if
they're moved to a namespace (_netns attribute != None) or if they have
a configuration object associated with them. This works around a bug on
older kernels that generate RTM_DELLINK messages for slave devices when
removing the master device (e.g. bridge).

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
*ConfigDevice: split device creation and configuration

This patch splits the device creation (destruction) part of  configure
(deconfigure) method of ConfigDevice objects into it's own separate
method create (destroy). This split is usefull mostly for configuring
veth devices, however to keep the code consistent I changed all other
device types as well.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
*ConfigDevice: add VEth classes

This patch adds the classes NetConfigDeviceVEth and NmConfigDeviceVEth.
That represent configuration of veth type devices. Since NM doesn't
support veth devices, the NmConfigDeviceVEth class just to defines the
is_nm_managed method.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestSlave: add methods {create, deconfigure}_if_pair

These two new methods are used to create paired interfaces, such as
veth. Since these devices are created together LNST representation of
the devices needs to reflect that. After device creation the method also
takes care of moving the devices to the correct network namespaces.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Machine: Interface class veth support

This patch adds support for configuring veth interfaces from the
Interface class and its subclass SoftInterface. The most important
changes are in the configure and deconfigure methods.

When configuring a veth interface we call a new slave method
'create_if_pair' that creates and configures both of the paired
interfaces. The first of the configured interfaces also marks the second
one as configured so it skiped.

Deconfiguration follows a similar pattern  by calling the
'deconfigure_if_pair' method.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
From: Ondrej Lichtner <olichtne@redhat.com>

The following set of patches further improves network namespace support in
LNST.

Most of the patch set implements support for veth devices. Since veth devices
are always created in pairs they're represented a bit differently in the recipe
XML - by encompasing two <veth> tags within a <veth_pair> tag.

The first patch of the set also takes care of remounting sysfs on namespace
creation which makes it usable for configuration again.

Example recipe with veth devices:
<lnstrecipe>
    <network>
        <host id="testmachine1">
            <interfaces>
                <eth id="out_if" label="tnet"/>
                <veth_pair>
                    <veth id="testifc1" netns="xyz">
                        <addresses>
                            <address value="192.168.200.2/24"/>
                        </addresses>
                    </veth>
                    <veth id="testifc2"/>
                </veth_pair>
                <bridge id="br">
                    <slaves>
                        <slave id="out_if"/>
                        <slave id="testifc2"/>
                    </slaves>
                </bridge>
            </interfaces>
        </host>

        <host id="testmachine2">
            <interfaces>
                <eth id="testifc2" label="tnet">
                    <addresses>
                        <address value="192.168.200.3/24"/>
                    </addresses>
                </eth>
            </interfaces>
        </host>
    </network>

    <task>
        <run host="testmachine1" module="IcmpPing" netns="xyz">
            <options>
                <option name="addr" value="{ip(testmachine2,testifc2)}"/>
                <option name="count" value="40"/>
                <option name="interval" value="1"/>
            </options>
        </run>
    </task>
</lnstrecipe>