dumpon: Fix unconfiguring netdump with "off" and "/dev/null".

Netdump has its own configuration tracking such that
ioctl(/dev/null, DIOCSKERNELDUMP) does a dumper_remove() but does not
notify netdump about the removal. Simply sending the same ioctl to
/dev/netdump handles the situation.

Reviewed by:	markj, cem
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D31300
This commit is contained in:
Bryan Drewery 2021-07-24 14:18:23 -07:00
parent 372557d8c3
commit accff08c2f

View file

@ -550,6 +550,24 @@ main(int argc, char *argv[])
} else
dev = argv[0];
netdump = false;
if (strcmp(dev, _PATH_DEVNULL) == 0) {
/*
* Netdump has its own configuration tracking that
* is not removed when using /dev/null.
*/
fd = open(_PATH_NETDUMP, O_RDONLY);
if (fd != -1) {
bzero(&ndconf, sizeof(ndconf));
ndconf.kda_index = KDA_REMOVE_ALL;
ndconf.kda_af = AF_INET;
error = ioctl(fd, DIOCSKERNELDUMP, &ndconf);
if (error != 0)
err(1, "ioctl(%s, DIOCSKERNELDUMP)",
_PATH_NETDUMP);
close(fd);
}
}
} else
usage();