1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2020, Felix Dörre
25#
26
27. $STF_SUITE/include/libtest.shlib
28
29#
30# DESCRIPTION:
31# Verify that NFS share options including ipv6 literals are parsed and propagated correctly.
32#
33
34verify_runnable "global"
35
36function cleanup
37{
38	log_must zfs set sharenfs=off $TESTPOOL/$TESTFS
39	is_shared $TESTPOOL/$TESTFS && \
40		log_must unshare_fs $TESTPOOL/$TESTFS
41}
42
43log_onexit cleanup
44
45cleanup
46
47log_must zfs set sharenfs="rw=[::1]" $TESTPOOL/$TESTFS
48output=$(showshares_nfs 2>&1)
49log_must grep "::1(" <<< "$output" > /dev/null
50
51log_must zfs set sharenfs="rw=[2::3]" $TESTPOOL/$TESTFS
52output=$(showshares_nfs 2>&1)
53log_must grep "2::3(" <<< "$output" > /dev/null
54
55log_must zfs set sharenfs="rw=[::1]:[2::3]" $TESTPOOL/$TESTFS
56output=$(showshares_nfs 2>&1)
57log_must grep "::1(" <<< "$output" > /dev/null
58log_must grep "2::3(" <<< "$output" > /dev/null
59
60log_must zfs set sharenfs="rw=[::1]/64" $TESTPOOL/$TESTFS
61output=$(showshares_nfs 2>&1)
62log_must grep "::1/64(" <<< "$output" > /dev/null
63
64log_must zfs set sharenfs="rw=[2::3]/128" $TESTPOOL/$TESTFS
65output=$(showshares_nfs 2>&1)
66log_must grep "2::3/128(" <<< "$output" > /dev/null
67
68log_must zfs set sharenfs="rw=[::1]/32:[2::3]/128" $TESTPOOL/$TESTFS
69output=$(showshares_nfs 2>&1)
70log_must grep "::1/32(" <<< "$output" > /dev/null
71log_must grep "2::3/128(" <<< "$output" > /dev/null
72
73log_must zfs set sharenfs="rw=[::1]:[2::3]/64:[2a01:1234:1234:1234:aa34:234:1234:1234]:1.2.3.4/24" $TESTPOOL/$TESTFS
74output=$(showshares_nfs 2>&1)
75log_must grep "::1(" <<< "$output" > /dev/null
76log_must grep "2::3/64(" <<< "$output" > /dev/null
77log_must grep "2a01:1234:1234:1234:aa34:234:1234:1234(" <<< "$output" > /dev/null
78log_must grep "1\\.2\\.3\\.4/24(" <<< "$output" > /dev/null
79
80log_pass "NFS share ip address propagated correctly."
81