bin/158500: Add -p to arp(8) to hide permanent entries

Jille Timmermans jille at quis.cx
Wed Jun 29 18:30:28 UTC 2011


>Number:         158500
>Category:       bin
>Synopsis:       Add -p to arp(8) to hide permanent entries
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 29 18:30:26 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Jille Timmermans
>Release:        FreeBSD 8.0-STABLE i386
>Organization:
>Environment:
System: FreeBSD 8.0-STABLE FreeBSD 8.0-STABLE #0 r204041


	
>Description:
	I have 36 aliases on my network interfaces which result in 36 permanent arp entries. When I want to see hosts on my network I don't care about the permanent entries, so I'd like an option to hide them.
>How-To-Repeat:
	arp -pa
>Fix:

--- arp.diff begins here ---
Index: arp.c
===================================================================
--- arp.c	(revision 204041)
+++ arp.c	(working copy)
@@ -99,6 +99,7 @@
 static int valid_type(int type);
 
 static int nflag;	/* no reverse dns lookups */
+static int pflag = 0;	/* hide permanemt entries */
 static char *rifname;
 
 static int	expire_time, flags, doing_proxy, proxy_only;
@@ -119,7 +120,7 @@
 	int rtn = 0;
 	int aflag = 0;	/* do it for all entries */
 
-	while ((ch = getopt(argc, argv, "andfsSi:")) != -1)
+	while ((ch = getopt(argc, argv, "andfpsSi:")) != -1)
 		switch(ch) {
 		case 'a':
 			aflag = 1;
@@ -130,6 +131,9 @@
 		case 'n':
 			nflag = 1;
 			break;
+		case 'p':
+			pflag = 1;
+			break;
 		case 'S':
 			SETFUNC(F_REPLACE);
 			break;
@@ -161,6 +165,10 @@
 				err(1, "if_nametoindex(%s)", rifname);
 		}
 	}
+	if (pflag) {
+		if (func != F_GET && !(func == F_DELETE && aflag))
+			errx(1, "-p not applicable to this operation");
+	}
 	switch (func) {
 	case F_GET:
 		if (aflag) {
@@ -540,6 +548,10 @@
 		if (rifname && if_indextoname(sdl->sdl_index, ifname) &&
 		    strcmp(ifname, rifname))
 			continue;
+		if (pflag) {
+			if (rtm->rtm_rmx.rmx_expire == 0)
+				continue;
+		}
 		if (addr) {
 			if (addr != sin2->sin_addr.s_addr)
 				continue;
@@ -653,10 +665,10 @@
 usage(void)
 {
 	fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
-		"usage: arp [-n] [-i interface] hostname",
-		"       arp [-n] [-i interface] -a",
+		"usage: arp [-np] [-i interface] hostname",
+		"       arp [-np] [-i interface] -a",
 		"       arp -d hostname [pub]",
-		"       arp -d [-i interface] -a",
+		"       arp -d [-p] [-i interface] -a",
 		"       arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
 		"       arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
 		"       arp -f filename");
Index: arp.8
===================================================================
--- arp.8	(revision 204041)
+++ arp.8	(working copy)
@@ -36,11 +36,11 @@
 .Nd address resolution display and control
 .Sh SYNOPSIS
 .Nm
-.Op Fl n
+.Op Fl np
 .Op Fl i Ar interface
 .Ar hostname
 .Nm
-.Op Fl n
+.Op Fl np
 .Op Fl i Ar interface
 .Fl a
 .Nm
@@ -48,6 +48,7 @@
 .Op Cm pub
 .Nm
 .Fl d
+.Op Fl p
 .Op Fl i Ar interface
 .Fl a
 .Nm
@@ -111,6 +112,8 @@
 Show network addresses as numbers (normally
 .Nm
 attempts to display addresses symbolically).
+.It Fl p
+Hide permanent entries.
 .It Fl s Ar hostname ether_addr
 Create an
 .Tn ARP
--- arp.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list