From nobody Mon May 16 16:22:47 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1DF081AEEF0D; Mon, 16 May 2022 16:22:51 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L24Kl0LbDz4Sbp; Mon, 16 May 2022 16:22:51 +0000 (UTC) (envelope-from rpokala@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652718171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dNkjsq/gg1bn0Er141cuEUCkxzjXtyqU+3n4A0RIRn8=; b=LRS9zVaFQmZBfhIcrSu+XQKklIFjTJd005K39qC3gc7jrQxQQYTxH9Qb8bpY9wgU7QKHz2 J06ULLNvnwgS/LXqIdEd7lJd6FL5lHQ83117Z1dhtJhpIq76xT2v1eOeJNImfk29NbiO8X /mMLkpZDi/UIfdfovnndFsVCI0IRG3lWHQojaCnyoEi0SiW4bvkI1PvSKJNFTO049sSryX 2V/qJ8RjYflnP2trUbIJChLdqfNeT++UeoRSpWXf7cnMEGCsMkk/3hvgMb8yd0fDbF2Bt0 87+fnjWVAxFFECQzBb0BOhTSq5uKOfmC2DPddWkofRGKXQVtKhZCFJY4jQQ+eA== Received: from [192.168.1.10] (unknown [98.42.164.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: rpokala) by smtp.freebsd.org (Postfix) with ESMTPSA id 5C0DE30CB4; Mon, 16 May 2022 16:22:50 +0000 (UTC) (envelope-from rpokala@freebsd.org) User-Agent: Microsoft-MacOutlook/16.61.22050700 Date: Mon, 16 May 2022 09:22:47 -0700 Subject: Re: 6543fa5a5c47 - main - dumpon: warn if the configured netdump link is down From: Ravi Pokala To: Mitchell Horne , , , Message-ID: <6D107983-F702-4931-AFBD-ED8CC62DAFF8@panasas.com> Thread-Topic: 6543fa5a5c47 - main - dumpon: warn if the configured netdump link is down References: <202205141328.24EDSlW1051370@gitrepo.freebsd.org> In-Reply-To: <202205141328.24EDSlW1051370@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652718171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dNkjsq/gg1bn0Er141cuEUCkxzjXtyqU+3n4A0RIRn8=; b=TCx6IjCqx5bWdrvMEnOTQL66S9gKUTGOLBYa2CyhOXsE/VlsVXylxEArAioqx9zIRutdRn m5BZg15kJdPG7ta4aoFuwuWcNEbVa+Q9CLPR6C8rrz7JZJy54UKxMoGC6gEmy9G7S95qGG kame5bFQ/Sy7ECobE5gCaLzN5+wVViO0e6BsOnp1OV8FoVtJbEdZadPcqi8TYajT+uctFC hGZ60vz8KHEmoroIstT5gP9GVN+ByR/X7w+giYQN4vZ6W5IsICdviu35Doq0mvEp2UdmpD Qm3L40DPZ//8Yq8x1QvRSEw5c1n6pOhp7hLdMPn66Y93fh/gqL83XKs468RV9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652718171; a=rsa-sha256; cv=none; b=iCyZ4oSo3/YMubpyph9Jlk/x+V4uxOy1+r2h1qFIzEo8zIh6GK8JCsQ8G/8VXcPKaM7xZz kMx9vKNMIQeIuOjkTVUiCmO8bJOAEiLhmOBTP3nvqMcXHiuHpGN31anHeKLjF5QgPvx7yB IjxUEp1b5C6jOGjtg3f491PV7HOFYLT0CmEOPXQNM9Lu0aTi/Eyc7tIuaaVeEKO4QqCWiq EwhjIyKPID+u+RrsxT0hbfnjmsTooQtoqoHarqMvtFzwpayPVM3ctEDymwO2xxVo1sVsZu LpuLYohfQyvcZYJ/q3lqkM3kXES3Ns63jJAtSvZTEdxHkZC+LtxNfNQ1B2cYLQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N -----Original Message----- From: on behalf of Mitchell Horne Date: 2022-05-14, Saturday at 06:28 To: , , Subject: git: 6543fa5a5c47 - main - dumpon: warn if the configured netdump link is down The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=6543fa5a5c47cfbea92586f0994431fc8ba09f6a commit 6543fa5a5c47cfbea92586f0994431fc8ba09f6a Author: Mitchell Horne AuthorDate: 2022-05-14 13:25:21 +0000 Commit: Mitchell Horne CommitDate: 2022-05-14 13:27:54 +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. Testing whether or not a given link is up sounds like something that should be in libifconfig. If it's there, wouldn't it be better to use that rather than creating check_link_status()? And if it's not there, shouldn't it be? Thanks, Ravi (rpokala@) Reviewed by: cem MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D35196 --- 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 7d8f81d5eaaf..626350427595 100644 --- a/sbin/dumpon/dumpon.c +++ b/sbin/dumpon/dumpon.c @@ -186,6 +186,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) { @@ -659,6 +678,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)); @@ -669,10 +691,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.");