1 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # Filename: package/.../ipvsadm2/ipvsadm-1.24.backwards_compat.patch
5 # Copyright (C) 2004 - 2006 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
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
15 # --- SDE-COPYRIGHT-NOTE-END ---
16 http://www.in-addr.de/pipermail/lvs-users/2005-January/013076.html
17 Horms <horms@verge.net.au>
19 BACKWARDS_COMPET_DEFINE= let you use ipvsadm on lx2.4 and lx2.6
20 NOTE: original patch exec `ipvsadm-1.21` but i choosed `ipvsadm.old`
23 diff -ruN ipvsadm-1.24/Makefile ipvsadm-1.24.backwards_compat/Makefile
24 --- ipvsadm-1.24/Makefile 2004-10-28 00:53:07.000000000 +0900
25 +++ ipvsadm-1.24.backwards_compat/Makefile 2005-01-27 13:24:45.000000000 +0900
27 POPT_DEFINE = -DHAVE_POPT
30 +# If defined then if the version of ipvs in the kernel is too old
31 +# for ipvsadm 1.24, then instead of trying to execute ipvsadm.1.21,
32 +# print a warning and soldier on
33 +BACKWARDS_COMPET_DEFINE= -DNO_BACKWARDS_COMPAT
35 OBJS = ipvsadm.o config_stream.o dynamic_array.o
37 DEFINES = -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
39 + $(POPT_DEFINE) $(BACKWARDS_COMPET_DEFINE)
40 DEFINES += $(shell if [ ! -f ../ip_vs.h ]; then \
41 echo "-DHAVE_NET_IP_VS_H"; fi;)
43 diff -ruN ipvsadm-1.24/ipvsadm.c ipvsadm-1.24.backwards_compat/ipvsadm.c
44 --- ipvsadm-1.24/ipvsadm.c 2004-01-10 18:39:03.000000000 +0900
45 +++ ipvsadm-1.24.backwards_compat/ipvsadm.c 2005-01-27 13:32:46.000000000 +0900
48 * Alexandre Cassen : added ipvs_syncd SyncdID support to filter
49 * incoming sync messages.
50 + * Horms : Added backwards compatibility code
53 * ippfvsadm - Port Fowarding & Virtual Server ADMinistration program
55 static void list_daemon(void);
57 static int modprobe_ipvs(void);
58 -static void check_ipvs_version(void);
59 +static void check_ipvs_version(char **argv);
60 static int process_options(int argc, char **argv, int reading_stdin);
62 +static void exec_old(char **argv);
65 int main(int argc, char **argv)
70 /* warn the user if the IPVS version is out of date */
71 - check_ipvs_version();
72 + check_ipvs_version(argv);
74 /* list the table if there is no other arguement */
76 @@ -1393,13 +1396,14 @@
80 -static void check_ipvs_version(void)
81 +static void check_ipvs_version(char *argv[])
83 /* verify the IPVS version */
84 if (ipvs_info.version <
85 IPVS_VERSION(MINIMUM_IPVS_VERSION_MAJOR,
86 MINIMUM_IPVS_VERSION_MINOR,
87 MINIMUM_IPVS_VERSION_PATCH)) {
90 "Warning: IPVS version missmatch: \n"
91 " Kernel compiled with IPVS version %d.%d.%d\n"
92 @@ -1896,3 +1900,46 @@
94 return (offset<top)?0:1;
98 +/* Simple backwards compat code to exec old version */
99 +/* Based on code form module-init-tools 3.1 */
101 +#ifndef NO_BACKWARDS_COMPAT
103 +static void exec_old(char **argv)
107 + char ascii_pid[32];
108 + char pathname[strlen(argv[0])+1];
109 + char oldname[strlen(argv[0])+strlen("ipvsadm.old")+1];
111 + memset(pathname, 0, strlen(argv[0])+1);
112 + sep = strrchr(argv[0], '/');
114 + memcpy(pathname, argv[0], sep - argv[0]+1);
115 + sprintf(oldname, "%sipvsadm.old", pathname);
117 + /* Use an environment variable for recursion detection */
119 + snprintf(ascii_pid, sizeof(ascii_pid), "%lu", (unsigned long)pid);
120 + if (strcmp(getenv("IPVSADM_RECURSE") ?: "", ascii_pid) == 0) {
121 + fprintf(stderr, "WARNING: %s: I am not the old version!\n",
125 + setenv("IPVSADM_RECURSE", ascii_pid, 1);
127 + execvp(oldname, argv);
129 + "Kernel requires old ipvsadm, but couldn't run %s: %s\n",
130 + oldname, strerror(errno));
134 +#else /* NO_BACKWARDS_COMPAT */
135 +static void exec_old(char **argv)
138 +#endif /* !NO_BACKWARDS_COMPAT */