From 5dee77c211f4fc68221b39a49c7d96baecc625c2 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Fri, 9 Oct 2026 18:54:16 +0800 Subject: [PATCH] Fix emitting of unknown/other attributes We are incorrect writing header of Other NLA to the buffer when only value should be emitted. Fixed by use `attr.emit_value(buffer)` instead. Signed-off-by: Gris Ge --- src/channel/attr.rs | 2 +- src/coalesce/attr.rs | 2 +- src/eeprom/attr.rs | 2 +- src/feature/attr.rs | 2 +- src/fec/attr.rs | 4 ++-- src/link_mode/attr.rs | 2 +- src/pause/attr.rs | 2 +- src/ring/attr.rs | 2 +- src/tsinfo/attr.rs | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/channel/attr.rs b/src/channel/attr.rs index 797f22f..4a8589a 100644 --- a/src/channel/attr.rs +++ b/src/channel/attr.rs @@ -73,7 +73,7 @@ impl Nla for EthtoolChannelAttr { | Self::TxCount(d) | Self::OtherCount(d) | Self::CombinedCount(d) => emit_u32(buffer, *d).unwrap(), - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), } } } diff --git a/src/coalesce/attr.rs b/src/coalesce/attr.rs index f11a653..aaa027b 100644 --- a/src/coalesce/attr.rs +++ b/src/coalesce/attr.rs @@ -295,7 +295,7 @@ impl Nla for EthtoolCoalesceAttr { fn emit_value(&self, buffer: &mut [u8]) { match self { Self::Header(ref nlas) => nlas.as_slice().emit(buffer), - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), Self::RxUsecs(d) | Self::RxMaxFrames(d) | Self::RxUsecsIrq(d) diff --git a/src/eeprom/attr.rs b/src/eeprom/attr.rs index 891826c..8b5f61b 100644 --- a/src/eeprom/attr.rs +++ b/src/eeprom/attr.rs @@ -59,7 +59,7 @@ impl Nla for EthtoolModuleEEPROMAttr { buffer[0] = *d } Self::Offset(d) | Self::Length(d) => emit_u32(buffer, *d).unwrap(), - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), } } } diff --git a/src/feature/attr.rs b/src/feature/attr.rs index 0b6cac6..97e94fc 100644 --- a/src/feature/attr.rs +++ b/src/feature/attr.rs @@ -91,7 +91,7 @@ impl Nla for EthtoolFeatureAttr { | Self::NoChange(feature_bits) => { feature_bits_emit(feature_bits.as_slice(), buffer) } - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), } } } diff --git a/src/fec/attr.rs b/src/fec/attr.rs index 82cf543..c97d99c 100644 --- a/src/fec/attr.rs +++ b/src/fec/attr.rs @@ -64,7 +64,7 @@ impl Nla for EthtoolFecAttr { fn emit_value(&self, buffer: &mut [u8]) { match self { Self::Header(ref nlas) => nlas.as_slice().emit(buffer), - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), _ => todo!("Does not support changing ethtool fec yet"), } } @@ -236,7 +236,7 @@ impl Nla for EthtoolFecStat { Self::Corrected(v) | Self::Uncorrected(v) | Self::CorrectBits(v) => emit_u64(buffer, *v).unwrap(), - Self::Other(attr) => attr.emit(buffer), + Self::Other(attr) => attr.emit_value(buffer), } } } diff --git a/src/link_mode/attr.rs b/src/link_mode/attr.rs index c072d8f..03dd955 100644 --- a/src/link_mode/attr.rs +++ b/src/link_mode/attr.rs @@ -108,7 +108,7 @@ impl Nla for EthtoolLinkModeAttr { fn emit_value(&self, buffer: &mut [u8]) { match self { Self::Header(ref nlas) => nlas.as_slice().emit(buffer), - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), _ => todo!("Does not support changing ethtool link mode yet"), } } diff --git a/src/pause/attr.rs b/src/pause/attr.rs index f18dfe5..b1e6b3f 100644 --- a/src/pause/attr.rs +++ b/src/pause/attr.rs @@ -108,7 +108,7 @@ impl Nla for EthtoolPauseAttr { buffer[0] = *value as u8 } Self::Stats(ref nlas) => nlas.as_slice().emit(buffer), - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), } } } diff --git a/src/ring/attr.rs b/src/ring/attr.rs index b8395ca..f6065be 100644 --- a/src/ring/attr.rs +++ b/src/ring/attr.rs @@ -93,7 +93,7 @@ impl Nla for EthtoolRingAttr { | 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), + Self::Other(ref attr) => attr.emit_value(buffer), } } } diff --git a/src/tsinfo/attr.rs b/src/tsinfo/attr.rs index 4fb58a2..f213441 100644 --- a/src/tsinfo/attr.rs +++ b/src/tsinfo/attr.rs @@ -51,7 +51,7 @@ impl Nla for EthtoolTsInfoAttr { fn emit_value(&self, buffer: &mut [u8]) { match self { Self::Header(ref nlas) => nlas.as_slice().emit(buffer), - Self::Other(ref attr) => attr.emit(buffer), + Self::Other(ref attr) => attr.emit_value(buffer), _ => todo!("Does not support changing ethtool ts info yet"), } }