diff -ruN ipvs-0.9.0/ipvs/ip_vs.h ipvs-0.9.0.new/ipvs/ip_vs.h --- ipvs-0.9.0/ipvs/ip_vs.h Wed May 9 08:01:14 2001 +++ ipvs-0.9.0.new/ipvs/ip_vs.h Fri May 11 14:54:35 2001 @@ -69,13 +69,13 @@ #define IP_VS_SO_SET_NONE IP_VS_BASE_CTL /* just peek */ #define IP_VS_SO_SET_INSERT (IP_VS_BASE_CTL+1) #define IP_VS_SO_SET_ADD (IP_VS_BASE_CTL+2) -#define IP_VS_SO_SET_EDIT (IP_VS_BASE_CTL+3) +#define IP_VS_SO_SET_EDIT (IP_VS_BASE_CTL+3) /* Depreciated */ #define IP_VS_SO_SET_DEL (IP_VS_BASE_CTL+4) #define IP_VS_SO_SET_FLUSH (IP_VS_BASE_CTL+5) #define IP_VS_SO_SET_LIST (IP_VS_BASE_CTL+6) #define IP_VS_SO_SET_ADDDEST (IP_VS_BASE_CTL+7) #define IP_VS_SO_SET_DELDEST (IP_VS_BASE_CTL+8) -#define IP_VS_SO_SET_EDITDEST (IP_VS_BASE_CTL+9) +#define IP_VS_SO_SET_EDITDEST (IP_VS_BASE_CTL+9) /* Depreciated */ #define IP_VS_SO_SET_TIMEOUTS (IP_VS_BASE_CTL+10) #define IP_VS_SO_SET_MAX IP_VS_SO_SET_TIMEOUTS diff -ruN ipvs-0.9.0/ipvs/ip_vs_ctl.c ipvs-0.9.0.new/ipvs/ip_vs_ctl.c --- ipvs-0.9.0/ipvs/ip_vs_ctl.c Wed May 9 08:01:15 2001 +++ ipvs-0.9.0.new/ipvs/ip_vs_ctl.c Fri May 11 14:46:26 2001 @@ -739,32 +739,21 @@ /* - * Add a destination into an existing service + * Actually add a new destination to a service + * Note: You should call ip_vs_add_dest() which will add or delete + * a destination as appropriate. */ -static int ip_vs_add_dest(struct ip_vs_service *svc, + +static int __ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_rule_user *ur) { - struct ip_vs_dest *dest; __u32 daddr = ur->daddr; __u16 dport = ur->dport; int ret; + struct ip_vs_dest *dest; EnterFunction(2); - if (ur->weight < 0) { - IP_VS_ERR("ip_vs_add_dest(): server weight less than zero\n"); - return -ERANGE; - } - - /* - * Check if the dest already exists in the list - */ - dest = ip_vs_lookup_dest(svc, daddr, dport); - if (dest != NULL) { - IP_VS_DBG(1, "ip_vs_add_dest(): dest already exists\n"); - return -EEXIST; - } - /* * Check if the dest already exists in the trash and * is from the same service @@ -838,10 +827,12 @@ /* - * Edit a destination in the given service + * Edit a destination in the given service + * Note: You should call ip_vs_add_dest() which will add or delete + * a destination as appropriate. */ -static int ip_vs_edit_dest(struct ip_vs_service *svc, - struct ip_vs_rule_user *ur) +static int __ip_vs_edit_dest(struct ip_vs_service *svc, + struct ip_vs_rule_user *ur) { struct ip_vs_dest *dest; __u32 daddr = ur->daddr; @@ -850,11 +841,6 @@ EnterFunction(2); - if (ur->weight < 0) { - IP_VS_ERR("ip_vs_add_dest(): server weight less than zero\n"); - return -ERANGE; - } - /* * Lookup the destination list */ @@ -873,6 +859,42 @@ /* + * Add a destination into an existing service + * If the destination alrady exists it will be edited + * using __ip_vs_edit_dest() + * Else add the destination using __ip_vs_add_dest() + */ +static int ip_vs_add_dest(struct ip_vs_service *svc, + struct ip_vs_rule_user *ur) +{ + __u32 daddr = ur->daddr; + __u16 dport = ur->dport; + struct ip_vs_dest *dest; + + EnterFunction(2); + + if (ur->weight < 0) { + IP_VS_ERR("ip_vs_add_dest(): server weight less than zero\n"); + return -ERANGE; + } + + /* + * Check if the dest already exists in the list + * If it does, edit the existing entry + * Else add a new one + */ + + dest = ip_vs_lookup_dest(svc, daddr, dport); + if (dest != NULL) + return __ip_vs_edit_dest(svc, ur); + else + return __ip_vs_add_dest(svc, ur); + + LeaveFunction(2); +} + + +/* * Delete a destination (must be already unlinked from the service) */ @@ -1788,14 +1810,11 @@ switch (cmd) { case IP_VS_SO_SET_ADD: - if (svc != NULL) - ret = -EEXIST; - else - ret = ip_vs_add_service(urule, &svc); - break; case IP_VS_SO_SET_EDIT: - if (svc == NULL || svc->protocol != urule->protocol) - ret = -ESRCH; + if (svc != NULL && svc->protocol != urule->protocol) + svc = NULL; + if (svc == NULL) + ret = ip_vs_add_service(urule, &svc); else ret = ip_vs_edit_service(svc, urule); break; @@ -1809,16 +1828,11 @@ } break; case IP_VS_SO_SET_ADDDEST: - if (svc == NULL || svc->protocol != urule->protocol) - ret = -ESRCH; - else - ret = ip_vs_add_dest(svc, urule); - break; case IP_VS_SO_SET_EDITDEST: if (svc == NULL || svc->protocol != urule->protocol) ret = -ESRCH; else - ret = ip_vs_edit_dest(svc, urule); + ret = ip_vs_add_dest(svc, urule); break; case IP_VS_SO_SET_DELDEST: if (svc == NULL || svc->protocol != urule->protocol) diff -ruN ipvs-0.9.0/ipvs/ipvsadm/VERSION ipvs-0.9.0.new/ipvs/ipvsadm/VERSION --- ipvs-0.9.0/ipvs/ipvsadm/VERSION Thu Mar 22 04:57:46 2001 +++ ipvs-0.9.0.new/ipvs/ipvsadm/VERSION Sat May 12 11:38:19 2001 @@ -1 +1 @@ -1.17 +1.18 diff -ruN ipvs-0.9.0/ipvs/ipvsadm/debian/changelog ipvs-0.9.0.new/ipvs/ipvsadm/debian/changelog --- ipvs-0.9.0/ipvs/ipvsadm/debian/changelog Thu Jan 11 06:14:59 2001 +++ ipvs-0.9.0.new/ipvs/ipvsadm/debian/changelog Sat May 12 11:39:08 2001 @@ -1,8 +1,8 @@ -ipvsadm (1.13-1) nstable; urgency=low +ipvsadm (1.18-1) nstable; urgency=low * A release - -- Horms Thu, 14 Dec 2000 17:00:00 -0800 + -- Simon Horman Sat, 12 May 2001 11:39:05 -0700 Local variables: mode: debian-changelog diff -ruN ipvs-0.9.0/ipvs/ipvsadm/ipvsadm.8 ipvs-0.9.0.new/ipvs/ipvsadm/ipvsadm.8 --- ipvs-0.9.0/ipvs/ipvsadm/ipvsadm.8 Thu Mar 22 04:57:46 2001 +++ ipvs-0.9.0.new/ipvs/ipvsadm/ipvsadm.8 Sat May 12 11:41:31 2001 @@ -14,6 +14,8 @@ .\" Horms : Tidy up some of the description and the .\" grammar in the -f and sysctl sections .\" Wensong Zhang : -s option description taken from ipchains(8) +.\" Horms : Depreciated Edit options, they are now +.\" handled by add. .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by @@ -30,12 +32,12 @@ .\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. .\" .\" -.TH IPVSADM 8 "11th January 2001" "LVS Administration" "Linux Administrator's Guide" +.TH IPVSADM 8 "11th May 2001" "LVS Administration" "Linux Administrator's Guide" .UC 4 .SH NAME ipvsadm \- Linux Virtual Server administration .SH SYNOPSIS -.B ipvsadm -A|E -t|u|f \fIservice-address\fP [-s \fIscheduler\fP] +.B ipvsadm -A -t|u|f \fIservice-address\fP [-s \fIscheduler\fP] .ti 15 .B [-p [\fItimeout\fP]] [-M \fInetmask\fP] .br @@ -47,7 +49,7 @@ .br .B ipvsadm -S [-n] .br -.B ipvsadm -a|e -t|u|f \fIservice-address\fP +.B ipvsadm -a -t|u|f \fIservice-address\fP .ti 15 .B -r|R \fIserver-address\fP [-g|i|m] [-w \fIweight\fP] .br @@ -99,10 +101,8 @@ .B -A, --add-service Add a virtual service. A service address is uniquely defined by a triplet: IP address, port number, and protocol. Alternatively, a -virtual service may be defined by a firewall-mark. -.TP -.B -E, --edit-service -Edit a virtual service. +virtual service may be defined by a firewall-mark. If the service +already exists then it will be modified according to the values given. .TP .B -D, --delete-service Delete a virtual service, along with any associated real servers. @@ -127,10 +127,8 @@ This option only works if \fIipvsadm\fP is compiled against \fBpopt\fR(3). .TP .B -a, --add-server -Add a real server to a virtual service. -.TP -.B -e, --edit-server -Edit a real server in a virtual service. +Add a real server to a virtual service. If the real server already exists +then it will be modified according to the values given. .TP .B -d, --delete-server Remove a real server from a virtual service. diff -ruN ipvs-0.9.0/ipvs/ipvsadm/ipvsadm.c ipvs-0.9.0.new/ipvs/ipvsadm/ipvsadm.c --- ipvs-0.9.0/ipvs/ipvsadm/ipvsadm.c Wed Apr 11 19:59:31 2001 +++ ipvs-0.9.0.new/ipvs/ipvsadm/ipvsadm.c Sat May 12 11:41:56 2001 @@ -50,6 +50,9 @@ * in an informative error message rather * than the usage information * Horms : added -v option + * Horms : Merged funtionality of add and edit options + * Depreciated edit option + * * * * ippfvsadm - Port Fowarding & Virtual Server ADMinistration program @@ -119,7 +122,7 @@ #endif #define IPVSADM_VERSION_NO "v" VERSION -#define IPVSADM_VERSION_DATE "2001/03/18" +#define IPVSADM_VERSION_DATE "2001/05/12" #define IPVSADM_VERSION IPVSADM_VERSION_NO " " IPVSADM_VERSION_DATE #define MINIMUM_IPVS_VERSION_MAJOR 0 @@ -218,7 +221,7 @@ struct poptOption add_service_option = {"add-service", 'A', POPT_ARG_NONE, NULL, 'A'}; struct poptOption edit_service_option = - {"edit-service", 'E', POPT_ARG_NONE, NULL, 'E'}; + {"edit-service", 'E', POPT_ARG_NONE, NULL, 'E'}; /* Depreciated */ struct poptOption delete_service_option = {"delete-service", 'D', POPT_ARG_NONE, NULL, 'D'}; struct poptOption clear_option = @@ -229,8 +232,8 @@ {"list", 'l', POPT_ARG_NONE, NULL, 'l'}; struct poptOption add_server_option = {"add-server", 'a', POPT_ARG_NONE, NULL, 'a'}; - struct poptOption edit_server_option = - {"edit-server", 'e', POPT_ARG_NONE, NULL, 'e'}; + struct poptOption edit_server_option = + {"edit-server", 'e', POPT_ARG_NONE, NULL, 'e'}; /* Depreciated */ struct poptOption delete_server_option = {"delete-server", 'd', POPT_ARG_NONE, NULL, 'd'}; struct poptOption set_option = @@ -359,11 +362,8 @@ switch (cmd) { case 'A': - *op = IP_VS_SO_SET_ADD; - options_sub = options_service; - break; case 'E': - *op = IP_VS_SO_SET_EDIT; + *op = IP_VS_SO_SET_ADD; options_sub = options_service; break; case 'D': @@ -371,11 +371,8 @@ options_sub = options_delete_service; break; case 'a': - *op = IP_VS_SO_SET_ADDDEST; - options_sub = options_server; - break; case 'e': - *op = IP_VS_SO_SET_EDITDEST; + *op = IP_VS_SO_SET_ADDDEST; options_sub = options_server; break; case 'd': @@ -621,12 +618,12 @@ struct option long_options[] = { {"add-service", 0, 0, 'A'}, - {"edit-service", 0, 0, 'E'}, + {"edit-service", 0, 0, 'E'}, /* Depreciated */ {"delete-service", 0, 0, 'D'}, {"clear", 0, 0, 'C'}, {"list", 0, 0, 'L'}, {"add-server", 0, 0, 'a'}, - {"edit-server", 0, 0, 'e'}, + {"edit-server", 0, 0, 'e'}, /* Depreciated */ {"delete-server", 0, 0, 'd'}, {"help", 0, 0, 'h'}, {"version", 0, 0, 'v'}, @@ -664,11 +661,8 @@ switch (cmd) { case 'A': - *op = IP_VS_SO_SET_ADD; - optstr = "t:u:f:s:M:p::"; - break; case 'E': - *op = IP_VS_SO_SET_EDIT; + *op = IP_VS_SO_SET_ADD; optstr = "t:u:f:s:M:p::"; break; case 'D': @@ -676,11 +670,8 @@ optstr = "t:u:f:"; break; case 'a': - *op = IP_VS_SO_SET_ADDDEST; - optstr = "t:u:f:w:r:R:gmi"; - break; case 'e': - *op = IP_VS_SO_SET_EDITDEST; + *op = IP_VS_SO_SET_ADDDEST; optstr = "t:u:f:w:r:R:gmi"; break; case 'd': @@ -886,7 +877,7 @@ return 0; } - if (op == IP_VS_SO_SET_ADD || op == IP_VS_SO_SET_EDIT) { + if (op == IP_VS_SO_SET_ADD) { /* * Make sure that port zero service is persistent */ @@ -907,13 +898,12 @@ * i.e. make sure that a -r accompanies a -[t|u|f] */ if ((op == IP_VS_SO_SET_ADDDEST - || op == IP_VS_SO_SET_EDITDEST || op == IP_VS_SO_SET_DELDEST) && !urule.daddr) { fail(2, "No destination specified"); } - if (op == IP_VS_SO_SET_ADDDEST || op == IP_VS_SO_SET_EDITDEST) { + if (op == IP_VS_SO_SET_ADDDEST) { /* * Set the default weight 1 if not specified */ @@ -947,16 +937,7 @@ */ switch (op) { case IP_VS_SO_SET_ADD: - if (errno == EEXIST) - printf("Service already exists\n"); - else if (errno == ENOENT) - printf("Scheduler not found: ip_vs_%s.o\n", - urule.sched_name); - break; - case IP_VS_SO_SET_EDIT: - if (errno==ESRCH) - printf("No such service\n"); - else if (errno == ENOENT) + if (errno == ENOENT) printf("Scheduler not found: ip_vs_%s.o\n", urule.sched_name); break; @@ -967,10 +948,6 @@ case IP_VS_SO_SET_ADDDEST: if (errno == ESRCH) printf("Service not defined\n"); - else if (errno == EEXIST) - printf("Destination already exists\n"); - break; - case IP_VS_SO_SET_EDITDEST: case IP_VS_SO_SET_DELDEST: if (errno==ESRCH) printf("Service not defined\n"); @@ -1124,14 +1101,14 @@ version(stream); fprintf(stream, "Usage:\n" - " %s -A|E -t|u|f service-address [-s scheduler] [-p [timeout]] [-M netmask]\n" + " %s -A -t|u|f service-address [-s scheduler] [-p [timeout]] [-M netmask]\n" " %s -D -t|u|f service-address\n" " %s -C\n" #ifdef HAVE_POPT " %s -R\n" " %s -S [-n]\n" #endif - " %s -a|e -t|u|f service-address -r|R server-address [-g|i|m] [-w weight]\n" + " %s -a -t|u|f service-address -r|R server-address [-g|i|m] [-w weight]\n" " %s -d -t|u|f service-address -r|R server-address\n" " %s -L|l [-c] [-n]\n" " %s -s tcp tcpfin udp\n" @@ -1145,16 +1122,14 @@ fprintf(stream, "Commands:\n" "Either long or short options are allowed.\n" - " --add-service -A add virtual service with options\n" - " --edit-service -E edit virtual service with options\n" + " --add-service -A add/edit virtual service with options\n" " --delete-service -D delete virtual service\n" " --clear -C clear the whole table\n" #ifdef HAVE_POPT " --restore -R restore rules from stdin\n" " --save -S save rules to stdout\n" #endif - " --add-server -a add real server with options\n" - " --edit-server -e edit real server with options\n" + " --add-server -a add/edit real server with options\n" " --delete-server -d delete real server\n" " --list -L|-l list the table\n" " --set|-s tcp tcpfin udp set connection timeout values\n"