diff -ur ipvsadm-1.21/ipvsadm.c ipvsadm-1.21-ops/ipvsadm.c --- ipvsadm-1.21/ipvsadm.c 2004-01-10 11:35:54.000000000 +0200 +++ ipvsadm-1.21-ops/ipvsadm.c 2004-03-31 01:13:39.367464584 +0300 @@ -166,7 +166,8 @@ #define OPT_STATS 0x01000 #define OPT_RATE 0x02000 #define OPT_SORT 0x04000 -#define NUMBER_OF_OPT 15 +#define OPT_ONEPACKET 0x08000 +#define NUMBER_OF_OPT 16 static const char* optnames[] = { "numeric", @@ -184,6 +185,7 @@ "stats", "rate", "sort", + "ops", }; /* @@ -359,6 +361,7 @@ {"stats", '\0', POPT_ARG_NONE, NULL, '7'}, {"rate", '\0', POPT_ARG_NONE, NULL, '8'}, {"sort", '\0', POPT_ARG_NONE, NULL, '9'}, + {"ops", 'o', POPT_ARG_NONE, NULL, 'o'}, {NULL, 0, 0, NULL, 0} }; @@ -456,7 +459,7 @@ break; case 'p': set_option(options, OPT_PERSISTENT); - ur->vs_flags = IP_VS_SVC_F_PERSISTENT; + ur->vs_flags |= IP_VS_SVC_F_PERSISTENT; ur->timeout = parse_timeout(optarg, 1, MAX_TIMEOUT); break; case 'M': @@ -526,6 +529,10 @@ set_option(options, OPT_SORT); *format |= FMT_SORT; break; + case 'o': + set_option(options, OPT_ONEPACKET); + ur->vs_flags |= IP_VS_SVC_F_ONEPACKET; + break; default: fail(2, "invalid option"); } @@ -571,7 +578,7 @@ int *cmd, unsigned int *options, unsigned int *format) { int c, parse; - const char *optstring = "AEDCZSRaedlLhvt:u:f:s:M:p::w:r:gmicn"; + const char *optstring = "AEDCZSRaedlLhvt:u:f:s:M:p::w:r:gmicno"; const struct option long_options[] = { {"add-service", 0, 0, 'A'}, {"edit-service", 0, 0, 'E'}, @@ -608,6 +615,7 @@ {"stats", 0, 0, '7'}, {"rate", 0, 0, '8'}, {"sort", 0, 0, '9'}, + {"ops", 0, 0, 'o'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0} }; @@ -725,7 +733,7 @@ break; case 'p': set_option(options, OPT_PERSISTENT); - ur->vs_flags = IP_VS_SVC_F_PERSISTENT; + ur->vs_flags |= IP_VS_SVC_F_PERSISTENT; if (!optarg && optind < argc && argv[optind][0] != '-' && argv[optind][0] != '!') optarg = argv[optind++]; @@ -798,6 +806,10 @@ set_option(options, OPT_SORT); *format |= FMT_SORT; break; + case 'o': + set_option(options, OPT_ONEPACKET); + ur->vs_flags |= IP_VS_SVC_F_ONEPACKET; + break; default: fail(2, "invalid option"); } @@ -884,10 +896,15 @@ * Make sure that port zero service is persistent */ if (!urule.vfwmark && !urule.vport && - (urule.vs_flags != IP_VS_SVC_F_PERSISTENT)) + !(urule.vs_flags & IP_VS_SVC_F_PERSISTENT)) fail(2, "Zero port specified " "for non-persistent service"); + if (urule.vs_flags & IP_VS_SVC_F_ONEPACKET && + !urule.vfwmark && urule.protocol != IPPROTO_UDP) + fail(2, "One-Packet Scheduling is only " + "for UDP virtual services"); + /* * Set the default scheduling algorithm if not specified */ @@ -1187,6 +1204,7 @@ " --stats output of statistics information\n" " --rate output of rate information\n" " --sort sorting output of service/server entries\n" + " --ops -o one-packet scheduling\n" " --numeric -n numeric output of addresses and ports\n", DEF_SCHED); @@ -1482,6 +1500,9 @@ printf(" -M %s", inet_ntoa(mask)); } } + if (svc->flags & IP_VS_SVC_F_ONEPACKET) { + printf(" ops"); + } } else if (format & FMT_STATS) { printf("%-33s", svc_name); print_largenum(svc->stats.conns); @@ -1506,6 +1527,9 @@ printf(" mask %s", inet_ntoa(mask)); } } + if (svc->flags & IP_VS_SVC_F_ONEPACKET) { + printf(" ops"); + } } printf("\n");