blob: 2e5d7613cd7d592789868d6e6cb39e38a744a662 [file] [log] [blame]
Jean-Tiare Le Bigota1ac2f92016-03-04 21:45:32 +01001Demonstrations of solisten.py, the Linux eBPF/bcc version.
2
3
4This tool traces the kernel function called when a program wants to listen
5for TCP connections. It will not see UDP neither UNIX domain sockets.
6
7It can be used to dynamically update a load balancer as a program is actually
8ready to accept connexion, hence avoiding the "downtime" while it is initializing.
9
10# ./solisten.py --show-netns
11PID COMM NETNS PROTO BACKLOG ADDR PORT
123643 nc 4026531957 TCPv4 1 0.0.0.0 4242
133659 nc 4026531957 TCPv6 1 2001:f0d0:1002:51::4 4242
144221 redis-server 4026532165 TCPv6 128 :: 6379
154221 redis-server 4026532165 TCPv4 128 0.0.0.0 6379
166067 nginx 4026531957 TCPv4 128 0.0.0.0 80
176067 nginx 4026531957 TCPv6 128 :: 80
186069 nginx 4026531957 TCPv4 128 0.0.0.0 80
196069 nginx 4026531957 TCPv6 128 :: 80
206069 nginx 4026531957 TCPv4 128 0.0.0.0 80
216069 nginx 4026531957 TCPv6 128 :: 80
22
23This output show the listen event from 3 programs. Netcat was started twice as
Michael Prokopc14d02a2020-01-09 02:29:18 +010024shown by the 2 different PIDs. The first time on the wildcard IPv4, the second
Jean-Tiare Le Bigota1ac2f92016-03-04 21:45:32 +010025time on an IPv6. Netcat being a "one shot" program. It can accept a single
26connection, hence the backlog of "1".
27
28The next program is redis-server. As the netns column shows, it is in a
29different network namespace than netcat and nginx. In this specific case
30it was launched in a docker container. It listens both on IPv4 and IPv4
31with up to 128 pending connections.
32
33Determining the actual container is out if the scope of this tool. It could
34be derived by scrapping /proc/<PID>/cgroup. Note that this is racy.
35
36The overhead of this tool is negligeable as it traces listen() calls which are
37invoked in the initialization path of a program. The operation part will remain
38unaffected. In particular, accept() calls will not be affected. Neither
39individual read() and write().
40