From nobody Tue Apr 16 04:36:41 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 4VJWTP4VMwz5Hm5b; Tue, 16 Apr 2024 04:36:41 +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 4VJWTP2Qpyz4Ywx; Tue, 16 Apr 2024 04:36:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713242201; 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=k1YlPZ3+yd1wLELHV165X6r18DPbG3Tg41U/10GRaDg=; b=fei+5vJoAD0fdZ9OFkI4NBv1qLCZB3ImIdoDt4UtHfY9bjIPxRKK3lZ8ckNHHZXiTb4RpO SgHXptTitaRJUxQHHX1SjqFmW0ICEVnJrGvrp28zUmeHGMxZa6wvE4P17zJw/rJJS2BDHp 6CN5LDzUixY0tsQZoATNE/ETanI3U4FAbbk4YGnyDyUfBCWBjEQLFSfhdIlMAG00q0PPzH HKyYMNn1w3aaqhpPFWvdMsypbVuplvRjR72r2+cTV3gPtU9mw04DGbyTNjJeI0e02pwXOC mhG4MWmm4bW7jnCWti37ZXg9r90LlKRiWZb6qTa6I388XviPSoXS1R1o97nL+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713242201; a=rsa-sha256; cv=none; b=md1vRwL+PBuDEYvw0TBFGYanEaJC3pkM22qoUNfd69D9aevoKupCzkxbYcJWbkZ/UY0ZfG Er9Zz2o2ZIyYZb5x7RjKvUOECDm2lASu7FygodR4gtSMg3+hkX1S9oYk9dSvI8dPAzzl7b k1FAnp5OtZW0DhGB/vN7oKXjPI17gagE1XRrcx3tlLiORZO3H9afokMPgPtvwvAtF90Q3E 2+ePsZVVy4o2XbRGpvswXoPRlORWRGgczinTx/cJXLOLwQFDM4fhulqd9nS4d1afDMpBlZ WSGs6KN4zXsAeR6lcH4RNkVBJ0HspVSa5AdBdiHteOMBeJclZoaQcY/G3qXNQQ== 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=1713242201; 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=k1YlPZ3+yd1wLELHV165X6r18DPbG3Tg41U/10GRaDg=; b=N0iAN5BLM2Cm7YSlqsDulDbqYRNY0JlBzoCXn9aA1p1RBG2bzpB/o8a5fPffgZ+7GGUawX 8Q5MjsuaNR4UwjPoIRaZfOLndLFTT8YED0W6C2Kd1dFK7lwlCw5AmDn49ncr0aWCsnrWp9 X5R/kQ9WluquiIwHfe4nDRIpw1jHfCQXEwNkMeNk0Z8gJ0ZH5jTD5jZOju8ZjlbDDAjE++ u6Mbfwgnnqrkg2VSbwt1m/hgReI85xjAU7ceHfHQPlP+s5lSvGlCmHR2yr3nEjVN6f0WW/ PS8GZs5ksY/xFtDSPKzd9xZmnHeD8PKpzVEYgVjtX/qLLg+an6dWsrkTAzQokw== 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 4VJWTP22RGzTG4; Tue, 16 Apr 2024 04:36:41 +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 43G4af10043335; Tue, 16 Apr 2024 04:36:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43G4afBd043332; Tue, 16 Apr 2024 04:36:41 GMT (envelope-from git) Date: Tue, 16 Apr 2024 04:36:41 GMT Message-Id: <202404160436.43G4afBd043332@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: d77e45e29f04 - stable/13 - 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/13 X-Git-Reftype: branch X-Git-Commit: d77e45e29f0462ea7a2eb1e56fac8fd850ea460c Auto-Submitted: auto-generated The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=d77e45e29f0462ea7a2eb1e56fac8fd850ea460c commit d77e45e29f0462ea7a2eb1e56fac8fd850ea460c Author: Zhenlei Huang AuthorDate: 2024-04-09 10:04:47 +0000 Commit: Zhenlei Huang CommitDate: 2024-04-16 04:36:16 +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 (cherry picked from commit f6f67f58c19db4f25f5c2cf4869efc7054493a55) (cherry picked from commit 2e8d60c6854006a391491bc2c1c48c459c32e2c4) --- 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 63180114ee3f..a6b391400f1c 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; } }