• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) Köry Maincent <kory.maincent@bootlin.com> 2020
4# Copyright (c) 2015 Red Hat, Inc.
5#
6# SYNOPSIS:
7# netns_breakns.sh <NS_EXEC_PROGRAM> <IP_VERSION> <COMM_TYPE>
8#
9# OPTIONS:
10#	* NS_EXEC_PROGRAM (ns_exec|ip)
11#		Program which will be used to enter and run other commands
12#		inside a network namespace.
13#	* IP_VERSION (ipv4|ipv6)
14#		Version of IP. (ipv4|ipv6)
15#	* COMM_TYPE (netlink|ioctl)
16#		Communication type between kernel and user space
17#		for basic setup: enabling and assigning IP addresses
18#		to the virtual ethernet devices. (Uses 'ip' command for netlink
19#		and 'ifconfig' for ioctl.)
20#
21# Tests communication with ip (uses netlink) and ifconfig (uses ioctl)
22# over a device which is not visible from the current network namespace.
23#
24# There are two test cases which are trying to set an ip address on the veth1
25# device which is not inside the network namespace referred to by NS_HANDLE0:
26# 1. using netlink (ip command).
27# 2. using ioctl (ifconfig command).
28
29TST_POS_ARGS=3
30TST_SETUP=do_setup
31TST_TESTFUNC=do_test
32. netns_helper.sh
33
34PROG=$1
35IP_VER=$2
36COM_TYPE=$3
37
38do_setup()
39{
40	netns_setup $PROG $IP_VER $COM_TYPE "192.168.0.2" "192.168.0.3" "fd00::2" "fd00::3"
41	tst_res TINFO "NS interaction: $PROG | devices setup: $COM_TYPE"
42}
43
44do_test()
45{
46	EXPECT_FAIL $NS_EXEC $NS_HANDLE0 $NS_TYPE ip address add $IP1/$NETMASK dev veth1
47
48	tst_require_cmds ifconfig
49	EXPECT_FAIL $NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig veth1 $IFCONF_IN6_ARG $IP1/$NETMASK
50}
51
52tst_run
53