Bug 31632

Summary: ip6fw error under DNS dislabled environment
Product: Base System Reporter: Yuichi SHIMODA <shimoda>
Component: binAssignee: Crist J. Clark <cjc>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Yuichi SHIMODA 2001-10-30 10:10:01 UTC
when my /etc/host.conf contains no "bind" entries,
ip6fw command with ipv6 address argument shows error message.

  ip6fw: error: hostname ``ff02::'' unknown
  usage: ip6fw [options]
    :
    :

How-To-Repeat: edit your /etc/host.conf:
  hosts
  # bind    <-- commented out
  # nis
use ip6fw command:
  ip6fw add allow ipv6-icmp from ff02::/16 to ::
Comment 1 Crist J. Clark 2001-11-15 10:43:06 UTC
On Tue, Oct 30, 2001 at 07:02:54PM +0900, Yuichi SHIMODA wrote:
[snip]

> >Description:
> when my /etc/host.conf contains no "bind" entries,
> ip6fw command with ipv6 address argument shows error message.
> 
>   ip6fw: error: hostname ``ff02::'' unknown
>   usage: ip6fw [options]
>     :
>     :

This bug was fixed in ipfw(8) long ago. There must be a way to keep
these two in better sync (like, should they really be separate code
bases?).

This patch is more in sync with the current ipfw.c way to do this,

Index: ip6fw.c
===================================================================
RCS file: /export/ncvs/src/sbin/ip6fw/ip6fw.c,v
retrieving revision 1.8
diff -u -r1.8 ip6fw.c
--- ip6fw.c	28 Oct 2001 20:19:14 -0000	1.8
+++ ip6fw.c	15 Nov 2001 10:41:00 -0000
@@ -515,15 +515,15 @@
 static int
 lookup_host (host, addr, family)
 	char *host;
-	u_char *addr;
+	struct in6_addr *addr;
 {
-	struct hostent *he = gethostbyname2(host, family);
-
-	if (!he)
-		return(-1);
-
-	memcpy(addr, he->h_addr_list[0], he->h_length);
+	struct hostent *he;
 
+	if (inet_pton(family, host, addr) != 1) {
+		if ((he = gethostbyname2(host, family)) == NULL)
+			return(-1);
+		*addr = *(struct in6_addr *)he->h_addr_list[0];
+	}	
 	return(0);
 }
 

-- 
Crist J. Clark                     |     cjclark@alum.mit.edu
                                   |     cjclark@jhu.edu
http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
Comment 2 Crist J. Clark freebsd_committer freebsd_triage 2002-07-13 23:05:48 UTC
State Changed
From-To: open->analyzed

This is a bug. 


Comment 3 Crist J. Clark freebsd_committer freebsd_triage 2002-07-13 23:05:48 UTC
Responsible Changed
From-To: freebsd-bugs->cjc

'Bout time someone fixed this.
Comment 4 Crist J. Clark freebsd_committer freebsd_triage 2002-08-25 06:44:28 UTC
State Changed
From-To: analyzed->patched

Fixed in -CURRENT. Will MFC in three days.
Comment 5 Crist J. Clark freebsd_committer freebsd_triage 2002-08-28 22:15:51 UTC
State Changed
From-To: patched->closed

MFC'ed.