Bug 252554 - dumpon doesn't work with -z or -Z options?
Summary: dumpon doesn't work with -z or -Z options?
Status: Open
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:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-10 09:28 UTC by dmilith
Modified: 2021-01-11 14:46 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 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 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 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 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 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 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 2021-01-11 14:46:58 UTC
(In reply to Ed Maste from comment #6)
LGTM.  Will you post a patch to phabricator?