Skip to content

Commit

Permalink
Speed socket (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoftsm authored Aug 24, 2023
1 parent 93fb552 commit b7594a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions includes/netdata_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ typedef struct netdata_socket {
__u64 tcp_bytes_received;
__u32 close; //It is never used with UDP
__u32 retransmit; //It is never used with UDP
__u32 ipv4_connect;
__u32 ipv6_connect;
__u32 ipv4_connect; // Use to count new connections
__u32 ipv6_connect; // Use to count new connections
} tcp;
// Number of calls
struct {
__u32 call_udp_sent;
__u32 call_udp_sent; // Use to count new connections
__u32 call_udp_received;
__u64 udp_bytes_sent;
__u64 udp_bytes_received;
Expand All @@ -59,7 +59,7 @@ typedef struct netdata_bandwidth {
// Index used together previous structure
typedef struct netdata_socket_idx {
union netdata_ip saddr;
__u16 sport;
//__u16 sport;
union netdata_ip daddr;
__u16 dport;
__u32 pid;
Expand Down
5 changes: 3 additions & 2 deletions kernel/socket_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ static __always_inline __u16 set_idx_value(netdata_socket_idx_t *nsi, struct ine

//Read destination port
bpf_probe_read(&nsi->dport, sizeof(u16), &is->inet_dport);
bpf_probe_read(&nsi->sport, sizeof(u16), &is->inet_num);
// bpf_probe_read(&nsi->sport, sizeof(u16), &is->inet_num);

// Socket for nowhere or system looking for port
// This can be an attack vector that needs to be addressed in another opportunity
if (nsi->sport == 0 || nsi->dport == 0)
//if (nsi->sport == 0 || nsi->dport == 0)
if (nsi->dport == 0)
return AF_UNSPEC;


Expand Down

0 comments on commit b7594a7

Please sign in to comment.