Hello Nick,
On Wednesday 09 June 2010 20:17:43 Nick Rogers wrote:
> Is there something that can be done to speedup the call to
> if_indextoname(), or would it be worthwhile for me to submit a patch that
> adds the ability to skip the interface lookup as an arp(8) option?
how about the attached:
# time arp -an > /dev/null
0.171u 0.462s 0:00.63 100.0% 21+1538k 0+0io 0pf+0w
# time arp.patched -an > /dev/null
0.005u 0.000s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
# arp -an | wc -l
1095
I'll commit this soon unless somebody objects.
Thanks for your report.
Max
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index a0e228c..cc4d383 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -555,6 +555,9 @@ search(u_long addr, action_fn *action)
/*
* Display an arp entry
*/
+static char lifname[IF_NAMESIZE];
+static long lifindex = -1;
+
static void
print_entry(struct sockaddr_dl *sdl,
struct sockaddr_inarp *addr, struct rt_msghdr *rtm)
@@ -562,7 +565,6 @@ print_entry(struct sockaddr_dl *sdl,
const char *host;
struct hostent *hp;
struct iso88025_sockaddr_dl_data *trld;
- char ifname[IF_NAMESIZE];
int seg;
if (nflag == 0)
@@ -591,8 +593,12 @@ print_entry(struct sockaddr_dl *sdl,
}
} else
printf("(incomplete)");
- if (if_indextoname(sdl->sdl_index, ifname) != NULL)
- printf(" on %s", ifname);
+ if (sdl->sdl_index != lifindex &&
+ if_indextoname(sdl->sdl_index, lifname) != NULL) {
+ lifindex = sdl->sdl_index;
+ printf(" on %s", lifname);
+ } else if (sdl->sdl_index == lifindex)
+ printf(" on %s", lifname);
if (rtm->rtm_rmx.rmx_expire == 0)
printf(" permanent");
else {
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"