rust-netlink / netlink-packet-utils Goto Github PK
View Code? Open in Web Editor NEWmacros and helpers for parsing netlink messages
License: Other
macros and helpers for parsing netlink messages
License: Other
---- nla::tests::network_byteorder stdout ----
thread 'nla::tests::network_byteorder' panicked at 'range end index 2048 out of range for slice of length 8', src/nla.rs:168:10
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
failures:
nla::tests::network_byteorder
test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass --lib
The library panics when trying to parse an sfq
qdisc.
sudo ip link add dummy1 type dummy
sudo tc qdisc add dev dummy1 parent root handle 1:0 sfq
#[test]
fn test_qdisc() {
use netlink_packet_core::{
NetlinkHeader, NetlinkMessage, NetlinkPayload, NLM_F_DUMP, NLM_F_REQUEST,
};
use netlink_sys::{protocols::NETLINK_ROUTE, Socket, SocketAddr};
use crate::RtnlMessage;
let socket = Socket::new(NETLINK_ROUTE).unwrap();
socket.connect(&SocketAddr::new(0, 0)).unwrap();
let mut nl_hdr = NetlinkHeader::default();
nl_hdr.flags = NLM_F_REQUEST | NLM_F_DUMP;
let mut packet = NetlinkMessage::new(
nl_hdr,
NetlinkPayload::from(RtnlMessage::GetQueueDiscipline(TcMessage::default())),
);
packet.finalize();
let mut buf = vec![0; packet.header.length as usize];
packet.serialize(&mut buf[..]);
socket.send(&buf[..], 0).unwrap();
let mut receive_buffer = vec![0; 4096];
let mut offset = 0;
let mut tc_messages = Vec::new();
while let Ok(size) = socket.recv(&mut &mut receive_buffer[..], 0) {
let mut i: u8 = 0;
loop {
i += 1;
if i == 6 {
println!("sfq");
}
let bytes = &receive_buffer[offset..];
// !!! PANICS here !!!
let rx_packet = <NetlinkMessage<RtnlMessage>>::deserialize(bytes).unwrap();
let payload = rx_packet.payload;
match payload {
NetlinkPayload::InnerMessage(RtnlMessage::NewQueueDiscipline(message)) => {
tc_messages.push(message.clone())
}
NetlinkPayload::Error(error) => {
panic!("Received Netlink Error: {:?}", error);
}
NetlinkPayload::Done(_) => break,
_ => {}
}
offset += rx_packet.header.length as usize;
if offset == size || rx_packet.header.length == 0 {
offset = 0;
break;
}
}
}
}
The error is because of this logic
netlink-packet-utils/src/nla.rs
Line 69 in 51ef451
DecodeError { inner: invalid NLA buffer
Caused by:
Decode error occurred: buffer has length: 72, but the NLA is 1514 bytes }
anyhow::Error
is an opaque type and dynamically dispatched. It can be useful to present errors as an enum
in order for downstream users to see what error has occurred.
Packit failed on creating pull-requests in dist-git (https://src.fedoraproject.org/rpms/rust-netlink-packet-utils.git):
dist-git branch | error |
---|---|
f36 |
See https://dashboard.packit.dev/results/propose-downstream/1872 |
f37 |
See https://dashboard.packit.dev/results/propose-downstream/1870 |
rawhide |
See https://dashboard.packit.dev/results/propose-downstream/1871 |
Get in touch with us if you need some help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.