jbaublitz/neli

GETROUTE does not receive responses in 0.7rc

Closed this issue · 8 comments

Version of neli
git main branch

Describe the bug
Creating a GETROUTE request via

let dstip = Ipv4Addr::new(192, 0, 2, 0);
let raw_dstip = u32::from(dstip).to_be();
let route_attr = RtattrBuilder::default()
    .rta_type(Rta::Dst)
    .rta_payload(raw_dstip)
    .build()?;

let mut route_payload = RtBuffer::new();
route_payload.push(route_attr);

let (rtnl, _) = NlRouter::connect(NlFamily::Route, None, Groups::empty())?;

let ifroutemsg = RtmsgBuilder::default()
    .rtm_family(family)
    .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(RTM_F_LOOKUP_TABLE))
    .rtattrs(route_payload)
    .build()?;

let recv = rtnl
    .send(Rtm::Getroute, NlmF::REQUEST, NlPayload::Payload(ifroutemsg))?;

for response in recv {
    ...

(edit: dst_len needs to be the size of the family address length)

results in no responses.
Via strace(8) the response seems to arrive in a spawned helper fork:

Main process (pid 132773):

sendto(3, [{nlmsg_len=36, nlmsg_type=RTM_GETROUTE, nlmsg_flags=NLM_F_REQUEST, nlmsg_seq=0, nlmsg_pid=132773}, {rtm_family=AF_INET, rtm_dst_len=0, rtm_src_len=0, rtm_tos=0, rtm_table=RT_TABLE_UNSPEC, rtm_protocol=RTPROT_UNSPEC, rtm_scope=RT_SCOPE_UNIVERSE, rtm_type=RTN_UNSPEC, rtm_flags=RTM_F_LOOKUP_TABLE}, [{nla_len=8, nla_type=RTA_DST}, inet_addr("192.0.2.0")]], 36, 0, NULL, 0) = 36
futex(0x5640cf897b58, FUTEX_WAIT_BITSET_PRIVATE, 4294967295, NULL, FUTEX_BITSET_MATCH_ANY) = 0

Fork (pid 132774):

recvfrom(3, [{nlmsg_len=112, nlmsg_type=RTM_NEWROUTE, nlmsg_flags=0, nlmsg_seq=0, nlmsg_pid=132773}, {rtm_family=AF_INET, rtm_dst_len=32, rtm_src_len=0, rtm_tos=0, rtm_table=RT_TABLE_MAIN, rtm_protocol=RTPROT_UNSPEC, rtm_scope=RT_SCOPE_UNIVERSE, rtm_type=RTN_UNICAST, rtm_flags=RTM_F_CLONED}, [[{nla_len=8, nla_type=RTA_TABLE}, RT_TABLE_MAIN], [{nla_len=8, nla_type=RTA_DST}, inet_addr("192.0.2.0")], [{nla_len=8, nla_type=RTA_OIF}, if_nametoindex("enp5s0")], [{nla_len=8, nla_type=RTA_PREFSRC}, inet_addr("192.168.1.42")], [{nla_len=8, nla_type=RTA_GATEWAY}, inet_addr("192.168.1.200")], [{nla_len=8, nla_type=RTA_UID}, 1000], [{nla_len=36, nla_type=RTA_CACHEINFO}, {rta_clntref=2, rta_lastuse=567495, rta_expires=0, rta_error=0, rta_used=0, rta_id=0, rta_ts=0, rta_tsage=0}]]], 32768, 0, NULL, NULL) = 112
getrandom("\xdf\x1a\x9a\x20\xa1\x25\x4b\xf8\x23\xca\xcf\x26\xcf\x84\x64\xad", 16, GRND_INSECURE) = 16
futex(0x5640cf897b58, FUTEX_WAKE_PRIVATE, 1) = 1
recvfrom(3,  <unfinished ...>)          = ?

Maybe nlmsg_pid must not be set, or the payload attribute causes timing issues?

GETADDR works fine:

Main process (pid 132773):

sendto(4, [{nlmsg_len=24, nlmsg_type=RTM_GETADDR, nlmsg_flags=NLM_F_REQUEST|NLM_F_ROOT, nlmsg_seq=0, nlmsg_pid=-17449847}, {ifa_family=AF_INET, ifa_prefixlen=0, ifa_flags=0, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=0}], 24, 0, NULL, 0) = 24
futex(0x5640cf897b58, FUTEX_WAIT_BITSET_PRIVATE, 4294967295, NULL, FUTEX_BITSET_MATCH_ANY) = 0

Fork (pid 132775):

recvfrom(4, [[{nlmsg_len=76, nlmsg_type=RTM_NEWADDR, nlmsg_flags=NLM_F_MULTI, nlmsg_seq=0, nlmsg_pid=-17449847}, {ifa_family=AF_INET, ifa_prefixlen=8, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_HOST, ifa_index=if_nametoindex("lo")}, [[{nla_len=8, nla_type=IFA_ADDRESS}, inet_addr("127.0.0.1")], [{nla_len=8, nla_type=IFA_LOCAL}, inet_addr("127.0.0.1")], [{nla_len=7, nla_type=IFA_LABEL}, "lo"], [{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT], [{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=1142, tstamp=1142}]]], [{nlmsg_len=88, nlmsg_type=RTM_NEWADDR, nlmsg_flags=NLM_F_MULTI, nlmsg_seq=0, nlmsg_pid=-17449847}, {ifa_family=AF_INET, ifa_prefixlen=24, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=if_nametoindex("enp5s0")}, [[{nla_len=8, nla_type=IFA_ADDRESS}, inet_addr("192.168.1.42")], [{nla_len=8, nla_type=IFA_LOCAL}, inet_addr("192.168.1.42")], [{nla_len=8, nla_type=IFA_BROADCAST}, inet_addr("192.168.1.255")], [{nla_len=11, nla_type=IFA_LABEL}, "enp5s0"], [{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT|IFA_F_NOPREFIXROUTE], [{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=774470, tstamp=774470}]]], [{nlmsg_len=88, nlmsg_type=RTM_NEWADDR, nlmsg_flags=NLM_F_MULTI, nlmsg_seq=0, nlmsg_pid=-17449847}, {ifa_family=AF_INET, ifa_prefixlen=24, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=if_nametoindex("virbr0")}, [[{nla_len=8, nla_type=IFA_ADDRESS}, inet_addr("192.168.122.1")], [{nla_len=8, nla_type=IFA_LOCAL}, inet_addr("192.168.122.1")], [{nla_len=8, nla_type=IFA_BROADCAST}, inet_addr("192.168.122.255")], [{nla_len=11, nla_type=IFA_LABEL}, "virbr0"], [{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT], [{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=1583, tstamp=1583}]]]], 32768, 0, NULL, NULL) = 252
getrandom("\x1f\x9b\xcf\x4a\x23\xee\x90\xf2\xdf\xcc\xd4\x8b\x23\x4f\x11\x2f", 16, GRND_INSECURE) = 16
futex(0x5640cf897b58, FUTEX_WAKE_PRIVATE, 1) = 1

Hi @cgzones, I apologize for the delay. Have you taken a look at the route listing example in the examples directory? I'll gladly investigate this further, but last time I tested that, it had no errors fetching the routes.

Is this still relevant?

Yes, it is.
The netlink response is received (by a forked thread) but not returned in the iterator of the send result.
Maybe src/router/synchronous.rs:spawn_processing_thread() mishandles the channels?

Example trace output (with some adjusted logging):

2023-08-15T15:08:39.947Z INFO  [local_ip_address::linux] Created rt message: Rtmsg { rtm_family: Inet, rtm_dst_len: 32, rtm_src_len: 0, rtm_tos: 0, rtm_table: Unspec, rtm_protocol: Unspec, rtm_scope: Universe, rtm_type: Unspec, rtm_flags: RtmF(4096), rtattrs: RtBuffer([Rtattr { rta_len: 8, rta_type: Dst, rta_payload: Buffer }]) }
2023-08-15T15:08:39.947Z DEBUG [neli::socket::synchronous] Message sent:
Nlmsghdr { nl_len: 36, nl_type: Getroute, nl_flags: NlmF(1), nl_seq: 0, nl_pid: 67661, nl_payload: Payload(Rtmsg { rtm_family: Inet, rtm_dst_len: 32, rtm_src_len: 0, rtm_tos: 0, rtm_table: Unspec, rtm_protocol: Unspec, rtm_scope: Universe, rtm_type: Unspec, rtm_flags: RtmF(4096), rtattrs: RtBuffer([Rtattr { rta_len: 8, rta_type: Dst, rta_payload: Buffer }]) }) }
2023-08-15T15:08:39.947Z INFO  [local_ip_address::linux] Send rt message
2023-08-15T15:08:39.947Z TRACE [neli::utils::synchronous] Semaphore acquired; current count is 1, available is 2
2023-08-15T15:08:39.947Z TRACE [neli::socket::synchronous] Buffer received: [112, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 77, 8, 1, 0, 2, 32, 0, 0, 254, 0, 0, 1, 0, 2, 0, 0, 8, 0, 15, 0, 254, 0, 0, 0, 8, 0, 1, 0, 192, 0, 2, 0, 8, 0, 4, 0, 2, 0, 0, 0, 8, 0, 7, 0, 192, 168, 24, 24, 8, 0, 5, 0, 192, 168, 24, 200, 8, 0, 25, 0, 232, 3, 0, 0, 36, 0, 12, 0, 2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.947Z DEBUG [neli::iter] next() called
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing data type Nlmsghdr
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing field type u32
2023-08-15T15:08:39.947Z TRACE [neli::nl] Buffer to be deserialized: [112, 0, 0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::nl] Field deserialized: 112
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing field type u16
2023-08-15T15:08:39.947Z TRACE [neli::nl] Buffer to be deserialized: [24, 0]
2023-08-15T15:08:39.947Z TRACE [neli::nl] Field deserialized: 24
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing field type neli::consts::nl::NlmF
2023-08-15T15:08:39.947Z TRACE [neli::nl] Buffer to be deserialized: [0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::consts::nl] Deserializing data type NlmF
2023-08-15T15:08:39.947Z TRACE [neli::consts::nl] Deserializing field type u16
2023-08-15T15:08:39.947Z TRACE [neli::consts::nl] Buffer to be deserialized: [0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::consts::nl] Field deserialized: 0
2023-08-15T15:08:39.947Z TRACE [neli::nl] Field deserialized: NlmF(0)
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing field type u32
2023-08-15T15:08:39.947Z TRACE [neli::nl] Buffer to be deserialized: [0, 0, 0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::nl] Field deserialized: 0
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing field type u32
2023-08-15T15:08:39.947Z TRACE [neli::nl] Buffer to be deserialized: [77, 8, 1, 0]
2023-08-15T15:08:39.947Z TRACE [neli::nl] Field deserialized: 67661
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing field type neli::nl::NlPayload<u16, neli::types::Buffer>
2023-08-15T15:08:39.947Z TRACE [neli::nl] Buffer to be deserialized: [2, 32, 0, 0, 254, 0, 0, 1, 0, 2, 0, 0, 8, 0, 15, 0, 254, 0, 0, 0, 8, 0, 1, 0, 192, 0, 2, 0, 8, 0, 4, 0, 2, 0, 0, 0, 8, 0, 7, 0, 192, 168, 24, 24, 8, 0, 5, 0, 192, 168, 24, 200, 8, 0, 25, 0, 232, 3, 0, 0, 36, 0, 12, 0, 2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::nl] Deserializing data type neli::nl::NlPayload<u16, neli::types::Buffer>
2023-08-15T15:08:39.947Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.947Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.947Z TRACE [neli::types] Buffer to be deserialized: [2, 32, 0, 0, 254, 0, 0, 1, 0, 2, 0, 0, 8, 0, 15, 0, 254, 0, 0, 0, 8, 0, 1, 0, 192, 0, 2, 0, 8, 0, 4, 0, 2, 0, 0, 0, 8, 0, 7, 0, 192, 168, 24, 24, 8, 0, 5, 0, 192, 168, 24, 200, 8, 0, 25, 0, 232, 3, 0, 0, 36, 0, 12, 0, 2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::types] Field deserialized: [2, 32, 0, 0, 254, 0, 0, 1, 0, 2, 0, 0, 8, 0, 15, 0, 254, 0, 0, 0, 8, 0, 1, 0, 192, 0, 2, 0, 8, 0, 4, 0, 2, 0, 0, 0, 8, 0, 7, 0, 192, 168, 24, 24, 8, 0, 5, 0, 192, 168, 24, 200, 8, 0, 25, 0, 232, 3, 0, 0, 36, 0, 12, 0, 2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::nl] Field deserialized: Payload(Buffer)
2023-08-15T15:08:39.947Z DEBUG [neli::iter] Message received3: Nlmsghdr { nl_len: 112, nl_type: 24, nl_flags: NlmF(0), nl_seq: 0, nl_pid: 67661, nl_payload: Payload(Buffer) }
2023-08-15T15:08:39.947Z DEBUG [neli::iter] next() finished, got: Some(Ok(Nlmsghdr { nl_len: 112, nl_type: 24, nl_flags: NlmF(0), nl_seq: 0, nl_pid: 67661, nl_payload: Payload(Buffer) }))
2023-08-15T15:08:39.947Z TRACE [neli::router::synchronous] Message received1: Ok(Nlmsghdr { nl_len: 112, nl_type: 24, nl_flags: NlmF(0), nl_seq: 0, nl_pid: 67661, nl_payload: Payload(Buffer) })
2023-08-15T15:08:39.947Z DEBUG [neli::iter] next() called
2023-08-15T15:08:39.947Z DEBUG [neli::iter] next() finished, got: None
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing data type Rtmsg
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::RtAddrFamily
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [2]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: Inet
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type u8
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [32]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: 32
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type u8
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [0]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: 0
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type u8
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [0]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: 0
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::RtTable
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [254]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: Main
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rtprot
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [0]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: Unspec
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::RtScope
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [0]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: Universe
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rtn
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [1]
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Field deserialized: Unicast
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::RtmF
2023-08-15T15:08:39.947Z TRACE [neli::rtnl] Buffer to be deserialized: [0, 2, 0, 0]
2023-08-15T15:08:39.947Z TRACE [neli::consts::rtnl] Deserializing data type RtmF
2023-08-15T15:08:39.948Z TRACE [neli::consts::rtnl] Deserializing field type u32
2023-08-15T15:08:39.948Z TRACE [neli::consts::rtnl] Buffer to be deserialized: [0, 2, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::consts::rtnl] Field deserialized: 512
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: RtmF(512)
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::RtBuffer<neli::consts::rtnl::Rta, neli::types::Buffer>
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [8, 0, 15, 0, 254, 0, 0, 0, 8, 0, 1, 0, 192, 0, 2, 0, 8, 0, 4, 0, 2, 0, 0, 0, 8, 0, 7, 0, 192, 168, 24, 24, 8, 0, 5, 0, 192, 168, 24, 200, 8, 0, 25, 0, 232, 3, 0, 0, 36, 0, 12, 0, 2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type RtBuffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<neli::rtnl::Rtattr<neli::consts::rtnl::Rta, neli::types::Buffer>>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [8, 0, 15, 0, 254, 0, 0, 0, 8, 0, 1, 0, 192, 0, 2, 0, 8, 0, 4, 0, 2, 0, 0, 0, 8, 0, 7, 0, 192, 168, 24, 24, 8, 0, 5, 0, 192, 168, 24, 200, 8, 0, 25, 0, 232, 3, 0, 0, 36, 0, 12, 0, 2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing data type Rtattr
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type u16
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [8, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: 8
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rta
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [15, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Table
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [254, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [254, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [254, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing data type Rtattr
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type u16
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [8, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: 8
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rta
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [1, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Dst
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [192, 0, 2, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [192, 0, 2, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [192, 0, 2, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing data type Rtattr
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type u16
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [8, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: 8
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rta
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [4, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Oif
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::Buffer
2023-08-15T15:08:39.948Z TRACE [neli::utils::synchronous] Semaphore released; current count is 0, available is 3
2023-08-15T15:08:39.948Z TRACE [neli::utils::synchronous] Semaphore acquired; current count is 1, available is 2
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [2, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [2, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [2, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing data type Rtattr
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type u16
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [8, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: 8
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rta
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [7, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Prefsrc
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [192, 168, 24, 24]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [192, 168, 24, 24]
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [192, 168, 24, 24]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing data type Rtattr
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type u16
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [8, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: 8
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rta
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [5, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Gateway
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [192, 168, 24, 200]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [192, 168, 24, 200]
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [192, 168, 24, 200]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing data type Rtattr
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type u16
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [8, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: 8
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rta
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [25, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Uid
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [232, 3, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [232, 3, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [232, 3, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing data type Rtattr
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type u16
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [36, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: 36
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::consts::rtnl::Rta
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [12, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Cacheinfo
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Deserializing field type neli::types::Buffer
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Buffer to be deserialized: [2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing data type Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Deserializing field type alloc::vec::Vec<u8>
2023-08-15T15:08:39.948Z TRACE [neli::types] Buffer to be deserialized: [2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [2, 0, 0, 0, 106, 156, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: Buffer
2023-08-15T15:08:39.948Z TRACE [neli::types] Field deserialized: [Rtattr { rta_len: 8, rta_type: Table, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Dst, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Oif, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Prefsrc, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Gateway, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Uid, rta_payload: Buffer }, Rtattr { rta_len: 36, rta_type: Cacheinfo, rta_payload: Buffer }]
2023-08-15T15:08:39.948Z TRACE [neli::rtnl] Field deserialized: RtBuffer([Rtattr { rta_len: 8, rta_type: Table, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Dst, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Oif, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Prefsrc, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Gateway, rta_payload: Buffer }, Rtattr { rta_len: 8, rta_type: Uid, rta_payload: Buffer }, Rtattr { rta_len: 36, rta_type: Cacheinfo, rta_payload: Buffer }])
2023-08-15T15:08:39.948Z WARN  [local_ip_address::linux] using fallback...

See https://github.com/cgzones/local-ip-address/blob/neli/src/linux.rs for the usage.

As I mentioned, this works in the example in the examples directory of neli. I took a look at what you're doing and I'm pretty confident this is a user error as you're not providing the correct netlink flags to the request as is provided in the example I pointed you to. When I remove NlmF::DUMP from the flags in my example, I also get responses from the netlink socket but route-list doesn't display any routes. Adding in NlmF::DUMP causes the routes to show up in the example program.

As a general rule of thumb, NlmF::ACK is a good flag for requests where you're "doing" something. When listing multiple resources like routes, you generally want NlmF::DUMP. Can you check if adding that to the request resolves your issue?

I'm going to keep looking into why we're getting responses even without that flag as I don't want to rule out that this could be a bug, but try that first and see if it resolves your issue.

My usage is a bit different: I don't want to dump all routes, I want to lookup the route with a specific destination IP address. Thus I use the flag RTM_F_LOOKUP_TABLE and provide a payload.

With NlmF::DUMP instead of NlmF::REQUEST there is also no result:

2023-08-15T17:42:35.143Z INFO  [local_ip_address::linux] Created rt message: Rtmsg { rtm_family: Inet, rtm_dst_len: 32, rtm_src_len: 0, rtm_tos: 0, rtm_table: Unspec, rtm_protocol: Unspec, rtm_scope: Universe, rtm_type: Unspec, rtm_flags: RtmF(4096), rtattrs: RtBuffer([Rtattr { rta_len: 8, rta_type: Dst, rta_payload: Buffer }]) }
2023-08-15T17:42:35.143Z DEBUG [neli::socket::synchronous] Message sent:
Nlmsghdr { nl_len: 36, nl_type: Getroute, nl_flags: NlmF(769), nl_seq: 0, nl_pid: 94408, nl_payload: Payload(Rtmsg { rtm_family: Inet, rtm_dst_len: 32, rtm_src_len: 0, rtm_tos: 0, rtm_table: Unspec, rtm_protocol: Unspec, rtm_scope: Universe, rtm_type: Unspec, rtm_flags: RtmF(4096), rtattrs: RtBuffer([Rtattr { rta_len: 8, rta_type: Dst, rta_payload: Buffer }]) }) }
2023-08-15T17:42:35.143Z INFO  [local_ip_address::linux] Send rt message
2023-08-15T17:42:35.143Z TRACE [neli::utils::synchronous] Semaphore acquired; current count is 1, available is 2
2023-08-15T17:42:35.143Z TRACE [neli::socket::synchronous] Buffer received: [20, 0, 0, 0, 3, 0, 2, 0, 0, 0, 0, 0, 200, 112, 1, 0, 234, 255, 255, 255]
2023-08-15T17:42:35.144Z DEBUG [neli::iter] next() called
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing data type Nlmsghdr
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing field type u32
2023-08-15T17:42:35.144Z TRACE [neli::nl] Buffer to be deserialized: [20, 0, 0, 0]
2023-08-15T17:42:35.144Z TRACE [neli::nl] Field deserialized: 20
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing field type u16
2023-08-15T17:42:35.144Z TRACE [neli::nl] Buffer to be deserialized: [3, 0]
2023-08-15T17:42:35.144Z TRACE [neli::nl] Field deserialized: 3
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing field type neli::consts::nl::NlmF
2023-08-15T17:42:35.144Z TRACE [neli::nl] Buffer to be deserialized: [2, 0]
2023-08-15T17:42:35.144Z TRACE [neli::consts::nl] Deserializing data type NlmF
2023-08-15T17:42:35.144Z TRACE [neli::consts::nl] Deserializing field type u16
2023-08-15T17:42:35.144Z TRACE [neli::consts::nl] Buffer to be deserialized: [2, 0]
2023-08-15T17:42:35.144Z TRACE [neli::consts::nl] Field deserialized: 2
2023-08-15T17:42:35.144Z TRACE [neli::nl] Field deserialized: NlmF(2)
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing field type u32
2023-08-15T17:42:35.144Z TRACE [neli::nl] Buffer to be deserialized: [0, 0, 0, 0]
2023-08-15T17:42:35.144Z TRACE [neli::nl] Field deserialized: 0
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing field type u32
2023-08-15T17:42:35.144Z TRACE [neli::nl] Buffer to be deserialized: [200, 112, 1, 0]
2023-08-15T17:42:35.144Z TRACE [neli::nl] Field deserialized: 94408
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing field type neli::nl::NlPayload<u16, neli::types::Buffer>
2023-08-15T17:42:35.144Z TRACE [neli::nl] Buffer to be deserialized: [234, 255, 255, 255]
2023-08-15T17:42:35.144Z TRACE [neli::nl] Deserializing data type neli::nl::NlPayload<u16, neli::types::Buffer>
2023-08-15T17:42:35.144Z TRACE [neli::nl] Received empty payload
2023-08-15T17:42:35.144Z TRACE [neli::nl] Padding: [234, 255, 255, 255]
2023-08-15T17:42:35.144Z TRACE [neli::nl] Field deserialized: Empty
2023-08-15T17:42:35.144Z DEBUG [neli::iter] Message received3: Nlmsghdr { nl_len: 20, nl_type: 3, nl_flags: NlmF(2), nl_seq: 0, nl_pid: 94408, nl_payload: Empty }
2023-08-15T17:42:35.144Z DEBUG [neli::iter] next() finished, got: Some(Ok(Nlmsghdr { nl_len: 20, nl_type: 3, nl_flags: NlmF(2), nl_seq: 0, nl_pid: 94408, nl_payload: Empty }))
2023-08-15T17:42:35.144Z TRACE [neli::router::synchronous] Message received1: Ok(Nlmsghdr { nl_len: 20, nl_type: 3, nl_flags: NlmF(2), nl_seq: 0, nl_pid: 94408, nl_payload: Empty })
2023-08-15T17:42:35.144Z DEBUG [neli::iter] next() called
2023-08-15T17:42:35.144Z DEBUG [neli::iter] next() finished, got: None
thread 'main' panicked at 'using fallback...', src/linux.rs:157:5

It works with NlmF::REQUEST | NlmF::ACK.
But if I am reading netlink(7) correctly the ACK flag should be optional.

Okay, then this is definitely a bug. Let me look into this when I get a moment. I will try to take some time to do a deeper dive into this this weekend at the latest. Thanks for the report!

@cgzones I think this is a duplicate of #223 actually. Please test #227 as I believe based on my testing of your example code that it should resolve your issue.