diff --git a/Cargo.toml b/Cargo.toml index a346ddb5..a25aa39e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,5 @@ netlink-packet-utils = { version = "0.5.2" } name = "dump_packet_links" [dev-dependencies] -hex = "0.4.3" netlink-sys = { version = "0.8.5" } pretty_assertions = "0.7.2" diff --git a/src/tc/actions/action.rs b/src/tc/actions/action.rs index 81203188..d56ba9a7 100644 --- a/src/tc/actions/action.rs +++ b/src/tc/actions/action.rs @@ -25,7 +25,10 @@ const TCA_ACT_TAB: u16 = 1; #[derive(Debug, PartialEq, Eq, Clone)] #[non_exhaustive] pub struct TcAction { - /// Table id. Corresponds to the `Kind` of the action. + /// Table id. + /// Corresponds to the [`Kind`] of the action. + /// + /// [`Kind`]: crate::tc::TcActionAttribute::Kind pub tab: u16, /// Attributes of the action. pub attributes: Vec, @@ -203,17 +206,7 @@ impl Nla for TcActionAttribute { fn kind(&self) -> u16 { match self { Self::Kind(_) => TCA_ACT_KIND, - Self::Options(opts) => { - // NOTE: the kernel simply doesn't consistently use the nested - // flag based on captured messages. - // This is heuristically trying to match the kernel's behavior - // but may not be correct. - if opts.len() == 1 { - TCA_ACT_OPTIONS | NLA_F_NESTED - } else { - TCA_ACT_OPTIONS - } - } + Self::Options(_) => TCA_ACT_OPTIONS | NLA_F_NESTED, Self::Index(_) => TCA_ACT_INDEX, Self::Stats(_) => TCA_ACT_STATS, Self::Cookie(_) => TCA_ACT_COOKIE, @@ -274,8 +267,8 @@ where } } -/// `TcActionOption` is a netlink message attribute that describes an option of -/// a [tc-actions] action. +/// [`TcActionOption`] is a netlink message attribute that describes an option +/// of a [tc-actions] action. /// /// This enum is non-exhaustive as new action types may be added to the kernel /// at any time. diff --git a/src/tc/actions/message.rs b/src/tc/actions/message.rs index 5f3185d9..9038ed1f 100644 --- a/src/tc/actions/message.rs +++ b/src/tc/actions/message.rs @@ -28,27 +28,11 @@ bitflags! { #[derive(Debug, PartialEq, Eq, Clone, Copy, Default, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct TcActionMessageFlags: u32 { - /// From `iproute2`'s [`rtnetlink.h`] - /// - /// If set, this flag enables more than TCA_ACT_MAX_PRIO actions in a single + /// If set, this flag enables more than `TCA_ACT_MAX_PRIO` actions in a single /// actions listing operation. - /// - /// > TCA_ACT_FLAG_LARGE_DUMP_ON user->kernel to request for larger than - /// TCA_ACT_MAX_PRIO actions in a dump. - /// All dump responses will contain the number of actions being dumped - /// stored in for user app's consumption in TCA_ROOT_COUNT - /// - /// [`rtnetlink.h`]: https://github.com/iproute2/iproute2/blob/89210b9ec1c445ae963d181b5816d12a0cdafbb6/include/uapi/linux/rtnetlink.h#L803-L806 const LargeDump = TCA_ACT_FLAG_LARGE_DUMP_ON; /// If set, this flag restricts an action dump to only include essential /// details. - /// - /// From `iproute2`'s [`rtnetlink.h`]: - /// - /// > TCA_ACT_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump - /// that only includes essential action info (kind, index, etc.) - /// - /// [`rtnetlink.h`]: https://github.com/iproute2/iproute2/blob/89210b9ec1c445ae963d181b5816d12a0cdafbb6/include/uapi/linux/rtnetlink.h#L808-L809 const TerseDump = TCA_ACT_FLAG_TERSE_DUMP; const _ = !0; } @@ -147,7 +131,7 @@ const TCA_ROOT_TIME_DELTA: u16 = 4; const TCA_ROOT_EXT_WARN_MSG: u16 = 5; /// This enum is used to represent the different types of attributes that can be -/// part of a `TcActionMessage`. +/// part of a [`TcActionMessage`]. /// /// This enum is non-exhaustive, additional variants may be added in the future. #[derive(Debug, PartialEq, Eq, Clone)] diff --git a/src/tc/actions/tests/message.rs b/src/tc/actions/tests/message.rs index 47031710..d12efd14 100644 --- a/src/tc/actions/tests/message.rs +++ b/src/tc/actions/tests/message.rs @@ -39,21 +39,75 @@ mod mirror { /// Captured `TcActionMessage` examples used for testing. mod message { - /// Request + /// Capture of request message for + /// /// ```bash /// tc actions add action mirred egress redirect dev lo index 1 /// ``` - pub(super) const CREATE1: &str = "0000000038000100340001000b0001006d69727265640000240002802000020001000000000000000400000000000000000000000100000001000000"; - /// Request + pub(super) const CREATE1: &[u8] = &[ + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x34, 0x00, 0x01, + 0x00, 0x0b, 0x00, 0x01, 0x00, 0x6d, 0x69, 0x72, 0x72, 0x65, 0x64, + 0x00, 0x00, 0x24, 0x00, 0x02, 0x80, 0x20, 0x00, 0x02, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, + ]; + /// Capture of request message for + /// /// ```bash /// tc actions add action mirred ingress mirror dev lo index 2 /// ``` - pub(super) const CREATE2: &str = "0000000038000100340001000b0001006d69727265640000240002802000020002000000000000000300000000000000000000000400000001000000"; - /// Response + pub(super) const CREATE2: &[u8] = &[ + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x34, 0x00, 0x01, + 0x00, 0x0b, 0x00, 0x01, 0x00, 0x6d, 0x69, 0x72, 0x72, 0x65, 0x64, + 0x00, 0x00, 0x24, 0x00, 0x02, 0x80, 0x20, 0x00, 0x02, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, + ]; + /// Capture of request message for + /// /// ```bash /// tc actions list action mirred /// ``` - pub(super) const LIST: &str = "00000000080003000200000064010100b00000000b0001006d6972726564000044000400140001000000000000000000000000000000000014000700000000000000000000000000000000001800030000000000000000000000000000000000000000000c000900000000000300000008000a0000000000480002002000020001000000000000000400000001000000000000000100000001000000240001000000000000000000000000000000000000000000000000000000000000000000b00001000b0001006d6972726564000044000400140001000000000000000000000000000000000014000700000000000000000000000000000000001800030000000000000000000000000000000000000000000c000900000000000300000008000a0000000000480002002000020002000000000000000300000001000000000000000400000001000000240001000000000000000000000000000000000000000000000000000000000000000000"; + /// + /// after the messages in [`CREATE1`] and [`CREATE2`] have been added. + pub(super) const LIST: &[u8] = &[ + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x64, 0x01, 0x01, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x0b, 0x00, + 0x01, 0x00, 0x6d, 0x69, 0x72, 0x72, 0x65, 0x64, 0x00, 0x00, 0x44, + 0x00, 0x04, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x14, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0c, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, + 0x00, 0x02, 0x00, 0x20, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x24, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x01, 0x00, 0x0b, 0x00, + 0x01, 0x00, 0x6d, 0x69, 0x72, 0x72, 0x65, 0x64, 0x00, 0x00, 0x44, + 0x00, 0x04, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x14, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0c, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, + 0x00, 0x02, 0x00, 0x20, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x24, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + ]; } #[test] @@ -81,9 +135,8 @@ mod mirror { }])], }; - let buf = hex::decode(message::CREATE1).unwrap(); let parsed = TcActionMessage::parse( - &TcActionMessageBuffer::new_checked(&buf).unwrap(), + &TcActionMessageBuffer::new_checked(&message::CREATE1).unwrap(), ) .unwrap(); assert_eq!(parsed, expected); @@ -114,7 +167,7 @@ mod mirror { }])], }; - let buf = hex::decode(message::CREATE2).unwrap(); + let buf = message::CREATE2; let parsed = TcActionMessage::parse( &TcActionMessageBuffer::new_checked(&buf).unwrap(), ) @@ -123,6 +176,7 @@ mod mirror { } #[test] + #[allow(clippy::too_many_lines)] fn parse_message3_list() { let expected = TcActionMessage { header: TcActionMessageHeader { @@ -226,9 +280,8 @@ mod mirror { ]), ], }; - let buf = hex::decode(message::LIST).unwrap(); let parsed = TcActionMessage::parse( - &TcActionMessageBuffer::new_checked(&buf).unwrap(), + &TcActionMessageBuffer::new_checked(&message::LIST).unwrap(), ) .unwrap(); assert_eq!(parsed, expected); diff --git a/src/tc/actions/tests/nat.rs b/src/tc/actions/tests/nat.rs index e1eec778..06d2b804 100644 --- a/src/tc/actions/tests/nat.rs +++ b/src/tc/actions/tests/nat.rs @@ -23,7 +23,14 @@ use crate::AddressFamily; /// ```bash /// tc actions add action nat ingress 1.2.3.4/32 5.6.7.0 index 1 /// ``` -const TC_ACTION_NAT_EXAMPLE1: &str = "000000003c00010038000100080001006e6174002c0002802800010001000000000000000000000000000000000000000102030405060700ffffffff00000000"; +const TC_ACTION_NAT_EXAMPLE1: &[u8] = &[ + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x6e, 0x61, 0x74, 0x00, 0x2c, 0x00, 0x02, 0x80, + 0x28, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, +]; fn tc_action_message_nat_example1() -> TcActionMessage { TcActionMessage { @@ -34,7 +41,7 @@ fn tc_action_message_nat_example1() -> TcActionMessage { tab: 1, attributes: vec![ Kind("nat".into()), - Options(vec![Nat(TcActionNatOption::Parms(TcNat { + Options(vec![Nat(Parms(TcNat { generic: TcActionGeneric { index: 1, capab: 0, @@ -54,7 +61,7 @@ fn tc_action_message_nat_example1() -> TcActionMessage { #[test] fn parse_tc_action_nat_example1() { - let buf = hex::decode(TC_ACTION_NAT_EXAMPLE1).unwrap(); + let buf = TC_ACTION_NAT_EXAMPLE1; let parsed = TcActionMessage::parse( &TcActionMessageBuffer::new_checked(&buf).unwrap(), ) @@ -67,7 +74,7 @@ fn emit_tc_action_nat_example1() { let example = tc_action_message_nat_example1(); let mut buf = vec![0; example.buffer_len()]; example.emit(&mut buf); - assert_eq!(buf, hex::decode(TC_ACTION_NAT_EXAMPLE1).unwrap()); + assert_eq!(buf.as_slice(), TC_ACTION_NAT_EXAMPLE1); } /// Capture of request for @@ -75,7 +82,14 @@ fn emit_tc_action_nat_example1() { /// ```bash /// tc actions add action nat ingress 1.2.3.0/24 5.6.7.9 index 2 /// ``` -const TC_ACTION_NAT_EXAMPLE2: &str = "000000003c00010038000100080001006e6174002c0002802800010002000000000000000000000000000000000000000102030005060709ffffff0000000000"; +const TC_ACTION_NAT_EXAMPLE2: &[u8] = &[ + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x6e, 0x61, 0x74, 0x00, 0x2c, 0x00, 0x02, 0x80, + 0x28, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x02, 0x03, 0x00, 0x05, 0x06, 0x07, 0x09, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, +]; fn tc_action_message_nat_example2() -> TcActionMessage { TcActionMessage { @@ -86,7 +100,7 @@ fn tc_action_message_nat_example2() -> TcActionMessage { tab: 1, attributes: vec![ Kind("nat".into()), - Options(vec![Nat(TcActionNatOption::Parms(TcNat { + Options(vec![Nat(Parms(TcNat { generic: TcActionGeneric { index: 2, capab: 0, @@ -106,7 +120,7 @@ fn tc_action_message_nat_example2() -> TcActionMessage { #[test] fn parse_tc_action_nat_example2() { - let buf = hex::decode(TC_ACTION_NAT_EXAMPLE2).unwrap(); + let buf = TC_ACTION_NAT_EXAMPLE2; let parsed = TcActionMessage::parse( &TcActionMessageBuffer::new_checked(&buf).unwrap(), ) @@ -119,7 +133,7 @@ fn emit_tc_action_nat_example2() { let example = tc_action_message_nat_example2(); let mut buf = vec![0; example.buffer_len()]; example.emit(&mut buf); - assert_eq!(buf, hex::decode(TC_ACTION_NAT_EXAMPLE2).unwrap()); + assert_eq!(buf.as_slice(), TC_ACTION_NAT_EXAMPLE2); } /// Capture of request for @@ -127,7 +141,14 @@ fn emit_tc_action_nat_example2() { /// ```bash /// tc actions add action nat egress 2.3.4.0/24 5.6.7.9 index 3 /// ``` -const TC_ACTION_NAT_EXAMPLE3: &str = "000000003c00010038000100080001006e6174002c0002802800010003000000000000000000000000000000000000000203040005060709ffffff0001000000"; +const TC_ACTION_NAT_EXAMPLE3: &[u8] = &[ + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x6e, 0x61, 0x74, 0x00, 0x2c, 0x00, 0x02, 0x80, + 0x28, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x03, 0x04, 0x00, 0x05, 0x06, 0x07, 0x09, 0xff, 0xff, 0xff, 0x00, + 0x01, 0x00, 0x00, 0x00, +]; fn tc_action_message_nat_example3() -> TcActionMessage { TcActionMessage { @@ -138,7 +159,7 @@ fn tc_action_message_nat_example3() -> TcActionMessage { tab: 1, attributes: vec![ Kind("nat".into()), - Options(vec![Nat(TcActionNatOption::Parms(TcNat { + Options(vec![Nat(Parms(TcNat { generic: TcActionGeneric { index: 3, capab: 0, @@ -158,7 +179,7 @@ fn tc_action_message_nat_example3() -> TcActionMessage { #[test] fn parse_tc_action_nat_example3() { - let buf = hex::decode(TC_ACTION_NAT_EXAMPLE3).unwrap(); + let buf = TC_ACTION_NAT_EXAMPLE3; let parsed = TcActionMessage::parse( &TcActionMessageBuffer::new_checked(&buf).unwrap(), ) @@ -171,11 +192,11 @@ fn emit_tc_action_nat_example3() { let example = tc_action_message_nat_example3(); let mut buf = vec![0x00; example.buffer_len()]; example.emit(&mut buf); - assert_eq!(buf, hex::decode(TC_ACTION_NAT_EXAMPLE3).unwrap()); + assert_eq!(buf.as_slice(), TC_ACTION_NAT_EXAMPLE3); } const TC_ACTION_NAT_OPTION_PARAMS_EXAMPLES: [TcActionNatOption; 2] = [ - TcActionNatOption::Parms(TcNat { + Parms(TcNat { flags: TcNatFlags::empty(), generic: TcActionGeneric { action: TcActionType::Reclassify, @@ -188,7 +209,7 @@ const TC_ACTION_NAT_OPTION_PARAMS_EXAMPLES: [TcActionNatOption; 2] = [ new_addr: Ipv4Addr::new(1, 2, 3, 4), old_addr: Ipv4Addr::new(5, 6, 7, 8), }), - TcActionNatOption::Parms(TcNat { + Parms(TcNat { flags: TcNatFlags::empty(), generic: TcActionGeneric { action: TcActionType::Pipe, @@ -229,16 +250,16 @@ fn tc_action_nat_option_emit_uses_whole_buffer() { fn tc_action_nat_option_tm_examples() -> [TcActionNatOption; 4] { [ - TcActionNatOption::Tm(vec![]), - TcActionNatOption::Tm(vec![1]), - TcActionNatOption::Tm(vec![1, 2, 3, 4]), - TcActionNatOption::Tm(vec![99; 10]), + Tm(vec![]), + Tm(vec![1]), + Tm(vec![1, 2, 3, 4]), + Tm(vec![99; 10]), ] } #[test] fn tc_action_nat_option_parse_back_example_tm() { - for example in tc_action_nat_option_tm_examples().iter() { + for example in &tc_action_nat_option_tm_examples() { let mut buffer = vec![0; example.buffer_len()]; example.emit(&mut buffer); let parsed = TcActionNatOption::parse( @@ -251,7 +272,7 @@ fn tc_action_nat_option_parse_back_example_tm() { #[test] fn tc_action_nat_option_emit_tm_uses_whole_buffer() { - for example in tc_action_nat_option_tm_examples().iter() { + for example in &tc_action_nat_option_tm_examples() { let mut buffer1 = vec![0x00; example.buffer_len()]; let mut buffer2 = vec![0xff; example.buffer_len()]; example.emit(&mut buffer1); @@ -278,8 +299,23 @@ fn tc_action_nat_option_emit_tm_uses_whole_buffer() { /// * rtnetlink header removed (16 bytes). #[test] fn test_get_filter_nat() { - const RAW: &str = "00000000ac000100a8000100080001006e617400440004001400010000000000000000000000000000000000140007000000000000000000000000000000000018000300000000000000000000000000000000000000000008000a000000000050000200280001000100000000000000000000000100000000000000c0000201cb007101ffffffff00000000240002000000000000000000000000000000000000000000000000000000000000000000"; - let raw = hex::decode(RAW).unwrap(); + const RAW: &[u8] = &[ + 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x01, 0x00, 0xa8, 0x00, 0x01, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x6e, 0x61, 0x74, 0x00, 0x44, 0x00, 0x04, 0x00, + 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x02, 0x80, 0x28, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x02, 0x01, 0xcb, 0x00, 0x71, 0x01, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; let expected = TcActionMessage { header: TcActionMessageHeader { @@ -332,12 +368,12 @@ fn test_get_filter_nat() { assert_eq!( expected, - TcActionMessage::parse(&TcActionMessageBuffer::new(&raw)).unwrap() + TcActionMessage::parse(&TcActionMessageBuffer::new(&RAW)).unwrap() ); let mut buf = vec![0; expected.buffer_len()]; expected.emit(&mut buf); - assert_eq!(buf, raw); + assert_eq!(buf, RAW); } diff --git a/src/tc/tests/filter_matchall.rs b/src/tc/tests/filter_matchall.rs index 135fadc9..58755d04 100644 --- a/src/tc/tests/filter_matchall.rs +++ b/src/tc/tests/filter_matchall.rs @@ -82,7 +82,7 @@ fn test_get_filter_matchall() { 0x0a, 0x00, // TCA_ACT_IN_HW_COUNT 0x00, 0x00, 0x00, 0x00, // 0 0x48, 0x00, // length 72 - 0x02, 0x00, // TCA_ACT_OPTIONS + 0x02, 0x80, // TCA_ACT_OPTIONS 0x20, 0x00, // length 32 0x02, 0x00, // TCA_MIRRED_PARMS 0x01, 0x00, 0x00, 0x00, // index 1