Bug 237843 - arp: Skips all name lookups if first fail with TRY_AGAIN
Summary: arp: Skips all name lookups if first fail with TRY_AGAIN
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-net (Nobody)
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2019-05-11 21:52 UTC by Pete French
Modified: 2019-05-12 09:23 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pete French 2019-05-11 21:52:55 UTC
This appears to be deliberate, but I am not sure the actual outcome is as intended. My arp table looks like this:

[pete@skerry /usr/src/usr.sbin/arp]$ arp -a
? (82.47.240.1) at 00:01:5c:73:86:47 on bge1 expires in 1199 seconds [ethernet]
? (82.47.240.30) at d0:bf:9c:45:8b:71 on bge1 permanent [ethernet]
? (192.168.3.42) at 60:6d:3c:07:8c:2c on bge0 expires in 1142 seconds [ethernet]
? (192.168.3.201) at d0:bf:9c:45:8b:70 on bge0 permanent [ethernet]
? (192.168.3.200) at d0:bf:9c:45:8b:70 on bge0 permanent [ethernet]

all of the 192.168 addresses will resolve, but because the first one (and possibly the second one) do not, then it need tries to look them up. removing the line which sets 'nflag' to 1 after a TRY_AGAIN results in this.

[pete@skerry ~]$ ./a.out -a 
? (82.47.240.1) at 00:01:5c:73:86:47 on bge1 expires in 1198 seconds [ethernet]
? (82.47.240.30) at d0:bf:9c:45:8b:71 on bge1 permanent [ethernet]
fire-tv.drayhouse.twisted.org.uk (192.168.3.42) at 60:6d:3c:07:8c:2c on bge0 expires in 1126 seconds [ethernet]
skerry-ns.drayhouse.twisted.org.uk (192.168.3.201) at d0:bf:9c:45:8b:70 on bge0 permanent [ethernet]
skerry.drayhouse.twisted.org.uk (192.168.3.200) at d0:bf:9c:45:8b:70 on bge0 permanent [ethernet]
madeira.drayhouse.twisted.org.uk (192.168.3.47) at 08:f4:ab:00:5f:86 on bge0 expires in 1183 seconds [ethernet]

Which is far more useful - I;ve trimmed the output there, there are a lot of machines on the local LAN, and arp always used to be an easy way to see what was connected by name. its behaviour hasn't changed, but the presence of the unresolvable 82. address has stopped it resolving the rest.

I assume the intent was to stop trying slow lookups that always failed, but the actual end result is that it won't look up any names. Not sure how to fix this - would the simple, approach of not giving up name lookups be unacceptable ? Probably a better fix would be to disable lookups which are for addresses not on any local LAN, but that is a lot more complex, and maybe outside the scope of what arp should be doing.

But having a way to get a list of name lookups on the local LAN wold be very useful, which is what I am really after here.
Comment 1 Pete French 2019-05-11 21:54:34 UTC
BTW, I realise I can use -i to just limit it to certain interfaces, which is the workaround I am currently using....
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2019-05-12 02:20:41 UTC
Thank you for the report Pete

"removing the line which sets 'nflag' to 1 after a TRY_AGAIN results in this."

If the above refers to a patch to attempt to fix the issue, could you please include it as an attachment
Comment 3 Pete French 2019-05-12 09:22:21 UTC
Wasn't supposed to be a patch, as its not a real fix - its removing intended functionality to let me debug what was going on, which is not a great way to proceed, but for reference the diff looks like this:

--- arp.c	2019-05-12 10:20:57.920473000 +0100
+++ /usr/src/usr.sbin/arp/arp.c	2018-11-11 17:59:35.794752000 +0000
@@ -605,8 +605,11 @@
 		hp = 0;
 	if (hp)
 		host = hp->h_name;
-	else
+	else {
 		host = "?";
+		if (h_errno == TRY_AGAIN)
+			nflag = 1;
+	}
 	xo_emit("{:hostname/%s} ({:ip-address/%s}) at ", host,
 	    inet_ntoa(addr->sin_addr));
 	if (sdl->sdl_alen) {
Comment 4 Pete French 2019-05-12 09:23:56 UTC
Gah, thats backwards of course! here it is with the arguments the right way round :)

--- /usr/src/usr.sbin/arp/arp.c	2018-11-11 17:59:35.794752000 +0000
+++ arp.c	2019-05-12 10:20:57.920473000 +0100
@@ -605,11 +605,8 @@
 		hp = 0;
 	if (hp)
 		host = hp->h_name;
-	else {
+	else
 		host = "?";
-		if (h_errno == TRY_AGAIN)
-			nflag = 1;
-	}
 	xo_emit("{:hostname/%s} ({:ip-address/%s}) at ", host,
 	    inet_ntoa(addr->sin_addr));
 	if (sdl->sdl_alen) {