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