From 86c81a32cfccde1deac04f21eaa6fb0a03d8f7dc Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Thu, 24 Aug 2017 09:23:16 +0100 Subject: [PATCH] libknet: some FreeBSD compatibility fixes. Also add support for KNET_LINK_FLAG_TRAFFICHIPRIO on FreeBSD Signed-off-by: Christine Caulfield --- libknet/internals.h | 1 + libknet/threads_tx.c | 3 ++- libknet/transport_common.c | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libknet/internals.h b/libknet/internals.h index e87c35e..69760f7 100644 --- a/libknet/internals.h +++ b/libknet/internals.h @@ -14,6 +14,7 @@ * NOTE: you shouldn't need to include this header normally */ +#include #include "libknet.h" #include "onwire.h" #include "compat.h" diff --git a/libknet/threads_tx.c b/libknet/threads_tx.c index b4466a2..c1a7932 100644 --- a/libknet/threads_tx.c +++ b/libknet/threads_tx.c @@ -55,7 +55,8 @@ static int _dispatch_to_links(knet_handle_t knet_h, struct knet_host *dst_host, while (msg_idx < msgs_to_send) { msg[msg_idx].msg_hdr.msg_name = &cur_link->dst_addr; - for (i=0; istatus.stats.tx_data_bytes += msg[msg_idx].msg_hdr.msg_iov[i].iov_len; } cur_link->status.stats.tx_data_packets++; diff --git a/libknet/transport_common.c b/libknet/transport_common.c index b952405..f0f3eaf 100644 --- a/libknet/transport_common.c +++ b/libknet/transport_common.c @@ -132,6 +132,18 @@ int _configure_common_socket(knet_handle_t knet_h, int sock, uint64_t flags, con } } #endif +#if defined(IP_TOS) && defined(IPTOS_LOWDELAY) + if (flags & KNET_LINK_FLAG_TRAFFICHIPRIO) { + value = IPTOS_LOWDELAY; + if (setsockopt(sock, IPPROTO_IP, IP_TOS, &value, sizeof(value)) < 0) { + savederrno = errno; + err = -1; + log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s priority: %s", + type, strerror(savederrno)); + goto exit_error; + } + } +#endif exit_error: errno = savederrno; -- 2.39.5