summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_socket.c')
-rw-r--r--collectors/ebpf.plugin/ebpf_socket.c247
1 files changed, 124 insertions, 123 deletions
diff --git a/collectors/ebpf.plugin/ebpf_socket.c b/collectors/ebpf.plugin/ebpf_socket.c
index 3a023e4a..1954be71 100644
--- a/collectors/ebpf.plugin/ebpf_socket.c
+++ b/collectors/ebpf.plugin/ebpf_socket.c
@@ -62,8 +62,6 @@ ebpf_socket_publish_apps_t **socket_bandwidth_curr = NULL;
static ebpf_bandwidth_t *bandwidth_vector = NULL;
pthread_mutex_t nv_mutex;
-int wait_to_plot = 0;
-
netdata_vector_plot_t inbound_vectors = { .plot = NULL, .next = 0, .last = 0 };
netdata_vector_plot_t outbound_vectors = { .plot = NULL, .next = 0, .last = 0 };
netdata_socket_t *socket_values;
@@ -389,7 +387,7 @@ static void ebpf_socket_adjust_map_size(struct socket_bpf *obj, ebpf_module_t *e
* @param obj is the main structure for bpf objects.
* @param em structure with configuration
*
- * @return it returns 0 on succes and -1 otherwise
+ * @return it returns 0 on success and -1 otherwise
*/
static inline int ebpf_socket_load_and_attach(struct socket_bpf *obj, ebpf_module_t *em)
{
@@ -459,6 +457,9 @@ static inline void clean_internal_socket_plot(netdata_socket_plot_t *ptr)
*/
static void clean_allocated_socket_plot()
{
+ if (!network_viewer_opt.enabled)
+ return;
+
uint32_t i;
uint32_t end = inbound_vectors.last;
netdata_socket_plot_t *plot = inbound_vectors.plot;
@@ -647,7 +648,8 @@ static void ebpf_socket_free(ebpf_module_t *em )
static void ebpf_socket_exit(void *ptr)
{
ebpf_module_t *em = (ebpf_module_t *)ptr;
- netdata_thread_cancel(*socket_threads.thread);
+ if (socket_threads.thread)
+ netdata_thread_cancel(*socket_threads.thread);
ebpf_socket_free(em);
}
@@ -724,7 +726,7 @@ static void ebpf_update_global_publish(
*/
static inline void update_nv_plot_data(netdata_plot_values_t *plot, netdata_socket_t *sock)
{
- if (sock->ct > plot->last_time) {
+ if (sock->ct != plot->last_time) {
plot->last_time = sock->ct;
plot->plot_recv_packets = sock->recv_packets;
plot->plot_sent_packets = sock->sent_packets;
@@ -747,6 +749,7 @@ static inline void update_nv_plot_data(netdata_plot_values_t *plot, netdata_sock
*/
static inline void calculate_nv_plot()
{
+ pthread_mutex_lock(&nv_mutex);
uint32_t i;
uint32_t end = inbound_vectors.next;
for (i = 0; i < end; i++) {
@@ -764,9 +767,12 @@ static inline void calculate_nv_plot()
}
outbound_vectors.max_plot = end;
+ /*
// The 'Other' dimension is always calculated for the chart to have at least one dimension
update_nv_plot_data(&outbound_vectors.plot[outbound_vectors.last].plot,
&outbound_vectors.plot[outbound_vectors.last].sock);
+ */
+ pthread_mutex_unlock(&nv_mutex);
}
/**
@@ -1441,17 +1447,17 @@ static void ebpf_socket_create_nv_charts(netdata_vector_plot_t *ptr, int update_
*
* @return It returns 1 if the IP is inside the range and 0 otherwise
*/
-static int is_specific_ip_inside_range(union netdata_ip_t *cmp, int family)
+static int ebpf_is_specific_ip_inside_range(union netdata_ip_t *cmp, int family)
{
if (!network_viewer_opt.excluded_ips && !network_viewer_opt.included_ips)
return 1;
- uint32_t ipv4_test = ntohl(cmp->addr32[0]);
+ uint32_t ipv4_test = htonl(cmp->addr32[0]);
ebpf_network_viewer_ip_list_t *move = network_viewer_opt.excluded_ips;
while (move) {
if (family == AF_INET) {
- if (ntohl(move->first.addr32[0]) <= ipv4_test &&
- ipv4_test <= ntohl(move->last.addr32[0]) )
+ if (move->first.addr32[0] <= ipv4_test &&
+ ipv4_test <= move->last.addr32[0])
return 0;
} else {
if (memcmp(move->first.addr8, cmp->addr8, sizeof(union netdata_ip_t)) <= 0 &&
@@ -1464,12 +1470,13 @@ static int is_specific_ip_inside_range(union netdata_ip_t *cmp, int family)
move = network_viewer_opt.included_ips;
while (move) {
- if (family == AF_INET) {
- if (ntohl(move->first.addr32[0]) <= ipv4_test &&
- ntohl(move->last.addr32[0]) >= ipv4_test)
+ if (family == AF_INET && move->ver == AF_INET) {
+ if (move->first.addr32[0] <= ipv4_test &&
+ move->last.addr32[0] >= ipv4_test)
return 1;
} else {
- if (memcmp(move->first.addr8, cmp->addr8, sizeof(union netdata_ip_t)) <= 0 &&
+ if (move->ver == AF_INET6 &&
+ memcmp(move->first.addr8, cmp->addr8, sizeof(union netdata_ip_t)) <= 0 &&
memcmp(move->last.addr8, cmp->addr8, sizeof(union netdata_ip_t)) >= 0) {
return 1;
}
@@ -1565,7 +1572,7 @@ int is_socket_allowed(netdata_socket_idx_t *key, int family)
if (!is_port_inside_range(key->dport))
return 0;
- return is_specific_ip_inside_range(&key->daddr, family);
+ return ebpf_is_specific_ip_inside_range(&key->daddr, family);
}
/**
@@ -1580,38 +1587,26 @@ int is_socket_allowed(netdata_socket_idx_t *key, int family)
*
* @return It returns 0 case the values are equal, 1 case a is bigger than b and -1 case a is smaller than b.
*/
-static int compare_sockets(void *a, void *b)
+static int ebpf_compare_sockets(void *a, void *b)
{
struct netdata_socket_plot *val1 = a;
struct netdata_socket_plot *val2 = b;
- int cmp;
+ int cmp = 0;
// We do not need to compare val2 family, because data inside hash table is always from the same family
if (val1->family == AF_INET) { //IPV4
- if (val1->flags & NETDATA_INBOUND_DIRECTION) {
- if (val1->index.sport == val2->index.sport)
- cmp = 0;
- else {
- cmp = (val1->index.sport > val2->index.sport)?1:-1;
- }
- } else {
+ if (network_viewer_opt.included_port || network_viewer_opt.excluded_port)
cmp = memcmp(&val1->index.dport, &val2->index.dport, sizeof(uint16_t));
- if (!cmp) {
- cmp = memcmp(&val1->index.daddr.addr32[0], &val2->index.daddr.addr32[0], sizeof(uint32_t));
- }
+
+ if (!cmp) {
+ cmp = memcmp(&val1->index.daddr.addr32[0], &val2->index.daddr.addr32[0], sizeof(uint32_t));
}
} else {
- if (val1->flags & NETDATA_INBOUND_DIRECTION) {
- if (val1->index.sport == val2->index.sport)
- cmp = 0;
- else {
- cmp = (val1->index.sport > val2->index.sport)?1:-1;
- }
- } else {
+ if (network_viewer_opt.included_port || network_viewer_opt.excluded_port)
cmp = memcmp(&val1->index.dport, &val2->index.dport, sizeof(uint16_t));
- if (!cmp) {
- cmp = memcmp(&val1->index.daddr.addr32, &val2->index.daddr.addr32, 4*sizeof(uint32_t));
- }
+
+ if (!cmp) {
+ cmp = memcmp(&val1->index.daddr.addr32, &val2->index.daddr.addr32, 4*sizeof(uint32_t));
}
}
@@ -1631,12 +1626,15 @@ static int compare_sockets(void *a, void *b)
*
* @return it returns the size of the data copied on success and -1 otherwise.
*/
-static inline int build_outbound_dimension_name(char *dimname, char *hostname, char *service_name,
- char *proto, int family)
+static inline int ebpf_build_outbound_dimension_name(char *dimname, char *hostname, char *service_name,
+ char *proto, int family)
{
- return snprintf(dimname, CONFIG_MAX_NAME - 7, (family == AF_INET)?"%s:%s:%s_":"%s:%s:[%s]_",
- service_name, proto,
- hostname);
+ if (network_viewer_opt.included_port || network_viewer_opt.excluded_port)
+ return snprintf(dimname, CONFIG_MAX_NAME - 7, (family == AF_INET)?"%s:%s:%s_":"%s:%s:[%s]_",
+ service_name, proto, hostname);
+
+ return snprintf(dimname, CONFIG_MAX_NAME - 7, (family == AF_INET)?"%s:%s_":"%s:[%s]_",
+ proto, hostname);
}
/**
@@ -1692,7 +1690,7 @@ static inline void fill_resolved_name(netdata_socket_plot_t *ptr, char *hostname
}
if (is_outbound)
- size = build_outbound_dimension_name(dimname, hostname, service_name, protocol, ptr->family);
+ size = ebpf_build_outbound_dimension_name(dimname, hostname, service_name, protocol, ptr->family);
else
size = build_inbound_dimension_name(dimname,service_name, protocol);
@@ -1850,14 +1848,12 @@ static void fill_last_nv_dimension(netdata_socket_plot_t *ptr, int is_outbound)
*/
static inline void update_socket_data(netdata_socket_t *sock, netdata_socket_t *lvalues)
{
- sock->recv_packets += lvalues->recv_packets;
- sock->sent_packets += lvalues->sent_packets;
- sock->recv_bytes += lvalues->recv_bytes;
- sock->sent_bytes += lvalues->sent_bytes;
- sock->retransmit += lvalues->retransmit;
-
- if (lvalues->ct > sock->ct)
- sock->ct = lvalues->ct;
+ sock->recv_packets = lvalues->recv_packets;
+ sock->sent_packets = lvalues->sent_packets;
+ sock->recv_bytes = lvalues->recv_bytes;
+ sock->sent_bytes = lvalues->sent_bytes;
+ sock->retransmit = lvalues->retransmit;
+ sock->ct = lvalues->ct;
}
/**
@@ -1881,7 +1877,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
ret = (netdata_socket_plot_t *) avl_search_lock(&out->tree, (avl_t *)&test);
if (ret) {
- if (lvalues->ct > ret->plot.last_time) {
+ if (lvalues->ct != ret->plot.last_time) {
update_socket_data(&ret->sock, lvalues);
}
} else {
@@ -1892,7 +1888,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
int resolved;
if (curr == last) {
- if (lvalues->ct > w->plot.last_time) {
+ if (lvalues->ct != w->plot.last_time) {
update_socket_data(&w->sock, lvalues);
}
return;
@@ -1977,6 +1973,9 @@ netdata_vector_plot_t * select_vector_to_store(uint32_t *direction, netdata_sock
*/
static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key, int family, int end)
{
+ if (!network_viewer_opt.enabled || !is_socket_allowed(key, family))
+ return;
+
uint64_t bsent = 0, brecv = 0, psent = 0, precv = 0;
uint16_t retransmit = 0;
int i;
@@ -1994,7 +1993,7 @@ static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key
if (!protocol)
protocol = w->protocol;
- if (w->ct > ct)
+ if (w->ct != ct)
ct = w->ct;
}
@@ -2006,11 +2005,9 @@ static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key
values[0].protocol = (!protocol)?IPPROTO_TCP:protocol;
values[0].ct = ct;
- if (is_socket_allowed(key, family)) {
- uint32_t dir;
- netdata_vector_plot_t *table = select_vector_to_store(&dir, key, protocol);
- store_socket_inside_avl(table, &values[0], key, family, dir);
- }
+ uint32_t dir;
+ netdata_vector_plot_t *table = select_vector_to_store(&dir, key, protocol);
+ store_socket_inside_avl(table, &values[0], key, family, dir);
}
/**
@@ -2018,16 +2015,13 @@ static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key
*
* Read data from hash tables created on kernel ring.
*
- * @param fd the hash table with data.
- * @param family the family associated to the hash table
+ * @param fd the hash table with data.
+ * @param family the family associated to the hash table
*
* @return it returns 0 on success and -1 otherwise.
*/
-static void read_socket_hash_table(int fd, int family, int network_connection)
+static void ebpf_read_socket_hash_table(int fd, int family)
{
- if (wait_to_plot)
- return;
-
netdata_socket_idx_t key = {};
netdata_socket_idx_t next_key = {};
@@ -2046,9 +2040,7 @@ static void read_socket_hash_table(int fd, int family, int network_connection)
continue;
}
- if (network_connection) {
- hash_accumulator(values, &key, family, end);
- }
+ hash_accumulator(values, &key, family, end);
key = next_key;
}
@@ -2057,12 +2049,12 @@ static void read_socket_hash_table(int fd, int family, int network_connection)
/**
* Fill Network Viewer Port list
*
- * Fill the strcture with values read from /proc or hash table.
+ * Fill the structure with values read from /proc or hash table.
*
* @param out the structure where we will store data.
* @param value the ports we are listen to.
* @param proto the protocol used for this connection.
- * @param in the strcuture with values read form different sources.
+ * @param in the structure with values read form different sources.
*/
static inline void fill_nv_port_list(ebpf_network_viewer_port_list_t *out, uint16_t value, uint16_t proto,
netdata_passive_connection_t *in)
@@ -2081,7 +2073,7 @@ static inline void fill_nv_port_list(ebpf_network_viewer_port_list_t *out, uint1
*
* @param value the ports we are listen to.
* @param proto the protocol used with port connection.
- * @param in the strcuture with values read form different sources.
+ * @param in the structure with values read form different sources.
*/
void update_listen_table(uint16_t value, uint16_t proto, netdata_passive_connection_t *in)
{
@@ -2159,22 +2151,19 @@ static void read_listen_table()
void *ebpf_socket_read_hash(void *ptr)
{
netdata_thread_cleanup_push(ebpf_socket_cleanup, ptr);
- ebpf_module_t *em = (ebpf_module_t *)ptr;
heartbeat_t hb;
heartbeat_init(&hb);
- usec_t step = NETDATA_SOCKET_READ_SLEEP_MS * em->update_every;
int fd_ipv4 = socket_maps[NETDATA_SOCKET_TABLE_IPV4].map_fd;
int fd_ipv6 = socket_maps[NETDATA_SOCKET_TABLE_IPV6].map_fd;
- int network_connection = em->optional;
while (!ebpf_exit_plugin) {
- (void)heartbeat_next(&hb, step);
+ (void)heartbeat_next(&hb, USEC_PER_SEC);
+ if (ebpf_exit_plugin)
+ continue;
pthread_mutex_lock(&nv_mutex);
- read_listen_table();
- read_socket_hash_table(fd_ipv4, AF_INET, network_connection);
- read_socket_hash_table(fd_ipv6, AF_INET6, network_connection);
- wait_to_plot = 1;
+ ebpf_read_socket_hash_table(fd_ipv4, AF_INET);
+ ebpf_read_socket_hash_table(fd_ipv6, AF_INET6);
pthread_mutex_unlock(&nv_mutex);
}
@@ -2863,44 +2852,50 @@ static void ebpf_socket_send_cgroup_data(int update_every)
/**
* Main loop for this collector.
*
- * @param step the number of microseconds used with heart beat
* @param em the structure with thread information
*/
-static void socket_collector(usec_t step, ebpf_module_t *em)
+static void socket_collector(ebpf_module_t *em)
{
heartbeat_t hb;
heartbeat_init(&hb);
+ uint32_t network_connection = network_viewer_opt.enabled;
- socket_threads.thread = mallocz(sizeof(netdata_thread_t));
- socket_threads.start_routine = ebpf_socket_read_hash;
+ if (network_connection) {
+ socket_threads.thread = mallocz(sizeof(netdata_thread_t));
+ socket_threads.start_routine = ebpf_socket_read_hash;
- netdata_thread_create(socket_threads.thread, socket_threads.name,
- NETDATA_THREAD_OPTION_DEFAULT, ebpf_socket_read_hash, em);
+ netdata_thread_create(socket_threads.thread, socket_threads.name,
+ NETDATA_THREAD_OPTION_DEFAULT, ebpf_socket_read_hash, em);
+ }
int cgroups = em->cgroup_charts;
if (cgroups)
ebpf_socket_update_cgroup_algorithm();
int socket_global_enabled = em->global_charts;
- int network_connection = em->optional;
int update_every = em->update_every;
+ int counter = update_every - 1;
while (!ebpf_exit_plugin) {
- (void)heartbeat_next(&hb, step);
- if (ebpf_exit_plugin)
- break;
+ (void)heartbeat_next(&hb, USEC_PER_SEC);
+ if (ebpf_exit_plugin || ++counter != update_every)
+ continue;
+ counter = 0;
netdata_apps_integration_flags_t socket_apps_enabled = em->apps_charts;
- pthread_mutex_lock(&collect_data_mutex);
- if (socket_global_enabled)
+ if (socket_global_enabled) {
+ read_listen_table();
read_hash_global_tables();
+ }
+ pthread_mutex_lock(&collect_data_mutex);
if (socket_apps_enabled)
ebpf_socket_update_apps_data();
if (cgroups)
ebpf_update_socket_cgroup();
- calculate_nv_plot();
+ if (network_connection)
+ calculate_nv_plot();
pthread_mutex_lock(&lock);
if (socket_global_enabled)
@@ -2925,7 +2920,6 @@ static void socket_collector(usec_t step, ebpf_module_t *em)
ebpf_socket_create_nv_charts(&outbound_vectors, update_every);
fflush(stdout);
ebpf_socket_send_nv_data(&outbound_vectors);
- wait_to_plot = 0;
pthread_mutex_unlock(&nv_mutex);
}
@@ -2959,8 +2953,10 @@ static void ebpf_socket_allocate_global_vectors(int apps)
bandwidth_vector = callocz((size_t)ebpf_nprocs, sizeof(ebpf_bandwidth_t));
socket_values = callocz((size_t)ebpf_nprocs, sizeof(netdata_socket_t));
- inbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
- outbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
+ if (network_viewer_opt.enabled) {
+ inbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
+ outbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
+ }
}
/**
@@ -3219,12 +3215,11 @@ static void get_ipv6_first_addr(union netdata_ip_t *out, union netdata_ip_t *in,
*
* @return It returns 1 if the IP is inside the range and 0 otherwise
*/
-static int is_ip_inside_range(union netdata_ip_t *rfirst, union netdata_ip_t *rlast,
- union netdata_ip_t *cmpfirst, union netdata_ip_t *cmplast, int family)
+static int ebpf_is_ip_inside_range(union netdata_ip_t *rfirst, union netdata_ip_t *rlast,
+ union netdata_ip_t *cmpfirst, union netdata_ip_t *cmplast, int family)
{
if (family == AF_INET) {
- if (ntohl(rfirst->addr32[0]) <= ntohl(cmpfirst->addr32[0]) &&
- ntohl(rlast->addr32[0]) >= ntohl(cmplast->addr32[0]))
+ if ((rfirst->addr32[0] <= cmpfirst->addr32[0]) && (rlast->addr32[0] >= cmplast->addr32[0]))
return 1;
} else {
if (memcmp(rfirst->addr8, cmpfirst->addr8, sizeof(union netdata_ip_t)) <= 0 &&
@@ -3241,16 +3236,22 @@ static int is_ip_inside_range(union netdata_ip_t *rfirst, union netdata_ip_t *rl
*
* @param out a pointer to the link list.
* @param in the structure that will be linked.
+ * @param table the modified table.
*/
-void fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_list_t *in, char *table)
+void ebpf_fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_list_t *in, char *table)
{
#ifndef NETDATA_INTERNAL_CHECKS
UNUSED(table);
#endif
+ if (in->ver == AF_INET) { // It is simpler to compare using host order
+ in->first.addr32[0] = ntohl(in->first.addr32[0]);
+ in->last.addr32[0] = ntohl(in->last.addr32[0]);
+ }
if (likely(*out)) {
ebpf_network_viewer_ip_list_t *move = *out, *store = *out;
while (move) {
- if (in->ver == move->ver && is_ip_inside_range(&move->first, &move->last, &in->first, &in->last, in->ver)) {
+ if (in->ver == move->ver &&
+ ebpf_is_ip_inside_range(&move->first, &move->last, &in->first, &in->last, in->ver)) {
info("The range/value (%s) is inside the range/value (%s) already inserted, it will be ignored.",
in->value, move->value);
freez(in->value);
@@ -3267,14 +3268,12 @@ void fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_li
}
#ifdef NETDATA_INTERNAL_CHECKS
- char first[512], last[512];
+ char first[256], last[512];
if (in->ver == AF_INET) {
- if (inet_ntop(AF_INET, in->first.addr8, first, INET_ADDRSTRLEN) &&
- inet_ntop(AF_INET, in->last.addr8, last, INET_ADDRSTRLEN))
- info("Adding values %s - %s to %s IP list \"%s\" used on network viewer",
- first, last,
- (*out == network_viewer_opt.included_ips)?"included":"excluded",
- table);
+ info("Adding values %s: (%u - %u) to %s IP list \"%s\" used on network viewer",
+ in->value, in->first.addr32[0], in->last.addr32[0],
+ (*out == network_viewer_opt.included_ips)?"included":"excluded",
+ table);
} else {
if (inet_ntop(AF_INET6, in->first.addr8, first, INET6_ADDRSTRLEN) &&
inet_ntop(AF_INET6, in->last.addr8, last, INET6_ADDRSTRLEN))
@@ -3294,7 +3293,7 @@ void fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_li
* @param out a pointer to store the link list
* @param ip the value given as parameter
*/
-static void parse_ip_list(void **out, char *ip)
+static void ebpf_parse_ip_list(void **out, char *ip)
{
ebpf_network_viewer_ip_list_t **list = (ebpf_network_viewer_ip_list_t **)out;
@@ -3442,7 +3441,7 @@ static void parse_ip_list(void **out, char *ip)
ebpf_network_viewer_ip_list_t *store;
- storethisip:
+storethisip:
store = callocz(1, sizeof(ebpf_network_viewer_ip_list_t));
store->value = ipdup;
store->hash = simple_hash(ipdup);
@@ -3450,7 +3449,7 @@ static void parse_ip_list(void **out, char *ip)
memcpy(store->first.addr8, first.addr8, sizeof(first.addr8));
memcpy(store->last.addr8, last.addr8, sizeof(last.addr8));
- fill_ip_list(list, store, "socket");
+ ebpf_fill_ip_list(list, store, "socket");
return;
cleanipdup:
@@ -3464,7 +3463,7 @@ cleanipdup:
*
* @param ptr is a pointer with the text to parse.
*/
-static void parse_ips(char *ptr)
+static void ebpf_parse_ips(char *ptr)
{
// No value
if (unlikely(!ptr))
@@ -3491,8 +3490,9 @@ static void parse_ips(char *ptr)
}
if (isascii(*ptr)) { // Parse port
- parse_ip_list((!neg)?(void **)&network_viewer_opt.included_ips:(void **)&network_viewer_opt.excluded_ips,
- ptr);
+ ebpf_parse_ip_list((!neg)?(void **)&network_viewer_opt.included_ips:
+ (void **)&network_viewer_opt.excluded_ips,
+ ptr);
}
ptr = end;
@@ -3762,7 +3762,7 @@ void parse_network_viewer_section(struct config *cfg)
value = appconfig_get(cfg, EBPF_NETWORK_VIEWER_SECTION,
"ips", "!127.0.0.1/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 fc00::/7 !::1/128");
- parse_ips(value);
+ ebpf_parse_ips(value);
}
/**
@@ -3916,16 +3916,9 @@ void *ebpf_socket_thread(void *ptr)
{
netdata_thread_cleanup_push(ebpf_socket_exit, ptr);
- memset(&inbound_vectors.tree, 0, sizeof(avl_tree_lock));
- memset(&outbound_vectors.tree, 0, sizeof(avl_tree_lock));
- avl_init_lock(&inbound_vectors.tree, compare_sockets);
- avl_init_lock(&outbound_vectors.tree, compare_sockets);
-
ebpf_module_t *em = (ebpf_module_t *)ptr;
em->maps = socket_maps;
- parse_network_viewer_section(&socket_config);
- parse_service_name_section(&socket_config);
parse_table_size_options(&socket_config);
if (pthread_mutex_init(&nv_mutex, NULL)) {
@@ -3935,7 +3928,15 @@ void *ebpf_socket_thread(void *ptr)
}
ebpf_socket_allocate_global_vectors(em->apps_charts);
- initialize_inbound_outbound();
+
+ if (network_viewer_opt.enabled) {
+ memset(&inbound_vectors.tree, 0, sizeof(avl_tree_lock));
+ memset(&outbound_vectors.tree, 0, sizeof(avl_tree_lock));
+ avl_init_lock(&inbound_vectors.tree, ebpf_compare_sockets);
+ avl_init_lock(&outbound_vectors.tree, ebpf_compare_sockets);
+
+ initialize_inbound_outbound();
+ }
if (running_on_kernel < NETDATA_EBPF_KERNEL_5_0)
em->mode = MODE_ENTRY;
@@ -3966,7 +3967,7 @@ void *ebpf_socket_thread(void *ptr)
pthread_mutex_unlock(&lock);
- socket_collector((usec_t)(em->update_every * USEC_PER_SEC), em);
+ socket_collector(em);
endsocket:
ebpf_update_disabled_plugin_stats(em);