Skip to content

Commit

Permalink
add test for link with IFLA_VRF_PORT_TABLE attribute
Browse files Browse the repository at this point in the history
Note that I had to derive `Default` on a couple structs to make the
test manageable.

Also, I noticed that the packet we emit does not 100% matches the
packet emitted by the kernel.
  • Loading branch information
little-dude authored and cathay4t committed Apr 24, 2024
1 parent abfadc1 commit baed9af
Show file tree
Hide file tree
Showing 10 changed files with 325 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/link/af_spec/inet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ buffer!(InetDevConfBuffer(DEV_CONF_LEN) {
arp_evict_nocarrier: (i32, 128..132),
});

#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[derive(Clone, Copy, Eq, PartialEq, Debug, Default)]
#[non_exhaustive]
pub struct InetDevConf {
pub forwarding: i32,
Expand Down
2 changes: 1 addition & 1 deletion src/link/af_spec/inet6_devconf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl Emitable for Inet6DevConf {
}
}

#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[derive(Clone, Copy, Eq, PartialEq, Debug, Default)]
#[non_exhaustive]
pub struct Inet6DevConf {
pub forwarding: i32,
Expand Down
2 changes: 1 addition & 1 deletion src/link/af_spec/inet6_icmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use netlink_packet_utils::{

pub(crate) const ICMP6_STATS_LEN: usize = 48;

#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[derive(Clone, Copy, Eq, PartialEq, Debug, Default)]
#[non_exhaustive]
pub struct Icmp6Stats {
pub num: i64,
Expand Down
2 changes: 1 addition & 1 deletion src/link/af_spec/inet6_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ buffer!(Inet6StatsBuffer(INET6_STATS_LEN) {
in_ce_pkts: (i64, 280..288),
});

#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[derive(Clone, Copy, Eq, PartialEq, Debug, Default)]
#[non_exhaustive]
pub struct Inet6Stats {
pub num: i64,
Expand Down
2 changes: 1 addition & 1 deletion src/link/link_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub use self::gre_tap6::InfoGreTap6;
pub use self::gtp::InfoGtp;
pub use self::hsr::{HsrProtocol, InfoHsr};
pub use self::info_data::InfoData;
pub use self::info_port::{InfoPortData, InfoPortKind};
pub use self::info_port::{InfoPortData, InfoPortKind, InfoVrfPort};
pub use self::infos::{InfoKind, LinkInfo};
pub use self::ipoib::InfoIpoib;
pub use self::ipvlan::{InfoIpVlan, InfoIpVtap, IpVlanMode, IpVtapMode};
Expand Down
2 changes: 1 addition & 1 deletion src/link/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buffer!(MapBuffer(LINK_MAP_LEN) {
port: (u8, 27),
});

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
#[non_exhaustive]
pub struct Map {
pub memory_start: u64,
Expand Down
6 changes: 3 additions & 3 deletions src/link/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ pub use self::link_info::{
InfoGreTap, InfoGreTap6, InfoGreTun, InfoGreTun6, InfoGtp, InfoHsr,
InfoIpVlan, InfoIpVtap, InfoIpoib, InfoKind, InfoMacSec, InfoMacVlan,
InfoMacVtap, InfoPortData, InfoPortKind, InfoSitTun, InfoTun, InfoVeth,
InfoVlan, InfoVrf, InfoVti, InfoVxlan, InfoXfrm, IpVlanMode, IpVtapMode,
LinkInfo, LinkXstats, MacSecCipherId, MacSecOffload, MacSecValidate,
MacVlanMode, MacVtapMode, MiiStatus, VlanQosMapping,
InfoVlan, InfoVrf, InfoVrfPort, InfoVti, InfoVxlan, InfoXfrm, IpVlanMode,
IpVtapMode, LinkInfo, LinkXstats, MacSecCipherId, MacSecOffload,
MacSecValidate, MacVlanMode, MacVtapMode, MiiStatus, VlanQosMapping,
};
pub use self::link_layer_type::LinkLayerType;
pub use self::link_state::State;
Expand Down
2 changes: 1 addition & 1 deletion src/link/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use netlink_packet_utils::{

pub(crate) const LINK_STATS_LEN: usize = 96;

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
#[non_exhaustive]
pub struct Stats {
/// total packets received
Expand Down
2 changes: 1 addition & 1 deletion src/link/stats64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ buffer!(Stats64Buffer(LINK_STATS64_LEN) {
rx_otherhost_dropped: (u64, 192..200),
});

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
#[non_exhaustive]
pub struct Stats64 {
/// total packets received
Expand Down
316 changes: 314 additions & 2 deletions src/link/tests/vrf.rs

Large diffs are not rendered by default.

0 comments on commit baed9af

Please sign in to comment.