From nobody Tue Apr 09 10:06:42 2024 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 4VDM7Q3sJHz5GdLJ; Tue, 9 Apr 2024 10:06:42 +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 4VDM7Q2zRFz4fTl; Tue, 9 Apr 2024 10:06:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712657202; 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=rYecTAnoEW/pFeVexlwjc8X5ug22ueUqZhyfI4oQL2I=; b=ExNdkdBbuq09SArIZADGCaHrHSUnIhryOgU3VPMng5Su+DGGLyFCruKoHg+sGtnueiDw03 U29aDJJNEcOrsq01P20kTTVQ5GKms6qlw+L9pZ61WfuHEwhu13F2aVM07Pnt4bFCrKzgcr g8wQFkkyC1Uje/mCx67AIIdBM+iVqjrf1iHrXJJE8R833ksJOugpFSaQCHOMdZ8npouSoa OLm4tqZp45QoaNcC1d6jsyZJLXcWW0mzp4G8Rv2yi9Ing1pEMHZSQX2eBHt3FMRjM9NEkA nPwSB1Ka443rbfhs1sdohsc4Av8L8dTOpFw+5xyGu9YWM9tOpBN5+6cuiJlCbQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712657202; a=rsa-sha256; cv=none; b=V6x4cKzyWY9accpmhtvP5XENEZFL43JOnsoVqdzOlb8xv6byWt+9/I/1iDMa5rUTwpC+z3 d4IgJO8V8SCNzjMC5E8n7b3Si65UdRL8HKgBP3T2e3szQKG4RyntY3tFlemo1wvHaNxoeA WDJCZhVvmP6muuRlLXA6vvU4Y5/OtX4YJFgvY87mnRc3v1/zYqGyM2CFF3BHk43h23XrJC o8FvT3AnySn2GaWoKs9AOAH0BXTKA0NB8qXyjOeJXzLIMmmwuBjIJZTHK2a7VYrPyRzAax WWsJwh22O7kIhPjn/Vxpox8LfoQzoK3Oxmg+m/VlLog3I8avlSrOmq/DqfPfZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712657202; 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=rYecTAnoEW/pFeVexlwjc8X5ug22ueUqZhyfI4oQL2I=; b=nSkr+3ovcZAtyuk3nQ7n1+xFRQkLFC0Tzs/eegfkOI2I/FoJpSpfZZaOzDdxNX2VcxQRI/ dLBAYBb0ft9R5lA3OMKol6v0m6h/yaELqYnMUaclEFXkFdCCLUKbeHH9cpHjtpEHUEFSnV aDl8vKsbIbvGb3h1aq27o6MxY2jv3K9rdapRHndVKcrtVQhJG6D0aK3QBomvsq7TlaVEJB 2kymuktMvcmdHR+Xf71p0sKflIHVH6XUNz81u9dmetO+5qiFgwWadTeL3SAepON6KvrocN JH9MuOgy4nBEgt1fOGzYPP0fJSqQ68q1SXYIsFGAWe9l4z/BzBNjJvmF2i3B5g== 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 4VDM7Q2SffzqCp; Tue, 9 Apr 2024 10:06:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 439A6g32032796; Tue, 9 Apr 2024 10:06:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 439A6g7Y032793; Tue, 9 Apr 2024 10:06:42 GMT (envelope-from git) Date: Tue, 9 Apr 2024 10:06:42 GMT Message-Id: <202404091006.439A6g7Y032793@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: f6f67f58c19d - main - ng_socket: Treat EEXIST from kern_kldload() as success 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: dev-commits-src-all+owner@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: zlei X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f6f67f58c19db4f25f5c2cf4869efc7054493a55 Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=f6f67f58c19db4f25f5c2cf4869efc7054493a55 commit f6f67f58c19db4f25f5c2cf4869efc7054493a55 Author: Zhenlei Huang AuthorDate: 2024-04-09 10:04:47 +0000 Commit: Zhenlei Huang CommitDate: 2024-04-09 10:04:47 +0000 ng_socket: Treat EEXIST from kern_kldload() as success EEXIST is possible in a race condition. Inspired by: ffc72591b1f5 (Don't worry if a module is already loaded ...) Reviewed by: glebius MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44633 --- sys/netgraph/ng_socket.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index c356f7d6aa12..c570584d4b44 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -285,11 +285,15 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, if (ng_findtype(mkp->type) == NULL) { char filename[NG_TYPESIZ + 3]; int fileid; + bool loaded; /* Not found, try to load it as a loadable module. */ snprintf(filename, sizeof(filename), "ng_%s", mkp->type); error = kern_kldload(curthread, filename, &fileid); + loaded = (error == 0); + if (error == EEXIST) + error = 0; if (error != 0) { free(msg, M_NETGRAPH_MSG); goto release; @@ -298,9 +302,10 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, /* See if type has been loaded successfully. */ if (ng_findtype(mkp->type) == NULL) { free(msg, M_NETGRAPH_MSG); - (void)kern_kldunload(curthread, fileid, - LINKER_UNLOAD_NORMAL); - error = ENXIO; + if (loaded) + (void)kern_kldunload(curthread, fileid, + LINKER_UNLOAD_NORMAL); + error = ENXIO; goto release; } }