summaryrefslogtreecommitdiffstats
path: root/lib/libnetgraph/sock.c
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2000-01-28 00:48:27 +0000
committerarchie <archie@FreeBSD.org>2000-01-28 00:48:27 +0000
commitf31600a4538b8a34be7a762a8a9e2279f278f5fd (patch)
tree7de73b89bae7b4f52d84df1dec41b529cf303d7e /lib/libnetgraph/sock.c
parent8d6158347d464a5c03ce4218f62f0c02ae59690b (diff)
downloadFreeBSD-src-f31600a4538b8a34be7a762a8a9e2279f278f5fd.zip
FreeBSD-src-f31600a4538b8a34be7a762a8a9e2279f278f5fd.tar.gz
Have NgMkSockNode() load the socket node type KLD if it's not
already loaded (indicated by EPROTONOSUPPORT from socket(2)).
Diffstat (limited to 'lib/libnetgraph/sock.c')
-rw-r--r--lib/libnetgraph/sock.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/libnetgraph/sock.c b/lib/libnetgraph/sock.c
index b8bb9e6..c5a8234 100644
--- a/lib/libnetgraph/sock.c
+++ b/lib/libnetgraph/sock.c
@@ -48,6 +48,9 @@
#include "netgraph.h"
#include "internal.h"
+/* The socket node type KLD */
+#define NG_SOCKET_KLD "ng_socket.ko"
+
/*
* Create a socket type node and give it the supplied name.
* Return data and control sockets corresponding to the node.
@@ -65,14 +68,28 @@ NgMkSockNode(const char *name, int *csp, int *dsp)
if (name && *name == 0)
name = NULL;
- /* Create control socket; this also creates the netgraph node */
+ /* Create control socket; this also creates the netgraph node.
+ If we get a EPROTONOSUPPORT then the socket node type is
+ not loaded, so load it and try again. */
if ((cs = socket(AF_NETGRAPH, SOCK_DGRAM, NG_CONTROL)) < 0) {
+ if (errno == EPROTONOSUPPORT) {
+ if (kldload(NG_SOCKET_KLD) < 0) {
+ errnosv = errno;
+ if (_gNgDebugLevel >= 1)
+ NGLOG("can't load %s", NG_SOCKET_KLD);
+ goto errout;
+ }
+ cs = socket(AF_NETGRAPH, SOCK_DGRAM, NG_CONTROL);
+ if (cs >= 0)
+ goto gotNode;
+ }
errnosv = errno;
if (_gNgDebugLevel >= 1)
NGLOG("socket");
goto errout;
}
+gotNode:
/* Assign the node the desired name, if any */
if (name != NULL) {
u_char sbuf[NG_NODELEN + 3];
OpenPOWER on IntegriCloud