Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When logging ipv6 state change, journal_fields tries to pack event.addr and event.daddr, which is not an integer in this, to present a bytes-like object to socket.inet_ntop. This can be fixed by having a similar type for [sd]addr for IPv4 and IPv6. Making both an array of u32 solves the issue by presenting a bytes-like object directly to inet_ntop, without the need for the struct packing stage. Also now, the similar behavior, makes it easier to factor code for IPv4 and IPv6. It solves the following error: /usr/share/bcc/tools/tcpstates -Y SKADDR C-PID C-COMM LADDR LPORT RADDR RPORT OLDSTATE -> NEWSTATE MS ffff8b2e83e56180 0 swapper/9 :: 22 :: 0 LISTEN -> SYN_RECV 0.000 Exception ignored on calling ctypes callback function: <function PerfEventArray._open_perf_buffer.<locals>.raw_cb_ at 0x7f894c8d7f70> Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/bcc/table.py", line 982, in raw_cb_ callback(cpu, data, size) File "/usr/share/bcc/tools/tcpstates", line 419, in print_ipv6_event journal.send(**journal_fields(event, AF_INET6)) File "/usr/share/bcc/tools/tcpstates", line 348, in journal_fields 'OBJECT_' + addr_pfx + '_SOURCE_ADDRESS': inet_ntop(addr_family, pack("I", event.saddr)), struct.error: required argument is not an integer ffff8b2e83e56180 0 swapper/9 2620:52:0:2580:5054:ff:fe6b:6f1f 22 2620:52:0:2b11:2f5e:407d:b35d:4663 60396 SYN_RECV -> ESTABLISHED 0.010 Exception ignored on calling ctypes callback function: <function PerfEventArray._open_perf_buffer.<locals>.raw_cb_ at 0x7f894c8d7f70> Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/bcc/table.py", line 982, in raw_cb_ callback(cpu, data, size) File "/usr/share/bcc/tools/tcpstates", line 419, in print_ipv6_event journal.send(**journal_fields(event, AF_INET6)) File "/usr/share/bcc/tools/tcpstates", line 348, in journal_fields 'OBJECT_' + addr_pfx + '_SOURCE_ADDRESS': inet_ntop(addr_family, pack("I", event.saddr)), struct.error: required argument is not an integer Signed-off-by: Jerome Marchand <[email protected]>
- Loading branch information