xl2tpd: Remove modprobe invocation from kernel-mode patch
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> git-svn-id: svn://svn.openwrt.org/openwrt/packages@31563 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
dd16348dc0
commit
c52af22cd4
@ -108,66 +108,6 @@ diff --git a/network.c b/network.c
|
||||
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;
|
||||
@ -187,14 +127,6 @@ index 241bd82..fde250e 100644
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user