Add support for NetBSD systems which have TCP_INFO implemented.
Этот коммит содержится в:
родитель
a337b698d0
Коммит
86daf673f3
@ -66,8 +66,9 @@ struct iperf_interval_results
|
|||||||
int cnt_error;
|
int cnt_error;
|
||||||
|
|
||||||
int omitted;
|
int omitted;
|
||||||
#if defined(linux) || defined(__FreeBSD__)
|
#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)) && \
|
||||||
struct tcp_info tcpInfo; /* getsockopt(TCP_INFO) for Linux and FreeBSD */
|
defined(TCP_INFO)
|
||||||
|
struct tcp_info tcpInfo; /* getsockopt(TCP_INFO) for Linux, {Free,Net}BSD */
|
||||||
#else
|
#else
|
||||||
/* Just placeholders, never accessed. */
|
/* Just placeholders, never accessed. */
|
||||||
char *tcpInfo;
|
char *tcpInfo;
|
||||||
|
@ -369,6 +369,10 @@ const char report_tcpInfo[] =
|
|||||||
const char report_tcpInfo[] =
|
const char report_tcpInfo[] =
|
||||||
"event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n";
|
"event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n";
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
const char report_tcpInfo[] =
|
||||||
|
"event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_QUAD_SUPPORT
|
#ifdef HAVE_QUAD_SUPPORT
|
||||||
|
@ -61,7 +61,8 @@
|
|||||||
int
|
int
|
||||||
has_tcpinfo(void)
|
has_tcpinfo(void)
|
||||||
{
|
{
|
||||||
#if defined(linux) || defined(__FreeBSD__)
|
#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)) \
|
||||||
|
&& defined(TCP_INFO)
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
@ -81,8 +82,9 @@ has_tcpinfo_retransmits(void)
|
|||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
||||||
/* return 1; */
|
return 1; /* Should work now */
|
||||||
return 0; /* FreeBSD retransmit reporting doesn't actually work yet */
|
#elif defined(__NetBSD__) && defined(TCP_INFO)
|
||||||
|
return 1;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@ -93,7 +95,8 @@ has_tcpinfo_retransmits(void)
|
|||||||
void
|
void
|
||||||
save_tcpinfo(struct iperf_stream *sp, struct iperf_interval_results *irp)
|
save_tcpinfo(struct iperf_stream *sp, struct iperf_interval_results *irp)
|
||||||
{
|
{
|
||||||
#if defined(linux) || defined(__FreeBSD__)
|
#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)) && \
|
||||||
|
defined(TCP_INFO)
|
||||||
socklen_t tcp_info_length = sizeof(struct tcp_info);
|
socklen_t tcp_info_length = sizeof(struct tcp_info);
|
||||||
|
|
||||||
if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&irp->tcpInfo, &tcp_info_length) < 0)
|
if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&irp->tcpInfo, &tcp_info_length) < 0)
|
||||||
@ -114,13 +117,13 @@ get_total_retransmits(struct iperf_interval_results *irp)
|
|||||||
{
|
{
|
||||||
#if defined(linux) && defined(TCP_MD5SIG)
|
#if defined(linux) && defined(TCP_MD5SIG)
|
||||||
return irp->tcpInfo.tcpi_total_retrans;
|
return irp->tcpInfo.tcpi_total_retrans;
|
||||||
#else
|
#elif defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
||||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
return irp->tcpInfo.tcpi_snd_rexmitpack;
|
||||||
return irp->tcpInfo.__tcpi_retransmits;
|
#elif defined(__NetBSD__) && defined(TCP_INFO)
|
||||||
|
return irp->tcpInfo.tcpi_snd_rexmitpack;
|
||||||
#else
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
@ -132,13 +135,13 @@ get_snd_cwnd(struct iperf_interval_results *irp)
|
|||||||
{
|
{
|
||||||
#if defined(linux) && defined(TCP_MD5SIG)
|
#if defined(linux) && defined(TCP_MD5SIG)
|
||||||
return irp->tcpInfo.tcpi_snd_cwnd * irp->tcpInfo.tcpi_snd_mss;
|
return irp->tcpInfo.tcpi_snd_cwnd * irp->tcpInfo.tcpi_snd_mss;
|
||||||
#else
|
#elif defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
||||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
return irp->tcpInfo.tcpi_snd_cwnd * irp->tcpInfo.tcpi_snd_mss;
|
||||||
|
#elif defined(__NetBSD__) && defined(TCP_INFO)
|
||||||
return irp->tcpInfo.tcpi_snd_cwnd * irp->tcpInfo.tcpi_snd_mss;
|
return irp->tcpInfo.tcpi_snd_cwnd * irp->tcpInfo.tcpi_snd_mss;
|
||||||
#else
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
@ -150,8 +153,9 @@ get_rtt(struct iperf_interval_results *irp)
|
|||||||
{
|
{
|
||||||
#if defined(linux) && defined(TCP_MD5SIG)
|
#if defined(linux) && defined(TCP_MD5SIG)
|
||||||
return irp->tcpInfo.tcpi_rtt;
|
return irp->tcpInfo.tcpi_rtt;
|
||||||
#else
|
#elif defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
||||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
|
return irp->tcpInfo.tcpi_rtt;
|
||||||
|
#elif defined(__NetBSD__) && defined(TCP_INFO)
|
||||||
return irp->tcpInfo.tcpi_rtt;
|
return irp->tcpInfo.tcpi_rtt;
|
||||||
#else
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
@ -173,4 +177,8 @@ build_tcpinfo_message(struct iperf_interval_results *r, char *message)
|
|||||||
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd,
|
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd,
|
||||||
r->tcpInfo.tcpi_rcv_space, r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
|
r->tcpInfo.tcpi_rcv_space, r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__NetBSD__) && defined(TCP_INFO)
|
||||||
|
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd,
|
||||||
|
r->tcpInfo.tcpi_rcv_space, r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user