Subject: misc/873: rarpd error logging enhancement request
To: None <gnats-admin@NetBSD.ORG>
From: None <giles@nemeton.com.au>
List: netbsd-bugs
Date: 03/14/1995 00:20:04
>Number:         873
>Category:       misc
>Synopsis:       rarpd is silent for most configuration errors
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 14 00:20:02 1995
>Originator:     Giles Lean
>Organization:
Giles Lean                                             Nemeton Pty Ltd
<giles@nemeton.com.au>                           phone: +61 3 480 2118        
>Release:        1.0
>Environment:
	
System: NetBSD nemeton.com.au 1.0 NetBSD 1.0 (NEMETON) #16: Sat Feb 11 09:03:41 EST 1995 giles@nemeton.com.au:/usr/src/sys/arch/i386/compile/NEMETON i386


>Description:
	In both 1.0 and -current rarpd(8) does not log several configuration
	errors (for example missing ethernet addresses) even when running in
	debug mode.
>How-To-Repeat:
	Verify by code inspection.
>Fix:
	The following code adds some more debug output and adds a '-s'
	option to have debug output sent via syslog.

	The manual page is updated and clarified.

*** /usr/local/src/NetBSD-current/src/usr.sbin/rarpd/rarpd.c	Thu May 26 20:41:29 1994
--- src/usr.sbin/rarpd/rarpd.c	Mon Mar 13 16:44:37 1995
***************
*** 33,40 ****
  /*
   * rarpd - Reverse ARP Daemon
   *
!  * Usage:	rarpd -a [ -d -f ]
!  *		rarpd [ -d -f ] interface
   */
  
  #include <stdio.h>
--- 33,40 ----
  /*
   * rarpd - Reverse ARP Daemon
   *
!  * Usage:	rarpd -a [ -d -f -s ]
!  *		rarpd [ -d -f -s ] interface
   */
  
  #include <stdio.h>
***************
*** 95,100 ****
--- 95,101 ----
  
  int     aflag = 0;		/* listen on "all" interfaces  */
  int     dflag = 0;		/* print debugging messages */
+ int     sflag = 0;		/* print debugging messages to syslog */
  int     fflag = 0;		/* don't fork */
  
  void
***************
*** 119,125 ****
  	openlog(name, LOG_PID | LOG_CONS, LOG_DAEMON);
  
  	opterr = 0;
! 	while ((op = getopt(argc, argv, "adf")) != EOF) {
  		switch (op) {
  		case 'a':
  			++aflag;
--- 120,126 ----
  	openlog(name, LOG_PID | LOG_CONS, LOG_DAEMON);
  
  	opterr = 0;
! 	while ((op = getopt(argc, argv, "adfs")) != EOF) {
  		switch (op) {
  		case 'a':
  			++aflag;
***************
*** 133,138 ****
--- 134,143 ----
  			++fflag;
  			break;
  
+ 		case 's':
+ 			++sflag;
+ 			break;
+ 
  		default:
  			usage();
  			/* NOTREACHED */
***************
*** 248,255 ****
  void
  usage()
  {
! 	(void) fprintf(stderr, "usage: rarpd -a [ -d -f ]\n");
! 	(void) fprintf(stderr, "       rarpd [ -d -f ] interface\n");
  	exit(1);
  }
  
--- 253,260 ----
  void
  usage()
  {
! 	(void) fprintf(stderr, "usage: rarpd -a [ -d -f -s ]\n");
! 	(void) fprintf(stderr, "       rarpd [ -d -f -s ] interface\n");
  	exit(1);
  }
  
***************
*** 520,528 ****
  
  	ep = (struct ether_header *) pkt;
  
! 	if (ether_ntohost(ename, &ep->ether_shost) != 0 ||
! 	    (hp = gethostbyname(ename)) == 0)
  		return;
  
  	/* Choose correct address from list. */
  	if (hp->h_addrtype != AF_INET) {
--- 525,539 ----
  
  	ep = (struct ether_header *) pkt;
  
! 	if (ether_ntohost(ename, &ep->ether_shost) != 0) {
! 		debug("no IP address for %s", ether_ntoa(&ep->ether_shost));
  		return;
+ 	}
+ 
+ 	if ((hp = gethostbyname(ename)) == 0) {
+ 		debug("gethostbyname(%s) failed", ename);
+ 		return;
+ 	}
  
  	/* Choose correct address from list. */
  	if (hp->h_addrtype != AF_INET) {
***************
*** 540,545 ****
--- 551,558 ----
  	}
  	if (rarp_bootable(htonl(target_ipaddr)))
  		rarp_reply(ii, ep, target_ipaddr);
+ 	else
+ 		debug("%08X not bootable", htonl(target_ipaddr));
  }
  /*
   * Lookup the ethernet address of the interface attached to the BPF
***************
*** 588,593 ****
--- 601,610 ----
  				fprintf(stderr, "%s: %x:%x:%x:%x:%x:%x\n",
  				    ifr->ifr_name, eaddr[0], eaddr[1],
  				    eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
+ 			if (sflag)
+ 				syslog(LOG_WARNING, "%s: %x:%x:%x:%x:%x:%x\n",
+ 				    ifr->ifr_name, eaddr[0], eaddr[1],
+ 				    eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
  			return;
  		}
  	}
***************
*** 794,807 ****
  {
  	va_list ap;
  
! 	if (dflag) {
  #if __STDC__
  		va_start(ap, fmt);
  #else
  		va_start(ap);
  #endif
! 		(void) fprintf(stderr, "rarpd: ");
! 		(void) vfprintf(stderr, fmt, ap);
  		va_end(ap);
  		(void) fprintf(stderr, "\n");
  	}
--- 811,830 ----
  {
  	va_list ap;
  
! 	if (dflag || sflag) {
  #if __STDC__
  		va_start(ap, fmt);
  #else
  		va_start(ap);
  #endif
! 		if (dflag) {
! 			(void) fprintf(stderr, "rarpd: ");
! 			(void) vfprintf(stderr, fmt, ap);
! 		}
! 
! 		if (sflag)
! 			vsyslog(LOG_WARNING, fmt, ap);
! 
  		va_end(ap);
  		(void) fprintf(stderr, "\n");
  	}
*** /usr/local/src/NetBSD-current/src/usr.sbin/rarpd/rarpd.8	Sat Jan 15 21:27:57 1994
--- src/usr.sbin/rarpd/rarpd.8	Tue Mar 14 18:42:00 1995
***************
*** 26,32 ****
  .Nd Reverse ARP Daemon
  .Sh SYNOPSIS
  .Nm rarpd 
! .Op Fl adf
  .Op Ar interface
  .Sh DESCRIPTION
  .Nm Rarpd
--- 26,32 ----
  .Nd Reverse ARP Daemon
  .Sh SYNOPSIS
  .Nm rarpd 
! .Op Fl adfs
  .Op Ar interface
  .Sh DESCRIPTION
  .Nm Rarpd
***************
*** 40,55 ****
  and 
  .Xr hosts 5
  databases.
! If a host does not exist in both databases, the translation cannot
  proceed and a reply will not be sent.
  .Pp
  Additionally, a request is honored only if the server
! (i.e., the host that rarpd is running on)
! can "boot" the target; that is, if the directory 
  .Pa /tftpboot/ Ns Em ipaddr
! exists, where 
! .Rm ipaddr
! is the target IP address.
  .Pp
  In normal operation, 
  .Nm rarpd
--- 40,59 ----
  and 
  .Xr hosts 5
  databases.
! If a host does not exist in both databases the translation cannot
  proceed and a reply will not be sent.
  .Pp
  Additionally, a request is honored only if the server
! (the host that rarpd is running on)
! can `boot' the target.
! .Pp
! To be considered able to boot the target the server must have
! a file or directory
  .Pa /tftpboot/ Ns Em ipaddr
! where 
! .Pa ipaddr
! is the target IP address as an eight digit hexadecimal string.
! For example, the IP address 203.8.3.18 is represented as `CB080312'.
  .Pp
  In normal operation, 
  .Nm rarpd
***************
*** 70,75 ****
--- 74,81 ----
  option.
  .It Fl f
  Run in the foreground.
+ .It Fl s
+ Run in debug mode sending output to syslog.
  .El
  .Sh FILES
  .Bl -tag -width Pa -compact
***************
*** 87,92 ****
--- 93,109 ----
  .%A Mogul, J.C.
  .%A Theimer, M.
  .Re
+ .Sh BUGS
+ Few errors are logged unless the daemon is running in debug mode
+ via the
+ .Fl d
+ or
+ .Fl s
+ options.
+ .Pp
+ The
+ .Pa ipaddr
+ pathnames are required to be in uppercase.
  .Sh AUTHORS
  Craig Leres (leres@ee.lbl.gov) and Steven McCanne (mccanne@ee.lbl.gov).
  Lawrence Berkeley Laboratory, University of California, Berkeley, CA.
>Audit-Trail:
>Unformatted: