tcp_stats: fix compilation on CentOS 7

This is to fix the following compile error on CentOS 7:

[   74s] stats_tcp.c: In function 'fill_stats':
[   74s] stats_tcp.c:138:15: error: 'struct tcp_info' has no member named 'tcpi_notsent_bytes'
[   74s]        tcp_info.tcpi_notsent_bytes);
[   74s]                ^

Closes: OS#5374
Change-Id: Icde6651baeb0828477dbf540a02b16a1a5f91797
This commit is contained in:
Harald Welte 2021-12-24 11:31:12 +01:00
parent b1ef8f5f69
commit c809f4e494
2 changed files with 11 additions and 0 deletions

View File

@ -517,6 +517,13 @@ CHECK_BUILTIN_SUPPORT([__builtin_cpu_supports],
[Runtime SIMD detection will be disabled])
dnl There are some members in struct tcp_info that might not exist on all linux versions
AC_CHECK_MEMBER([struct tcp_info.tcpi_notsent_bytes],
AC_DEFINE([HAVE_TCP_INFO_TCPI_NOTSENT_BYTES],
[1],
[Define to 1 if your <linux/tcp.h> header file have the tcpi_notsent_bytes member in struct tcp_info]),
[],
[#include <linux/tcp.h>])
AC_CHECK_MEMBER([struct tcp_info.tcpi_rwnd_limited],
AC_DEFINE([HAVE_TCP_INFO_TCPI_RWND_LIMITED],
[1],

View File

@ -134,8 +134,12 @@ static void fill_stats(struct stats_tcp_entry *stats_tcp_entry)
osmo_stat_item_set(osmo_stat_item_group_get_item(stats_tcp_entry->stats_tcp, STATS_TCP_RTT), tcp_info.tcpi_rtt);
osmo_stat_item_set(osmo_stat_item_group_get_item(stats_tcp_entry->stats_tcp, STATS_TCP_RCV_RTT),
tcp_info.tcpi_rcv_rtt);
#if HAVE_TCP_INFO_TCPI_NOTSENT_BYTES == 1
osmo_stat_item_set(osmo_stat_item_group_get_item(stats_tcp_entry->stats_tcp, STATS_TCP_NOTSENT_BYTES),
tcp_info.tcpi_notsent_bytes);
#else
osmo_stat_item_set(osmo_stat_item_group_get_item(stats_tcp_entry->stats_tcp, STATS_TCP_NOTSENT_BYTES), -1);
#endif
#if HAVE_TCP_INFO_TCPI_RWND_LIMITED == 1
osmo_stat_item_set(osmo_stat_item_group_get_item(stats_tcp_entry->stats_tcp, STATS_TCP_RWND_LIMITED),