From owner-freebsd-sparc64@FreeBSD.ORG Sat Jul 31 06:12:27 2004 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 98A1816A4CE for ; Sat, 31 Jul 2004 06:12:27 +0000 (GMT) Received: from ns.kt-is.co.kr (ns.kt-is.co.kr [211.218.149.125]) by mx1.FreeBSD.org (Postfix) with ESMTP id C1E6743D4C for ; Sat, 31 Jul 2004 06:12:26 +0000 (GMT) (envelope-from yongari@kt-is.co.kr) Received: from michelle.kt-is.co.kr (ns2.kt-is.co.kr [220.76.118.193]) (authenticated bits=128) by ns.kt-is.co.kr (8.12.10/8.12.10) with ESMTP id i6V6C1Ah054276 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 31 Jul 2004 15:12:01 +0900 (KST) Received: from michelle.kt-is.co.kr (localhost.kt-is.co.kr [127.0.0.1]) by michelle.kt-is.co.kr (8.12.10/8.12.10) with ESMTP id i6V6BWoI019951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 31 Jul 2004 15:11:32 +0900 (KST) (envelope-from yongari@kt-is.co.kr) Received: (from yongari@localhost) by michelle.kt-is.co.kr (8.12.10/8.12.10/Submit) id i6V6BWDk019950 for sparc64@freebsd.org; Sat, 31 Jul 2004 15:11:32 +0900 (KST) (envelope-from yongari@kt-is.co.kr) Date: Sat, 31 Jul 2004 15:11:32 +0900 From: Pyun YongHyeon To: sparc64@freebsd.org Message-ID: <20040731061132.GC19761@kt-is.co.kr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Filter-Version: 1.11a (ns.kt-is.co.kr) Subject: ifconfig(8) mediaopt bug and temporary fix X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: yongari@kt-is.co.kr List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Jul 2004 06:12:27 -0000 Hi, Normally, users with hme(4) + DP83840 PHY forcly set media type to full-duplex since that combination lacks auto-negotiation. However, this has side-effect of bind(2) problem. Typical phenomenon is binding error(EADDRNOTAVAIL) for locally assgined address.(INADDR_ANY works though). I guess this issue had been there for a long time and triggered by ifconfig mediaopt command in big-endian arch. The root cause of the problem seems to be in ifconfig(8) itself. When ifconfig(8) sets media with user-supplied one, it also sets its internal global variable(ifr_media) in 'struct ifreq ifr' to selected one. Since the member variable ifr_media in 'struct ifreq ifr' is shared with all other attributes, subsequent evaluation of 'ifr.ifr_addr.sa_family' is wrong. Under Ultra2, usually I see "atalk 0.0 range 0-0 phase 2" message when I try to set media with command "ifconfig hme0 media 100baseTX mediaopt full-duplex".(i.e. ifconfig(8) thinks I had set AF_APPLETALK.) I guess this affects little-endian machine too. But due to its endian-nature it's not triggered. Here is temporary fix for that issue. Since ifconfig(8) is too complex and very difficult to verify correct operations, I patched domediaopt() which is *not* correct fix. I'd like to see correct fix from commiters with thorough knowledge of ifconfig(8). --- ifmedia.c.orig Fri Jan 16 00:19:19 2004 +++ ifmedia.c Sat Jul 31 14:50:16 2004 @@ -250,7 +250,7 @@ domediaopt(const char *val, int clear, int s) { struct ifmediareq ifmr; - int *mwords, options; + int *mwords, options, optold; (void) memset(&ifmr, 0, sizeof(ifmr)); (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); @@ -281,6 +281,7 @@ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_media = ifmr.ifm_current; + optold = ifr.ifr_media; if (clear) ifr.ifr_media &= ~options; else @@ -288,6 +289,7 @@ if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0) err(1, "SIOCSIFMEDIA (mediaopt)"); + ifr.ifr_media = optold; /* XXX */ } Best regards, Pyun YongHyeon -- Pyun YongHyeon