Raw socket checks suitable for load balancers in direct routing mode (i.e. LVS-DR).
A collection of check scripts that uses RAW sockets to force the destination
MAC address, suitable to be used for load balancers (LB) in direct routing
mode (LVS-DR) to ensure that the real server is indeed answering to packets
that have as destination IP the Virtual IP (VIP).
Load balancers in direct routing mode (LVS-DR) usually works with this setup:
IF one of the real server is missing the configuration of the VIP as an alias
of the lo
interface, usually this is what happens:
While the enforcement of the VIP configuration on the loopback of the real
servers could be done with any configuration management tool, it will usually
not ensure that the interface is actually up at all time.
While an alarming tool could obviously check the status of the loopback
interface on the real server at all time, it will still just raise an alarm and
a manual or automatic intervention would be needed. Also in the case of an
automatic intervention the usual delay between checks in the alarming tools
will not avoid that some traffic got lost.
The proposed solution is to check the real servers using the same kind of
packets that characterize the normal routed traffic from the LB.
To achieve that a RAW socket is used to bypass both the ARP and the Kernel
networking stack that would not allow to use the VIP as the destination IP
in the checks given that the VIP is configured and announced on the LB
itself and the packets would not exit the LB at all.
The real server MAC address is resolved through ARP (for IPv4) and will be
used as the destination MAC address for all the packets. The destination IP
instead will be set to the VIP. RAW sockets are used in order to be able to
set all those values manually, by-passing the Kernel TCP stack.
In case of a cluster of LBs, usually the checks on the real servers are
performed by all the LBs, not only by the master one. Because the LBs in
stand-by/backup mode don’t have the VIP configured, the Kernel would reject
the traffic in response to the checks performed using the RAW sockets. In
this scenario the possible solutions are:
The first two solutions requires a manual configuration on the LBs, while the
third one requires that the check is aware of the LB role. In order to make
the checks aware of the role of the LB to use the third solution, an option
is available on all checks (-r) that allow to specify the path of a file
where the LB role is saved. The software that is in charge of changing the
LB role will need to update this file accordingly.
Because of the usage of RAW sockets, all checks need to be run as root
or have the CAP_NET_RAW capability.
To compile all checks just run:
make
bin/
directory.build/
directory.make clean
to clean all compiled artifacts.make tcp
, make http_get
make http
.