Index: Build
===================================================================
RCS file: Build
diff -N Build
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Build	21 Apr 2005 11:59:59 -0000	1.2
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+source ../../Config.sh
+
+pp_do "$@"
Index: Makefile
===================================================================
RCS file: /srv/CVS/pp_shared/ipvsadm/Makefile,v
retrieving revision 1.1.133.2
retrieving revision 1.2
diff -u -r1.1.133.2 -r1.2
--- Makefile	11 Jun 2004 12:39:32 -0000	1.1.133.2
+++ Makefile	21 Apr 2005 11:59:59 -0000	1.2
@@ -24,21 +24,25 @@
 #      Wensong        :   Changed the OBJS according to detection
 #
 
+include ../../Config.mk
+
+FORCE_GETOPT = 1
+
 NAME	= ipvsadm
 VERSION	= $(shell cat VERSION)
 RELEASE	= 9
 SCHEDULERS = "$(shell cat SCHEDULERS)"
 PROGROOT = $(shell basename `pwd`)
 
-CC	= gcc
-CFLAGS	= -Wall -Wunused -Wstrict-prototypes -g -O2
+#CC	= gcc
+CFLAGS	= -Wall -Wunused -Wstrict-prototypes $(FW_CFLAGS_3RDPARTY) -D_GNU_SOURCE
 SBIN    = $(BUILD_ROOT)/sbin
 MANDIR	= usr/man
 MAN	= $(BUILD_ROOT)/$(MANDIR)/man8
 INIT    = $(BUILD_ROOT)/etc/rc.d/init.d
 MKDIR   = mkdir
 INSTALL = install
-INCLUDE = -I/usr/src/linux/include -I.. -I.
+INCLUDE = -I$(FW_TOPDIR)/$(LINUX_KERNEL_DIR)/include -I.. -I.
 STATIC_LIBS = libipvs/libipvs.a
 
 
@@ -83,17 +87,8 @@
 		$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
 install:        ipvsadm
-		if [ ! -d $(SBIN) ]; then $(MKDIR) -p $(SBIN); fi
-		$(INSTALL) -m 0755 -s ipvsadm $(SBIN)
-		$(INSTALL) -m 0755 ipvsadm-save $(SBIN)
-		$(INSTALL) -m 0755 ipvsadm-restore $(SBIN)
-		[ -d $(MAN) ] || $(MKDIR) -p $(MAN)
-		$(INSTALL) -m 0644 ipvsadm.8 $(MAN)
-		$(INSTALL) -m 0644 ipvsadm-save.8 $(MAN)
-		$(INSTALL) -m 0644 ipvsadm-restore.8 $(MAN)
-		if [ -d $(INIT) ]; then \
-		  $(INSTALL) -m 0755 ipvsadm.sh $(INIT)/ipvsadm; \
-		fi
+		$(MKDIR) -p $(DESTDIR)/sbin
+		$(INSTALL) -m 0755 ipvsadm $(DESTDIR)/sbin/	
 
 clean:
 		rm -f ipvsadm $(NAME).spec $(NAME)-$(VERSION).tar.gz
Index: ipvsadm.c
===================================================================
RCS file: /srv/CVS/pp_shared/ipvsadm/ipvsadm.c,v
retrieving revision 1.1.133.2
retrieving revision 1.2
diff -u -r1.1.133.2 -r1.2
--- ipvsadm.c	11 Jun 2004 12:39:32 -0000	1.1.133.2
+++ ipvsadm.c	21 Apr 2005 11:59:59 -0000	1.2
@@ -53,6 +53,7 @@
  *        Wensong Zhang       :   rewrite most code of parsing options and
  *                                processing options.
  *        Horms               :   added to load ip_vs_ftp for VS/NAT at port 21
+ *        Alexandre Cassen    :   added SyncID support
  *
  *
  *      ippfvsadm - Port Fowarding & Virtual Server ADMinistration program
@@ -120,7 +121,7 @@
 #include "libipvs/libipvs.h"
 
 #define IPVSADM_VERSION_NO		"v" VERSION
-#define IPVSADM_VERSION_DATE		"2003/10/27"
+#define IPVSADM_VERSION_DATE		"2004/02/23"
 #define IPVSADM_VERSION			IPVSADM_VERSION_NO " " IPVSADM_VERSION_DATE
 
 #define MINIMUM_IPVS_VERSION_MAJOR      1
@@ -166,7 +167,9 @@
 #define OPT_STATS	0x01000
 #define OPT_RATE	0x02000
 #define OPT_SORT	0x04000
-#define NUMBER_OF_OPT	15
+#define OPT_BUILDNR	0x08000
+#define OPT_SYNCID	0x10000
+#define NUMBER_OF_OPT	17
 
 static const char* optnames[] = {
 	"numeric",
@@ -184,6 +187,8 @@
 	"stats",
 	"rate",
 	"sort",
+	"buildnr",
+	"syncid",
 };
 
 /*
@@ -196,22 +201,22 @@
  */
 static const char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] =
 {
-	/*     -n   -c   svc  -s   -p   -M   -r   fwd  -w   -mc  -to  dmn  -st  -rt  srt */
-/*INSERT*/    {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x'},
-/*ADD*/       {'x', 'x', '+', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*EDIT*/      {'x', 'x', '+', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*DEL*/       {'x', 'x', '+', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*FLUSH*/     {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*LIST*/      {' ', '1', '1', 'x', 'x', 'x', 'x', 'x', 'x', 'x', '1', '1', ' ', ' ', ' '},
-/*ADD-SERVER*/{'x', 'x', '+', 'x', 'x', 'x', '+', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*DEL-SERVER*/{'x', 'x', '+', 'x', 'x', 'x', '+', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*EDIT-SRV*/  {'x', 'x', '+', 'x', 'x', 'x', '+', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*TIMEOUT*/   {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*START-D*/   {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', ' ', 'x', 'x', 'x', 'x', 'x'},
-/*STOP-D*/    {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*RESTORE*/   {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*SAVE*/      {' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
-/*ZERO*/      {'x', 'x', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+	/*     -n   -c   svc  -s   -p   -M   -r   fwd  -w   -mc  -to  dmn  -st  -rt  srt  sid */
+/*INSERT*/    {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x', ' '},
+/*ADD*/       {'x', 'x', '+', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*EDIT*/      {'x', 'x', '+', ' ', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*DEL*/       {'x', 'x', '+', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*FLUSH*/     {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*LIST*/      {' ', '1', '1', 'x', 'x', 'x', 'x', 'x', 'x', 'x', '1', '1', ' ', ' ', ' ', 'x'},
+/*ADD-SERVER*/{'x', 'x', '+', 'x', 'x', 'x', '+', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*DEL-SERVER*/{'x', 'x', '+', 'x', 'x', 'x', '+', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*EDIT-SRV*/  {'x', 'x', '+', 'x', 'x', 'x', '+', ' ', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*TIMEOUT*/   {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*START-D*/   {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', ' ', 'x', 'x', 'x', 'x', 'x', ' '},
+/*STOP-D*/    {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', ' '},
+/*RESTORE*/   {'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*SAVE*/      {' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
+/*ZERO*/      {'x', 'x', ' ', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'},
 };
 
 /* printing format flags */
@@ -243,7 +248,7 @@
 
 /* various parsing helpers & parsing functions */
 static int str_is_digit(const char *str);
-static int string_to_number(const char *s, int min, int max);
+static u_int64_t string_to_number(const char *s, u_int64_t min, u_int64_t max);
 static int host_to_addr(const char *name, struct in_addr *addr);
 static char * addr_to_host(struct in_addr *addr);
 static char * addr_to_anyname(struct in_addr *addr);
@@ -338,7 +343,7 @@
 		{"restore", 'R', POPT_ARG_NONE, NULL, 'R'},
 		{"save", 'S', POPT_ARG_NONE, NULL, 'S'},
 		{"start-daemon", '\0', POPT_ARG_STRING, &optarg, '1'},
-		{"stop-daemon", '\0', POPT_ARG_NONE, NULL, '2'},
+		{"stop-daemon", '\0', POPT_ARG_STRING, &optarg, '2'},
 		{"tcp-service", 't', POPT_ARG_STRING, &optarg, 't'},
 		{"udp-service", 'u', POPT_ARG_STRING, &optarg, 'u'},
 		{"fwmark-service", 'f', POPT_ARG_STRING, &optarg, 'f'},
@@ -354,6 +359,7 @@
 		{"numeric", 'n', POPT_ARG_NONE, NULL, 'n'},
 		{"connection", 'c', POPT_ARG_NONE, NULL, 'c'},
 		{"mcast-interface", '\0', POPT_ARG_STRING, &optarg, '3'},
+		{"syncid", '\0', POPT_ARG_STRING, &optarg, 'I'},
 		{"timeout", '\0', POPT_ARG_NONE, NULL, '5'},
 		{"daemon", '\0', POPT_ARG_NONE, NULL, '6'},
 		{"stats", '\0', POPT_ARG_NONE, NULL, '7'},
@@ -416,6 +422,11 @@
 		break;
 	case '2':
 		set_command(cmd, IP_VS_SO_SET_STOPDAEMON);
+		if (!strcmp(optarg, "master"))
+			ur->state = IP_VS_STATE_MASTER;
+		else if (!strcmp(optarg, "backup"))
+			ur->state = IP_VS_STATE_BACKUP;
+		else fail(2, "illegal start_daemon specified");
 		break;
 	case 'h':
 		usage_exit(argv[0], 0);
@@ -508,6 +519,12 @@
 			set_option(options, OPT_MCAST);
 			strncpy(ur->mcast_ifn, optarg, IP_VS_IFNAME_MAXLEN);
 			break;
+		case 'I':
+			set_option(options, OPT_SYNCID);
+			if ((ur->syncid =
+			    string_to_number(optarg, 0, ULLONG_MAX)) == -1)
+				fail(2, "illegal syncid specified");
+                       break;
 		case '5':
 			set_option(options, OPT_TIMEOUT);
 			break;
@@ -588,7 +605,7 @@
 		{"restore", 0, 0, 'R'},
 		{"set", 1, 0, '4'},
 		{"start-daemon", 1, 0, '1'},
-		{"stop-daemon", 0, 0, '2'},
+		{"stop-daemon", 1, 0, '2'},
 		{"tcp-service", 1, 0, 't'},
 		{"udp-service", 1, 0, 'u'},
 		{"fwmark-service", 1, 0, 'f'},
@@ -603,6 +620,8 @@
 		{"numeric", 0, 0, 'n'},
 		{"connection", 0, 0, 'c'},
 		{"mcast-interface", 1, 0, '3'},
+		{"buildnr", 1, 0, 'B'},
+		{"syncid", 1, 0, 'I'},
 		{"timeout", 0, 0, '5'},
 		{"daemon", 0, 0, '6'},
 		{"stats", 0, 0, '7'},
@@ -684,6 +703,11 @@
 		break;
 	case '2':
 		set_command(cmd, IP_VS_SO_SET_STOPDAEMON);
+		if (!strcmp(optarg, "master"))
+			ur->state = IP_VS_STATE_MASTER;
+		else if (!strcmp(optarg, "backup"))
+			ur->state = IP_VS_STATE_BACKUP;
+		else fail(2, "illegal start_daemon specified");
 		break;
 	case 'h':
 		usage_exit(argv[0], 0);
@@ -766,7 +790,7 @@
 		case 'w':
 			set_option(options, OPT_WEIGHT);
 			if ((ur->weight =
-			     string_to_number(optarg,0,65535)) == -1)
+			     string_to_number(optarg, 0, 65535)) == -1)
 				fail(2, "illegal weight specified");
 			break;
 		case 'c':
@@ -780,6 +804,18 @@
 			set_option(options, OPT_MCAST);
 			strncpy(ur->mcast_ifn, optarg, IP_VS_IFNAME_MAXLEN);
 			break;
+		case 'B':
+			set_option(options, OPT_BUILDNR);
+			if ((ur->buildnr =
+			    string_to_number(optarg, 0, UINT_MAX)) == -1)
+				fail(2, "illegal buildnr specified");
+			break;
+		case 'I':
+			set_option(options, OPT_SYNCID);
+			if ((ur->syncid =
+			    string_to_number(optarg, 0, ULLONG_MAX)) == -1)
+				fail(2, "illegal syncid specified");
+			break;
 		case '5':
 			set_option(options, OPT_TIMEOUT);
 			break;
@@ -928,13 +964,13 @@
 }
 
 
-static int string_to_number(const char *s, int min, int max)
+static u_int64_t string_to_number(const char *s, u_int64_t min, u_int64_t max)
 {
-	long number;
+	u_int64_t number;
 	char *end;
 
 	errno = 0;
-	number = strtol(s, &end, 10);
+	number = strtoull(s, &end, 0);
 	if (*end == '\0' && end != s) {
 		/* We parsed a number, let's see if we want this. */
 		if (errno != ERANGE && min <= number && number <= max)
@@ -971,7 +1007,7 @@
 	char *end;
 
 	errno = 0;
-	l = strtol(buf, &end, 10);
+	l = strtoul(buf, &end, 10);
 	if (*end != '\0' || end == buf ||
 	    errno == ERANGE || l <= 0 || l > UINT_MAX)
 		fail(2, "invalid fwmark value `%s' specified", buf);
@@ -1139,8 +1175,8 @@
 		"  %s -L|l [options]\n"
 		"  %s -Z [-t|u|f service-address]\n"
 		"  %s --set tcp tcpfin udp\n"
-		"  %s --start-daemon state [--mcast-interface interface]\n"
-		"  %s --stop-daemon\n"
+		"  %s --start-daemon state [--mcast-interface interface] [--syncid sid]\n"
+		"  %s --stop-daemon master|backup\n"
 		"  %s -h\n\n",
 		program, program, program,
 		program, program, program, program, program,
@@ -1181,6 +1217,7 @@
 		"  --masquerading -m                   masquerading (NAT)\n"
 		"  --weight       -w weight            capacity of real server\n"
 		"  --mcast-interface interface         multicast interface for connection sync\n"
+		"  --syncid sid                        syncid for connection sync (default=0)\n"
 		"  --connection   -c                   output of current IPVS connections\n"
 		"  --timeout                           output of timeout (tcp tcpfin udp)\n"
 		"  --daemon                            output of daemon information\n"
@@ -1611,19 +1648,12 @@
 	if (!(u = ipvs_get_daemon()))
 		exit(1);
 
-	switch (u->state) {
-	case IP_VS_STATE_NONE:
+	if (!u->state)
 		printf("not running\n");
-		break;
-	case IP_VS_STATE_MASTER:
-		printf("running as master (mcast=%s)\n", u->mcast_ifn);
-		break;
-	case IP_VS_STATE_BACKUP:
-		printf("running as backup (mcast=%s)\n", u->mcast_ifn);
-		break;
-	default:
-		fail(2, "invalid state");
-	}
+	if (u->state & IP_VS_STATE_MASTER)
+		printf("master sync daemon (mcast=%s)\n", u->mcast_master_ifn);
+	if (u->state & IP_VS_STATE_BACKUP)
+		printf("backup sync daemon (mcast=%s)\n", u->mcast_backup_ifn);
 	free(u);
 }
 
Index: ipvsadm.spec
===================================================================
RCS file: ipvsadm.spec
diff -N ipvsadm.spec
--- ipvsadm.spec	11 Jun 2004 12:39:32 -0000	1.1.133.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,94 +0,0 @@
-%define prefix   /usr
-
-Summary: Utility to administer the Linux Virtual Server
-Name: ipvsadm
-Version: 1.21
-Release: 9
-Copyright: GNU General Public Licence
-URL: http://www.LinuxVirtualServer.org/
-Group: Applications/System
-Source0: http://www.LinuxVirtualServer.org/software/ipvsadm-%{version}.tar.gz
-BuildRoot: /var/tmp/%name-%{PACKAGE_VERSION}-root
-Provides: %{name}-%{version}
-Conflicts: piranha <= 0.4.14
-
-%description
-ipvsadm is a utility to administer the IP Virtual Server services
-offered by the Linux kernel augmented with the IP Virtual Server patch.
-
-
-%prep
-%setup -n %{name}-%{version}
-
-
-%build
-CFLAGS="${RPM_OPT_FLAGS}" make
-
-
-%install
-rm -rf $RPM_BUILD_ROOT
-mkdir -p ${RPM_BUILD_ROOT}/{sbin,%{_mandir}/man8,etc/rc.d/init.d}
-make install BUILD_ROOT=${RPM_BUILD_ROOT} MANDIR=%{_mandir}
-
-
-%files
-%defattr(-,root,root)
-%doc README
-%config /etc/rc.d/init.d/ipvsadm
-/sbin/ipvsadm*
-%{_mandir}/man8/ipvsadm*
-
-%post
-/sbin/chkconfig --add ipvsadm
-
-%preun
-/sbin/chkconfig --del ipvsadm
-
-
-%clean
-rm -rf $RPM_BUILD_DIR/%{name}
-rm -rf $RPM_BUILD_ROOT
-
-
-%changelog
-* Sat Apr  5 2003 Wensong Zhang <wensong@linux-vs.org>
-- Removed the unnecessary Docdir setting
-
-* Thu Dec 16 2001 Wensong Zhang <wensong@linuxvirtualserver.org>
-- Changed to install ipvsadm man pages according to the %{_mandir}
-
-* Thu Dec 30 2000 Wensong Zhang <wensong@linuxvirtualserver.org>
-- update the %file section
-
-* Thu Dec 17 2000 Wensong Zhang <wensong@linuxvirtualserver.org>
-- Added a if-condition to keep both new or old rpm utility building
-  the package happily.
-
-* Tue Dec 12 2000 P.Copeland <bryce@redhat.com>
-- Small modifications to make the compiler happy in RH7 and the Alpha
-- Fixed the documentation file that got missed off in building
-  the rpm
-- Made a number of -pedantic mods though popt will not compile with
-  -pedantic
-
-* Wed Aug 9 2000 Horms <horms@vergenet.net>
-- Removed Obseletes tag as ipvsadm is back in /sbin where it belongs 
-  as it is more or less analogous to both route and ipchains both of
-  which reside in /sbin.
-- Create directory to install init script into. Init scripts won't install
-  into build directory unless this is done
-
-* Thu Jul  6 2000 Wensong Zhang <wensong@linuxvirtualserver.org>
-- Changed to build rpms on the ipvsadm tar ball directly
-
-* Wed Jun 21 2000 P.Copeland <copeland@redhat.com>
-- fixed silly install permission settings
-
-* Mon Jun 19 2000 P.Copeland <copeland@redhat.com>
-- Added 'dist' and 'rpms' to the Makefile
-- Added Obsoletes tag since there were early versions
-  of ipvsadm-*.rpm that installed in /sbin
-- Obsolete tag was a bit vicious re: piranha
-
-* Mon Apr 10 2000 Horms <horms@vergenet.net>
-- created for version 1.9
