Skip to content

Commit 39a1702

Browse files
committed
Use latest rust-netlink crates
Signed-off-by: Gris Ge <[email protected]>
1 parent c64872a commit 39a1702

File tree

14 files changed

+44
-77
lines changed

14 files changed

+44
-77
lines changed

Cargo.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "ethtool"
33
version = "0.2.8"
44
authors = ["Gris Ge <[email protected]>"]
55
license = "MIT"
6-
edition = "2018"
6+
edition = "2021"
77
description = "Linux Ethtool Communication Library"
88
keywords = ["network"]
99
categories = ["network-programming", "os"]
@@ -20,16 +20,13 @@ tokio_socket = ["netlink-proto/tokio_socket", "tokio"]
2020
smol_socket = ["netlink-proto/smol_socket", "async-std"]
2121

2222
[dependencies]
23-
anyhow = "1.0.97"
2423
async-std = { version = "1.13.0", optional = true}
25-
byteorder = "1.5.0"
2624
futures = "0.3.31"
2725
log = "0.4.26"
28-
genetlink = { default-features = false, version = "0.2.5"}
29-
netlink-packet-core = { version = "0.7.0"}
30-
netlink-packet-generic = { version = "0.3.3" }
31-
netlink-packet-utils = { version = "0.5.2" }
32-
netlink-proto = { default-features = false, version = "0.11.5" }
26+
genetlink = { default-features = false, version = "0.2.6"}
27+
netlink-packet-core = { version = "0.8.0"}
28+
netlink-packet-generic = { version = "0.4.0" }
29+
netlink-proto = { default-features = false, version = "0.12.0" }
3330
netlink-sys = { version = "0.8.7" }
3431
thiserror = "1.0.69"
3532
tokio = { version = "1.44.0", features = ["rt"], optional = true}

src/bitset_util.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// SPDX-License-Identifier: MIT
22

3-
use anyhow::Context;
43
use log::warn;
5-
use netlink_packet_utils::{
6-
nla::NlasIterator,
7-
parsers::{parse_string, parse_u32},
8-
DecodeError,
4+
use netlink_packet_core::{
5+
parse_string, parse_u32, DecodeError, ErrorContext, NlasIterator,
96
};
107

118
const ETHTOOL_A_BITSET_BITS: u16 = 3;

src/channel/attr.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// SPDX-License-Identifier: MIT
22

3-
use anyhow::Context;
4-
use byteorder::{ByteOrder, NativeEndian};
5-
use netlink_packet_utils::{
6-
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
7-
parsers::parse_u32,
8-
DecodeError, Emitable, Parseable,
3+
use netlink_packet_core::{
4+
emit_u32, parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext, Nla,
5+
NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
96
};
107

118
use crate::{EthtoolAttr, EthtoolHeader};
@@ -75,7 +72,7 @@ impl Nla for EthtoolChannelAttr {
7572
| Self::RxCount(d)
7673
| Self::TxCount(d)
7774
| Self::OtherCount(d)
78-
| Self::CombinedCount(d) => NativeEndian::write_u32(buffer, *d),
75+
| Self::CombinedCount(d) => emit_u32(buffer, *d).unwrap(),
7976
Self::Other(ref attr) => attr.emit(buffer),
8077
}
8178
}

src/coalesce/attr.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// SPDX-License-Identifier: MIT
22

3-
use anyhow::Context;
4-
use byteorder::{ByteOrder, NativeEndian};
5-
use netlink_packet_utils::{
6-
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
7-
parsers::{parse_u32, parse_u8},
8-
DecodeError, Emitable, Parseable,
3+
use netlink_packet_core::{
4+
emit_u32, parse_u32, parse_u8, DecodeError, DefaultNla, Emitable,
5+
ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
96
};
107

118
use crate::{EthtoolAttr, EthtoolHeader};
@@ -145,9 +142,7 @@ impl Nla for EthtoolCoalesceAttr {
145142
| Self::RxMaxFramesHigh(d)
146143
| Self::TxUsecsHigh(d)
147144
| Self::TxMaxFramesHigh(d)
148-
| Self::RateSampleInterval(d) => {
149-
NativeEndian::write_u32(buffer, *d)
150-
}
145+
| Self::RateSampleInterval(d) => emit_u32(buffer, *d).unwrap(),
151146
Self::UseAdaptiveRx(d) | Self::UseAdaptiveTx(d) => {
152147
buffer[0] = (*d).into()
153148
}

src/feature/attr.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// SPDX-License-Identifier: MIT
22

3-
use anyhow::Context;
43
use log::warn;
5-
use netlink_packet_utils::{
6-
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
7-
parsers::{parse_string, parse_u32},
8-
DecodeError, Emitable, Parseable,
4+
use netlink_packet_core::{
5+
parse_string, parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext,
6+
Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
97
};
108

119
use crate::{EthtoolAttr, EthtoolHeader};

src/fec/attr.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// SPDX-License-Identifier: MIT
22

3-
use anyhow::Context;
4-
use byteorder::{ByteOrder, NativeEndian};
5-
use netlink_packet_utils::{
6-
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
7-
parsers::{parse_u32, parse_u64, parse_u8},
8-
DecodeError, Emitable, Parseable,
3+
use netlink_packet_core::{
4+
emit_u64, parse_u32, parse_u64, parse_u8, DecodeError, DefaultNla,
5+
Emitable, ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable,
6+
NLA_F_NESTED,
97
};
108

119
use crate::{
@@ -237,7 +235,7 @@ impl Nla for EthtoolFecStat {
237235
match self {
238236
Self::Corrected(v)
239237
| Self::Uncorrected(v)
240-
| Self::CorrectBits(v) => NativeEndian::write_u64(buffer, *v),
238+
| Self::CorrectBits(v) => emit_u64(buffer, *v).unwrap(),
241239
Self::Other(attr) => attr.emit(buffer),
242240
}
243241
}

src/handle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use futures::{future::Either, FutureExt, Stream, StreamExt, TryStream};
44
use genetlink::GenetlinkHandle;
5+
use netlink_packet_core::DecodeError;
56
use netlink_packet_core::{
67
NetlinkMessage, NLM_F_ACK, NLM_F_DUMP, NLM_F_REQUEST,
78
};
89
use netlink_packet_generic::GenlMessage;
9-
use netlink_packet_utils::DecodeError;
1010

1111
use crate::{
1212
try_ethtool, EthtoolChannelHandle, EthtoolCoalesceHandle, EthtoolError,

src/header.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
use std::ffi::CString;
44

5-
use anyhow::Context;
6-
use byteorder::{ByteOrder, NativeEndian};
7-
use netlink_packet_utils::{
8-
nla::{DefaultNla, Nla, NlaBuffer},
9-
parsers::{parse_string, parse_u32},
10-
DecodeError, Parseable,
5+
use netlink_packet_core::{
6+
emit_u32, parse_string, parse_u32, DecodeError, DefaultNla, ErrorContext,
7+
Nla, NlaBuffer, Parseable,
118
};
129

1310
const ALTIFNAMSIZ: usize = 128;
@@ -50,7 +47,7 @@ impl Nla for EthtoolHeader {
5047
fn emit_value(&self, buffer: &mut [u8]) {
5148
match self {
5249
Self::DevIndex(value) | Self::Flags(value) => {
53-
NativeEndian::write_u32(buffer, *value)
50+
emit_u32(buffer, *value).unwrap()
5451
}
5552
Self::DevName(s) => {
5653
str_to_zero_ended_u8_array(s, buffer, ALTIFNAMSIZ)

src/link_mode/attr.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// SPDX-License-Identifier: MIT
22

3-
use anyhow::Context;
4-
use netlink_packet_utils::{
5-
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED},
6-
parsers::{parse_u32, parse_u8},
7-
DecodeError, Emitable, Parseable,
3+
use netlink_packet_core::{
4+
parse_u32, parse_u8, DecodeError, DefaultNla, Emitable, ErrorContext, Nla,
5+
NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED,
86
};
97

108
use crate::{

src/message.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// SPDX-License-Identifier: MIT
22

3+
use netlink_packet_core::{DecodeError, Emitable, Nla, ParseableParametrized};
34
use netlink_packet_generic::{GenlFamily, GenlHeader};
4-
use netlink_packet_utils::{
5-
nla::Nla, DecodeError, Emitable, ParseableParametrized,
6-
};
75

86
use crate::{
97
channel::{parse_channel_nlas, EthtoolChannelAttr},

0 commit comments

Comments
 (0)