packages: sort network related packages into package/network/
[openwrt/staging/chunkeey.git] / package / network / services / ppp / patches / 400-simplify_kernel_checks.patch
1 pppd: Remove runtime kernel checks
2
3 On embedded system distributions the required kernel features for pppd are
4 more or less guaranteed to be present, so there is not much point in
5 performing runtime checks, it just increases the binary size.
6
7 This patch removes the runtime kernel feature checks.
8
9 Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10
11 --- a/pppd/sys-linux.c
12 +++ b/pppd/sys-linux.c
13 @@ -203,7 +203,7 @@ static int driver_is_old = 0;
14 static int restore_term = 0; /* 1 => we've munged the terminal */
15 static struct termios inittermios; /* Initial TTY termios */
16
17 -int new_style_driver = 0;
18 +static const int new_style_driver = 1;
19
20 static char loop_name[20];
21 static unsigned char inbuf[512]; /* buffer for chars read from loopback */
22 @@ -220,8 +220,8 @@ static int looped; /* 1 if using loop
23 static int link_mtu; /* mtu for the link (not bundle) */
24
25 static struct utsname utsname; /* for the kernel version */
26 -static int kernel_version;
27 #define KVERSION(j,n,p) ((j)*1000000 + (n)*1000 + (p))
28 +static const int kernel_version = KVERSION(2,6,37);
29
30 #define MAX_IFS 100
31
32 @@ -1438,11 +1438,12 @@ int ccp_fatal_error (int unit)
33 *
34 * path_to_procfs - find the path to the proc file system mount point
35 */
36 -static char proc_path[MAXPATHLEN];
37 -static int proc_path_len;
38 +static char proc_path[MAXPATHLEN] = "/proc";
39 +static int proc_path_len = 5;
40
41 static char *path_to_procfs(const char *tail)
42 {
43 +#if 0
44 struct mntent *mntent;
45 FILE *fp;
46
47 @@ -1464,6 +1465,7 @@ static char *path_to_procfs(const char *
48 fclose (fp);
49 }
50 }
51 +#endif
52
53 strlcpy(proc_path + proc_path_len, tail,
54 sizeof(proc_path) - proc_path_len);
55 @@ -2116,15 +2118,19 @@ int ppp_available(void)
56 int my_version, my_modification, my_patch;
57 int osmaj, osmin, ospatch;
58
59 +#if 0
60 /* get the kernel version now, since we are called before sys_init */
61 uname(&utsname);
62 osmaj = osmin = ospatch = 0;
63 sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch);
64 kernel_version = KVERSION(osmaj, osmin, ospatch);
65 +#endif
66
67 fd = open("/dev/ppp", O_RDWR);
68 if (fd >= 0) {
69 +#if 0
70 new_style_driver = 1;
71 +#endif
72
73 /* XXX should get from driver */
74 driver_version = 2;
75 @@ -2185,6 +2191,7 @@ int ppp_available(void)
76
77 if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
78 ok = 0;
79 + return ok;
80
81 /*
82 * This is the PPP device. Validate the version of the driver at this
83 @@ -2678,6 +2685,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
84 }
85 #endif /* TIOCGPTN */
86
87 +#if 0
88 if (sfd < 0) {
89 /* the old way - scan through the pty name space */
90 for (i = 0; i < 64; ++i) {
91 @@ -2696,6 +2704,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
92 }
93 }
94 }
95 +#endif
96
97 if (sfd < 0)
98 return 0;
99 --- a/pppd/plugins/pppoatm/pppoatm.c
100 +++ b/pppd/plugins/pppoatm/pppoatm.c
101 @@ -170,14 +170,6 @@ static void disconnect_pppoatm(void)
102
103 void plugin_init(void)
104 {
105 -#if defined(__linux__)
106 - extern int new_style_driver; /* From sys-linux.c */
107 - if (!ppp_available() && !new_style_driver)
108 - fatal("Kernel doesn't support ppp_generic - "
109 - "needed for PPPoATM");
110 -#else
111 - fatal("No PPPoATM support on this OS");
112 -#endif
113 info("PPPoATM plugin_init");
114 add_options(pppoa_options);
115 }
116 --- a/pppd/plugins/rp-pppoe/plugin.c
117 +++ b/pppd/plugins/rp-pppoe/plugin.c
118 @@ -60,9 +60,6 @@ static char const RCSID[] =
119
120 char pppd_version[] = VERSION;
121
122 -/* From sys-linux.c in pppd -- MUST FIX THIS! */
123 -extern int new_style_driver;
124 -
125 char *pppd_pppoe_service = NULL;
126 static char *acName = NULL;
127 static char *existingSession = NULL;
128 @@ -340,10 +337,6 @@ PPPoEDevnameHook(char *cmd, char **argv,
129 void
130 plugin_init(void)
131 {
132 - if (!ppp_available() && !new_style_driver) {
133 - fatal("Linux kernel does not support PPPoE -- are you running 2.4.x?");
134 - }
135 -
136 add_options(Options);
137
138 info("RP-PPPoE plugin version %s compiled against pppd %s",
139 --- a/pppd/plugins/pppol2tp/pppol2tp.c
140 +++ b/pppd/plugins/pppol2tp/pppol2tp.c
141 @@ -500,12 +500,7 @@ static void pppol2tp_cleanup(void)
142
143 void plugin_init(void)
144 {
145 -#if defined(__linux__)
146 - extern int new_style_driver; /* From sys-linux.c */
147 - if (!ppp_available() && !new_style_driver)
148 - fatal("Kernel doesn't support ppp_generic - "
149 - "needed for PPPoL2TP");
150 -#else
151 +#if !defined(__linux__)
152 fatal("No PPPoL2TP support on this OS");
153 #endif
154 add_options(pppol2tp_options);