|
Packit |
556e73 |
_ _ _ _ _ _
|
|
Packit |
556e73 |
| (_) |__ | | _____ ___ _ __ __ _| (_)_ _____
|
|
Packit |
556e73 |
| | | '_ \| |/ / _ \/ _ \ '_ \ / _` | | \ \ / / _ \
|
|
Packit |
556e73 |
| | | |_) | < __/ __/ |_) | (_| | | |\ V / __/
|
|
Packit |
556e73 |
|_|_|_.__/|_|\_\___|\___| .__/ \__,_|_|_| \_/ \___|
|
|
Packit |
556e73 |
|_|
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
(C) Fabio Busatto <fabio.busatto@gmail.com>
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
1. OVERVIEW
|
|
Packit |
556e73 |
Many systems provide the ability to keep tcp connections alive, so they
|
|
Packit |
556e73 |
aren't reset by peers or by routers because of inactivity.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
Even if this feature is present, only a few programs correctly implement
|
|
Packit |
556e73 |
the code to use it. If your favourite foo-client is not written with
|
|
Packit |
556e73 |
support for tcp keepalive, you'll continue to see your connection reset.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
libkeepalive library provides a way to enable tcp keepalive support in
|
|
Packit |
556e73 |
any program that uses shared libraries (e.g.: glibc shared object) to
|
|
Packit |
556e73 |
perform network operations. Using the preload method, you will be able to
|
|
Packit |
556e73 |
intercept normal program execution and to inject the code needed to enable
|
|
Packit |
556e73 |
the keepalive routines, everything done without modifying the original
|
|
Packit |
556e73 |
binary file and with no need to gain root privileges.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
2. OBTAINING SOFTWARE
|
|
Packit |
556e73 |
Latest version of libkeepalive is available on
|
|
Packit |
556e73 |
http://libkeepalive.sourceforge.net/#download.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
3. BUILDING BINARIES
|
|
Packit |
556e73 |
Just run make (use gmake if your default make is another one).
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
4. INSTALLING
|
|
Packit |
556e73 |
Simply copy libkeepalive.so in some cool directory (/usr/lib, or ~/lib if
|
|
Packit |
556e73 |
you're not so elite to have root privileges).
|
|
Packit |
556e73 |
If you want to enable keepalive in suid programs too, you have to copy
|
|
Packit |
556e73 |
libkeepalive.so in /lib or /usr/lib and suid it (according to ld.so
|
|
Packit |
556e73 |
manpage). In any other scenarios the library will not work with suid
|
|
Packit |
556e73 |
binaries.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
5. USER CONFIGURATION
|
|
Packit |
556e73 |
libkeepalive will do its job if you set the environment variable LD_PRELOAD
|
|
Packit |
556e73 |
to the path of libkeepalive.so shared library before executing the target
|
|
Packit |
556e73 |
program. You must specify the full path of the library if ld.so cannot is
|
|
Packit |
556e73 |
not able to find it. You can also set the variable in your startup script
|
|
Packit |
556e73 |
(i.e.: ~/.profile), depending from your shell.
|
|
Packit |
556e73 |
For informations about setting environment variables, refer to your shell
|
|
Packit |
556e73 |
documentation.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
6. SYSTEM-WIDE CONFIGURATION
|
|
Packit |
556e73 |
Host administrators may want to impose the use of libkeepalive to all their
|
|
Packit |
556e73 |
users and all daemons loaded by the system startup process.
|
|
Packit |
556e73 |
Adding the full path of the libkeepalive.so dynamic library to
|
|
Packit |
556e73 |
/etc/ld.so.preload you obtain the same result as the LD_PRELOAD variable is
|
|
Packit |
556e73 |
always set, forcing the use indipendently from the environment.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
7. DISABLING FOR A SPECIFIC EXECUTION
|
|
Packit |
556e73 |
If you need to disable the action of libkeepalive for a single job, or if
|
|
Packit |
556e73 |
your admin set the ld.so.preload, you can set the KEEPALIVE environment
|
|
Packit |
556e73 |
variable to "off", inhibiting the library even if it will be loaded.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
8. TUNING KEEPALIVE PARAMETERS
|
|
Packit |
556e73 |
You can change the keepalive parameters using environment variables or via
|
|
Packit |
556e73 |
sysctl/procfs.
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
env sysctl
|
|
Packit |
556e73 |
KEEPCNT <=> net.ipv4.tcp_keepalive_probes
|
|
Packit |
556e73 |
KEEPIDLE <=> net.ipv4.tcp_keepalive_time
|
|
Packit |
556e73 |
KEEPINTVL <=> net.ipv4.tcp_keepalive_intvl
|
|
Packit |
556e73 |
|
|
Packit |
556e73 |
DON'T FORGET to configure your system-specific parameters for keepalive!
|
|
Packit |
556e73 |
Many times, defaults are not what you need and you have to change your
|
|
Packit |
556e73 |
settings (see your system documentation for this).
|