|
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
|
|
#
|
|
|
|
# Filename: package/.../ipvsadm2/ipvsadm-1.24.backwards_compat.patch
|
|
|
|
# Copyright (C) 2004 - 2006 The T2 SDE Project
|
|
|
|
#
|
|
|
|
# More information can be found in the files COPYING and README.
|
|
|
|
#
|
|
|
|
# This patch file is dual-licensed. It is available under the license the
|
|
|
|
# patched project is licensed under, as long as it is an OpenSource license
|
|
|
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
|
|
|
# of the GNU General Public License as published by the Free Software
|
|
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
http://www.in-addr.de/pipermail/lvs-users/2005-January/013076.html
|
|
|
|
Horms <horms@verge.net.au>
|
|
|
|
|
|
|
|
BACKWARDS_COMPET_DEFINE= let you use ipvsadm on lx2.4 and lx2.6
|
|
|
|
NOTE: original patch exec `ipvsadm-1.21` but i choosed `ipvsadm.old`
|
|
|
|
Alejandro
|
|
|
|
|
|
|
|
diff -ruN ipvsadm-1.24/Makefile ipvsadm-1.24.backwards_compat/Makefile
|
|
|
|
--- ipvsadm-1.24/Makefile 2004-10-28 00:53:07.000000000 +0900
|
|
|
|
+++ ipvsadm-1.24.backwards_compat/Makefile 2005-01-27 13:24:45.000000000 +0900
|
|
|
|
@@ -74,10 +75,15 @@
|
|
|
|
POPT_DEFINE = -DHAVE_POPT
|
|
|
|
endif
|
|
|
|
|
|
|
|
+# If defined then if the version of ipvs in the kernel is too old
|
|
|
|
+# for ipvsadm 1.24, then instead of trying to execute ipvsadm.1.21,
|
|
|
|
+# print a warning and soldier on
|
|
|
|
+BACKWARDS_COMPET_DEFINE= -DNO_BACKWARDS_COMPAT
|
|
|
|
+
|
|
|
|
OBJS = ipvsadm.o config_stream.o dynamic_array.o
|
|
|
|
LIBS = $(POPT_LIB)
|
|
|
|
DEFINES = -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
|
|
|
|
- $(POPT_DEFINE)
|
|
|
|
+ $(POPT_DEFINE) $(BACKWARDS_COMPET_DEFINE)
|
|
|
|
DEFINES += $(shell if [ ! -f ../ip_vs.h ]; then \
|
|
|
|
echo "-DHAVE_NET_IP_VS_H"; fi;)
|
|
|
|
|
|
|
|
diff -ruN ipvsadm-1.24/ipvsadm.c ipvsadm-1.24.backwards_compat/ipvsadm.c
|
|
|
|
--- ipvsadm-1.24/ipvsadm.c 2004-01-10 18:39:03.000000000 +0900
|
|
|
|
+++ ipvsadm-1.24.backwards_compat/ipvsadm.c 2005-01-27 13:32:46.000000000 +0900
|
|
|
|
@@ -54,6 +54,7 @@
|
|
|
|
* processing options.
|
|
|
|
* Alexandre Cassen : added ipvs_syncd SyncdID support to filter
|
|
|
|
* incoming sync messages.
|
|
|
|
+ * Horms : Added backwards compatibility code
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ippfvsadm - Port Fowarding & Virtual Server ADMinistration program
|
|
|
|
@@ -301,9 +302,11 @@
|
|
|
|
static void list_daemon(void);
|
|
|
|
|
|
|
|
static int modprobe_ipvs(void);
|
|
|
|
-static void check_ipvs_version(void);
|
|
|
|
+static void check_ipvs_version(char **argv);
|
|
|
|
static int process_options(int argc, char **argv, int reading_stdin);
|
|
|
|
|
|
|
|
+static void exec_old(char **argv);
|
|
|
|
+
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
@@ -319,7 +322,7 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
/* warn the user if the IPVS version is out of date */
|
|
|
|
- check_ipvs_version();
|
|
|
|
+ check_ipvs_version(argv);
|
|
|
|
|
|
|
|
/* list the table if there is no other arguement */
|
|
|
|
if (argc == 1){
|
|
|
|
@@ -1393,13 +1396,14 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-static void check_ipvs_version(void)
|
|
|
|
+static void check_ipvs_version(char *argv[])
|
|
|
|
{
|
|
|
|
/* verify the IPVS version */
|
|
|
|
if (ipvs_info.version <
|
|
|
|
IPVS_VERSION(MINIMUM_IPVS_VERSION_MAJOR,
|
|
|
|
MINIMUM_IPVS_VERSION_MINOR,
|
|
|
|
MINIMUM_IPVS_VERSION_PATCH)) {
|
|
|
|
+ exec_old(argv);
|
|
|
|
fprintf(stderr,
|
|
|
|
"Warning: IPVS version missmatch: \n"
|
|
|
|
" Kernel compiled with IPVS version %d.%d.%d\n"
|
|
|
|
@@ -1896,3 +1900,46 @@
|
|
|
|
|
|
|
|
return (offset<top)?0:1;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/* Simple backwards compat code to exec old version */
|
|
|
|
+/* Based on code form module-init-tools 3.1 */
|
|
|
|
+
|
|
|
|
+#ifndef NO_BACKWARDS_COMPAT
|
|
|
|
+
|
|
|
|
+static void exec_old(char **argv)
|
|
|
|
+{
|
|
|
|
+ char *sep;
|
|
|
|
+ pid_t pid;
|
|
|
|
+ char ascii_pid[32];
|
|
|
|
+ char pathname[strlen(argv[0])+1];
|
|
|
|
+ char oldname[strlen(argv[0])+strlen("ipvsadm.old")+1];
|
|
|
|
+
|
|
|
|
+ memset(pathname, 0, strlen(argv[0])+1);
|
|
|
|
+ sep = strrchr(argv[0], '/');
|
|
|
|
+ if (sep)
|
|
|
|
+ memcpy(pathname, argv[0], sep - argv[0]+1);
|
|
|
|
+ sprintf(oldname, "%sipvsadm.old", pathname);
|
|
|
|
+
|
|
|
|
+ /* Use an environment variable for recursion detection */
|
|
|
|
+ pid = getpid();
|
|
|
|
+ snprintf(ascii_pid, sizeof(ascii_pid), "%lu", (unsigned long)pid);
|
|
|
|
+ if (strcmp(getenv("IPVSADM_RECURSE") ?: "", ascii_pid) == 0) {
|
|
|
|
+ fprintf(stderr, "WARNING: %s: I am not the old version!\n",
|
|
|
|
+ oldname);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ setenv("IPVSADM_RECURSE", ascii_pid, 1);
|
|
|
|
+
|
|
|
|
+ execvp(oldname, argv);
|
|
|
|
+ fprintf(stderr,
|
|
|
|
+ "Kernel requires old ipvsadm, but couldn't run %s: %s\n",
|
|
|
|
+ oldname, strerror(errno));
|
|
|
|
+ exit(2);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#else /* NO_BACKWARDS_COMPAT */
|
|
|
|
+static void exec_old(char **argv)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+#endif /* !NO_BACKWARDS_COMPAT */
|