Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use latest rust-netlink crate #39

Merged
merged 3 commits into from
Jul 10, 2023
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rich_nlas = []
anyhow = "1.0.31"
byteorder = "1.3.2"
libc = "0.2.66"
netlink-packet-core = { version = "0.6.0" }
netlink-packet-core = { version = "0.7.0" }
netlink-packet-utils = { version = "0.5.2" }
bitflags = "1.2.1"

Expand Down
2 changes: 1 addition & 1 deletion src/rtnl/link/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ mod test {

let packet = LinkMessage { header, nlas };

let mut buf = vec![0; 96];
let mut buf = [0; 96];

assert_eq!(packet.buffer_len(), 96);
packet.emit(&mut buf[..]);
Expand Down
19 changes: 6 additions & 13 deletions src/rtnl/link/nlas/link_infos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1810,8 +1810,7 @@ mod tests {
#[rustfmt::skip]
#[test]
fn parse_veth_info() {
let data = vec![
0x08, 0x00, // length = 8
let data = [0x08, 0x00, // length = 8
0x01, 0x00, // type = 1 = IFLA_INFO_KIND
0x76, 0x65, 0x74, 0x68, // VETH

Expand All @@ -1834,8 +1833,7 @@ mod tests {
// NLA
0x08, 0x00, // length = 8
0x0d, 0x00, // type = IFLA_TXQLEN
0x00, 0x00, 0x00, 0x00,
];
0x00, 0x00, 0x00, 0x00];
let nla = NlaBuffer::new_checked(&data[..]).unwrap();
let parsed = VecInfo::parse(&nla).unwrap().0;
let expected = vec![
Expand All @@ -1860,8 +1858,7 @@ mod tests {
#[rustfmt::skip]
#[test]
fn parse_info_bondport() {
let data = vec![
0x09, 0x00, // length
let data = [0x09, 0x00, // length
0x04, 0x00, // IFLA_INFO_PORT_KIND
0x62, 0x6f, 0x6e, 0x64, 0x00, // V = "bond\0"
0x00, 0x00, 0x00, // padding
Expand All @@ -1875,9 +1872,7 @@ mod tests {

0x08, 0x00, // length
0x09, 0x00, // IFLA_BOND_PORT_PRIO
0x32, 0x00, 0x00, 0x00, // 50

];
0x32, 0x00, 0x00, 0x00];
let nla = NlaBuffer::new_checked(&data[..]).unwrap();
let parsed = VecInfo::parse(&nla).unwrap().0;
let expected = vec![
Expand All @@ -1892,8 +1887,7 @@ mod tests {
#[rustfmt::skip]
#[test]
fn parse_info_bond() {
let data = vec![
0x08, 0x00, // length
let data = [0x08, 0x00, // length
0x01, 0x00, // IFLA_INFO_KIND
0x62, 0x6f, 0x6e, 0x64, // "bond"

Expand Down Expand Up @@ -1956,8 +1950,7 @@ mod tests {
0x05, 0x00, // IFLA_BOND_AD_INFO_PARTNER_MAC
0x00, 0x11, 0x22, // 00:11:22:33:44:55
0x33, 0x44, 0x55,
0x00, 0x00, // padding
];
0x00, 0x00];
let nla = NlaBuffer::new_checked(&data[..]).unwrap();
let parsed = VecInfo::parse(&nla).unwrap().0;
let expected = vec![
Expand Down
2 changes: 1 addition & 1 deletion src/rtnl/link/nlas/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ fn parse_af_inet() {

#[test]
fn emit_af_inet() {
let mut bytes = vec![0xff; 132];
let mut bytes = [0xff; 132];

// Note: the value is a Vec of nlas, so the padding is automatically added
// for each nla.
Expand Down
2 changes: 1 addition & 1 deletion src/rtnl/neighbour/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ mod test {

let nlas = vec![];
let packet = NeighbourMessage { header, nlas };
let mut buf = vec![0; 12];
let mut buf = [0; 12];

assert_eq!(packet.buffer_len(), 12);
packet.emit(&mut buf[..]);
Expand Down
1 change: 0 additions & 1 deletion src/rtnl/route/nlas/next_hops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use netlink_packet_utils::{
bitflags! {
#[non_exhaustive]
pub struct NextHopFlags: u8 {
const RTNH_F_EMPTY = 0;
const RTNH_F_DEAD = constants::RTNH_F_DEAD;
const RTNH_F_PERVASIVE = constants::RTNH_F_PERVASIVE;
const RTNH_F_ONLINK = constants::RTNH_F_ONLINK;
Expand Down