Skip to content

Commit

Permalink
net: use LTP ns_create/ns_exec
Browse files Browse the repository at this point in the history
* support OS with legacy iproute

* more flexible control over netns and have persistent NFS
  mounts inside ltp_ns namespace

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
  • Loading branch information
akodanev committed Jun 6, 2017
1 parent 7a1e726 commit 3fb501e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions testcases/lib/test_net.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2014-2016 Oracle and/or its affiliates. All Rights Reserved.
# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
# Copyright (c) 2016-2017 Petr Vorel <pvorel@suse.cz>
#
# This program is free software; you can redistribute it and/or
Expand All @@ -23,18 +23,26 @@

init_ltp_netspace()
{
local pid=

if [ ! -f /var/run/netns/ltp_ns ]; then
ROD ip net add ltp_ns
ROD ip li add name ltp_ns_veth1 type veth peer name ltp_ns_veth2
ROD ip li set dev ltp_ns_veth1 netns ltp_ns
ROD ip netns exec ltp_ns ip li set lo up
pid="$(ROD ns_create net,mnt)"
mkdir -p /var/run/netns
ROD ln -s /proc/$pid/ns/net /var/run/netns/ltp_ns
ROD ns_exec $pid net,mnt mount --make-rprivate /sys
ROD ns_exec $pid net,mnt mount -t sysfs none /sys
ROD ns_ifmove ltp_ns_veth1 $pid
ROD ns_exec $pid net,mnt ip li set lo up
fi

LHOST_IFACES="${LHOST_IFACES:-ltp_ns_veth2}"
RHOST_IFACES="${RHOST_IFACES:-ltp_ns_veth1}"

export TST_INIT_NETNS="no"
export LTP_NETNS="${LTP_NETNS:-ip netns exec ltp_ns}"

pid="$(echo $(readlink /var/run/netns/ltp_ns) | cut -f3 -d'/')"
export LTP_NETNS="${LTP_NETNS:-ns_exec $pid net,mnt}"

tst_restore_ipaddr
tst_restore_ipaddr rhost
Expand Down

0 comments on commit 3fb501e

Please sign in to comment.