xref: /illumos-gate/usr/src/test/util-tests/tests/dladm/show-overlay-exit.ksh (revision 29ed14768e5e76bb8c95f0a28b4d21d8741dfabe)
1*29ed1476SIsaac Davis#!/bin/ksh
2*29ed1476SIsaac Davis#
3*29ed1476SIsaac Davis# This file and its contents are supplied under the terms of the
4*29ed1476SIsaac Davis# Common Development and Distribution License ("CDDL"), version 1.0.
5*29ed1476SIsaac Davis# You may only use this file in accordance with the terms of version
6*29ed1476SIsaac Davis# 1.0 of the CDDL.
7*29ed1476SIsaac Davis#
8*29ed1476SIsaac Davis# A full copy of the text of the CDDL should have accompanied this
9*29ed1476SIsaac Davis# source.  A copy of the CDDL is also available via the Internet at
10*29ed1476SIsaac Davis# http://www.illumos.org/license/CDDL.
11*29ed1476SIsaac Davis#
12*29ed1476SIsaac Davis
13*29ed1476SIsaac Davis#
14*29ed1476SIsaac Davis# Copyright (c) 2017, Joyent, Inc.
15*29ed1476SIsaac Davis# Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
16*29ed1476SIsaac Davis#
17*29ed1476SIsaac Davis
18*29ed1476SIsaac Davissoe_arg0="$(basename $0)"
19*29ed1476SIsaac Davis
20*29ed1476SIsaac Davissoe_overlay="soe_overlay$$"
21*29ed1476SIsaac Davissoe_dummy_ip="169.254.0.0"
22*29ed1476SIsaac Davis
23*29ed1476SIsaac Davissoe_port="2000"
24*29ed1476SIsaac Davissoe_vnetid=20
25*29ed1476SIsaac Davissoe_encap="vxlan"
26*29ed1476SIsaac Davissoe_search="direct"
27*29ed1476SIsaac Davis
28*29ed1476SIsaac Davissoe_etherstub="soe_teststub$$"
29*29ed1476SIsaac Davis
30*29ed1476SIsaac Davisfunction fatal
31*29ed1476SIsaac Davis{
32*29ed1476SIsaac Davis	typeset msg="$*"
33*29ed1476SIsaac Davis	[[ -z "$msg" ]] && msg="failed"
34*29ed1476SIsaac Davis	echo "TEST_FAIL: $vt_arg0: $msg" >&2
35*29ed1476SIsaac Davis	dladm delete-overlay $soe_overlay
36*29ed1476SIsaac Davis	dladm delete-etherstub $soe_etherstub
37*29ed1476SIsaac Davis	exit 1
38*29ed1476SIsaac Davis}
39*29ed1476SIsaac Davis
40*29ed1476SIsaac Davisfunction setup
41*29ed1476SIsaac Davis{
42*29ed1476SIsaac Davis	dladm create-overlay -t -v $soe_vnetid -e $soe_encap -s $soe_search \
43*29ed1476SIsaac Davis	    -p vxlan/listen_ip=$soe_dummy_ip -p direct/dest_ip=$soe_dummy_ip \
44*29ed1476SIsaac Davis	    -p direct/dest_port=$soe_port $soe_overlay || \
45*29ed1476SIsaac Davis	    fatal "failed to create overlay"
46*29ed1476SIsaac Davis
47*29ed1476SIsaac Davis	dladm create-etherstub $soe_etherstub || \
48*29ed1476SIsaac Davis	    fatal "failed to create etherstub"
49*29ed1476SIsaac Davis}
50*29ed1476SIsaac Davis
51*29ed1476SIsaac Davisfunction cleanup
52*29ed1476SIsaac Davis{
53*29ed1476SIsaac Davis	dladm delete-overlay $soe_overlay || \
54*29ed1476SIsaac Davis	    fatal "failed to remove overlay"
55*29ed1476SIsaac Davis	dladm delete-etherstub $soe_etherstub || \
56*29ed1476SIsaac Davis	    fatal "failed to remove etherstub"
57*29ed1476SIsaac Davis}
58*29ed1476SIsaac Davis
59*29ed1476SIsaac Davisfunction runtest
60*29ed1476SIsaac Davis{
61*29ed1476SIsaac Davis	dladm show-overlay $* > /dev/null 2>&1
62*29ed1476SIsaac Davis}
63*29ed1476SIsaac Davis
64*29ed1476SIsaac Davisfunction epass
65*29ed1476SIsaac Davis{
66*29ed1476SIsaac Davis	runtest $* || fatal "show-overlay=$* failed, expected success\n"
67*29ed1476SIsaac Davis}
68*29ed1476SIsaac Davis
69*29ed1476SIsaac Davisfunction efail
70*29ed1476SIsaac Davis{
71*29ed1476SIsaac Davis	runtest $* && fatal "show-overlay=$* succeeded, expected failure\n"
72*29ed1476SIsaac Davis}
73*29ed1476SIsaac Davis
74*29ed1476SIsaac Davissetup
75*29ed1476SIsaac Davis
76*29ed1476SIsaac Davisepass $soe_overlay
77*29ed1476SIsaac Davisefail $soe_etherstub
78*29ed1476SIsaac Davisefail $soe_etherstub $soe_overlay
79*29ed1476SIsaac Davisefail $soe_overlay $soe_etherstub
80*29ed1476SIsaac Davis
81*29ed1476SIsaac Daviscleanup
82*29ed1476SIsaac Davis
83*29ed1476SIsaac Davisprint "TEST PASS: $soe_arg0"
84