Skip site navigation (1)Skip section navigation (2)
Date:      15 Nov 1998 16:56:52 +0000 (GMT)
From:      sthaug@nethelp.no
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Cc:        sthaug@nethelp.no
Subject:   bin/8698: telnet enhancement: option to prevent IP address to name lookup
Message-ID:  <19981115165652.21227.qmail@verdi.nethelp.no>

next in thread | raw e-mail | index | archive | help

>Number:         8698
>Category:       bin
>Synopsis:       add telnet option to prevent IP address to name lookup
>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:   Sun Nov 15 09:00:00 PST 1998
>Last-Modified:
>Originator:     Steinar Haug
>Organization:
Nethelp Consulting
>Release:        FreeBSD 3.0-CURRENT i386
>Environment:

	FreeBSD 3.0-CURRENT i386 (from around 24. october 1998)

>Description:

	If a telnet destination host is given by IP address, telnet will
	attempt a gethostbyaddr() to lookup the corresponding host name.
	If the relevant name servers take a long time to answer (e.g. if
	they are lame), the telnet connection attempt will take a long
	time due to the name lookup.

	This patch adds a -N option to prevent IP address to name lookup
	when the destination host is given by IP address.

	The option really should have been -n (for similarity with route,
	arp, netstat etc), but the -n option is already taken. So use -N.

>How-To-Repeat:

	telnet (using IP address) to a site where the relevant name servers
	aren't fully functional. Observe how long the connection attempt
	takes.

>Fix:
	
	Below is a patch relative to telnet in FreeBSD 3.0-CURRENT.

	Steinar Haug, Nethelp consulting, sthaug@nethelp.no

*** commands.c.orig	Fri Jun 12 14:54:53 1998
--- commands.c	Sun Nov 15 16:58:10 1998
***************
*** 2186,2192 ****
  	if (temp != INADDR_NONE) {
  	    sin.sin_addr.s_addr = temp;
  	    sin.sin_family = AF_INET;
! 	    host = gethostbyaddr((char *)&temp, sizeof(temp), AF_INET);
  	    if (host)
  	        (void) strncpy(_hostname, host->h_name, sizeof(_hostname));
  	    else
--- 2186,2193 ----
  	if (temp != INADDR_NONE) {
  	    sin.sin_addr.s_addr = temp;
  	    sin.sin_family = AF_INET;
! 	    if (doaddrlookup)
! 		host = gethostbyaddr((char *)&temp, sizeof(temp), AF_INET);
  	    if (host)
  	        (void) strncpy(_hostname, host->h_name, sizeof(_hostname));
  	    else
*** main.c.orig	Sat Mar 29 05:32:57 1997
--- main.c	Sun Nov 15 17:03:33 1998
***************
*** 135,141 ****
  	rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
  	autologin = -1;
  
! 	while ((ch = getopt(argc, argv, "8EKLS:X:acde:fFk:l:n:rt:x")) != -1) {
  		switch(ch) {
  		case '8':
  			eight = 3;	/* binary output and input */
--- 135,141 ----
  	rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
  	autologin = -1;
  
! 	while ((ch = getopt(argc, argv, "8EKLNS:X:acde:fFk:l:n:rt:x")) != -1) {
  		switch(ch) {
  		case '8':
  			eight = 3;	/* binary output and input */
***************
*** 150,155 ****
--- 150,158 ----
  			break;
  		case 'L':
  			eight |= 2;	/* binary output only */
+ 			break;
+ 		case 'N':
+ 			doaddrlookup = 0;
  			break;
  		case 'S':
  		    {
*** telnet.c.orig	Mon Jul  6 23:01:42 1998
--- telnet.c	Sun Nov 15 17:03:22 1998
***************
*** 106,111 ****
--- 106,112 ----
  	donebinarytoggle,	/* the user has put us in binary */
  	dontlecho,	/* do we suppress local echoing right now? */
  	globalmode,
+ 	doaddrlookup = 1, /* Should we do IP address to name lookup? */
  	clienteof = 0;
  
  char *prompt = 0;
*** externs.h.orig	Tue Jan  7 20:47:56 1997
--- externs.h	Sun Nov 15 16:56:14 1998
***************
*** 145,150 ****
--- 145,151 ----
      termdata,		/* Print out terminal data flow */
  #endif	/* defined(unix) */
      debug,		/* Debug level */
+     doaddrlookup,	/* Should we do IP address to name lookup? */
      clienteof;		/* Client received EOF */
  
  extern cc_t escape;	/* Escape to command mode */
*** telnet.1.orig	Sat Dec 27 19:58:27 1997
--- telnet.1	Sun Nov 15 17:30:04 1998
***************
*** 93,98 ****
--- 93,101 ----
  Specifies an 8-bit data path on output.  This causes the
  .Dv BINARY
  option to be negotiated on output.
+ .It Fl N
+ Prevents IP address to name lookup when destination host is given as an
+ IP address.
  .It Fl S Ar tos
  Sets the IP type-of-service (TOS) option for the telnet
  connection to the value
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981115165652.21227.qmail>