Skip to content

Commit

Permalink
Update ebpf socket (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoftsm authored Aug 18, 2021
1 parent 55a47f1 commit d099cdc
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 285 deletions.
2 changes: 1 addition & 1 deletion includes/netdata_ebpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ This header has the common definitions for all `.c` files.
#include "netdata_fs.h"
#include "netdata_hardirq.h"
#include "netdata_mount.h"
#include "netdata_network.h"
#include "netdata_process.h"
#include "netdata_socket.h"
#include "netdata_sync.h"
#include "netdata_swap.h"
#include "netdata_vfs.h"
Expand Down
33 changes: 0 additions & 33 deletions includes/netdata_network.h

This file was deleted.

78 changes: 78 additions & 0 deletions includes/netdata_socket.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef _NETDATA_NETWORK_H_
#define _NETDATA_NETWORK_H_ 1

#include <linux/sched.h>

/**
* Union used to store ip addresses
*/
union netdata_ip {
__u8 addr8[16];
__u16 addr16[8];
__u32 addr32[4];
__u64 addr64[2];
};

typedef struct netdata_socket {
__u64 recv_packets;
__u64 sent_packets;
__u64 recv_bytes;
__u64 sent_bytes;
__u64 first; //First timestamp
__u64 ct; //Current timestamp
__u16 retransmit; //It is never used with UDP
__u8 protocol;
__u8 removeme;
__u32 reserved;
} netdata_socket_t;

typedef struct netdata_bandwidth {
__u32 pid;

__u64 first;
__u64 ct;
__u64 bytes_sent;
__u64 bytes_received;
__u64 call_tcp_sent;
__u64 call_tcp_received;
__u64 retransmit;
__u64 call_udp_sent;
__u64 call_udp_received;
} netdata_bandwidth_t;

// Index used together previous structure
typedef struct netdata_socket_idx {
union netdata_ip saddr;
__u16 sport;
union netdata_ip daddr;
__u16 dport;
} netdata_socket_idx_t;

enum socket_counters {
NETDATA_KEY_CALLS_TCP_SENDMSG,
NETDATA_KEY_ERROR_TCP_SENDMSG,
NETDATA_KEY_BYTES_TCP_SENDMSG,

NETDATA_KEY_CALLS_TCP_CLEANUP_RBUF,
NETDATA_KEY_ERROR_TCP_CLEANUP_RBUF,
NETDATA_KEY_BYTES_TCP_CLEANUP_RBUF,

NETDATA_KEY_CALLS_TCP_CLOSE,

NETDATA_KEY_CALLS_UDP_RECVMSG,
NETDATA_KEY_ERROR_UDP_RECVMSG,
NETDATA_KEY_BYTES_UDP_RECVMSG,

NETDATA_KEY_CALLS_UDP_SENDMSG,
NETDATA_KEY_ERROR_UDP_SENDMSG,
NETDATA_KEY_BYTES_UDP_SENDMSG,

NETDATA_KEY_TCP_RETRANSMIT,

// Keep this as last and don't skip numbers as it is used as element counter
NETDATA_SOCKET_COUNTER
};

#endif /* _NETDATA_NETWORK_H_ */
Loading

0 comments on commit d099cdc

Please sign in to comment.