After thinking about this some more, I decided that although it makes
sense for scripts to convert a type to an IntEnum class, I'd prefer that
the helpers take and return drgn Objects rather than these classes.
Although it doesn't correspond to a Linux kernel function, it is more
convenient than open-coding it everywhere, especially since the leading
__ causes Python to mangle the name if it's inside of a class.
Add example script that goes over all TCP sockets and for every socket
prints:
- TCP state;
- IP:port pair;
- cgroup v2 path.
The script shows basic operations with sockets including getting `struct
sock`, `struct inet_sock`, socket fields and cgroup v2 of socket.
It provides output similar to `ss -nt` or `ss -lnt`:
% sudo python36 -m drgn examples/linux/tcp_sock.py | shuf -n 5
TIME_WAIT [::1]:2560 [::1]:44041
ESTABLISHED [::1]:54178 [::1]:11101 system.slice/async-distillery-server.service
LISTEN [::]:3201 [::]:0 system.slice/fbflow.service
ESTABLISHED [2401:db00:21:718a:face:0:31:0]:2406 [2401:db00:12:a106:face:0:1e:0]:46306 system.slice/configerator_proxy2.service
LISTEN 0.0.0.0:11150 0.0.0.0:0 system.slice/system-mcrouter.slice/mcrouter@tao.service
Signed-off-by: Andrey Ignatov <rdna@fb.com>