|
| 1 | +#!/bin/ksh -p |
| 2 | +# SPDX-License-Identifier: CDDL-1.0 |
| 3 | +# |
| 4 | +# CDDL HEADER START |
| 5 | +# |
| 6 | +# This file and its contents are supplied under the terms of the |
| 7 | +# Common Development and Distribution License ("CDDL"), version 1.0. |
| 8 | +# You may only use this file in accordance with the terms of version |
| 9 | +# 1.0 of the CDDL. |
| 10 | +# |
| 11 | +# A full copy of the text of the CDDL should have accompanied this |
| 12 | +# source. A copy of the CDDL is also available via the Internet at |
| 13 | +# http://www.illumos.org/license/CDDL. |
| 14 | +# |
| 15 | +# CDDL HEADER END |
| 16 | +# |
| 17 | + |
| 18 | +# |
| 19 | +# Copyright (c) 2026 by Garth Snyder. All rights reserved. |
| 20 | +# |
| 21 | + |
| 22 | +. $STF_SUITE/tests/functional/send_xdr_encoding/send_xdr_encoding.kshlib |
| 23 | + |
| 24 | +# |
| 25 | +# Description: |
| 26 | +# A raw incremental send from a redaction bookmark on an encrypted dataset |
| 27 | +# (zfs send -w -i ds#book ds@snap) carries both BEGINNV_REDACT_FROM_SNAPS |
| 28 | +# and crypt_keydata in its DRR_BEGIN nvlist payload. Verify that this |
| 29 | +# combined payload is XDR-encoded and the stream can be received. |
| 30 | +# |
| 31 | +# Strategy: |
| 32 | +# 1. Create an encrypted source dataset with a redaction bookmark and a |
| 33 | +# later snapshot. |
| 34 | +# 2. Establish a raw base on the receiver via zfs send -w of the bookmark's |
| 35 | +# source snapshot. |
| 36 | +# 3. zfs send -w -i sendfs#book sendfs@s1 to a file. |
| 37 | +# 4. Verify that the resulting stream is XDR-encoded. |
| 38 | +# 5. Verify that the zfs receive succeeds. |
| 39 | +# |
| 40 | + |
| 41 | +verify_runnable "both" |
| 42 | + |
| 43 | +sendfs="$POOL/xdr_bookmark_raw_src" |
| 44 | +clonefs="$POOL/xdr_bookmark_raw_clone" |
| 45 | +recvfs="$POOL2/xdr_bookmark_raw_recv" |
| 46 | +keyfile="/$POOL/xdr_bookmark_raw.key" |
| 47 | +full_stream="/$POOL/xdr_bookmark_raw_full.zsend" |
| 48 | +incr_stream="/$POOL/xdr_bookmark_raw_incr.zsend" |
| 49 | + |
| 50 | +function cleanup |
| 51 | +{ |
| 52 | + datasetexists $sendfs && destroy_dataset $sendfs -R |
| 53 | + datasetexists $recvfs && destroy_dataset $recvfs -R |
| 54 | + rm -f $keyfile $full_stream $incr_stream |
| 55 | +} |
| 56 | +log_onexit cleanup |
| 57 | + |
| 58 | +log_assert "BEGIN nvlist of a raw incremental from a redaction bookmark is " \ |
| 59 | + "XDR-encoded and receivable" |
| 60 | + |
| 61 | +log_must eval "echo 'thisisapassphrase' > $keyfile" |
| 62 | +log_must zfs create -o encryption=on -o keyformat=passphrase \ |
| 63 | + -o keylocation=file://$keyfile $sendfs |
| 64 | + |
| 65 | +log_must dd if=/dev/urandom of=/$sendfs/f1 bs=128k count=8 status=none |
| 66 | +log_must dd if=/dev/urandom of=/$sendfs/f2 bs=128k count=8 status=none |
| 67 | +log_must zfs snapshot $sendfs@s0 |
| 68 | + |
| 69 | +# The clone inherits encryption from $sendfs. |
| 70 | +log_must zfs clone $sendfs@s0 $clonefs |
| 71 | +log_must dd if=/dev/urandom of=/$clonefs/f1 bs=128k count=8 conv=notrunc \ |
| 72 | + status=none |
| 73 | +log_must zfs snapshot $clonefs@s |
| 74 | + |
| 75 | +log_must zfs redact $sendfs@s0 redaction-bookmark $clonefs@s |
| 76 | + |
| 77 | +# Take @s1 with no intervening writes. See xdr_bookmark_raw_with_write.ksh |
| 78 | +# for a variant that includes a post-redact write; that variant exercises |
| 79 | +# a known kernel-side issue (#18491) and may flake. |
| 80 | +log_must zfs snapshot $sendfs@s1 |
| 81 | + |
| 82 | +# Establish a raw base on the receiver. |
| 83 | +log_must eval "zfs send -w $sendfs@s0 > $full_stream" |
| 84 | +log_must eval "zfs receive $recvfs < $full_stream" |
| 85 | + |
| 86 | +# Raw incremental from the redaction bookmark. This is the test focus. |
| 87 | +log_must eval "zfs send -w -i $sendfs#redaction-bookmark $sendfs@s1 > \ |
| 88 | + $incr_stream" |
| 89 | +verify_xdr_nvlist_encoding $incr_stream |
| 90 | +log_must eval "zfs receive $recvfs < $incr_stream" |
| 91 | + |
| 92 | +log_pass "BEGIN nvlist of a raw incremental from a redaction bookmark is " \ |
| 93 | + "XDR-encoded and receivable" |
0 commit comments