From nobody@FreeBSD.org  Wed Jul 21 01:56:01 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B243516A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Jul 2004 01:56:01 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id AA81243D58
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Jul 2004 01:56:01 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i6L1u1ok072055
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Jul 2004 01:56:01 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i6L1u1nt072054;
	Wed, 21 Jul 2004 01:56:01 GMT
	(envelope-from nobody)
Message-Id: <200407210156.i6L1u1nt072054@www.freebsd.org>
Date: Wed, 21 Jul 2004 01:56:01 GMT
From: Christopher Sean Hilton <chris@vindaloo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: amd (automounter) does not properly detect the local network settings
X-Send-Pr-Version: www-2.3

>Number:         69362
>Category:       bin
>Synopsis:       amd(8) does not properly detect the local network settings
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mbr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 21 02:00:38 GMT 2004
>Closed-Date:    Wed Jul 03 01:32:41 UTC 2013
>Last-Modified:  Wed Jul 03 01:32:41 UTC 2013
>Originator:     Christopher Sean Hilton
>Release:        FreeBSD 4.10-Stable
>Organization:
>Environment:
FreeBSD hoth.pvt.vindaloo.com 4.10-STABLE FreeBSD 4.10-STABLE #0: Wed Jun  2 13:45:27 EDT 2004     chris@hoth.pvt.vindaloo.com:/usr/obj/usr/src/sys/HOTH  i386
>Description:
The automounter (amd) does not properly scan all network interfaces on laptop machines. If you have a conditional mount setting that should only work when your laptop is on a your home network and you are using a PCMCIA network card these mounts will fail.
>How-To-Repeat:
The wire-test program in FreeBSD will attempt to tell you what network you are on using the same code that amd used to determine if the mount you are trying is valid:

*** Incorrect operation ***
$ wire-test
No networks.
My IP address is 0xc0a80105.
NFS Version and protocol tests to host "localhost"...
        testing vers=2, proto="udp" -> failed!
        testing vers=3, proto="udp" -> failed!
        testing vers=2, proto="tcp" -> failed!
        testing vers=3, proto="tcp" -> failed!
$ ifconfig ed0
ed0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet6 XXXXXXXXXXXXXXXXXXXXXXXXXX%ed0 prefixlen 64 scopeid 0x9 
        inet 192.168.1.5 netmask 0xfffffe00 broadcast 192.168.1.255
        ether 00:40:f4:24:7b:61
$ 


*** Correct operation ***

$ /usr/obj/usr/src/usr.sbin/amd/wire-test/wire-test 
Network: wire="example-net" (netnumber=192.168.1).
My IP address is 0xc0a80105.
NFS Version and protocol tests to host "localhost"...
        testing vers=2, proto="udp" -> failed!
        testing vers=3, proto="udp" -> failed!
        testing vers=2, proto="tcp" -> failed!
        testing vers=3, proto="tcp" -> failed!
$ ifconfig ed0
ed0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet6 XXXXXXXXXXXXXXXXXXXXXXXXXX%ed0 prefixlen 64 scopeid 0x9 
        inet 192.168.1.5 netmask 0xfffffe00 broadcast 192.168.1.255
        ether 00:40:f4:24:7b:61
$ 


Notice that in the second case wire-test discovered that it was on example-net.
>Fix:
The problem exists in contrib/amd/libamu/wire.c. This code uses the SIOCGIFCONF ioctl to get a list of active network addresses. The SIOCGIFCONF call is limited though and on laptops only report built in (not pcmcia or usb) interfaces. The correct behaviour can be gotten by using the getifaddrs() library call. Code to do this is already in amd but it's turned off in config.h. The following patch turns it on.

# diff -u usr.sbin/amd/include/config.h.orig  usr.sbin/amd/include/config.h
--- usr.sbin/amd/include/config.h.orig  Wed Aug 29 18:32:17 2001
+++ usr.sbin/amd/include/config.h       Tue Jul 20 21:35:26 2004
@@ -824,7 +824,7 @@
 #define HAVE_FIELD_STRUCT_IFREQ_IFR_ADDR 1
 
 /* does struct ifaddrs have field ifa_next? */
-/* #undef HAVE_FIELD_STRUCT_IFADDRS_IFA_NEXT */
+#define HAVE_FIELD_STRUCT_IFADDRS_IFA_NEXT     1
 
 /* does struct sockaddr have field sa_len? */
 #define HAVE_FIELD_STRUCT_SOCKADDR_SA_LEN 1
@@ -1163,7 +1163,7 @@
 #define HAVE_GETHOSTNAME 1
 
 /* Define if you have the getifaddrs function.  */
-/* #undef HAVE_GETIFADDRS */
+#define HAVE_GETIFADDRS                1
 
 /* Define if you have the getmntinfo function.  */
 #define HAVE_GETMNTINFO 1
@@ -1520,7 +1520,7 @@
 /* #undef HAVE_HSFS_HSFS_H */
 
 /* Define if you have the <ifaddrs.h> header file.  */
-/* #undef HAVE_IFADDRS_H */
+#define HAVE_IFADDRS_H                 1
 
 /* Define if you have the <irs.h> header file.  */
 /* #undef HAVE_IRS_H */


Thanks:
-- chris



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mbr 
Responsible-Changed-By: mbr 
Responsible-Changed-When: Wed Jul 21 08:39:52 GMT 2004 
Responsible-Changed-Why:  
I'll fix this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=69362 
State-Changed-From-To: open->feedback 
State-Changed-By: mbr 
State-Changed-When: Sat Jan 2 23:08:49 UTC 2010 
State-Changed-Why:  
Can you confirm that this is fixed with freebsd 5/6/7/8 ? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=69362 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Wed Jul 3 00:50:32 UTC 2013 
State-Changed-Why:  
Feedback timeout (> 3 years). 


Responsible-Changed-From-To: mbr->mbr 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jul 3 00:50:32 UTC 2013 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=69362 
>Unformatted:
