From nobody Thu May 19 06:07:13 2022 X-Original-To: dev-commits-src-branches@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 7186E1AE9975; Thu, 19 May 2022 06:07:13 +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 4L3fX12kNzz4Vgt; Thu, 19 May 2022 06:07:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652940433; 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=HnG2r+1YBikGx6s4USsw5+7wyjcLhgloECDh8uj5ZIA=; b=jJ/OAbTfUwerDFjAWSu7BWFNbttiNHcSaTNHscD3ZfidFbfYytAsvcJBNLDJZnwlO6kF60 WE4ErHyDaSEbNJ5wTF1FrIk0SykBcMBotA1WSwjlo7ddyxMPVEOcWHR0d2EqiVl36m6jCL GGlUn5ZIEuJs1onP7MgUUZmWcvjqCqN/E/HjKGROp09uexumWeNZ4lg1+JQrp96G90fU+V FGSGMmcIOQwe7XwZJHiA7LGHeOOSy2bXbxqrmqutI7rvG2Y7vMDcR2b6o+v71SSerReo4T P7wBBlbuujdXsj0CXoYoQpDcm3F3fu19oJrQForp5ndHkLJyeNWZ8N0CdBHPJg== 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 3AD7A18448; Thu, 19 May 2022 06:07:13 +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 24J67Dfk079630; Thu, 19 May 2022 06:07:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24J67DMa079629; Thu, 19 May 2022 06:07:13 GMT (envelope-from git) Date: Thu, 19 May 2022 06:07:13 GMT Message-Id: <202205190607.24J67DMa079629@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eugene Grosbein Subject: git: 9132c793cb01 - stable/13 - setkey(8): MFC: load ipsec.ko automatically List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9132c793cb014e321c92ed502d20df4426492562 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652940433; 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=HnG2r+1YBikGx6s4USsw5+7wyjcLhgloECDh8uj5ZIA=; b=v30TAb0cPjmgvCuElGxVyJEOa/czKaIZBvlAfrACpJP9Xvsgjtc4SdjyZI923KpuO2Oh86 gTTXparZyo199hgL74k8KLdjR6l7AAgJL7gwq2EpSISpGe04xHtqOB1mZXq1i7+FE3QtPT 33kN8iUDfHfgMCpIma780dovZiOvn57LNZdHEHJ76Vp9LHr2vyDYQiFsGwZhpkXc7X+6/n LKVQjGZpBNHh+3jm1Wv2bjp/8FoGuSXgoaNOfyr5GCbv6/6h9jEVY5cvHs1wX1nppv52/Z wPPSZdliEJmo/djNIw9Zt4+EV1SOHsS7zvFz9Zoz20d1SIlCa97Daz3HN43Qdg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652940433; a=rsa-sha256; cv=none; b=gqwGVMqkWA6tHknG9TqnqZTV3ew/vnE6pe60brTwN/AhF/qryq/avePgOy2SDv826hEzR6 mApV4KETlhLetiuhZPjLE7Qv/yUBanGZg9dSoUd7AJ5LVzQIohcnB1++FFuCDDkp12wri2 8XJD4BRoQkjclJiR9bvTPXaJWBUleXi9IZZxfwcexwuLw4P3ygHXzLeNS7lLeiJd4ex25N L+miiZgQ2kDxlXvTSaIsK0giIo++tmBFR2Xx7+TD2FofrGWrEpxTTCNBN3nECn+zOIzeJ9 wMisOxKzCJOjunqpXewGD2Tpqlf7u5MZvHgiGCkvoedOleyowvVNk9Ry6lFBaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=9132c793cb014e321c92ed502d20df4426492562 commit 9132c793cb014e321c92ed502d20df4426492562 Author: Eugene Grosbein AuthorDate: 2022-05-05 12:02:29 +0000 Commit: Eugene Grosbein CommitDate: 2022-05-19 06:05:30 +0000 setkey(8): MFC: load ipsec.ko automatically If setkey(8) is used without ipsec.ko loaded beforehand, its attempt to install SA/SPD into the kernel results in cryptic EINVAL error code. Let it be a bit more user-friendly and try to load ipsec.ko automatically if it is not loaded, just like ifconfig(8) does it for modules it needs. PR: 263379 (cherry picked from commit 0aef8628458a7d03e3c7e63ae05e228191167eec) --- sbin/setkey/setkey.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sbin/setkey/setkey.c b/sbin/setkey/setkey.c index 1d66a92e0100..2bc8ec7e5816 100644 --- a/sbin/setkey/setkey.c +++ b/sbin/setkey/setkey.c @@ -34,6 +34,8 @@ #include #include +#include +#include #include #include #include @@ -67,6 +69,7 @@ void shortdump_hdr(void); void shortdump(struct sadb_msg *); static void printdate(void); static int32_t gmt2local(time_t); +static int modload(const char *name); #define MODE_SCRIPT 1 #define MODE_CMDDUMP 2 @@ -102,6 +105,17 @@ usage() exit(1); } +static int +modload(const char *name) +{ + if (modfind(name) < 0) + if (kldload(name) < 0 || modfind(name) < 0) { + warn("%s: module not found", name); + return 0; + } + return 1; +} + int main(ac, av) int ac; @@ -167,6 +181,7 @@ main(ac, av) } } + modload("ipsec"); so = pfkey_open(); if (so < 0) { perror("pfkey_open");