Add support for mh scheduler
PATCH v2 3/3 Add support for mh scheduler
Signed-off-by Quentin Armitage <[email protected]>
--- SCHEDULERS | 2 +- ipvsadm.8 | 9 +++++++++ ipvsadm.c | 17 +++++++++++++++-- libipvs/ip_vs.h | 3 +++ 4 files changed, 28 insertions(+), 3 deletions(-)
SCHEDULERS +1 -1
@@ -1 +1 @@ -rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq|fo|ovf +rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq|fo|ovf|mh
ipvsadm.8 +9 -0
@@ -276,6 +276,15 @@ with the highest weight that is currently available and overflows to the next when active connections exceed the node's weight. Note that this scheduler might not be suitable for UDP because it only uses active connections. +.sp +\fBmh\fR - Maglev Hashing: assigns incoming jobs based on Google's +Maglev hashing algorithm, providing an almost equal share of jobs to +each real server and provides minimal disruption. When the set of real +servers changes, a connection will likely be sent to the same real +server as it was before. +This scheduler has two flags: mh-fallback, which enables fallback to a +different server if the selected server was unavailable, and mh-port, +which adds the source port number to the hash computation. .TP .B -p, --persistent [\fItimeout\fP] Specify that a virtual service is persistent. If this option is
ipvsadm.c +15 -2
@@ -1145,6 +1145,16 @@ static unsigned int parse_sched_flags(const char *sched, char *optarg)if (strcmp (sched,"sh" ))fail (2 ,"incompatible scheduler flag `%s'" , flag); + }else if (!strcmp (flag,"mh-fallback" )) { + flags |=IP_VS_SVC_F_SCHED_MH_FALLBACK ; +if (strcmp (sched,"mh" )) +fail (2 ,"incompatible scheduler flag `%s'" , + flag); + }else if (!strcmp (flag,"mh-port" )) { + flags |=IP_VS_SVC_F_SCHED_MH_PORT ; +if (strcmp (sched,"mh" )) +fail (2 ,"incompatible scheduler flag `%s'" , + flag); }else {fail (2 ,"invalid scheduler flag `%s'" , flag); }
@@ -1589,8 +1599,11 @@ static void print_sched_flags(ipvs_service_entry_t *se)strcat (flags,"sh-fallback," );if (se->flags &IP_VS_SVC_F_SCHED_SH_PORT )strcat (flags,"sh-port," ); -if (se->flags &IP_VS_SVC_F_SCHED3 ) -strcat (flags,"flag-3," ); + }else if (!strcmp (se->sched_name,"mh" )) { +if (se->flags &IP_VS_SVC_F_SCHED_MH_FALLBACK ) +strcat (flags,"mh-fallback," ); +if (se->flags &IP_VS_SVC_F_SCHED_MH_PORT ) +strcat (flags,"mh-port," ); }else {if (se->flags &IP_VS_SVC_F_SCHED1 )strcat (flags,"flag-1," );
libipvs/ip_vs.h +3 -0
@@ -36,6 +36,9 @@#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 */ +#define IP_VS_SVC_F_SCHED_MH_FALLBACK IP_VS_SVC_F_SCHED1/* MH fallback */ +#define IP_VS_SVC_F_SCHED_MH_PORT IP_VS_SVC_F_SCHED2/* MH use port */ +/* * IPVS sync daemon states