Changeset View
Changeset View
Standalone View
Standalone View
sbin/dumpon/dumpon.c
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | if (dst->sin_addr.s_addr == INADDR_ANY && | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
free(buf); | free(buf); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
static void | static void | ||||
check_link_status(const char *ifname) | |||||
{ | |||||
struct ifaddrs *ifap, *ifa; | |||||
if (getifaddrs(&ifap) != 0) | |||||
err(EX_OSERR, "getifaddrs"); | |||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { | |||||
if (strcmp(ifname, ifa->ifa_name) != 0) | |||||
continue; | |||||
if ((ifa->ifa_flags & IFF_UP) == 0) { | |||||
warnx("warning: %s's link is down", ifname); | |||||
} | |||||
break; | |||||
} | |||||
freeifaddrs(ifap); | |||||
} | |||||
static void | |||||
check_size(int fd, const char *fn) | check_size(int fd, const char *fn) | ||||
{ | { | ||||
int name[] = { CTL_HW, HW_PHYSMEM }; | int name[] = { CTL_HW, HW_PHYSMEM }; | ||||
size_t namelen = nitems(name); | size_t namelen = nitems(name); | ||||
unsigned long physmem; | unsigned long physmem; | ||||
size_t len; | size_t len; | ||||
off_t mediasize; | off_t mediasize; | ||||
int minidump; | int minidump; | ||||
▲ Show 20 Lines • Show All 456 Lines • ▼ Show 20 Lines | if (error == EINVAL && (gzip || zstd)) { | ||||
/* Retry without compression in case kernel lacks support. */ | /* Retry without compression in case kernel lacks support. */ | ||||
kdap->kda_compression = KERNELDUMP_COMP_NONE; | kdap->kda_compression = KERNELDUMP_COMP_NONE; | ||||
error = ioctl(fd, DIOCSKERNELDUMP, kdap); | error = ioctl(fd, DIOCSKERNELDUMP, kdap); | ||||
if (error == 0) | if (error == 0) | ||||
warnx("Compression disabled; kernel may lack gzip or zstd support."); | warnx("Compression disabled; kernel may lack gzip or zstd support."); | ||||
else | else | ||||
error = errno; | error = errno; | ||||
} | } | ||||
/* Emit a warning if the user configured a downed interface. */ | |||||
if (error == 0 && netdump) | |||||
check_link_status(kdap->kda_iface); | |||||
explicit_bzero(kdap->kda_encryptedkey, kdap->kda_encryptedkeysize); | explicit_bzero(kdap->kda_encryptedkey, kdap->kda_encryptedkeysize); | ||||
free(kdap->kda_encryptedkey); | free(kdap->kda_encryptedkey); | ||||
explicit_bzero(kdap, sizeof(*kdap)); | explicit_bzero(kdap, sizeof(*kdap)); | ||||
if (error != 0) { | if (error != 0) { | ||||
if (netdump) { | if (netdump) { | ||||
/* | /* | ||||
* Be slightly less user-hostile for some common | * Be slightly less user-hostile for some common | ||||
* errors, especially as users don't have any great | * errors, especially as users don't have any great | ||||
* discoverability into which NICs support netdump. | * discoverability into which NICs support netdump. | ||||
*/ | */ | ||||
if (error == ENXIO) | if (error == ENODEV) | ||||
errx(EX_OSERR, "Unable to configure netdump " | |||||
"because the interface's link is down."); | |||||
else if (error == ENODEV) | |||||
errx(EX_OSERR, "Unable to configure netdump " | errx(EX_OSERR, "Unable to configure netdump " | ||||
"because the interface driver does not yet " | "because the interface driver does not yet " | ||||
"support netdump."); | "support netdump."); | ||||
} | } | ||||
errc(EX_OSERR, error, "ioctl(DIOCSKERNELDUMP)"); | errc(EX_OSERR, error, "ioctl(DIOCSKERNELDUMP)"); | ||||
} | } | ||||
if (verbose) | if (verbose) | ||||
listdumpdev(); | listdumpdev(); | ||||
exit(EX_OK); | exit(EX_OK); | ||||
} | } |