ndt-project / ndt

Network Diagnostic Tool
Other
177 stars 45 forks source link

pcap filter fails for IPs with reverse but without forward lookup #81

Open aaronmbr opened 9 years ago

aaronmbr commented 9 years ago

Original issue 81 created by aaronmbr on 2013-04-19T17:52:38.000Z:

If a client connects from an IP that has a valid DNS reverse lookup but an invalid forward lookup, the pcap filter will fail and the NDT client test will fail.

For example:

# host 209.66.96.66 
66.96.66.209.in-addr.arpa domain name pointer 209.66.96.66.available.above.net.
# host 209.66.96.66.available.above.net
Host 209.66.96.66.available.above.net not found: 3(NXDOMAIN)

src/web100-pcap.c creates a pcap filter using the reverse-resolved DNS name, i.e.:

   "host 209.66.96.66.available.above.net and port 44656"

But fails to resolve the hostname, and the test fails.

I do not believe that client DNS should cause an NDT test failure.

A fix could be to use the IP (rather than DNS name) for 'host' in the pcap filter.

The only risk I can imagine is if there might be problems with IPv4/IPv6.  Does anyone know of a reason that the pcap filter should NOT use the client IP directly?
aaronmbr commented 9 years ago

Comment #1 originally posted by aaronmbr on 2013-04-21T15:56:58.000Z:

I've got a patch that should do filtering on IP instead of hostname. I've attached the patch, and tested it on one of my boxes here. It seemed to work for me, but it'd be good if others tested.

Did you install via RPM or tarball? If the former, I can generate RPMs for you to test.

aaronmbr commented 9 years ago

Comment #2 originally posted by aaronmbr on 2013-04-24T14:15:04.000Z:

It's probably simpler to use getnameinfo here.

Something along the lines of

// In case getnameinfo fails make sure we null-terminate namebuf namebuf[0] = 0; getnameinfo(sock_addr, I2AddrSockLen(sockAddr), namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST)

This avoids separate IPv4 and IPv6 cases.

aaronmbr commented 9 years ago

Comment #3 originally posted by aaronmbr on 2013-04-24T15:04:38.000Z:

Sigh. I managed to forget about getnameinfo function...

aaronmbr commented 9 years ago

Comment #4 originally posted by aaronmbr on 2014-06-25T08:28:47.000Z:

<empty>