From owner-svn-src-head@freebsd.org Mon Oct 15 17:50:04 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 238ED10C3346; Mon, 15 Oct 2018 17:50:04 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 813A37DAFA; Mon, 15 Oct 2018 17:50:03 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 77D68107B7; Mon, 15 Oct 2018 17:50:03 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9FHo34Y093721; Mon, 15 Oct 2018 17:50:03 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9FHo34R093720; Mon, 15 Oct 2018 17:50:03 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201810151750.w9FHo34R093720@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Mon, 15 Oct 2018 17:50:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339363 - head/lib/libc/net X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/lib/libc/net X-SVN-Commit-Revision: 339363 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 17:50:04 -0000 Author: trasz Date: Mon Oct 15 17:50:02 2018 New Revision: 339363 URL: https://svnweb.freebsd.org/changeset/base/339363 Log: Don't call dlopen(3) for built-in NSS types - "cache", "compat", "dns", "files", "db", and "nis". It saves some path lookups during binary startup. Reviewed by: markj Approved by: re (gjb, kib) MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17557 Modified: head/lib/libc/net/nsdispatch.3 head/lib/libc/net/nsdispatch.c Modified: head/lib/libc/net/nsdispatch.3 ============================================================================== --- head/lib/libc/net/nsdispatch.3 Mon Oct 15 17:23:41 2018 (r339362) +++ head/lib/libc/net/nsdispatch.3 Mon Oct 15 17:50:02 2018 (r339363) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 4, 2010 +.Dd October 15, 2018 .Dt NSDISPATCH 3 .Os .Sh NAME @@ -112,10 +112,7 @@ which case they are selected using the and .Fa method_name arguments along with the configured source. -(The methods supplied via -.Fa dtab -take priority over those implemented in NSS modules in the event -of a conflict.) +Modules must use source names different from the built-in ones. .Pp .Va defaults contains a list of default sources to try if Modified: head/lib/libc/net/nsdispatch.c ============================================================================== --- head/lib/libc/net/nsdispatch.c Mon Oct 15 17:23:41 2018 (r339362) +++ head/lib/libc/net/nsdispatch.c Mon Oct 15 17:50:02 2018 (r339363) @@ -486,9 +486,19 @@ nss_load_module(const char *source, nss_module_registe */ mod.handle = nss_builtin_handle; fn = reg_fn; - } else if (!is_dynamic()) + } else if (!is_dynamic()) { goto fin; - else { + } else if (strcmp(source, NSSRC_CACHE) == 0 || + strcmp(source, NSSRC_COMPAT) == 0 || + strcmp(source, NSSRC_DB) == 0 || + strcmp(source, NSSRC_DNS) == 0 || + strcmp(source, NSSRC_FILES) == 0 || + strcmp(source, NSSRC_NIS) == 0) { + /* + * Avoid calling dlopen(3) for built-in modules. + */ + goto fin; + } else { if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name, NSS_MODULE_INTERFACE_VERSION) >= (int)sizeof(buf)) goto fin;