@cryptotaxi247 / netdata-1 / commits / 8f595a92d

eBPF (memory, NV, basis for functions) (#14131)

thiagoftsm committed Jan 3, 2023 at 16:13 UTC 8f595a92d4982824b80566732343ed01cd4f0dcc
12 files changed +129 -125
collectors/ebpf.plugin/ebpf.c
+16 -9
@@ -1317,7 +1317,7 @@ static void read_local_addresses()
1317 }
1318 }
1319
1320 - fill_ip_list((family == AF_INET)?&network_viewer_opt.ipv4_local_ip:&network_viewer_opt.ipv6_local_ip,
1320 + ebpf_fill_ip_list((family == AF_INET)?&network_viewer_opt.ipv4_local_ip:&network_viewer_opt.ipv6_local_ip,
1321 w,
1322 "selector");
1323 }
@@ -1520,13 +1520,8 @@ static void read_collector_values(int *disable_apps, int *disable_cgroups,
1520 enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION,
1521 ebpf_modules[EBPF_MODULE_SOCKET_IDX].config_name,
1522 CONFIG_BOOLEAN_NO);
1523 -
1523 if (enabled) {
1524 ebpf_enable_chart(EBPF_MODULE_SOCKET_IDX, *disable_apps, *disable_cgroups);
1526 - // Read network viewer section if network viewer is enabled
1527 - // This is kept here to keep backward compatibility
1528 - parse_network_viewer_section(&collector_config);
1529 - parse_service_name_section(&collector_config);
1525 started++;
1526 }
1527
@@ -1536,7 +1531,17 @@ static void read_collector_values(int *disable_apps, int *disable_cgroups,
1531 if (!enabled)
1532 enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "network connections",
1533 CONFIG_BOOLEAN_NO);
1539 - ebpf_modules[EBPF_MODULE_SOCKET_IDX].optional = (int)enabled;
1534 + network_viewer_opt.enabled = enabled;
1535 + if (enabled) {
1536 + if (!ebpf_modules[EBPF_MODULE_SOCKET_IDX].enabled)
1537 + ebpf_enable_chart(EBPF_MODULE_SOCKET_IDX, *disable_apps, *disable_cgroups);
1538 +
1539 + // Read network viewer section if network viewer is enabled
1540 + // This is kept here to keep backward compatibility
1541 + parse_network_viewer_section(&collector_config);
1542 + parse_service_name_section(&collector_config);
1543 + started++;
1544 + }
1545
1546 enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "cachestat",
1547 CONFIG_BOOLEAN_NO);
@@ -1642,8 +1647,10 @@ static void read_collector_values(int *disable_apps, int *disable_cgroups,
1647 ebpf_enable_all_charts(*disable_apps, *disable_cgroups);
1648 // Read network viewer section
1649 // This is kept here to keep backward compatibility
1645 - parse_network_viewer_section(&collector_config);
1646 - parse_service_name_section(&collector_config);
1650 + if (network_viewer_opt.enabled) {
1651 + parse_network_viewer_section(&collector_config);
1652 + parse_service_name_section(&collector_config);
1653 + }
1654 }
1655 }
1656
collectors/ebpf.plugin/ebpf_fd.h
-3
@@ -36,9 +36,6 @@
36 #define NETDATA_SYSTEMD_FD_CLOSE_ERR_CONTEXT "services.fd_close_error"
37
38 typedef struct netdata_fd_stat {
39 - uint64_t pid_tgid; // Unique identifier
40 - uint32_t pid; // Process ID
41 -
39 uint32_t open_call; // Open syscalls (open and openat)
40 uint32_t close_call; // Close syscall (close)
41
collectors/ebpf.plugin/ebpf_socket.c
+101 -102
@@ -62,8 +62,6 @@ ebpf_socket_publish_apps_t **socket_bandwidth_curr = NULL;
62 static ebpf_bandwidth_t *bandwidth_vector = NULL;
63
64 pthread_mutex_t nv_mutex;
65 -int wait_to_plot = 0;
66 -
65 netdata_vector_plot_t inbound_vectors = { .plot = NULL, .next = 0, .last = 0 };
66 netdata_vector_plot_t outbound_vectors = { .plot = NULL, .next = 0, .last = 0 };
67 netdata_socket_t *socket_values;
@@ -459,6 +457,9 @@ static inline void clean_internal_socket_plot(netdata_socket_plot_t *ptr)
457 */
458 static void clean_allocated_socket_plot()
459 {
460 + if (!network_viewer_opt.enabled)
461 + return;
462 +
463 uint32_t i;
464 uint32_t end = inbound_vectors.last;
465 netdata_socket_plot_t *plot = inbound_vectors.plot;
@@ -725,7 +726,7 @@ static void ebpf_update_global_publish(
726 */
727 static inline void update_nv_plot_data(netdata_plot_values_t *plot, netdata_socket_t *sock)
728 {
728 - if (sock->ct > plot->last_time) {
729 + if (sock->ct != plot->last_time) {
730 plot->last_time = sock->ct;
731 plot->plot_recv_packets = sock->recv_packets;
732 plot->plot_sent_packets = sock->sent_packets;
@@ -748,6 +749,7 @@ static inline void update_nv_plot_data(netdata_plot_values_t *plot, netdata_sock
749 */
750 static inline void calculate_nv_plot()
751 {
752 + pthread_mutex_lock(&nv_mutex);
753 uint32_t i;
754 uint32_t end = inbound_vectors.next;
755 for (i = 0; i < end; i++) {
@@ -765,9 +767,12 @@ static inline void calculate_nv_plot()
767 }
768 outbound_vectors.max_plot = end;
769
770 + /*
771 // The 'Other' dimension is always calculated for the chart to have at least one dimension
772 update_nv_plot_data(&outbound_vectors.plot[outbound_vectors.last].plot,
773 &outbound_vectors.plot[outbound_vectors.last].sock);
774 + */
775 + pthread_mutex_unlock(&nv_mutex);
776 }
777
778 /**
@@ -1442,17 +1447,17 @@ static void ebpf_socket_create_nv_charts(netdata_vector_plot_t *ptr, int update_
1447 *
1448 * @return It returns 1 if the IP is inside the range and 0 otherwise
1449 */
1445 -static int is_specific_ip_inside_range(union netdata_ip_t *cmp, int family)
1450 +static int ebpf_is_specific_ip_inside_range(union netdata_ip_t *cmp, int family)
1451 {
1452 if (!network_viewer_opt.excluded_ips && !network_viewer_opt.included_ips)
1453 return 1;
1454
1450 - uint32_t ipv4_test = ntohl(cmp->addr32[0]);
1455 + uint32_t ipv4_test = htonl(cmp->addr32[0]);
1456 ebpf_network_viewer_ip_list_t *move = network_viewer_opt.excluded_ips;
1457 while (move) {
1458 if (family == AF_INET) {
1454 - if (ntohl(move->first.addr32[0]) <= ipv4_test &&
1455 - ipv4_test <= ntohl(move->last.addr32[0]) )
1459 + if (move->first.addr32[0] <= ipv4_test &&
1460 + ipv4_test <= move->last.addr32[0])
1461 return 0;
1462 } else {
1463 if (memcmp(move->first.addr8, cmp->addr8, sizeof(union netdata_ip_t)) <= 0 &&
@@ -1465,12 +1470,13 @@ static int is_specific_ip_inside_range(union netdata_ip_t *cmp, int family)
1470
1471 move = network_viewer_opt.included_ips;
1472 while (move) {
1468 - if (family == AF_INET) {
1469 - if (ntohl(move->first.addr32[0]) <= ipv4_test &&
1470 - ntohl(move->last.addr32[0]) >= ipv4_test)
1473 + if (family == AF_INET && move->ver == AF_INET) {
1474 + if (move->first.addr32[0] <= ipv4_test &&
1475 + move->last.addr32[0] >= ipv4_test)
1476 return 1;
1477 } else {
1473 - if (memcmp(move->first.addr8, cmp->addr8, sizeof(union netdata_ip_t)) <= 0 &&
1478 + if (move->ver == AF_INET6 &&
1479 + memcmp(move->first.addr8, cmp->addr8, sizeof(union netdata_ip_t)) <= 0 &&
1480 memcmp(move->last.addr8, cmp->addr8, sizeof(union netdata_ip_t)) >= 0) {
1481 return 1;
1482 }
@@ -1566,7 +1572,7 @@ int is_socket_allowed(netdata_socket_idx_t *key, int family)
1572 if (!is_port_inside_range(key->dport))
1573 return 0;
1574
1569 - return is_specific_ip_inside_range(&key->daddr, family);
1575 + return ebpf_is_specific_ip_inside_range(&key->daddr, family);
1576 }
1577
1578 /**
@@ -1581,38 +1587,26 @@ int is_socket_allowed(netdata_socket_idx_t *key, int family)
1587 *
1588 * @return It returns 0 case the values are equal, 1 case a is bigger than b and -1 case a is smaller than b.
1589 */
1584 -static int compare_sockets(void *a, void *b)
1590 +static int ebpf_compare_sockets(void *a, void *b)
1591 {
1592 struct netdata_socket_plot *val1 = a;
1593 struct netdata_socket_plot *val2 = b;
1588 - int cmp;
1594 + int cmp = 0;
1595
1596 // We do not need to compare val2 family, because data inside hash table is always from the same family
1597 if (val1->family == AF_INET) { //IPV4
1592 - if (val1->flags & NETDATA_INBOUND_DIRECTION) {
1593 - if (val1->index.sport == val2->index.sport)
1594 - cmp = 0;
1595 - else {
1596 - cmp = (val1->index.sport > val2->index.sport)?1:-1;
1597 - }
1598 - } else {
1598 + if (network_viewer_opt.included_port || network_viewer_opt.excluded_port)
1599 cmp = memcmp(&val1->index.dport, &val2->index.dport, sizeof(uint16_t));
1600 - if (!cmp) {
1601 - cmp = memcmp(&val1->index.daddr.addr32[0], &val2->index.daddr.addr32[0], sizeof(uint32_t));
1602 - }
1600 +
1601 + if (!cmp) {
1602 + cmp = memcmp(&val1->index.daddr.addr32[0], &val2->index.daddr.addr32[0], sizeof(uint32_t));
1603 }
1604 } else {
1605 - if (val1->flags & NETDATA_INBOUND_DIRECTION) {
1606 - if (val1->index.sport == val2->index.sport)
1607 - cmp = 0;
1608 - else {
1609 - cmp = (val1->index.sport > val2->index.sport)?1:-1;
1610 - }
1611 - } else {
1605 + if (network_viewer_opt.included_port || network_viewer_opt.excluded_port)
1606 cmp = memcmp(&val1->index.dport, &val2->index.dport, sizeof(uint16_t));
1613 - if (!cmp) {
1614 - cmp = memcmp(&val1->index.daddr.addr32, &val2->index.daddr.addr32, 4*sizeof(uint32_t));
1615 - }
1607 +
1608 + if (!cmp) {
1609 + cmp = memcmp(&val1->index.daddr.addr32, &val2->index.daddr.addr32, 4*sizeof(uint32_t));
1610 }
1611 }
1612
@@ -1632,12 +1626,15 @@ static int compare_sockets(void *a, void *b)
1626 *
1627 * @return it returns the size of the data copied on success and -1 otherwise.
1628 */
1635 -static inline int build_outbound_dimension_name(char *dimname, char *hostname, char *service_name,
1636 - char *proto, int family)
1629 +static inline int ebpf_build_outbound_dimension_name(char *dimname, char *hostname, char *service_name,
1630 + char *proto, int family)
1631 {
1638 - return snprintf(dimname, CONFIG_MAX_NAME - 7, (family == AF_INET)?"%s:%s:%s_":"%s:%s:[%s]_",
1639 - service_name, proto,
1640 - hostname);
1632 + if (network_viewer_opt.included_port || network_viewer_opt.excluded_port)
1633 + return snprintf(dimname, CONFIG_MAX_NAME - 7, (family == AF_INET)?"%s:%s:%s_":"%s:%s:[%s]_",
1634 + service_name, proto, hostname);
1635 +
1636 + return snprintf(dimname, CONFIG_MAX_NAME - 7, (family == AF_INET)?"%s:%s_":"%s:[%s]_",
1637 + proto, hostname);
1638 }
1639
1640 /**
@@ -1693,7 +1690,7 @@ static inline void fill_resolved_name(netdata_socket_plot_t *ptr, char *hostname
1690 }
1691
1692 if (is_outbound)
1696 - size = build_outbound_dimension_name(dimname, hostname, service_name, protocol, ptr->family);
1693 + size = ebpf_build_outbound_dimension_name(dimname, hostname, service_name, protocol, ptr->family);
1694 else
1695 size = build_inbound_dimension_name(dimname,service_name, protocol);
1696
@@ -1851,14 +1848,12 @@ static void fill_last_nv_dimension(netdata_socket_plot_t *ptr, int is_outbound)
1848 */
1849 static inline void update_socket_data(netdata_socket_t *sock, netdata_socket_t *lvalues)
1850 {
1854 - sock->recv_packets += lvalues->recv_packets;
1855 - sock->sent_packets += lvalues->sent_packets;
1856 - sock->recv_bytes += lvalues->recv_bytes;
1857 - sock->sent_bytes += lvalues->sent_bytes;
1858 - sock->retransmit += lvalues->retransmit;
1859 -
1860 - if (lvalues->ct > sock->ct)
1861 - sock->ct = lvalues->ct;
1851 + sock->recv_packets = lvalues->recv_packets;
1852 + sock->sent_packets = lvalues->sent_packets;
1853 + sock->recv_bytes = lvalues->recv_bytes;
1854 + sock->sent_bytes = lvalues->sent_bytes;
1855 + sock->retransmit = lvalues->retransmit;
1856 + sock->ct = lvalues->ct;
1857 }
1858
1859 /**
@@ -1882,7 +1877,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
1877
1878 ret = (netdata_socket_plot_t *) avl_search_lock(&out->tree, (avl_t *)&test);
1879 if (ret) {
1885 - if (lvalues->ct > ret->plot.last_time) {
1880 + if (lvalues->ct != ret->plot.last_time) {
1881 update_socket_data(&ret->sock, lvalues);
1882 }
1883 } else {
@@ -1893,7 +1888,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
1888
1889 int resolved;
1890 if (curr == last) {
1896 - if (lvalues->ct > w->plot.last_time) {
1891 + if (lvalues->ct != w->plot.last_time) {
1892 update_socket_data(&w->sock, lvalues);
1893 }
1894 return;
@@ -1978,6 +1973,9 @@ netdata_vector_plot_t * select_vector_to_store(uint32_t *direction, netdata_sock
1973 */
1974 static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key, int family, int end)
1975 {
1976 + if (!network_viewer_opt.enabled || !is_socket_allowed(key, family))
1977 + return;
1978 +
1979 uint64_t bsent = 0, brecv = 0, psent = 0, precv = 0;
1980 uint16_t retransmit = 0;
1981 int i;
@@ -1995,7 +1993,7 @@ static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key
1993 if (!protocol)
1994 protocol = w->protocol;
1995
1998 - if (w->ct > ct)
1996 + if (w->ct != ct)
1997 ct = w->ct;
1998 }
1999
@@ -2007,11 +2005,9 @@ static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key
2005 values[0].protocol = (!protocol)?IPPROTO_TCP:protocol;
2006 values[0].ct = ct;
2007
2010 - if (is_socket_allowed(key, family)) {
2011 - uint32_t dir;
2012 - netdata_vector_plot_t *table = select_vector_to_store(&dir, key, protocol);
2013 - store_socket_inside_avl(table, &values[0], key, family, dir);
2014 - }
2008 + uint32_t dir;
2009 + netdata_vector_plot_t *table = select_vector_to_store(&dir, key, protocol);
2010 + store_socket_inside_avl(table, &values[0], key, family, dir);
2011 }
2012
2013 /**
@@ -2019,16 +2015,13 @@ static void hash_accumulator(netdata_socket_t *values, netdata_socket_idx_t *key
2015 *
2016 * Read data from hash tables created on kernel ring.
2017 *
2022 - * @param fd the hash table with data.
2023 - * @param family the family associated to the hash table
2018 + * @param fd the hash table with data.
2019 + * @param family the family associated to the hash table
2020 *
2021 * @return it returns 0 on success and -1 otherwise.
2022 */
2027 -static void read_socket_hash_table(int fd, int family, int network_connection)
2023 +static void ebpf_read_socket_hash_table(int fd, int family)
2024 {
2029 - if (wait_to_plot)
2030 - return;
2031 -
2025 netdata_socket_idx_t key = {};
2026 netdata_socket_idx_t next_key = {};
2027
@@ -2047,9 +2040,7 @@ static void read_socket_hash_table(int fd, int family, int network_connection)
2040 continue;
2041 }
2042
2050 - if (network_connection) {
2051 - hash_accumulator(values, &key, family, end);
2052 - }
2043 + hash_accumulator(values, &key, family, end);
2044
2045 key = next_key;
2046 }
@@ -2167,15 +2158,16 @@ void *ebpf_socket_read_hash(void *ptr)
2158 usec_t step = NETDATA_SOCKET_READ_SLEEP_MS * em->update_every;
2159 int fd_ipv4 = socket_maps[NETDATA_SOCKET_TABLE_IPV4].map_fd;
2160 int fd_ipv6 = socket_maps[NETDATA_SOCKET_TABLE_IPV6].map_fd;
2170 - int network_connection = em->optional;
2161 + uint32_t network_connection = network_viewer_opt.enabled;
2162 while (!ebpf_exit_plugin) {
2163 (void)heartbeat_next(&hb, step);
2164
2165 pthread_mutex_lock(&nv_mutex);
2166 read_listen_table();
2176 - read_socket_hash_table(fd_ipv4, AF_INET, network_connection);
2177 - read_socket_hash_table(fd_ipv6, AF_INET6, network_connection);
2178 - wait_to_plot = 1;
2167 + if (network_connection) {
2168 + ebpf_read_socket_hash_table(fd_ipv4, AF_INET);
2169 + ebpf_read_socket_hash_table(fd_ipv6, AF_INET6);
2170 + }
2171 pthread_mutex_unlock(&nv_mutex);
2172 }
2173
@@ -2883,7 +2875,7 @@ static void socket_collector(usec_t step, ebpf_module_t *em)
2875 ebpf_socket_update_cgroup_algorithm();
2876
2877 int socket_global_enabled = em->global_charts;
2886 - int network_connection = em->optional;
2878 + uint32_t network_connection = network_viewer_opt.enabled;
2879 int update_every = em->update_every;
2880 while (!ebpf_exit_plugin) {
2881 (void)heartbeat_next(&hb, step);
@@ -2901,7 +2893,8 @@ static void socket_collector(usec_t step, ebpf_module_t *em)
2893 if (cgroups)
2894 ebpf_update_socket_cgroup();
2895
2904 - calculate_nv_plot();
2896 + if (network_connection)
2897 + calculate_nv_plot();
2898
2899 pthread_mutex_lock(&lock);
2900 if (socket_global_enabled)
@@ -2926,7 +2919,6 @@ static void socket_collector(usec_t step, ebpf_module_t *em)
2919 ebpf_socket_create_nv_charts(&outbound_vectors, update_every);
2920 fflush(stdout);
2921 ebpf_socket_send_nv_data(&outbound_vectors);
2929 - wait_to_plot = 0;
2922 pthread_mutex_unlock(&nv_mutex);
2923
2924 }
@@ -2960,8 +2952,10 @@ static void ebpf_socket_allocate_global_vectors(int apps)
2952 bandwidth_vector = callocz((size_t)ebpf_nprocs, sizeof(ebpf_bandwidth_t));
2953
2954 socket_values = callocz((size_t)ebpf_nprocs, sizeof(netdata_socket_t));
2963 - inbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
2964 - outbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
2955 + if (network_viewer_opt.enabled) {
2956 + inbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
2957 + outbound_vectors.plot = callocz(network_viewer_opt.max_dim, sizeof(netdata_socket_plot_t));
2958 + }
2959 }
2960
2961 /**
@@ -3220,12 +3214,11 @@ static void get_ipv6_first_addr(union netdata_ip_t *out, union netdata_ip_t *in,
3214 *
3215 * @return It returns 1 if the IP is inside the range and 0 otherwise
3216 */
3223 -static int is_ip_inside_range(union netdata_ip_t *rfirst, union netdata_ip_t *rlast,
3224 - union netdata_ip_t *cmpfirst, union netdata_ip_t *cmplast, int family)
3217 +static int ebpf_is_ip_inside_range(union netdata_ip_t *rfirst, union netdata_ip_t *rlast,
3218 + union netdata_ip_t *cmpfirst, union netdata_ip_t *cmplast, int family)
3219 {
3220 if (family == AF_INET) {
3227 - if (ntohl(rfirst->addr32[0]) <= ntohl(cmpfirst->addr32[0]) &&
3228 - ntohl(rlast->addr32[0]) >= ntohl(cmplast->addr32[0]))
3221 + if ((rfirst->addr32[0] <= cmpfirst->addr32[0]) && (rlast->addr32[0] >= cmplast->addr32[0]))
3222 return 1;
3223 } else {
3224 if (memcmp(rfirst->addr8, cmpfirst->addr8, sizeof(union netdata_ip_t)) <= 0 &&
@@ -3242,16 +3235,22 @@ static int is_ip_inside_range(union netdata_ip_t *rfirst, union netdata_ip_t *rl
3235 *
3236 * @param out a pointer to the link list.
3237 * @param in the structure that will be linked.
3238 + * @param table the modified table.
3239 */
3246 -void fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_list_t *in, char *table)
3240 +void ebpf_fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_list_t *in, char *table)
3241 {
3242 #ifndef NETDATA_INTERNAL_CHECKS
3243 UNUSED(table);
3244 #endif
3245 + if (in->ver == AF_INET) { // It is simpler to compare using host order
3246 + in->first.addr32[0] = ntohl(in->first.addr32[0]);
3247 + in->last.addr32[0] = ntohl(in->last.addr32[0]);
3248 + }
3249 if (likely(*out)) {
3250 ebpf_network_viewer_ip_list_t *move = *out, *store = *out;
3251 while (move) {
3254 - if (in->ver == move->ver && is_ip_inside_range(&move->first, &move->last, &in->first, &in->last, in->ver)) {
3252 + if (in->ver == move->ver &&
3253 + ebpf_is_ip_inside_range(&move->first, &move->last, &in->first, &in->last, in->ver)) {
3254 info("The range/value (%s) is inside the range/value (%s) already inserted, it will be ignored.",
3255 in->value, move->value);
3256 freez(in->value);
@@ -3268,14 +3267,12 @@ void fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_li
3267 }
3268
3269 #ifdef NETDATA_INTERNAL_CHECKS
3271 - char first[512], last[512];
3270 + char first[256], last[512];
3271 if (in->ver == AF_INET) {
3273 - if (inet_ntop(AF_INET, in->first.addr8, first, INET_ADDRSTRLEN) &&
3274 - inet_ntop(AF_INET, in->last.addr8, last, INET_ADDRSTRLEN))
3275 - info("Adding values %s - %s to %s IP list \"%s\" used on network viewer",
3276 - first, last,
3277 - (*out == network_viewer_opt.included_ips)?"included":"excluded",
3278 - table);
3272 + info("Adding values %s: (%u - %u) to %s IP list \"%s\" used on network viewer",
3273 + in->value, in->first.addr32[0], in->last.addr32[0],
3274 + (*out == network_viewer_opt.included_ips)?"included":"excluded",
3275 + table);
3276 } else {
3277 if (inet_ntop(AF_INET6, in->first.addr8, first, INET6_ADDRSTRLEN) &&
3278 inet_ntop(AF_INET6, in->last.addr8, last, INET6_ADDRSTRLEN))
@@ -3295,7 +3292,7 @@ void fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_li
3292 * @param out a pointer to store the link list
3293 * @param ip the value given as parameter
3294 */
3298 -static void parse_ip_list(void **out, char *ip)
3295 +static void ebpf_parse_ip_list(void **out, char *ip)
3296 {
3297 ebpf_network_viewer_ip_list_t **list = (ebpf_network_viewer_ip_list_t **)out;
3298
@@ -3443,7 +3440,7 @@ static void parse_ip_list(void **out, char *ip)
3440
3441 ebpf_network_viewer_ip_list_t *store;
3442
3446 - storethisip:
3443 +storethisip:
3444 store = callocz(1, sizeof(ebpf_network_viewer_ip_list_t));
3445 store->value = ipdup;
3446 store->hash = simple_hash(ipdup);
@@ -3451,7 +3448,7 @@ static void parse_ip_list(void **out, char *ip)
3448 memcpy(store->first.addr8, first.addr8, sizeof(first.addr8));
3449 memcpy(store->last.addr8, last.addr8, sizeof(last.addr8));
3450
3454 - fill_ip_list(list, store, "socket");
3451 + ebpf_fill_ip_list(list, store, "socket");
3452 return;
3453
3454 cleanipdup:
@@ -3465,7 +3462,7 @@ cleanipdup:
3462 *
3463 * @param ptr is a pointer with the text to parse.
3464 */
3468 -static void parse_ips(char *ptr)
3465 +static void ebpf_parse_ips(char *ptr)
3466 {
3467 // No value
3468 if (unlikely(!ptr))
@@ -3492,8 +3489,9 @@ static void parse_ips(char *ptr)
3489 }
3490
3491 if (isascii(*ptr)) { // Parse port
3495 - parse_ip_list((!neg)?(void **)&network_viewer_opt.included_ips:(void **)&network_viewer_opt.excluded_ips,
3496 - ptr);
3492 + ebpf_parse_ip_list((!neg)?(void **)&network_viewer_opt.included_ips:
3493 + (void **)&network_viewer_opt.excluded_ips,
3494 + ptr);
3495 }
3496
3497 ptr = end;
@@ -3763,7 +3761,7 @@ void parse_network_viewer_section(struct config *cfg)
3761
3762 value = appconfig_get(cfg, EBPF_NETWORK_VIEWER_SECTION,
3763 "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");
3766 - parse_ips(value);
3764 + ebpf_parse_ips(value);
3765 }
3766
3767 /**
@@ -3917,16 +3915,9 @@ void *ebpf_socket_thread(void *ptr)
3915 {
3916 netdata_thread_cleanup_push(ebpf_socket_exit, ptr);
3917
3920 - memset(&inbound_vectors.tree, 0, sizeof(avl_tree_lock));
3921 - memset(&outbound_vectors.tree, 0, sizeof(avl_tree_lock));
3922 - avl_init_lock(&inbound_vectors.tree, compare_sockets);
3923 - avl_init_lock(&outbound_vectors.tree, compare_sockets);
3924 -
3918 ebpf_module_t *em = (ebpf_module_t *)ptr;
3919 em->maps = socket_maps;
3920
3928 - parse_network_viewer_section(&socket_config);
3929 - parse_service_name_section(&socket_config);
3921 parse_table_size_options(&socket_config);
3922
3923 if (pthread_mutex_init(&nv_mutex, NULL)) {
@@ -3936,7 +3927,15 @@ void *ebpf_socket_thread(void *ptr)
3927 }
3928
3929 ebpf_socket_allocate_global_vectors(em->apps_charts);
3939 - initialize_inbound_outbound();
3930 +
3931 + if (network_viewer_opt.enabled) {
3932 + memset(&inbound_vectors.tree, 0, sizeof(avl_tree_lock));
3933 + memset(&outbound_vectors.tree, 0, sizeof(avl_tree_lock));
3934 + avl_init_lock(&inbound_vectors.tree, ebpf_compare_sockets);
3935 + avl_init_lock(&outbound_vectors.tree, ebpf_compare_sockets);
3936 +
3937 + initialize_inbound_outbound();
3938 + }
3939
3940 if (running_on_kernel < NETDATA_EBPF_KERNEL_5_0)
3941 em->mode = MODE_ENTRY;
collectors/ebpf.plugin/ebpf_socket.h
+2 -1
@@ -244,6 +244,7 @@ typedef struct ebpf_network_viewer_hostname_list {
244
245 #define NETDATA_NV_CAP_VALUE 50L
246 typedef struct ebpf_network_viewer_options {
247 + uint32_t enabled;
248 uint32_t max_dim; // Store value read from 'maximum dimensions'
249
250 uint32_t hostname_resolution_enabled;
@@ -360,7 +361,7 @@ void clean_port_structure(ebpf_network_viewer_port_list_t **clean);
361 extern ebpf_network_viewer_port_list_t *listen_ports;
362 void update_listen_table(uint16_t value, uint16_t proto, netdata_passive_connection_t *values);
363 void parse_network_viewer_section(struct config *cfg);
363 -void fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_list_t *in, char *table);
364 +void ebpf_fill_ip_list(ebpf_network_viewer_ip_list_t **out, ebpf_network_viewer_ip_list_t *in, char *table);
365 void parse_service_name_section(struct config *cfg);
366
367 extern ebpf_socket_publish_apps_t **socket_bandwidth_curr;
packaging/current_libbpf.checksums
+1 -1
@@ -1 +1 @@
1 -63fe4ac3f6807e8ff4cd3af2ffae0091eb177fb7f6aca2f03d3f201a609b988c v1.0.1_netdata.tar.gz
1 +f2a8214c967153fcbb7a8f2af59c23a38f6e175384878dd37648649c5d8182c4 v1.1_netdata.tar.gz
packaging/current_libbpf.version
+1 -1
@@ -1 +1 @@
1 -1.0.1_netdata
1 +1.1_netdata
packaging/ebpf-co-re.checksums
+1 -1
@@ -1 +1 @@
1 -9fe4fccc160ca9e0fd0ffd8894dbf6e5fddcf9ca3a4ee04cb645bb7703e8cef2 netdata-ebpf-co-re-glibc-v1.0.1.tar.xz
1 +d1864cd736d236aa3738152d86096529830822a26405a62fe164779949bb3658 netdata-ebpf-co-re-glibc-v1.1.0.tar.xz
packaging/ebpf-co-re.version
+1 -1
@@ -1 +1 @@
1 -v1.0.1
1 +v1.1.0
packaging/ebpf.checksums
+3 -3
@@ -1,3 +1,3 @@
1 -e3836908a5cfd5a1b6c71463645ed7040be1a4890767844b744fe1054910b51f ./netdata-kernel-collector-glibc-v1.0.1.tar.xz
2 -091382fece7a470e505df4c655d834a8a49e50aa2a2fec4a52a324ab0ccd9870 ./netdata-kernel-collector-musl-v1.0.1.tar.xz
3 -11497ccb4f2cdac0d80b00bf97d2f1633c972e8720abdda2a63bd0de95859840 ./netdata-kernel-collector-static-v1.0.1.tar.xz
1 +7f28bb61b1e9fdac59e5f8f041502c54f319048c1cf4adaa96ace3360f55a80e ./netdata-kernel-collector-glibc-v1.1.0.tar.xz
2 +5d927deadac9a4a5bc8a5be386aec2ea4f9b8335e60eadf375b11e7656404270 ./netdata-kernel-collector-musl-v1.1.0.tar.xz
3 +0d8825b77b8ba20e10b6e24f15c1d65a43f1c47dced93798839adc789f1427d3 ./netdata-kernel-collector-static-v1.1.0.tar.xz
packaging/ebpf.version
+1 -1
@@ -1 +1 @@
1 -v1.0.1
1 +v1.1.0
packaging/libbpf.checksums
+1 -1
@@ -1 +1 @@
1 -63fe4ac3f6807e8ff4cd3af2ffae0091eb177fb7f6aca2f03d3f201a609b988c v1.0.1_netdata.tar.gz
1 +f2a8214c967153fcbb7a8f2af59c23a38f6e175384878dd37648649c5d8182c4 v1.1_netdata.tar.gz
packaging/libbpf.version
+1 -1
@@ -1 +1 @@
1 -1.0.1_netdata
1 +1.1_netdata