From 0f46005e4b679a1bc2792275b1b87aec33d801ee Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Tue, 10 Jul 2018 00:36:37 +0000 Subject: [PATCH] subr_hints: Skip static_env and static_hints if they don't contain hints This is possible because, well, they're static. Both the dynamic environment and the MD-environment (generally loader(8) environment) can potentially have room for new variables to be set, and thus do not receive this treatment. --- sys/kern/subr_hints.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index 437e6a06642..e63fe0cf356 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -49,7 +49,9 @@ __FBSDID("$FreeBSD$"); * static_hints to the dynamic environment. */ static bool hintenv_merged; - +/* Static environment and static hints cannot change, so we'll skip known bad */ +static bool stenv_skip; +static bool sthints_skip; /* * Access functions for device resources. */ @@ -179,17 +181,21 @@ fallback: } fbacklvl++; - if (fbacklvl <= FBACK_STENV && + if (!stenv_skip && fbacklvl <= FBACK_STENV && _res_checkenv(kern_envp)) { hintp = kern_envp; goto found; - } + } else + stenv_skip = true; + fbacklvl++; /* We'll fallback to static_hints if needed/can */ - if (fbacklvl <= FBACK_STATIC && + if (!sthints_skip && fbacklvl <= FBACK_STATIC && _res_checkenv(static_hints)) hintp = static_hints; + else + sthints_skip = true; found: fbacklvl++; }