Skip to contentSkip to conversation

ipvsadm: support for scheduler flags

PATCH In review Alexander Frolkin 3 participants 3 messages Jun 19, 2013 – Jun 20, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipvsadm: support for scheduler flags

This patch adds support for scheduler flags, necessary to make use of the "SH fallback and L4 hashing" kernel patch.

The flags are set per service (so using -A or -E) using -b <flags> or --sched-flags <flags>. <flags> is a comma-separated list of scheduler flags. The currently supported flags are sh-port, sh-fallback, and generic flag-1, flag-2, flag-3 for future-proofing.

This patch will work with older versions of IPVS, although setting the flags will have no effect.

---

ipvsadm.8 +9 -1
index 001ae74..9a9e9b3 100644
@@ -37,7 +37,7 @@ ipvsadm \- Linux Virtual Server administration
 .SH SYNOPSIS
 .B ipvsadm -A|E -t|u|f \fIservice-address\fP [-s \fIscheduler\fP]
 .ti 15
-.B [-p [\fItimeout\fP]] [-M \fInetmask\fP]
+.B [-p [\fItimeout\fP]] [-M \fInetmask\fP] [-b \fIsched-flags\fP]
 .br
 .B ipvsadm -D -t|u|f \fIservice-address\fP
 .br
@@ -248,6 +248,9 @@ addresses.
 .sp
 \fBsh\fR - Source Hashing: assigns jobs to servers through looking up
 a statically assigned hash table by their source IP addresses.
+This scheduler has two flags: sh-fallback, which enables fallback to a
+different server if the selected server was unavailable, and sh-port,
+which adds the source port number to the hash computation.
 .sp
 \fBsed\fR - Shortest Expected Delay: assigns an incoming job to the
 server with the shortest expected delay. The expected delay that the
@@ -286,6 +289,11 @@ resolve problems with non-persistent cache clusters on the client side.
 IPv6 netmasks should be specified as a prefix length between 1 and 128.
 The default prefix length is 128.
 .TP
+.B -b, --sched-flags \fIsched-flags\fP
+Set scheduler flags for this virtual server.  \fIsched-flags\fP is a
+comma-separated list of flags.  See the scheduler descriptions for
+valid scheduler flags.
+.TP
 .B -r, --real-server \fIserver-address\fP
 Real server that an associated request for service may be assigned to.
 The \fIserver-address\fP is the \fIhost\fP address of a real server,
ipvsadm.c +109 -19

215 lines not on this page · raw message

libipvs/ip_vs.h +7 -0
index 5e1d544..4db14ff 100644
@@ -29,6 +29,13 @@
 #define IP_VS_SVC_F_PERSISTENT	0x0001		/* persistent port */
 #define IP_VS_SVC_F_HASHED	0x0002		/* hashed entry */
 #define IP_VS_SVC_F_ONEPACKET	0x0004		/* one-packet scheduling */
+#define IP_VS_SVC_F_SCHED1	0x0008		/* scheduler flag 1 */
+#define IP_VS_SVC_F_SCHED2	0x0010		/* scheduler flag 2 */
+#define IP_VS_SVC_F_SCHED3	0x0020		/* scheduler flag 3 */
+
+#define IP_VS_SVC_F_SCHED_SH_FALLBACK	IP_VS_SVC_F_SCHED1 /* SH fallback */
+#define IP_VS_SVC_F_SCHED_SH_PORT	IP_VS_SVC_F_SCHED2 /* SH use port */
+
 
 /*
  *      IPVS sync daemon states
maintainer Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 8 lines · Alexander Frolkin

This patch adds support for scheduler flags, necessary to make use of the "SH fallback and L4 hashing" kernel patch.

The flags are set per service (so using -A or -E) using -b <flags> or --sched-flags <flags>. <flags> is a comma-separated list of scheduler flags. The currently supported flags are sh-port, sh-fallback, and generic flag-1, flag-2, flag-3 for future-proofing.

Quoted 4 lines

This patch will work with older versions of IPVS, although setting the flags will have no effect.

Change looks correct:

but we forgot some minor issues, see below...

ipvsadm.c parse_options(int argc, char **argv, struct ipvs_command_entry *ce, · line 432

Quoted 5 lines
ipvsadm.c +1 -0
@@ -426,9 +429,12 @@ parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
 		{ "ops", 'o', POPT_ARG_NONE, NULL, 'o', NULL, NULL },
 		{ "pe", '\0', POPT_ARG_STRING, &optarg, TAG_PERSISTENCE_ENGINE,
 		  NULL, NULL },
+		{ "sched-flags", 'b', POPT_ARG_STRING, &optarg, 'b', NULL, NULL },

You have to split this long line

ipvsadm.c parse_options(int argc, char **argv, struct ipvs_command_entry *ce, · line 667

Quoted 7 lines
ipvsadm.c +3 -0
@@ -656,6 +662,10 @@ parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
 			set_option(options, OPT_PERSISTENCE_ENGINE);
 			strncpy(ce->svc.pe_name, optarg, IP_VS_PENAME_MAXLEN);
 			break;
+		case 'b':
+			set_option(options, OPT_SCHED_FLAGS);
+			snprintf(sched_flags_arg, sizeof(sched_flags_arg), "%s", optarg);

This too

ipvsadm.c static void print_largenum(unsigned long long i, unsigned int format) · line 1450

Quoted 1 line
ipvsadm.c +1 -0
+static void print_sched_flags(ipvs_service_entry_t *se) {

{ <<< start func on new line

checkpatch.pl shows also this one:

ERROR: spaces required around that '=' (ctx:VxV) #121: FILE: ipvsadm.c:369:
+ char *optarg=NULL, sched_flags_arg[128];
^
May be you can send a fixed version to Simon.

Regards

--
Julian Anastasov <[email protected]>

maintainer
#2 lore raw
Quoted 46 lines · Julian Anastasov

Hello,

Quoted 8 lines · Alexander Frolkin

This patch adds support for scheduler flags, necessary to make use of the "SH fallback and L4 hashing" kernel patch.

The flags are set per service (so using -A or -E) using -b <flags> or --sched-flags <flags>. <flags> is a comma-separated list of scheduler flags. The currently supported flags are sh-port, sh-fallback, and generic flag-1, flag-2, flag-3 for future-proofing.

Quoted 4 lines

This patch will work with older versions of IPVS, although setting the flags will have no effect.

Change looks correct:

but we forgot some minor issues, see below...

ipvsadm.c parse_options(int argc, char **argv, struct ipvs_command_entry *ce, · line 432

Quoted 5 lines
ipvsadm.c +1 -0
@@ -426,9 +429,12 @@ parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
 		{ "ops", 'o', POPT_ARG_NONE, NULL, 'o', NULL, NULL },
 		{ "pe", '\0', POPT_ARG_STRING, &optarg, TAG_PERSISTENCE_ENGINE,
 		  NULL, NULL },
+		{ "sched-flags", 'b', POPT_ARG_STRING, &optarg, 'b', NULL, NULL },

You have to split this long line

ipvsadm.c parse_options(int argc, char **argv, struct ipvs_command_entry *ce, · line 667

Quoted 7 lines
ipvsadm.c +3 -0
@@ -656,6 +662,10 @@ parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
 			set_option(options, OPT_PERSISTENCE_ENGINE);
 			strncpy(ce->svc.pe_name, optarg, IP_VS_PENAME_MAXLEN);
 			break;
+		case 'b':
+			set_option(options, OPT_SCHED_FLAGS);
+			snprintf(sched_flags_arg, sizeof(sched_flags_arg), "%s", optarg);

This too

ipvsadm.c static void print_largenum(unsigned long long i, unsigned int format) · line 1450

Quoted 1 line
ipvsadm.c +1 -0
+static void print_sched_flags(ipvs_service_entry_t *se) {

{ <<< start func on new line

Quoted 7 lines

checkpatch.pl shows also this one:

ERROR: spaces required around that '=' (ctx:VxV) #121: FILE: ipvsadm.c:369:
+ char *optarg=NULL, sched_flags_arg[128];
^
May be you can send a fixed version to Simon.

Yes, please do.