dankamongmen / libnetstack

Small library around rtnetlink to track networking stack elements
https://nick-black.com/dankwiki/index.php/Libnetstack
Apache License 2.0
10 stars 0 forks source link

NoTrack.IfaceFailsLookup test is failing #46

Closed dankamongmen closed 2 years ago

dankamongmen commented 2 years ago

We get an error when running the NoTrack suite (interestingly, when we run only NoTrack.IfaceFailsLookup, it passes). IfaceFailsLookup fails after NoTrack.NoWorkIsInvalid succeeds. I've chased it down to no RTM_NEWLINK messages arriving.

dankamongmen commented 2 years ago

the failure actually manifests as

/home/dank/src/dankamongmen/libnetstack/tests/notrack.cpp:77: Failure
Expected: ("") != (cc.name), actual: "" vs ""

but this is due, i'm pretty sure, to the lack of RTM_NEWLINK messages.

dankamongmen commented 2 years ago

i bet we're not sending the request correctly in netstack_tx_thread()...let's strace

dankamongmen commented 2 years ago

indeed, it looks like we're leaving that out of the sendmsg()... oh yep:

  if(ns->opts.iface_cb || !ns->opts.iface_notrack){                                                                                 
    if(nl_socket_add_memberships(ns->nl, RTNLGRP_LINK, NFNLGRP_NONE)){                                                              
      return -1;                                                                                                                    
    }                      
dankamongmen commented 2 years ago

hrmm, but even with iface_notrack commented out, the problem persists? and why doesn't it happen when i run the test by itself?

dankamongmen commented 2 years ago

here's what we send when run by ourselves (without iface_notrack):

[pid 104795] sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=20, nlmsg_type=RTM_GETLINK, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_DUMP, nlmsg_seq=1649603781, nlmsg_pid=1195481433}, {ifi_family=AF_UNSPEC, ...}], iov_len=20}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 20
[pid 104795] sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=20, nlmsg_type=RTM_GETADDR, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_DUMP, nlmsg_seq=1649603782, nlmsg_pid=1195481433}, {ifa_family=AF_UNSPEC, ...}], iov_len=20}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 20
[pid 104795] sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=20, nlmsg_type=RTM_GETNEIGH, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_DUMP, nlmsg_seq=1649603783, nlmsg_pid=1195481433}, {ndm_family=AF_UNSPEC, ...}], iov_len=20}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 20
[pid 104795] sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=20, nlmsg_type=RTM_GETROUTE, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_DUMP, nlmsg_seq=1649603784, nlmsg_pid=1195481433}, {rtm_family=AF_UNSPEC, ...}], iov_len=20}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 20

and we appear to send the same with iface_notrack. i'm wondering if maybe this is something in libnl?

dankamongmen commented 2 years ago

yeah because we only send the ROUTE request, and that initial test uses *_notrack for everything but ROUTE. is libnl preserving state on us?

dankamongmen commented 2 years ago

nope, we're peresisting state through static dumpmsgs. pulling the static fixes things. yay!