diff --git a/src/buffer.rs b/src/buffer.rs index c967acf..dd41e31 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -49,7 +49,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> SockDiagBuffer<&'a T> { } } -impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> SockDiagBuffer<&'a mut T> { +impl + AsMut<[u8]> + ?Sized> SockDiagBuffer<&mut T> { pub fn inner_mut(&mut self) -> &mut [u8] { self.buffer.as_mut() } diff --git a/src/inet/nlas.rs b/src/inet/nlas.rs index a8e6a89..34dbd29 100644 --- a/src/inet/nlas.rs +++ b/src/inet/nlas.rs @@ -85,8 +85,8 @@ buffer!(MemInfoBuffer(MEM_INFO_LEN) { /// documentation with a huge grain of salt. Please report any error /// you may notice. Here are the references I used: /// -/// - [https://wiki.linuxfoundation.org/networking/sk_buff](a short introduction -/// to `sk_buff`, the struct used in the kernel to store packets) +/// - [a short introduction to `sk_buff`, the struct used in the kernel to store +/// packets](https://wiki.linuxfoundation.org/networking/sk_buff) /// - [vger.kernel.org has a lot of documentation about the low level network stack APIs](http://vger.kernel.org/~davem/skb_data.html) /// - [thorough high level explanation of buffering in the network stack](https://www.coverfire.com/articles/queueing-in-the-linux-network-stack/) /// - [understanding the backlog queue](http://veithen.io/2014/01/01/how-tcp-backlog-works-in-linux.html) @@ -150,7 +150,7 @@ pub struct MemInfo { /// Memory used for packets that have been passed down the network /// stack, i.e. that are either in the QDisc or device driver /// queues. This attribute is known as `sk_wmem_alloc` in the - /// kernel. See also [`send_queue`]. + /// kernel. See also [`send_queue`](#structfield.send_queue). pub bottom_send_queues: u32, /// The amount of memory already allocated for this socket but /// currently unused. When more memory is needed either for @@ -257,7 +257,7 @@ impl netlink_packet_core::Nla for Nla { #[cfg(not(feature = "rich_nlas"))] TcpInfo(ref bytes) => bytes.len(), // +1 because we need to append a null byte - Congestion(ref s) => s.as_bytes().len() + 1, + Congestion(ref s) => s.len() + 1, Tos(_) | Tc(_) | Shutdown(_) | Protocol(_) | SkV6Only(_) => 1, MemInfo(_) => MEM_INFO_LEN, Mark(_) | ClassId(_) => 4, @@ -470,7 +470,7 @@ pub struct TcpInfo { /// `TCP_CA_DISORDER`, `TCP_CA_CWR`, `TCP_CA_RECOVERY`, /// `TCP_CA_LOSS` pub ca_state: u8, - /// + /// Number of retransmits since the last ACK pub retransmits: u8, pub probes: u8, pub backoff: u8, @@ -500,7 +500,7 @@ pub struct TcpInfo { pub sacked: u32, /// Number of segments that have been lost pub lost: u32, - /// Number of segments that have been retransmitted + /// Number of segments that are currently being retransmitted pub retrans: u32, /// Number of segments that have been FACKed pub fackets: u32, @@ -532,6 +532,8 @@ pub struct TcpInfo { pub rcv_rtt: u32, pub rcv_space: u32, + /// Number of segments that have been retransmitted during lifetime of the + /// socket pub total_retrans: u32, pub pacing_rate: u64, diff --git a/src/unix/nlas.rs b/src/unix/nlas.rs index 0a03918..7119b65 100644 --- a/src/unix/nlas.rs +++ b/src/unix/nlas.rs @@ -26,12 +26,8 @@ pub enum Nla { /// attribute is reported for listening sockets only. This /// attribute is known as `UNIX_DIAG_ICONS` in the kernel. PendingConnections(Vec), - /// This attribute corresponds to the `UNIX_DIAG_RQLEN`. It - /// reports the length of the socket receive queue, and the queue - /// size limit. Note that for **listening** sockets the receive - /// queue is used to store actual data sent by other sockets. It - /// is used to store pending connections. So the meaning of this - /// attribute differs for listening sockets. + /// This attribute corresponds to the `UNIX_DIAG_RQLEN`. Actual meaning of + /// this attribute differs depending on the type of socket. /// /// For **listening** sockets: /// @@ -243,7 +239,7 @@ impl netlink_packet_core::Nla for Nla { use self::Nla::*; match *self { // +1 because we need to append a null byte - Name(ref s) => s.as_bytes().len() + 1, + Name(ref s) => s.len() + 1, Vfs(_) => VFS_LEN, Peer(_) => 4, PendingConnections(ref v) => 4 * v.len(), @@ -310,7 +306,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable> for Nla { parse_u32(payload).context("invalid UNIX_DIAG_PEER value")?, ), UNIX_DIAG_ICONS => { - if payload.len() % 4 != 0 { + if !payload.len().is_multiple_of(4) { return Err(DecodeError::from("invalid UNIX_DIAG_ICONS")); } Self::PendingConnections(