Bug 252554 - dumpon doesn't work with -z or -Z options?
Summary: dumpon doesn't work with -z or -Z options?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.2-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL: https://reviews.freebsd.org/D34520
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-10 09:28 UTC by dmilith
Modified: 2022-04-11 02:02 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dmilith 2021-01-10 09:28:15 UTC
I'm playing with NETDUMP kernel feature and dumpon manpage says that both -z and -Z options are accepted. But they're not?

Specifying -z or -Z like this: dumpon -Z -s IP1 -c IP2 fails with:

dumpon: ioctl(NETDUMPSCONF): Invalid argument
Comment 1 Ed Maste freebsd_committer freebsd_triage 2021-01-10 17:26:28 UTC
This is on HardenedBSD but I expect they don't have related changes. At least we should clarify the situation in the manpage.
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2021-01-10 18:21:01 UTC
Hidden in the CAVEATS section of the man page we have:

-Z requires a kernel compiled with the ZSTDIO kernel option.

so my first question is whether your kernel indeed has these options.  "sysctl kern.conftxt | grep ZSTDIO" should tell you.  FreeBSD GENERIC has them but if this is HardenedBSD (how do we know?) then presumably there is some custom config.
Comment 3 Ed Maste freebsd_committer freebsd_triage 2021-01-10 19:03:12 UTC
(In reply to Mark Johnston from comment #2)
Perhaps we can handle EINVAL by retrying the ioctl w/ compression turned off, and if that works emitting a warning that -z/-Z was ignored, kernel likely does not have support?
Comment 4 Ed Maste freebsd_committer freebsd_triage 2021-01-10 19:11:59 UTC
Something like (completely untested):

+       if (error == EINVAL && netdump && (gzip || zstd)) {
+               /* Retry w/o compression in case kernel lacks support. */
+               kdap->kda_compression = KERNELDUMP_COMP_NONE;
+               error = ioctl(fd, DIOCSKERNELDUMP, kdap);
+               if (error == 0) {
+                       warnx("Compression disabled; kernel may lack gzip or "
+                           "zstd support.");
+               } else {
+                       error = errno;
+               }
+       }
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2021-01-10 20:40:56 UTC
(In reply to Ed Maste from comment #4)
That seems reasonable to me.  I don't think it should be restricted to netdump though.
Comment 6 Ed Maste freebsd_committer freebsd_triage 2021-01-10 21:54:48 UTC
(In reply to Mark Johnston from comment #5)
Ah, of course. Just
+       if (error == EINVAL && (gzip || zstd)) {
Comment 7 Mark Johnston freebsd_committer freebsd_triage 2021-01-11 14:46:58 UTC
(In reply to Ed Maste from comment #6)
LGTM.  Will you post a patch to phabricator?
Comment 8 Ed Maste freebsd_committer freebsd_triage 2022-03-10 18:07:17 UTC
@dmilith would you kindly try the patch in review?

https://reviews.freebsd.org/D34520
Comment 9 commit-hook freebsd_committer freebsd_triage 2022-03-16 16:10:15 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2b20327ec9394754c0bac2d83567b972a08e3930

commit 2b20327ec9394754c0bac2d83567b972a08e3930
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-03-10 18:04:34 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-03-16 16:08:28 +0000

    dumpon: proceed without compression if the kernel lacks support

    PR:             252554
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D34520

 sbin/dumpon/dumpon.c | 9 +++++++++
 1 file changed, 9 insertions(+)
Comment 10 commit-hook freebsd_committer freebsd_triage 2022-04-10 23:13:52 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=fbc0c2a21b761f676050e8769ef6ea498c0ac579

commit fbc0c2a21b761f676050e8769ef6ea498c0ac579
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-03-10 18:04:34 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-04-10 23:12:30 +0000

    dumpon: proceed without compression if the kernel lacks support

    PR:             252554
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D34520

    (cherry picked from commit 2b20327ec9394754c0bac2d83567b972a08e3930)

 sbin/dumpon/dumpon.c | 9 +++++++++
 1 file changed, 9 insertions(+)
Comment 11 Ed Maste freebsd_committer freebsd_triage 2022-04-11 02:02:05 UTC
Believed fixed in main and stable/13 now, @dmilith please submit another PR if you still encounter an issue related to this.