Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "ethtool"
version = "0.2.8"
authors = ["Gris Ge <fge@redhat.com>"]
license = "MIT"
edition = "2018"
edition = "2021"
description = "Linux Ethtool Communication Library"
keywords = ["network"]
categories = ["network-programming", "os"]
Expand All @@ -20,16 +20,13 @@ tokio_socket = ["netlink-proto/tokio_socket", "tokio"]
smol_socket = ["netlink-proto/smol_socket", "async-std"]

[dependencies]
anyhow = "1.0.97"
async-std = { version = "1.13.0", optional = true}
byteorder = "1.5.0"
futures = "0.3.31"
log = "0.4.26"
genetlink = { default-features = false, version = "0.2.5"}
netlink-packet-core = { version = "0.7.0"}
netlink-packet-generic = { version = "0.3.3" }
netlink-packet-utils = { version = "0.5.2" }
netlink-proto = { default-features = false, version = "0.11.5" }
genetlink = { default-features = false, version = "0.2.6"}
netlink-packet-core = { version = "0.8.0"}
netlink-packet-generic = { version = "0.4.0" }
netlink-proto = { default-features = false, version = "0.12.0" }
netlink-sys = { version = "0.8.7" }
thiserror = "1.0.69"
tokio = { version = "1.44.0", features = ["rt"], optional = true}
Expand Down
7 changes: 2 additions & 5 deletions src/bitset_util.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use log::warn;
use netlink_packet_utils::{
nla::NlasIterator,
parsers::{parse_string, parse_u32},
DecodeError,
use netlink_packet_core::{
parse_string, parse_u32, DecodeError, ErrorContext, NlasIterator,
};

const ETHTOOL_A_BITSET_BITS: u16 = 3;
Expand Down
11 changes: 4 additions & 7 deletions src/channel/attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use byteorder::{ByteOrder, NativeEndian};
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::parse_u32,
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
emit_u32, parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext, Nla,
NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
};

use crate::{EthtoolAttr, EthtoolHeader};
Expand Down Expand Up @@ -75,7 +72,7 @@ impl Nla for EthtoolChannelAttr {
| Self::RxCount(d)
| Self::TxCount(d)
| Self::OtherCount(d)
| Self::CombinedCount(d) => NativeEndian::write_u32(buffer, *d),
| Self::CombinedCount(d) => emit_u32(buffer, *d).unwrap(),
Self::Other(ref attr) => attr.emit(buffer),
}
}
Expand Down
13 changes: 4 additions & 9 deletions src/coalesce/attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use byteorder::{ByteOrder, NativeEndian};
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::{parse_u32, parse_u8},
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
emit_u32, parse_u32, parse_u8, DecodeError, DefaultNla, Emitable,
ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
};

use crate::{EthtoolAttr, EthtoolHeader};
Expand Down Expand Up @@ -145,9 +142,7 @@ impl Nla for EthtoolCoalesceAttr {
| Self::RxMaxFramesHigh(d)
| Self::TxUsecsHigh(d)
| Self::TxMaxFramesHigh(d)
| Self::RateSampleInterval(d) => {
NativeEndian::write_u32(buffer, *d)
}
| Self::RateSampleInterval(d) => emit_u32(buffer, *d).unwrap(),
Self::UseAdaptiveRx(d) | Self::UseAdaptiveTx(d) => {
buffer[0] = (*d).into()
}
Expand Down
8 changes: 3 additions & 5 deletions src/feature/attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use log::warn;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::{parse_string, parse_u32},
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
parse_string, parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext,
Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
};

use crate::{EthtoolAttr, EthtoolHeader};
Expand Down
12 changes: 5 additions & 7 deletions src/fec/attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use byteorder::{ByteOrder, NativeEndian};
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::{parse_u32, parse_u64, parse_u8},
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
emit_u64, parse_u32, parse_u64, parse_u8, DecodeError, DefaultNla,
Emitable, ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable,
NLA_F_NESTED,
};

use crate::{
Expand Down Expand Up @@ -237,7 +235,7 @@ impl Nla for EthtoolFecStat {
match self {
Self::Corrected(v)
| Self::Uncorrected(v)
| Self::CorrectBits(v) => NativeEndian::write_u64(buffer, *v),
| Self::CorrectBits(v) => emit_u64(buffer, *v).unwrap(),
Self::Other(attr) => attr.emit(buffer),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

use futures::{future::Either, FutureExt, Stream, StreamExt, TryStream};
use genetlink::GenetlinkHandle;
use netlink_packet_core::DecodeError;
use netlink_packet_core::{
NetlinkMessage, NLM_F_ACK, NLM_F_DUMP, NLM_F_REQUEST,
};
use netlink_packet_generic::GenlMessage;
use netlink_packet_utils::DecodeError;

use crate::{
try_ethtool, EthtoolChannelHandle, EthtoolCoalesceHandle, EthtoolError,
Expand Down
11 changes: 4 additions & 7 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

use std::ffi::CString;

use anyhow::Context;
use byteorder::{ByteOrder, NativeEndian};
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer},
parsers::{parse_string, parse_u32},
DecodeError, Parseable,
use netlink_packet_core::{
emit_u32, parse_string, parse_u32, DecodeError, DefaultNla, ErrorContext,
Nla, NlaBuffer, Parseable,
};

const ALTIFNAMSIZ: usize = 128;
Expand Down Expand Up @@ -50,7 +47,7 @@ impl Nla for EthtoolHeader {
fn emit_value(&self, buffer: &mut [u8]) {
match self {
Self::DevIndex(value) | Self::Flags(value) => {
NativeEndian::write_u32(buffer, *value)
emit_u32(buffer, *value).unwrap()
}
Self::DevName(s) => {
str_to_zero_ended_u8_array(s, buffer, ALTIFNAMSIZ)
Expand Down
8 changes: 3 additions & 5 deletions src/link_mode/attr.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::{parse_u32, parse_u8},
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
parse_u32, parse_u8, DecodeError, DefaultNla, Emitable, ErrorContext, Nla,
NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
};

use crate::{
Expand Down
4 changes: 1 addition & 3 deletions src/message.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// SPDX-License-Identifier: MIT

use netlink_packet_core::{DecodeError, Emitable, Nla, ParseableParametrized};
use netlink_packet_generic::{GenlFamily, GenlHeader};
use netlink_packet_utils::{
nla::Nla, DecodeError, Emitable, ParseableParametrized,
};

use crate::{
channel::{parse_channel_nlas, EthtoolChannelAttr},
Expand Down
11 changes: 4 additions & 7 deletions src/pause/attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use byteorder::{ByteOrder, NativeEndian};
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::{parse_u64, parse_u8},
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
emit_u64, parse_u64, parse_u8, DecodeError, DefaultNla, Emitable,
ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
};

use crate::{EthtoolAttr, EthtoolHeader};
Expand Down Expand Up @@ -45,7 +42,7 @@ impl Nla for EthtoolPauseStatAttr {
fn emit_value(&self, buffer: &mut [u8]) {
match self {
Self::Rx(value) | Self::Tx(value) => {
NativeEndian::write_u64(buffer, *value)
emit_u64(buffer, *value).unwrap()
}
Self::Other(ref attr) => attr.emit_value(buffer),
}
Expand Down
11 changes: 4 additions & 7 deletions src/ring/attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use byteorder::{ByteOrder, NativeEndian};
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::{parse_u32, parse_u8},
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
emit_u32, parse_u32, parse_u8, DecodeError, DefaultNla, Emitable,
ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
};

use crate::{EthtoolAttr, EthtoolHeader};
Expand Down Expand Up @@ -93,7 +90,7 @@ impl Nla for EthtoolRingAttr {
| Self::RxJumbo(d)
| Self::RxBufLen(d)
| Self::CqeSize(d)
| Self::Tx(d) => NativeEndian::write_u32(buffer, *d),
| Self::Tx(d) => emit_u32(buffer, *d).unwrap(),
Self::TcpDataSplit(d) => buffer[0] = *d,
Self::TxPush(d) => buffer[0] = *d as u8,
Self::Other(ref attr) => attr.emit(buffer),
Expand Down
8 changes: 3 additions & 5 deletions src/tsinfo/attr.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
parsers::parse_u32,
DecodeError, Emitable, Parseable,
use netlink_packet_core::{
parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext, Nla, NlaBuffer,
NlasIterator, Parseable, NLA_F_NESTED,
};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion tests/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use ethtool::{
EthtoolAttr, EthtoolChannelAttr, EthtoolCmd, EthtoolHeader, EthtoolMessage,
};
use netlink_packet_core::{Emitable, Parseable, ParseableParametrized};
use netlink_packet_generic::{GenlBuffer, GenlHeader};
use netlink_packet_utils::{Emitable, Parseable, ParseableParametrized};

#[test]
fn test_channels_get_reply() {
Expand Down