summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-11-16 21:57:34 +0000
committerbrian <brian@FreeBSD.org>1999-11-16 21:57:34 +0000
commite6e4bcef4357616b146553ad1ac922c436b9bd0f (patch)
treec0799c864d2517e318d3cc4c032dfe10a6ef9ac6
parentfa089ea40acd74f58a2bb83ae7c5939434527ff5 (diff)
downloadFreeBSD-src-e6e4bcef4357616b146553ad1ac922c436b9bd0f.zip
FreeBSD-src-e6e4bcef4357616b146553ad1ac922c436b9bd0f.tar.gz
Use modfind() to check if a kld is already loaded.
Submitted mostly by: green
-rw-r--r--usr.sbin/ppp/bundle.c18
-rw-r--r--usr.sbin/ppp/ether.c16
-rw-r--r--usr.sbin/ppp/id.c2
-rw-r--r--usr.sbin/ppp/id.h2
4 files changed, 14 insertions, 24 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index 7f47e05..dcc07f2 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -47,6 +47,7 @@
#include <sys/wait.h>
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
#include <sys/linker.h>
+#include <sys/module.h>
#endif
#include <termios.h>
#include <unistd.h>
@@ -607,7 +608,7 @@ bundle_Create(const char *prefix, int type, int unit, const char **argv)
static struct bundle bundle; /* there can be only one */
int enoentcount, err, minunit, maxunit;
const char *ifname;
-#ifdef KLDSYM_LOOKUP
+#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
int kldtried;
#endif
#if defined(TUNSIFMODE) || defined(TUNSLMODE)
@@ -628,7 +629,7 @@ bundle_Create(const char *prefix, int type, int unit, const char **argv)
}
err = ENOENT;
enoentcount = 0;
-#ifdef KLDSYM_LOOKUP
+#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
kldtried = 0;
#endif
for (bundle.unit = minunit; bundle.unit != maxunit; bundle.unit++) {
@@ -638,18 +639,13 @@ bundle_Create(const char *prefix, int type, int unit, const char **argv)
if (bundle.dev.fd >= 0)
break;
else if (errno == ENXIO) {
-#ifdef KLDSYM_LOOKUP
+#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
if (bundle.unit == minunit && !kldtried++) {
/*
- * XXX: For some odd reason, FreeBSD (right now) allows if_tun.ko to
- * load even when the kernel contains the tun device. This lookup
- * should go away when this is fixed, leaving just the kldload().
- * Note also that kldsym() finds static symbols...
+ * Attempt to load the tunnel interface KLD if it isn't loaded
+ * already.
*/
- char devsw[] = "tun_cdevsw";
- struct kld_sym_lookup ksl = { sizeof ksl, devsw, 0, 0 };
-
- if (kldsym(0, KLDSYM_LOOKUP, &ksl) == -1) {
+ if (modfind("if_tun") == -1) {
if (ID0kldload("if_tun") != -1) {
bundle.unit--;
continue;
diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c
index da20f9f..52ae083 100644
--- a/usr.sbin/ppp/ether.c
+++ b/usr.sbin/ppp/ether.c
@@ -49,6 +49,7 @@
#include <sys/fcntl.h>
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
#include <sys/linker.h>
+#include <sys/module.h>
#endif
#include <sys/uio.h>
#include <termios.h>
@@ -409,22 +410,15 @@ ether_Create(struct physical *p)
int ifacelen, providerlen, oldflag;
char connectpath[sizeof dev->hook + 2]; /* .:<hook> */
-#ifdef KLDSYM_LOOKUP
- /* First make sure we've got the right code loaded */
- char basesym[] = "ng_make_node", socksym[] = "ngdomain";
- struct kld_sym_lookup baselookup = { sizeof baselookup, basesym, 0, 0 };
- struct kld_sym_lookup socklookup = { sizeof socklookup, socksym, 0, 0 };
-#endif
-
p->fd--; /* We own the device - change fd */
-#ifdef KLDSYM_LOOKUP
- if (kldsym(0, KLDSYM_LOOKUP, &baselookup) == -1) {
- log_Printf(LogWARN, "Can't run without options NETGRAPH in the kernel\n");
+#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
+ if (modfind("netgraph") == -1) {
+ log_Printf(LogWARN, "Netgraph is not built into the kernel\n");
return NULL;
}
- if (kldsym(0, KLDSYM_LOOKUP, &socklookup) == -1 &&
+ if (modfind("ng_socket") == -1 &&
ID0kldload("ng_socket") == -1) {
log_Printf(LogWARN, "kldload: ng_socket: %s\n", strerror(errno));
return NULL;
diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c
index 3ca74c6..06aad02 100644
--- a/usr.sbin/ppp/id.c
+++ b/usr.sbin/ppp/id.c
@@ -269,7 +269,7 @@ ID0kill(pid_t pid, int sig)
return result;
}
-#ifdef KLDSYM_LOOKUP
+#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
int
ID0kldload(const char *dev)
{
diff --git a/usr.sbin/ppp/id.h b/usr.sbin/ppp/id.h
index bba273f..3254f64 100644
--- a/usr.sbin/ppp/id.h
+++ b/usr.sbin/ppp/id.h
@@ -45,6 +45,6 @@ extern void ID0logout(const char *, int);
extern int ID0bind_un(int, const struct sockaddr_un *);
extern int ID0connect_un(int, const struct sockaddr_un *);
extern int ID0kill(pid_t, int);
-#ifdef KLDSYM_LOOKUP
+#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
extern int ID0kldload(const char *);
#endif
OpenPOWER on IntegriCloud