400-simplify_kernel_checks.patch 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 <jo@mein.io>
  7. --- a/pppd/sys-linux.c
  8. +++ b/pppd/sys-linux.c
  9. @@ -196,7 +196,7 @@ static int driver_is_old = 0;
  10. static int restore_term = 0; /* 1 => we've munged the terminal */
  11. static struct termios inittermios; /* Initial TTY termios */
  12. -int new_style_driver = 0;
  13. +static const int new_style_driver = 1;
  14. static char loop_name[20];
  15. static unsigned char inbuf[512]; /* buffer for chars read from loopback */
  16. @@ -214,8 +214,8 @@ static int looped; /* 1 if using loop
  17. static int link_mtu; /* mtu for the link (not bundle) */
  18. static struct utsname utsname; /* for the kernel version */
  19. -static int kernel_version;
  20. #define KVERSION(j,n,p) ((j)*1000000 + (n)*1000 + (p))
  21. +static const int kernel_version = KVERSION(2,6,37);
  22. #define MAX_IFS 100
  23. @@ -1451,11 +1451,12 @@ int ccp_fatal_error (int unit)
  24. *
  25. * path_to_procfs - find the path to the proc file system mount point
  26. */
  27. -static char proc_path[MAXPATHLEN];
  28. -static int proc_path_len;
  29. +static char proc_path[MAXPATHLEN] = "/proc";
  30. +static int proc_path_len = 5;
  31. static char *path_to_procfs(const char *tail)
  32. {
  33. +#if 0
  34. struct mntent *mntent;
  35. FILE *fp;
  36. @@ -1477,6 +1478,7 @@ static char *path_to_procfs(const char *
  37. fclose (fp);
  38. }
  39. }
  40. +#endif
  41. strlcpy(proc_path + proc_path_len, tail,
  42. sizeof(proc_path) - proc_path_len);
  43. @@ -2129,15 +2131,19 @@ int ppp_available(void)
  44. int my_version, my_modification, my_patch;
  45. int osmaj, osmin, ospatch;
  46. +#if 0
  47. /* get the kernel version now, since we are called before sys_init */
  48. uname(&utsname);
  49. osmaj = osmin = ospatch = 0;
  50. sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch);
  51. kernel_version = KVERSION(osmaj, osmin, ospatch);
  52. +#endif
  53. fd = open("/dev/ppp", O_RDWR);
  54. if (fd >= 0) {
  55. +#if 0
  56. new_style_driver = 1;
  57. +#endif
  58. /* XXX should get from driver */
  59. driver_version = 2;
  60. @@ -2197,6 +2203,7 @@ int ppp_available(void)
  61. if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
  62. ok = 0;
  63. + return ok;
  64. /*
  65. * This is the PPP device. Validate the version of the driver at this
  66. @@ -2730,6 +2737,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
  67. }
  68. #endif /* TIOCGPTN */
  69. +#if 0
  70. if (sfd < 0) {
  71. /* the old way - scan through the pty name space */
  72. for (i = 0; i < 64; ++i) {
  73. @@ -2748,6 +2756,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
  74. }
  75. }
  76. }
  77. +#endif
  78. if (sfd < 0)
  79. return 0;
  80. --- a/pppd/plugins/pppoatm/pppoatm.c
  81. +++ b/pppd/plugins/pppoatm/pppoatm.c
  82. @@ -168,14 +168,6 @@ static void disconnect_pppoatm(void)
  83. void plugin_init(void)
  84. {
  85. -#if defined(__linux__)
  86. - extern int new_style_driver; /* From sys-linux.c */
  87. - if (!ppp_available() && !new_style_driver)
  88. - fatal("Kernel doesn't support ppp_generic - "
  89. - "needed for PPPoATM");
  90. -#else
  91. - fatal("No PPPoATM support on this OS");
  92. -#endif
  93. info("PPPoATM plugin_init");
  94. add_options(pppoa_options);
  95. }
  96. --- a/pppd/plugins/rp-pppoe/plugin.c
  97. +++ b/pppd/plugins/rp-pppoe/plugin.c
  98. @@ -59,9 +59,6 @@ static char const RCSID[] =
  99. char pppd_version[] = VERSION;
  100. -/* From sys-linux.c in pppd -- MUST FIX THIS! */
  101. -extern int new_style_driver;
  102. -
  103. char *pppd_pppoe_service = NULL;
  104. static char *acName = NULL;
  105. static char *existingSession = NULL;
  106. @@ -371,10 +368,6 @@ PPPoEDevnameHook(char *cmd, char **argv,
  107. void
  108. plugin_init(void)
  109. {
  110. - if (!ppp_available() && !new_style_driver) {
  111. - fatal("Linux kernel does not support PPPoE -- are you running 2.4.x?");
  112. - }
  113. -
  114. add_options(Options);
  115. info("RP-PPPoE plugin version %s compiled against pppd %s",
  116. --- a/pppd/plugins/pppol2tp/pppol2tp.c
  117. +++ b/pppd/plugins/pppol2tp/pppol2tp.c
  118. @@ -486,12 +486,7 @@ static void pppol2tp_cleanup(void)
  119. void plugin_init(void)
  120. {
  121. -#if defined(__linux__)
  122. - extern int new_style_driver; /* From sys-linux.c */
  123. - if (!ppp_available() && !new_style_driver)
  124. - fatal("Kernel doesn't support ppp_generic - "
  125. - "needed for PPPoL2TP");
  126. -#else
  127. +#if !defined(__linux__)
  128. fatal("No PPPoL2TP support on this OS");
  129. #endif
  130. add_options(pppol2tp_options);