--- src/sys/netgraph/netgraph/ng_base.c 2005/08/30 14:22:05 1.17 +++ src/sys/netgraph/netgraph/ng_base.c 2005/09/04 06:58:24 1.18 @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -305,14 +306,28 @@ static const struct ng_cmdlist ng_generi ************************************************************************/ static int +linker_api_available(void) +{ + /* linker_* API won't work without a process context */ + if (curproc == NULL) + return 0; + /* + * nlookup_init() relies on namei_zone to be initialized, + * but it's not when the netgraph module is loaded during boot. + */ + if (namei_zone == NULL) + return 0; + return 1; +} + +static int ng_load_module(const char *name) { char *path, filename[NG_TYPELEN + 4]; linker_file_t lf; int error; - /* linker_* API won't work without a process context */ - if (curproc == NULL) + if (!linker_api_available()) return (ENXIO); /* Not found, try to load it as a loadable module */ @@ -333,8 +348,7 @@ ng_unload_module(const char *name) linker_file_t lf; int error; - /* linker_* API won't work without a process context */ - if (curproc == NULL) + if (!linker_api_available()) return (ENXIO); /* Not found, try to load it as a loadable module */