From nobody Thu May 19 06:12:13 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 E1FDA1AEAF53; Thu, 19 May 2022 06:12: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 4L3fdn64Dqz4X37; Thu, 19 May 2022 06:12:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652940733; 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=ldC0+imjbaBUJ6mYAVhUo8ao9IXcBeSzswuV+q3kJS8=; b=Hi8lPtqKy4bNW/4BP6OkQnflOHoRbbEyBSMs8JSuDDvUI65FIjq/jFeGgJeih156FUnB/a Prnn2kIboo7nlvLGo2u+84Xf/B0Bhim3cqNLxBxtjrWYibzGT/5TV4Wd79nILSb5oTtSyh cwk3JRd2RYsmShI3et++Klx5oiXZNRm+hwmaFvV5VDyOHU7SWHgqWWZRzvDhTtwQRNqda6 VvzpuRVVQjpDmFE/3t3AHdpRyYeRumQuHM0R7yVDBCRcYb0+5j9IoyWZfJpVVFviMTo1qs VMLlWQQ/z1EK5nVfj4gRhd92tyg39uRPrTOzuSJxiGPMxMEbjBFd9Rzs+t6NRw== 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 B02E118476; Thu, 19 May 2022 06:12: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 24J6CDQq092537; Thu, 19 May 2022 06:12:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24J6CDGn092536; Thu, 19 May 2022 06:12:13 GMT (envelope-from git) Date: Thu, 19 May 2022 06:12:13 GMT Message-Id: <202205190612.24J6CDGn092536@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: dc72e1b86f8a - stable/12 - setkey: MFC: load ipsec.ko automatically 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: eugen X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: dc72e1b86f8ae396215418cdeda037e37df11e98 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652940733; 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=ldC0+imjbaBUJ6mYAVhUo8ao9IXcBeSzswuV+q3kJS8=; b=AiSTpei33hoU7zAox895i4hcVZXg0zGUJu56hnZwyh5KJMTiUe/K0AQG6aUHP9oSG2WxRW 2KXFQVS+9fDYHIzeP88aSxn25oBm0o+pZ9epC1vj/zphcLSh+Q8hVU8BjZboov+HT6rihd 7kOV6uI1lyeNXu1aGyxvzsikIWmEM05yCL1OdgDuDyJN4uP8z5pRJklzQfnaVR+ZMbbOCg QssefMdh41/wt6mIFUL4AgjMv3xrGyhacMGObqGs7djSJTb+mR84w2z19NrbCAMpDYC31a GGnMl0z9/DWtsakEhFf3eKb0wg9CrDpmIPOFBeY1Obnyq4Jsu7OrmzFL/XbILA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652940733; a=rsa-sha256; cv=none; b=DaFwYA8XzsfTld0q24TuwJh7GaLxwwB9eiyWNqahy640hU6CMraf4gtcZEg2dR5u5yyGXz zocsHOe+EkuH8CyFtgDK8WdUt8KWn14HZMwEPsGzrSJdBU/jkN/A5MfADQ2HG+3u2blHjy coLsYO7ley1c6T0VPyUhbQT6RZMpfMwatyY6IdZLrPzcmth5ZcpMoUqFsCRsGaztZFNtBi 8uDuIoeJcdygbk0jkgX9BvfHqE68KztJ7E4sXgmom+Jd53cr80CWy/H9qmRBcHz3PPDDbM p4hIf/fLqPcS8VCh/yYPxqbEEB5PNVFml4Qjahm37rKspgi8L+ks1tH8UhqSCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=dc72e1b86f8ae396215418cdeda037e37df11e98 commit dc72e1b86f8ae396215418cdeda037e37df11e98 Author: Eugene Grosbein AuthorDate: 2022-05-05 12:02:29 +0000 Commit: Eugene Grosbein CommitDate: 2022-05-19 06:11:34 +0000 setkey: 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");