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
diff --git a/configure.ac b/configure.ac
index 8fb299b..89615fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -517,6 +517,13 @@
[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],
diff --git a/src/stats_tcp.c b/src/stats_tcp.c
index fffb10a..d2be6a9 100644
--- a/src/stats_tcp.c
+++ b/src/stats_tcp.c
@@ -134,8 +134,12 @@
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),