index 241bd82..fde250e 100644
--- a/network.c
+++ b/network.c
-@@ -22,6 +22,7 @@
- #include <unistd.h>
- #include <stdlib.h>
- #include <sys/ioctl.h>
-+#include <sys/wait.h>
- #ifndef LINUX
- # include <sys/uio.h>
- #endif
-@@ -36,6 +37,51 @@ int server_socket; /* Server socket */
- int kernel_support; /* Kernel Support there or not? */
- #endif
-
-+#ifdef USE_KERNEL
-+void modprobe() {
-+ char * modules[] = { "l2tp_ppp", "pppol2tp", NULL };
-+ char ** module;
-+ char buf[256], *tok;
-+ int pid, exit_status, fd;
-+
-+ FILE * fmod = fopen("/proc/modules", "r");
-+
-+ if (fmod == NULL)
-+ return;
-+
-+ while (fgets(buf, 255, fmod) != NULL) {
-+ if ((tok = strtok(buf, " ")) != NULL) {
-+ for (module = modules; *module != NULL; ++module) {
-+ if (!strcmp(*module, tok)) {
-+ fclose(fmod);
-+ return;
-+ }
-+ }
-+ }
-+ }
-+
-+ fclose(fmod);
-+
-+ for (module = modules; *module != NULL; ++module) {
-+ if ((pid = fork()) >= 0) {
-+ if (pid == 0) {
-+ setenv("PATH", "/sbin:/usr/sbin:/bin:/usr/bin", 1);
-+ if ((fd = open("/dev/null", O_RDWR)) > -1) {
-+ dup2(fd, 1);
-+ dup2(fd, 2);
-+ }
-+ execlp("modprobe", "modprobe", "-q", *module, (char *)NULL);
-+ exit(1);
-+ } else {
-+ if ((pid = waitpid(pid, &exit_status, 0)) != -1 && WIFEXITED(exit_status)) {
-+ if (WEXITSTATUS(exit_status) == 0)
-+ return;
-+ }
-+ }
-+ }
-+ }
-+}
-+#endif
-
- int init_network (void)
- {
@@ -45,6 +91,7 @@ int init_network (void)
server.sin_family = AF_INET;
server.sin_addr.s_addr = gconfig.listenaddr;
if (bind (server_socket, (struct sockaddr *) &server, sizeof (server)))
{
close (server_socket);
-@@ -91,6 +142,7 @@ int init_network (void)
- }
- else
- {
-+ modprobe();
- int kernel_fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
- if (kernel_fd < 0)
- {
@@ -321,6 +373,11 @@ int build_fdset (fd_set *readfds)
while (tun)