From 67e3e74845b4053a48177873e4550b5e01322eee Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 9 Mar 2022 08:06:36 +0100 Subject: [PATCH 1/2] network-mux: platform independent TCP info trace --- network-mux/network-mux.cabal | 3 ++- network-mux/src/Network/Mux/TCPInfo.hs | 16 ++++++++++++++++ .../Mux/{TCPInfo.hsc => TCPInfo/Linux.hsc} | 4 ++-- network-mux/src/Network/Mux/Trace.hs | 10 ++-------- 4 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 network-mux/src/Network/Mux/TCPInfo.hs rename network-mux/src/Network/Mux/{TCPInfo.hsc => TCPInfo/Linux.hsc} (98%) diff --git a/network-mux/network-mux.cabal b/network-mux/network-mux.cabal index 66db07042b7..d1e0e5202ca 100644 --- a/network-mux/network-mux.cabal +++ b/network-mux/network-mux.cabal @@ -94,10 +94,11 @@ library Network.Mux.DeltaQ.TraceStatsSupport Network.Mux.DeltaQ.TraceTransformer Network.Mux.DeltaQ.TraceTypes + Network.Mux.TCPInfo Control.Concurrent.JobPool if os(linux) - other-modules: Network.Mux.TCPInfo + other-modules: Network.Mux.TCPInfo.Linux if os(windows) exposed-modules: diff --git a/network-mux/src/Network/Mux/TCPInfo.hs b/network-mux/src/Network/Mux/TCPInfo.hs new file mode 100644 index 00000000000..4cf39dcdf0b --- /dev/null +++ b/network-mux/src/Network/Mux/TCPInfo.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE CPP #-} + +module Network.Mux.TCPInfo + ( StructTCPInfo (..) +#if os_HOST_linux + , SocketOption (TCPInfoSocketOption) +#endif + ) where + +#if os_HOST_linux +import Network.Mux.TCPInfo.Linux +#else +data StructTCPInfo = TCPInfoUnavailable + deriving (Eq, Ord, Show) +#endif + diff --git a/network-mux/src/Network/Mux/TCPInfo.hsc b/network-mux/src/Network/Mux/TCPInfo/Linux.hsc similarity index 98% rename from network-mux/src/Network/Mux/TCPInfo.hsc rename to network-mux/src/Network/Mux/TCPInfo/Linux.hsc index 8387b08224c..9fff1d73df6 100644 --- a/network-mux/src/Network/Mux/TCPInfo.hsc +++ b/network-mux/src/Network/Mux/TCPInfo/Linux.hsc @@ -15,9 +15,9 @@ #include "HsNet.h" -module Network.Mux.TCPInfo +module Network.Mux.TCPInfo.Linux ( StructTCPInfo (..) - , SocketOption(TCPInfoSocketOption) + , SocketOption (TCPInfoSocketOption) ) where import Foreign.C diff --git a/network-mux/src/Network/Mux/Trace.hs b/network-mux/src/Network/Mux/Trace.hs index bee1d86e042..45c6ed3643d 100644 --- a/network-mux/src/Network/Mux/Trace.hs +++ b/network-mux/src/Network/Mux/Trace.hs @@ -29,9 +29,7 @@ import GHC.Generics (Generic (..)) import Quiet (Quiet (..)) import Network.Mux.Types -#ifdef linux_HOST_OS import Network.Mux.TCPInfo -#endif -- @@ -152,11 +150,7 @@ data MuxTrace = | MuxTraceStartedOnDemand MiniProtocolNum MiniProtocolDir | MuxTraceTerminating MiniProtocolNum MiniProtocolDir | MuxTraceShutdown -#ifdef linux_HOST_OS | MuxTraceTCPInfo StructTCPInfo Word16 -#else - | MuxTraceTCPInfo Word16 -#endif instance Show MuxTrace where show MuxTraceRecvHeaderStart = printf "Bearer Receive Header Start" @@ -194,7 +188,7 @@ instance Show MuxTrace where show (MuxTraceStartedOnDemand mid dir) = printf "Started on demand (%s) in %s" (show mid) (show dir) show (MuxTraceTerminating mid dir) = printf "Terminating (%s) in %s" (show mid) (show dir) show MuxTraceShutdown = "Mux shutdown" -#ifdef linux_HOST_OS +#ifdef os_HOST_linux show (MuxTraceTCPInfo StructTCPInfo { tcpi_snd_mss, tcpi_rcv_mss, tcpi_lost, tcpi_retrans , tcpi_rtt, tcpi_rttvar, tcpi_snd_cwnd } @@ -207,6 +201,6 @@ instance Show MuxTrace where (fromIntegral tcpi_retrans :: Word) len #else - show (MuxTraceTCPInfo len) = printf "TCPInfo len %d" len + show (MuxTraceTCPInfo _ len) = printf "TCPInfo len %d" len #endif From 976d0d5914d7461b54f99b81cbfc5ca099712897 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 9 Mar 2022 08:06:37 +0100 Subject: [PATCH 2/2] Added interface-CHANGELOG.md file `tracetcpinfo` cabal flag was provided in PR #3648. --- docs/interface-CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/interface-CHANGELOG.md diff --git a/docs/interface-CHANGELOG.md b/docs/interface-CHANGELOG.md new file mode 100644 index 00000000000..425ac440c27 --- /dev/null +++ b/docs/interface-CHANGELOG.md @@ -0,0 +1,16 @@ +# Interface Change Log + +This change log file is written for the benefit of Cardano Node development +team. See [consensus +CHANGELOG](../ouroboros-consensus/docs/interface-CHANGELOG.md) file for how +this changelog is supposed to be used. + + +## Circa 2022-03-08 + + +### Added + +- on Linux when `network-mux` is compiled with `tracetcpinfo` cabal flag, mux + will log `MuxTraceTCPInfo`. For performance reasons this is disabled by + default.