OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../ipvsadm2/ipvsadm-1.24.backwards_compat.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. http://www.in-addr.de/pipermail/lvs-users/2005-January/013076.html
  17. Horms <horms@verge.net.au>
  18. BACKWARDS_COMPET_DEFINE= let you use ipvsadm on lx2.4 and lx2.6
  19. NOTE: original patch exec `ipvsadm-1.21` but i choosed `ipvsadm.old`
  20. Alejandro
  21. diff -ruN ipvsadm-1.24/Makefile ipvsadm-1.24.backwards_compat/Makefile
  22. --- ipvsadm-1.24/Makefile 2004-10-28 00:53:07.000000000 +0900
  23. +++ ipvsadm-1.24.backwards_compat/Makefile 2005-01-27 13:24:45.000000000 +0900
  24. @@ -74,10 +75,15 @@
  25. POPT_DEFINE = -DHAVE_POPT
  26. endif
  27. +# If defined then if the version of ipvs in the kernel is too old
  28. +# for ipvsadm 1.24, then instead of trying to execute ipvsadm.1.21,
  29. +# print a warning and soldier on
  30. +BACKWARDS_COMPET_DEFINE= -DNO_BACKWARDS_COMPAT
  31. +
  32. OBJS = ipvsadm.o config_stream.o dynamic_array.o
  33. LIBS = $(POPT_LIB)
  34. DEFINES = -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
  35. - $(POPT_DEFINE)
  36. + $(POPT_DEFINE) $(BACKWARDS_COMPET_DEFINE)
  37. DEFINES += $(shell if [ ! -f ../ip_vs.h ]; then \
  38. echo "-DHAVE_NET_IP_VS_H"; fi;)
  39. diff -ruN ipvsadm-1.24/ipvsadm.c ipvsadm-1.24.backwards_compat/ipvsadm.c
  40. --- ipvsadm-1.24/ipvsadm.c 2004-01-10 18:39:03.000000000 +0900
  41. +++ ipvsadm-1.24.backwards_compat/ipvsadm.c 2005-01-27 13:32:46.000000000 +0900
  42. @@ -54,6 +54,7 @@
  43. * processing options.
  44. * Alexandre Cassen : added ipvs_syncd SyncdID support to filter
  45. * incoming sync messages.
  46. + * Horms : Added backwards compatibility code
  47. *
  48. *
  49. * ippfvsadm - Port Fowarding & Virtual Server ADMinistration program
  50. @@ -301,9 +302,11 @@
  51. static void list_daemon(void);
  52. static int modprobe_ipvs(void);
  53. -static void check_ipvs_version(void);
  54. +static void check_ipvs_version(char **argv);
  55. static int process_options(int argc, char **argv, int reading_stdin);
  56. +static void exec_old(char **argv);
  57. +
  58. int main(int argc, char **argv)
  59. {
  60. @@ -319,7 +322,7 @@
  61. }
  62. /* warn the user if the IPVS version is out of date */
  63. - check_ipvs_version();
  64. + check_ipvs_version(argv);
  65. /* list the table if there is no other arguement */
  66. if (argc == 1){
  67. @@ -1393,13 +1396,14 @@
  68. }
  69. -static void check_ipvs_version(void)
  70. +static void check_ipvs_version(char *argv[])
  71. {
  72. /* verify the IPVS version */
  73. if (ipvs_info.version <
  74. IPVS_VERSION(MINIMUM_IPVS_VERSION_MAJOR,
  75. MINIMUM_IPVS_VERSION_MINOR,
  76. MINIMUM_IPVS_VERSION_PATCH)) {
  77. + exec_old(argv);
  78. fprintf(stderr,
  79. "Warning: IPVS version missmatch: \n"
  80. " Kernel compiled with IPVS version %d.%d.%d\n"
  81. @@ -1896,3 +1900,46 @@
  82. return (offset<top)?0:1;
  83. }
  84. +
  85. +
  86. +/* Simple backwards compat code to exec old version */
  87. +/* Based on code form module-init-tools 3.1 */
  88. +
  89. +#ifndef NO_BACKWARDS_COMPAT
  90. +
  91. +static void exec_old(char **argv)
  92. +{
  93. + char *sep;
  94. + pid_t pid;
  95. + char ascii_pid[32];
  96. + char pathname[strlen(argv[0])+1];
  97. + char oldname[strlen(argv[0])+strlen("ipvsadm.old")+1];
  98. +
  99. + memset(pathname, 0, strlen(argv[0])+1);
  100. + sep = strrchr(argv[0], '/');
  101. + if (sep)
  102. + memcpy(pathname, argv[0], sep - argv[0]+1);
  103. + sprintf(oldname, "%sipvsadm.old", pathname);
  104. +
  105. + /* Use an environment variable for recursion detection */
  106. + pid = getpid();
  107. + snprintf(ascii_pid, sizeof(ascii_pid), "%lu", (unsigned long)pid);
  108. + if (strcmp(getenv("IPVSADM_RECURSE") ?: "", ascii_pid) == 0) {
  109. + fprintf(stderr, "WARNING: %s: I am not the old version!\n",
  110. + oldname);
  111. + return;
  112. + }
  113. + setenv("IPVSADM_RECURSE", ascii_pid, 1);
  114. +
  115. + execvp(oldname, argv);
  116. + fprintf(stderr,
  117. + "Kernel requires old ipvsadm, but couldn't run %s: %s\n",
  118. + oldname, strerror(errno));
  119. + exit(2);
  120. +}
  121. +
  122. +#else /* NO_BACKWARDS_COMPAT */
  123. +static void exec_old(char **argv)
  124. +{
  125. +}
  126. +#endif /* !NO_BACKWARDS_COMPAT */