git: 8fab6c484931 - stable/13 - dumpon: warn if the configured netdump link is down
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 27 May 2022 16:23:32 UTC
The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8fab6c48493177662a9d34694cf23a0be719bbf1 commit 8fab6c48493177662a9d34694cf23a0be719bbf1 Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2022-05-14 13:25:21 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2022-05-27 16:22:48 +0000 dumpon: warn if the configured netdump link is down Previously we expected the DIOCSKERNELDUMP ioctl to return ENXIO if the interface was down, but it does not actually do this. Grab the link status using getifaddrs(3) instead, and downgrade this case from an error to a warning; the user might bring the link back up at a later time. Reviewed by: cem MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D35196 (cherry picked from commit 6543fa5a5c47cfbea92586f0994431fc8ba09f6a) --- sbin/dumpon/dumpon.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c index e7f1d06ea666..ca7a1c5671f2 100644 --- a/sbin/dumpon/dumpon.c +++ b/sbin/dumpon/dumpon.c @@ -185,6 +185,25 @@ find_gateway(const char *ifname) return (ret); } +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) { @@ -581,6 +600,9 @@ main(int argc, char *argv[]) else 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); free(kdap->kda_encryptedkey); explicit_bzero(kdap, sizeof(*kdap)); @@ -591,10 +613,7 @@ main(int argc, char *argv[]) * errors, especially as users don't have any great * discoverability into which NICs support netdump. */ - if (error == ENXIO) - errx(EX_OSERR, "Unable to configure netdump " - "because the interface's link is down."); - else if (error == ENODEV) + if (error == ENODEV) errx(EX_OSERR, "Unable to configure netdump " "because the interface driver does not yet " "support netdump.");