400-simplify_kernel_checks.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. pppd: Remove runtime kernel checks
  2. On embedded system distributions the required kernel features for pppd are
  3. more or less guaranteed to be present, so there is not much point in
  4. performing runtime checks, it just increases the binary size.
  5. This patch removes the runtime kernel feature checks.
  6. Signed-off-by: Jo-Philipp Wich <[email protected]>
  7. --- a/pppd/sys-linux.c
  8. +++ b/pppd/sys-linux.c
  9. @@ -220,14 +220,10 @@ static fd_set in_fds; /* set of fds tha
  10. static int max_in_fd; /* highest fd set in in_fds */
  11. static int has_proxy_arp = 0;
  12. -static int driver_version = 0;
  13. -static int driver_modification = 0;
  14. -static int driver_patch = 0;
  15. -static int driver_is_old = 0;
  16. static int restore_term = 0; /* 1 => we've munged the terminal */
  17. static struct termios inittermios; /* Initial TTY termios */
  18. -int new_style_driver = 0;
  19. +static const int new_style_driver = 1;
  20. static char loop_name[20];
  21. static unsigned char inbuf[512]; /* buffer for chars read from loopback */
  22. @@ -245,9 +241,8 @@ static int dynaddr_set; /* 1 if ip_dyna
  23. static int looped; /* 1 if using loop */
  24. static int link_mtu; /* mtu for the link (not bundle) */
  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(4,9,0);
  29. #define MAX_IFS 100
  30. @@ -1966,11 +1961,12 @@ int ccp_fatal_error (int unit)
  31. *
  32. * path_to_procfs - find the path to the proc file system mount point
  33. */
  34. -static char proc_path[MAXPATHLEN];
  35. -static int proc_path_len;
  36. +static char proc_path[MAXPATHLEN] = "/proc";
  37. +static int proc_path_len = 5;
  38. static char *path_to_procfs(const char *tail)
  39. {
  40. +#if 0
  41. struct mntent *mntent;
  42. FILE *fp;
  43. @@ -1992,6 +1988,7 @@ static char *path_to_procfs(const char *
  44. fclose (fp);
  45. }
  46. }
  47. +#endif
  48. strlcpy(proc_path + proc_path_len, tail,
  49. sizeof(proc_path) - proc_path_len);
  50. @@ -2883,6 +2880,8 @@ ppp_registered(void)
  51. int ppp_check_kernel_support(void)
  52. {
  53. + return 1; /* OpenWrt support ppp device "/dev/ppp" by default */
  54. +#if 0
  55. int s, ok, fd;
  56. struct ifreq ifr;
  57. int size;
  58. @@ -3010,6 +3009,7 @@ int ppp_check_kernel_support(void)
  59. }
  60. close(s);
  61. return ok;
  62. +#endif
  63. }
  64. #ifndef HAVE_LOGWTMP
  65. @@ -3571,6 +3571,7 @@ get_pty(int *master_fdp, int *slave_fdp,
  66. }
  67. #endif /* TIOCGPTN */
  68. +#if 0
  69. if (sfd < 0) {
  70. /* the old way - scan through the pty name space */
  71. for (i = 0; i < 64; ++i) {
  72. @@ -3595,6 +3596,7 @@ get_pty(int *master_fdp, int *slave_fdp,
  73. }
  74. }
  75. }
  76. +#endif
  77. if (sfd < 0)
  78. return 0;
  79. @@ -3710,6 +3712,7 @@ get_host_seed(void)
  80. int
  81. sys_check_options(void)
  82. {
  83. +#if 0
  84. if (demand && driver_is_old) {
  85. ppp_option_error("demand dialling is not supported by kernel driver "
  86. "version %d.%d.%d", driver_version, driver_modification,
  87. @@ -3720,6 +3723,7 @@ sys_check_options(void)
  88. warn("Warning: multilink is not supported by the kernel driver");
  89. multilink = 0;
  90. }
  91. +#endif
  92. return 1;
  93. }
  94. --- a/pppd/plugins/pppoatm/pppoatm.c
  95. +++ b/pppd/plugins/pppoatm/pppoatm.c
  96. @@ -180,10 +180,6 @@ static void disconnect_pppoatm(void)
  97. void plugin_init(void)
  98. {
  99. #ifdef linux
  100. - extern int new_style_driver; /* From sys-linux.c */
  101. - if (!ppp_check_kernel_support() && !new_style_driver)
  102. - fatal("Kernel doesn't support ppp_generic - "
  103. - "needed for PPPoATM");
  104. #else
  105. fatal("No PPPoATM support on this OS");
  106. #endif
  107. --- a/pppd/plugins/pppoe/plugin.c
  108. +++ b/pppd/plugins/pppoe/plugin.c
  109. @@ -54,9 +54,6 @@
  110. char pppd_version[] = PPPD_VERSION;
  111. -/* From sys-linux.c in pppd -- MUST FIX THIS! */
  112. -extern int new_style_driver;
  113. -
  114. char *pppd_pppoe_service = NULL;
  115. static char *acName = NULL;
  116. static char *existingSession = NULL;
  117. @@ -418,10 +415,6 @@ PPPoEDevnameHook(char *cmd, char **argv,
  118. void
  119. plugin_init(void)
  120. {
  121. - if (!ppp_check_kernel_support() && !new_style_driver) {
  122. - fatal("Linux kernel does not support PPPoE -- are you running 2.4.x?");
  123. - }
  124. -
  125. ppp_add_options(Options);
  126. info("PPPoE plugin from pppd %s", PPPD_VERSION);
  127. --- a/pppd/plugins/pppol2tp/pppol2tp.c
  128. +++ b/pppd/plugins/pppol2tp/pppol2tp.c
  129. @@ -501,10 +501,6 @@ static void pppol2tp_cleanup(void)
  130. void plugin_init(void)
  131. {
  132. #if defined(__linux__)
  133. - extern int new_style_driver; /* From sys-linux.c */
  134. - if (!ppp_check_kernel_support() && !new_style_driver)
  135. - fatal("Kernel doesn't support ppp_generic - "
  136. - "needed for PPPoL2TP");
  137. #else
  138. fatal("No PPPoL2TP support on this OS");
  139. #endif