1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2022 Petr Vorel <[email protected]> 4# Copyright (c) Köry Maincent <[email protected]> 2020 5# Copyright (c) 2015 Red Hat, Inc. 6# 7# Tests that a separate network namespace can configure and communicate 8# over the devices it sees. Tests are done using netlink(7) ('ip' command) 9# or ioctl(2) ('ifconfig' command) for controlling devices. 10# 11# There are three test cases: 12# 1,2. communication over paired veth (virtual ethernet) devices 13# from two different network namespaces (each namespace has 14# one device) 15# 3. communication over the lo (localhost) device in a separate 16# network namespace 17 18TST_TESTFUNC="do_test" 19 20do_test() 21{ 22 local ip_lo="127.0.0.1" 23 [ "$TST_IPV6" ] && ip_lo="::1" 24 25 EXPECT_PASS $NS_EXEC $NS_HANDLE0 $NS_TYPE $tping -q -c2 -I veth0 $IP1 1>/dev/null 26 EXPECT_PASS $NS_EXEC $NS_HANDLE1 $NS_TYPE $tping -q -c2 -I veth1 $IP0 1>/dev/null 27 28 if [ "$COMM_TYPE" = "netlink" ]; then 29 ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ip link set dev lo up 30 else 31 ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig lo up 32 fi 33 34 EXPECT_PASS $NS_EXEC $NS_HANDLE0 $NS_TYPE $tping -q -c2 -I lo $ip_lo 1>/dev/null 35} 36 37. netns_lib.sh 38tst_run 39