1#!/bin/sh 2#============================================================================== 3# Copyright (c) 2015 Red Hat, Inc. 4# 5# This program is free software: you can redistribute it and/or modify 6# it under the terms of version 2 the GNU General Public License as 7# published by the Free Software Foundation. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# 17# Written by Matus Marhefka <mmarhefk@redhat.com> 18# 19#============================================================================== 20# 21# SYNOPSIS: 22# netns_breakns.sh <NS_EXEC_PROGRAM> <IP_VERSION> <COMM_TYPE> 23# 24# OPTIONS: 25# * NS_EXEC_PROGRAM (ns_exec|ip) 26# Program which will be used to enter and run other commands 27# inside a network namespace. 28# * IP_VERSION (ipv4|ipv6) 29# Version of IP. (ipv4|ipv6) 30# * COMM_TYPE (netlink|ioctl) 31# Communication type between kernel and user space 32# for basic setup: enabling and assigning IP addresses 33# to the virtual ethernet devices. (Uses 'ip' command for netlink 34# and 'ifconfig' for ioctl.) 35# 36# Tests communication with ip (uses netlink) and ifconfig (uses ioctl) 37# over a device which is not visible from the current network namespace. 38# 39# There are two test cases which are trying to set an ip address on the veth1 40# device which is not inside the network namespace referred to by NS_HANDLE0: 41# 1. using netlink (ip command). 42# 2. using ioctl (ifconfig command). 43#============================================================================== 44 45TCID="netns_breakns_$1_$2_$3" 46TST_TOTAL=2 47. netns_helper.sh 48 49# SETUP 50netns_setup $1 $2 $3 "192.168.0.2" "192.168.0.3" "fd00::2" "fd00::3" 51tst_resm TINFO "NS interaction: $1 | devices setup: $3" 52 53 54# TEST CASE #1 55$NS_EXEC $NS_HANDLE0 $NS_TYPE ip address add $IP1/$NETMASK dev veth1 2>/dev/null 56if [ $? -ne 0 ]; then 57 tst_resm TPASS "controlling device over netlink" 58else 59 tst_resm TFAIL "controlling device over netlink" 60fi 61 62 63# TEST CASE #2 64tst_require_cmds ifconfig 65$NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig veth1 $IFCONF_IN6_ARG $IP1/$NETMASK 2>/dev/null 66if [ $? -ne 0 ]; then 67 tst_resm TPASS "controlling device over ioctl" 68else 69 tst_resm TFAIL "controlling device over ioctl" 70fi 71 72 73tst_exit 74