From 702a9aa6e7b221ff32231cce9393bc87b2f13239 Mon Sep 17 00:00:00 2001 From: John Baublitz Date: Fri, 3 Nov 2023 13:59:24 -0400 Subject: [PATCH] Regression test for #214 --- src/rtnl.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/rtnl.rs b/src/rtnl.rs index 06402941..ad2c9f13 100644 --- a/src/rtnl.rs +++ b/src/rtnl.rs @@ -424,6 +424,8 @@ where mod test { use super::*; + use std::net::Ipv4Addr; + use crate::{ consts::{nl::NlmF, socket::NlFamily}, nl::NlPayload, @@ -532,4 +534,43 @@ mod test { )); } } + + #[test] + #[cfg(target_env = "gnu")] + fn real_test_rtmsg_search() { + setup(); + + let dstip = Ipv4Addr::new(127, 0, 0, 1); + let raw_dstip = u32::from(dstip).to_be(); + let route_attr = RtattrBuilder::default() + .rta_type(Rta::Dst) + .rta_payload(raw_dstip) + .build() + .unwrap(); + + let mut route_payload = RtBuffer::new(); + route_payload.push(route_attr); + + let (rtnl, _) = NlRouter::connect(NlFamily::Route, None, Groups::empty()).unwrap(); + + let ifroutemsg = RtmsgBuilder::default() + .rtm_family(RtAddrFamily::Inet) + .rtm_dst_len(32) + .rtm_src_len(0) + .rtm_tos(0) + .rtm_table(RtTable::Unspec) + .rtm_protocol(Rtprot::Unspec) + .rtm_scope(RtScope::Universe) + .rtm_type(Rtn::Unspec) + .rtm_flags(RtmF::from(libc::RTM_F_LOOKUP_TABLE)) + .rtattrs(route_payload) + .build() + .unwrap(); + + let recv = rtnl + .send::<_, _, Rtm, Rtmsg>(Rtm::Getroute, NlmF::REQUEST, NlPayload::Payload(ifroutemsg)) + .unwrap(); + + assert!(recv.count() > 0); + } }