Skip to content

Commit

Permalink
change_vector: Modify index for socket
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoftsm committed Aug 12, 2023
1 parent 3d73318 commit 002e66f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/socket.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,23 @@ static __always_inline short unsigned int set_idx_value(netdata_socket_idx_t *ns
BPF_CORE_READ_INTO(&family, is, sk.__sk_common.skc_family);
// Read source and destination IPs
if ( family == AF_INET ) { //AF_INET
BPF_CORE_READ_INTO(&nsi->saddr.addr32, is, sk.__sk_common.skc_rcv_saddr );
BPF_CORE_READ_INTO(&nsi->daddr.addr32, is, sk.__sk_common.skc_daddr );
BPF_CORE_READ_INTO(&nsi->saddr.addr32[0], is, sk.__sk_common.skc_rcv_saddr );
BPF_CORE_READ_INTO(&nsi->daddr.addr32[0], is, sk.__sk_common.skc_daddr );

if ((nsi->saddr.addr32[0] == 0 || nsi->daddr.addr32[0] == 0) || // Zero addr
nsi->saddr.addr64[0] == 16777343) // Loopback
nsi->saddr.addr32[0] == 16777343 || nsi->daddr.addr32[0] == 16777343) // Loopback
return AF_UNSPEC;
} else if ( family == AF_INET6 ) {
#if defined(NETDATA_CONFIG_IPV6)
BPF_CORE_READ_INTO(&nsi->saddr.addr8, is, sk.__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr8 );
BPF_CORE_READ_INTO(&nsi->daddr.addr8, is, sk.__sk_common.skc_v6_daddr.in6_u.u6_addr8 );

if ( ((!nsi->saddr.addr64[0]) && (!nsi->saddr.addr64[1])) || ((!nsi->daddr.addr64[0]) && (!nsi->daddr.addr64[1])) || // Zero addr
((nsi->saddr.addr64[0] == 0) && (nsi->saddr.addr64[1] == 72057594037927936))) // Loopback
if (((nsi->saddr.addr64[0] == 0) && (nsi->saddr.addr64[1] == 72057594037927936)) || // Loopback
((nsi->daddr.addr64[0] == 0) && (nsi->daddr.addr64[1] == 72057594037927936)))
return AF_UNSPEC;

if (((nsi->saddr.addr64[0] == 0) && (nsi->saddr.addr64[1] == 0)) ||
((nsi->daddr.addr64[0] == 0) && (nsi->daddr.addr64[1] == 0))) // Zero addr
return AF_UNSPEC;
#endif
} else {
Expand Down

0 comments on commit 002e66f

Please sign in to comment.