From nobody Fri May 27 16:23:32 2022 X-Original-To: dev-commits-src-all@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 D76961B4FAC0; Fri, 27 May 2022 16:23:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L8qqT3WVxz3sj6; Fri, 27 May 2022 16:23:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653668613; 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; bh=goCAg8KyO2RihU5RX+ucS412bVg+G+We5mxxoAhivDI=; b=Y8puBplOJ0fAwtgt8LlivjUg13rGEHzw8kk7F9+2qXMnfcaRU8V4O6zXFidedsRwzpEEdN dujzN5w/3x2T/0HnrGa+DgRFq2FW7p3RmT3DCivuAP0WHkZBtEqQDJPULDqEMGz0Ram4mb 9wD7JpNz1eBun9q7UvgJWr05LY0o0sd2SlIkcYaKtQP+mDvLY3wCO5BRUlinKbWdliPam6 HXgNIcV5UAyh3BMFC25W8dMzoNRiPJk1hjnMimxY5HIHmEwbXJactUGyUIYfDaX5zjasyi qlxrcSRE85644NyyWJBT0XDclDbkmi53KOC3PS0BHQTUyBDp4IZz1ZfFZuuzRQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1A74425843; Fri, 27 May 2022 16:23:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24RGNXlF096685; Fri, 27 May 2022 16:23:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24RGNWEl096684; Fri, 27 May 2022 16:23:32 GMT (envelope-from git) Date: Fri, 27 May 2022 16:23:32 GMT Message-Id: <202205271623.24RGNWEl096684@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 8fab6c484931 - stable/13 - dumpon: warn if the configured netdump link is down List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8fab6c48493177662a9d34694cf23a0be719bbf1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653668613; 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; bh=goCAg8KyO2RihU5RX+ucS412bVg+G+We5mxxoAhivDI=; b=o8T6kjWerHOiDT5yGycmjV8kjkmZQLbfdeBGaE2aH2/TjZGpzP2u/RuIGnH1ppBpQi3mqA 96uRFvUZrfmCEs/2wnAF2AZ1VAQBoeOYo9/su3j3mF5yAPUWj5Jpiywvcizw9bUgU7450c DXItq+SV5eG2429s20AyBs/6B5/p5h2PM+mzUh2ZxH+ODfTQQLf93EYPeCCmvhVxzpKiXl 4UgL08IyZjggPFt1R+ZJALiWkp5Rfz4ezJLN6cbYslBNyEt6OP/7rkG1q/Ky2+y/zKzILF lmu6/EByjLYFXqtjOhXKKexHvLg+GI/nGsVLEwFSXUxR6/WX6BVBk/Ak9Y4bZg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653668613; a=rsa-sha256; cv=none; b=ut+Z33hgY98x2eFyouIfBs1l6EjNxirwHrUNPD2hp13D4LThqSYKFgeyxqxNoOc19ZlwSM cwmH6qdnTJkmna1JO1d111ykiu1603oX2YHn6+Pbh+Rb0u8AEub5x4maTbAnoqx111KtsS 7pTwwNWgUXXvObKoP8Ggje9UOGwTmGw2ddD61kv52Kzdt1fzbmKZ95ZORJnajxnMddXyu5 RyQV+6ItKxBYe9yfP3vtRntQZevlL5NY7pqDavklNU/MGsu27VPvlUIK+IfNuQ11RRO/qb 1paR08J3+NyaLkCzowM6bSYMh96+ntZGl0nfy/0wopvdWtPHG5tVS8FcRA2gbQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8fab6c48493177662a9d34694cf23a0be719bbf1 commit 8fab6c48493177662a9d34694cf23a0be719bbf1 Author: Mitchell Horne AuthorDate: 2022-05-14 13:25:21 +0000 Commit: Mitchell Horne 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.");