-
Notifications
You must be signed in to change notification settings - Fork 2k
Consistently encode DRR_BEGIN packed nvlist payloads with NV_ENCODE_XDR #18372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,481
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/zfs-tests/tests/functional/send_xdr_encoding/cleanup.ksh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/bin/ksh -p | ||
| # SPDX-License-Identifier: CDDL-1.0 | ||
| # | ||
| # CDDL HEADER START | ||
| # | ||
| # This file and its contents are supplied under the terms of the | ||
| # Common Development and Distribution License ("CDDL"), version 1.0. | ||
| # You may only use this file in accordance with the terms of version | ||
| # 1.0 of the CDDL. | ||
| # | ||
| # A full copy of the text of the CDDL should have accompanied this | ||
| # source. A copy of the CDDL is also available via the Internet at | ||
| # http://www.illumos.org/license/CDDL. | ||
| # | ||
| # CDDL HEADER END | ||
| # | ||
|
|
||
| # | ||
| # Copyright (c) 2026 by Garth Snyder. All rights reserved. | ||
| # | ||
|
|
||
| . $STF_SUITE/tests/functional/send_xdr_encoding/send_xdr_encoding.kshlib | ||
|
|
||
| destroy_pool $POOL | ||
| destroy_pool $POOL2 | ||
|
|
||
| log_pass |
25 changes: 25 additions & 0 deletions
25
tests/zfs-tests/tests/functional/send_xdr_encoding/send_xdr_encoding.cfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # SPDX-License-Identifier: CDDL-1.0 | ||
| # | ||
| # CDDL HEADER START | ||
| # | ||
| # This file and its contents are supplied under the terms of the | ||
| # Common Development and Distribution License ("CDDL"), version 1.0. | ||
| # You may only use this file in accordance with the terms of version | ||
| # 1.0 of the CDDL. | ||
| # | ||
| # A full copy of the text of the CDDL should have accompanied this | ||
| # source. A copy of the CDDL is also available via the Internet at | ||
| # http://www.illumos.org/license/CDDL. | ||
| # | ||
| # CDDL HEADER END | ||
| # | ||
|
|
||
| # | ||
| # Copyright (c) 2026 by Garth Snyder. All rights reserved. | ||
| # | ||
|
|
||
| read -r DISK1 DISK2 _ <<<"$DISKS" | ||
| export DISK1 DISK2 | ||
|
|
||
| export POOL=$TESTPOOL | ||
| export POOL2=$TESTPOOL2 |
71 changes: 71 additions & 0 deletions
71
tests/zfs-tests/tests/functional/send_xdr_encoding/send_xdr_encoding.kshlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/bin/ksh | ||
| # SPDX-License-Identifier: CDDL-1.0 | ||
| # | ||
| # CDDL HEADER START | ||
| # | ||
| # This file and its contents are supplied under the terms of the | ||
| # Common Development and Distribution License ("CDDL"), version 1.0. | ||
| # You may only use this file in accordance with the terms of version | ||
| # 1.0 of the CDDL. | ||
| # | ||
| # A full copy of the text of the CDDL should have accompanied this | ||
| # source. A copy of the CDDL is also available via the Internet at | ||
| # http://www.illumos.org/license/CDDL. | ||
| # | ||
| # CDDL HEADER END | ||
| # | ||
|
|
||
| # | ||
| # Copyright (c) 2026 by Garth Snyder. All rights reserved. | ||
| # | ||
|
|
||
| . $STF_SUITE/include/libtest.shlib | ||
| . $STF_SUITE/tests/functional/send_xdr_encoding/send_xdr_encoding.cfg | ||
|
|
||
| # | ||
| # Verify that the DRR_BEGIN records in the given send stream encode their | ||
| # nvlist payloads with NV_ENCODE_XDR (and not NV_ENCODE_NATIVE). | ||
| # | ||
| # DRR_BEGIN records that carry an nvlist payload (raw sends, redacted sends, | ||
| # resumed sends, and combinations thereof) must encode that payload with | ||
| # NV_ENCODE_XDR so the resulting stream can be portably consumed across | ||
| # endianness. Encoding the payload with NV_ENCODE_NATIVE produces a stream | ||
| # that is unreadable on a receiver of the opposite endianness. | ||
| # | ||
| # zstream dump prints a single "nvlist encoding = ..." line per DRR_BEGIN | ||
| # record that carries an nvlist payload. The possible values are: | ||
| # | ||
| # NV_ENCODE_XDR | ||
| # NV_ENCODE_NATIVE (big-endian) | ||
| # NV_ENCODE_NATIVE (little-endian) | ||
| # | ||
| # Every test in this suite generates a stream whose DRR_BEGIN record | ||
| # carries an nvlist payload, so the pass criterion is: | ||
| # | ||
| # - At least one NV_ENCODE_XDR line appears, AND | ||
| # - No NV_ENCODE_NATIVE line appears. | ||
| # | ||
| # Requiring at least one XDR line catches the case where zstream dump | ||
| # itself fails before producing any encoding output. Asserting on dump | ||
| # content rather than dump exit status means a partial dump can still | ||
| # fail the test on an NV_ENCODE_NATIVE seen before the failure point. | ||
| # | ||
| function verify_xdr_nvlist_encoding | ||
| { | ||
| typeset stream=$1 | ||
| typeset out | ||
|
|
||
| [[ -f "$stream" ]] || \ | ||
| log_fail "verify_xdr_nvlist_encoding: stream not found: $stream" | ||
|
|
||
| out=$(zstream dump "$stream" 2>/dev/null) | ||
|
|
||
| if echo "$out" | grep -q 'NV_ENCODE_NATIVE'; then | ||
| log_fail "verify_xdr_nvlist_encoding: " \ | ||
| "NV_ENCODE_NATIVE found in $stream" | ||
| fi | ||
| if ! echo "$out" | grep -q 'NV_ENCODE_XDR'; then | ||
| log_fail "verify_xdr_nvlist_encoding: " \ | ||
| "no NV_ENCODE_XDR found in $stream" | ||
|
GarthSnyder marked this conversation as resolved.
|
||
| fi | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
tests/zfs-tests/tests/functional/send_xdr_encoding/setup.ksh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/bin/ksh -p | ||
| # SPDX-License-Identifier: CDDL-1.0 | ||
| # | ||
| # CDDL HEADER START | ||
| # | ||
| # This file and its contents are supplied under the terms of the | ||
| # Common Development and Distribution License ("CDDL"), version 1.0. | ||
| # You may only use this file in accordance with the terms of version | ||
| # 1.0 of the CDDL. | ||
| # | ||
| # A full copy of the text of the CDDL should have accompanied this | ||
| # source. A copy of the CDDL is also available via the Internet at | ||
| # http://www.illumos.org/license/CDDL. | ||
| # | ||
| # CDDL HEADER END | ||
| # | ||
|
|
||
| # | ||
| # Copyright (c) 2026 by Garth Snyder. All rights reserved. | ||
| # | ||
|
|
||
| . $STF_SUITE/tests/functional/send_xdr_encoding/send_xdr_encoding.kshlib | ||
|
|
||
| verify_disk_count "$DISKS" 2 | ||
|
|
||
| create_pool $POOL $DISK1 | ||
| create_pool $POOL2 $DISK2 | ||
|
|
||
| log_pass |
93 changes: 93 additions & 0 deletions
93
tests/zfs-tests/tests/functional/send_xdr_encoding/xdr_bookmark_raw.ksh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #!/bin/ksh -p | ||
| # SPDX-License-Identifier: CDDL-1.0 | ||
| # | ||
| # CDDL HEADER START | ||
| # | ||
| # This file and its contents are supplied under the terms of the | ||
| # Common Development and Distribution License ("CDDL"), version 1.0. | ||
| # You may only use this file in accordance with the terms of version | ||
| # 1.0 of the CDDL. | ||
| # | ||
| # A full copy of the text of the CDDL should have accompanied this | ||
| # source. A copy of the CDDL is also available via the Internet at | ||
| # http://www.illumos.org/license/CDDL. | ||
| # | ||
| # CDDL HEADER END | ||
| # | ||
|
|
||
| # | ||
| # Copyright (c) 2026 by Garth Snyder. All rights reserved. | ||
| # | ||
|
|
||
| . $STF_SUITE/tests/functional/send_xdr_encoding/send_xdr_encoding.kshlib | ||
|
|
||
| # | ||
| # Description: | ||
| # A raw incremental send from a redaction bookmark on an encrypted dataset | ||
| # (zfs send -w -i ds#book ds@snap) carries both BEGINNV_REDACT_FROM_SNAPS | ||
| # and crypt_keydata in its DRR_BEGIN nvlist payload. Verify that this | ||
| # combined payload is XDR-encoded and the stream can be received. | ||
| # | ||
| # Strategy: | ||
| # 1. Create an encrypted source dataset with a redaction bookmark and a | ||
| # later snapshot. | ||
| # 2. Establish a raw base on the receiver via zfs send -w of the bookmark's | ||
| # source snapshot. | ||
| # 3. zfs send -w -i sendfs#book sendfs@s1 to a file. | ||
| # 4. Verify that the resulting stream is XDR-encoded. | ||
| # 5. Verify that the zfs receive succeeds. | ||
| # | ||
|
|
||
| verify_runnable "both" | ||
|
|
||
| sendfs="$POOL/xdr_bookmark_raw_src" | ||
| clonefs="$POOL/xdr_bookmark_raw_clone" | ||
| recvfs="$POOL2/xdr_bookmark_raw_recv" | ||
| keyfile="/$POOL/xdr_bookmark_raw.key" | ||
| full_stream="/$POOL/xdr_bookmark_raw_full.zsend" | ||
| incr_stream="/$POOL/xdr_bookmark_raw_incr.zsend" | ||
|
|
||
| function cleanup | ||
| { | ||
|
GarthSnyder marked this conversation as resolved.
|
||
| datasetexists $sendfs && destroy_dataset $sendfs -R | ||
| datasetexists $recvfs && destroy_dataset $recvfs -R | ||
| rm -f $keyfile $full_stream $incr_stream | ||
| } | ||
| log_onexit cleanup | ||
|
|
||
| log_assert "BEGIN nvlist of a raw incremental from a redaction bookmark is " \ | ||
| "XDR-encoded and receivable" | ||
|
|
||
| log_must eval "echo 'thisisapassphrase' > $keyfile" | ||
| log_must zfs create -o encryption=on -o keyformat=passphrase \ | ||
| -o keylocation=file://$keyfile $sendfs | ||
|
|
||
| log_must dd if=/dev/urandom of=/$sendfs/f1 bs=128k count=8 status=none | ||
| log_must dd if=/dev/urandom of=/$sendfs/f2 bs=128k count=8 status=none | ||
| log_must zfs snapshot $sendfs@s0 | ||
|
|
||
| # The clone inherits encryption from $sendfs. | ||
| log_must zfs clone $sendfs@s0 $clonefs | ||
| log_must dd if=/dev/urandom of=/$clonefs/f1 bs=128k count=8 conv=notrunc \ | ||
| status=none | ||
| log_must zfs snapshot $clonefs@s | ||
|
|
||
| log_must zfs redact $sendfs@s0 redaction-bookmark $clonefs@s | ||
|
|
||
| # Take @s1 with no intervening writes. See xdr_bookmark_raw_with_write.ksh | ||
| # for a variant that includes a post-redact write; that variant exercises | ||
| # a known kernel-side issue (#18491) and may flake. | ||
| log_must zfs snapshot $sendfs@s1 | ||
|
|
||
| # Establish a raw base on the receiver. | ||
| log_must eval "zfs send -w $sendfs@s0 > $full_stream" | ||
| log_must eval "zfs receive $recvfs < $full_stream" | ||
|
|
||
| # Raw incremental from the redaction bookmark. This is the test focus. | ||
| log_must eval "zfs send -w -i $sendfs#redaction-bookmark $sendfs@s1 > \ | ||
| $incr_stream" | ||
| verify_xdr_nvlist_encoding $incr_stream | ||
| log_must eval "zfs receive $recvfs < $incr_stream" | ||
|
|
||
| log_pass "BEGIN nvlist of a raw incremental from a redaction bookmark is " \ | ||
| "XDR-encoded and receivable" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.