Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 146cd6b5 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso
Browse files
Simon Horman says:

====================
IPVS Updates for v4.18

please consider these IPVS enhancements for v4.18.

* Whitepace cleanup

* Add Maglev hashing algorithm as a IPVS scheduler

  Inju Song says "Implements the Google's Maglev hashing algorithm as a
  IPVS scheduler.  Basically it provides consistent hashing but offers some
  special features about disruption and load balancing.

  1) minimal disruption: when the set of destinations changes,
     a connection will likely be sent to the same destination
     as it was before.

  2) load balancing: each destination will receive an almost
     equal number of connections.

 Seel also: [3.4 Consistent Hasing] in
 https://www.usenix.org/system/files/conference/nsdi16/nsdi16-paper-eisenbud.pdf


 "

* Fix to correct implementation of Knuth's multiplicative hashing
  which is used in sh/dh/lblc/lblcr algorithms. Instead the
  implementation provided by the hash_32() macro is used.
====================

Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parents d0103158 9a17740e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -668,6 +668,7 @@ struct ip_vs_dest {
	volatile unsigned int	flags;		/* dest status flags */
	volatile unsigned int	flags;		/* dest status flags */
	atomic_t		conn_flags;	/* flags to copy to conn */
	atomic_t		conn_flags;	/* flags to copy to conn */
	atomic_t		weight;		/* server weight */
	atomic_t		weight;		/* server weight */
	atomic_t		last_weight;	/* server latest weight */


	refcount_t		refcnt;		/* reference counter */
	refcount_t		refcnt;		/* reference counter */
	struct ip_vs_stats      stats;          /* statistics */
	struct ip_vs_stats      stats;          /* statistics */
+37 −0
Original line number Original line Diff line number Diff line
@@ -225,6 +225,25 @@ config IP_VS_SH
	  If you want to compile it in kernel, say Y. To compile it as a
	  If you want to compile it in kernel, say Y. To compile it as a
	  module, choose M here. If unsure, say N.
	  module, choose M here. If unsure, say N.


config	IP_VS_MH
	tristate "maglev hashing scheduling"
	---help---
	  The maglev consistent hashing scheduling algorithm provides the
	  Google's Maglev hashing algorithm as a IPVS scheduler. It assigns
	  network connections to the servers through looking up a statically
	  assigned special hash table called the lookup table. Maglev hashing
	  is to assign a preference list of all the lookup table positions
	  to each destination.

	  Through this operation, The maglev hashing gives an almost equal
	  share of the lookup table to each of the destinations and provides
	  minimal disruption by using the lookup table. When the set of
	  destinations changes, a connection will likely be sent to the same
	  destination as it was before.

	  If you want to compile it in kernel, say Y. To compile it as a
	  module, choose M here. If unsure, say N.

config	IP_VS_SED
config	IP_VS_SED
	tristate "shortest expected delay scheduling"
	tristate "shortest expected delay scheduling"
	---help---
	---help---
@@ -266,6 +285,24 @@ config IP_VS_SH_TAB_BITS
	  needs to be large enough to effectively fit all the destinations
	  needs to be large enough to effectively fit all the destinations
	  multiplied by their respective weights.
	  multiplied by their respective weights.


comment 'IPVS MH scheduler'

config IP_VS_MH_TAB_INDEX
	int "IPVS maglev hashing table index of size (the prime numbers)"
	range 8 17
	default 12
	---help---
	  The maglev hashing scheduler maps source IPs to destinations
	  stored in a hash table. This table is assigned by a preference
	  list of the positions to each destination until all slots in
	  the table are filled. The index determines the prime for size of
	  the table as 251, 509, 1021, 2039, 4093, 8191, 16381, 32749,
	  65521 or 131071. When using weights to allow destinations to
	  receive more connections, the table is assigned an amount
	  proportional to the weights specified. The table needs to be large
	  enough to effectively fit all the destinations multiplied by their
	  respective weights.

comment 'IPVS application helper'
comment 'IPVS application helper'


config	IP_VS_FTP
config	IP_VS_FTP
+1 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ obj-$(CONFIG_IP_VS_LBLC) += ip_vs_lblc.o
obj-$(CONFIG_IP_VS_LBLCR) += ip_vs_lblcr.o
obj-$(CONFIG_IP_VS_LBLCR) += ip_vs_lblcr.o
obj-$(CONFIG_IP_VS_DH) += ip_vs_dh.o
obj-$(CONFIG_IP_VS_DH) += ip_vs_dh.o
obj-$(CONFIG_IP_VS_SH) += ip_vs_sh.o
obj-$(CONFIG_IP_VS_SH) += ip_vs_sh.o
obj-$(CONFIG_IP_VS_MH) += ip_vs_mh.o
obj-$(CONFIG_IP_VS_SED) += ip_vs_sed.o
obj-$(CONFIG_IP_VS_SED) += ip_vs_sed.o
obj-$(CONFIG_IP_VS_NQ) += ip_vs_nq.o
obj-$(CONFIG_IP_VS_NQ) += ip_vs_nq.o


+4 −0
Original line number Original line Diff line number Diff line
@@ -821,6 +821,10 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
	if (add && udest->af != svc->af)
	if (add && udest->af != svc->af)
		ipvs->mixed_address_family_dests++;
		ipvs->mixed_address_family_dests++;


	/* keep the last_weight with latest non-0 weight */
	if (add || udest->weight != 0)
		atomic_set(&dest->last_weight, udest->weight);

	/* set the weight and the flags */
	/* set the weight and the flags */
	atomic_set(&dest->weight, udest->weight);
	atomic_set(&dest->weight, udest->weight);
	conn_flags = udest->conn_flags & IP_VS_CONN_F_DEST_MASK;
	conn_flags = udest->conn_flags & IP_VS_CONN_F_DEST_MASK;
+2 −1
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@
#include <linux/module.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
#include <linux/skbuff.h>
#include <linux/hash.h>


#include <net/ip_vs.h>
#include <net/ip_vs.h>


@@ -81,7 +82,7 @@ static inline unsigned int ip_vs_dh_hashkey(int af, const union nf_inet_addr *ad
		addr_fold = addr->ip6[0]^addr->ip6[1]^
		addr_fold = addr->ip6[0]^addr->ip6[1]^
			    addr->ip6[2]^addr->ip6[3];
			    addr->ip6[2]^addr->ip6[3];
#endif
#endif
	return (ntohl(addr_fold)*2654435761UL) & IP_VS_DH_TAB_MASK;
	return hash_32(ntohl(addr_fold), IP_VS_DH_TAB_BITS);
}
}




Loading