From owner-freebsd-bugs@FreeBSD.ORG Wed Oct 6 13:00:23 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 813F516A4CE for ; Wed, 6 Oct 2004 13:00:23 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C88943D58 for ; Wed, 6 Oct 2004 13:00:23 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i96D0NMT049678 for ; Wed, 6 Oct 2004 13:00:23 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i96D0NOv049675; Wed, 6 Oct 2004 13:00:23 GMT (envelope-from gnats) Resent-Date: Wed, 6 Oct 2004 13:00:23 GMT Resent-Message-Id: <200410061300.i96D0NOv049675@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Larry Chang Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 54E9E16A4CE for ; Wed, 6 Oct 2004 12:51:37 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FBBB43D2D for ; Wed, 6 Oct 2004 12:51:37 +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 i96CpawI099700 for ; Wed, 6 Oct 2004 12:51:36 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.11/8.12.11/Submit) id i96CpahE099699; Wed, 6 Oct 2004 12:51:36 GMT (envelope-from nobody) Message-Id: <200410061251.i96CpahE099699@www.freebsd.org> Date: Wed, 6 Oct 2004 12:51:36 GMT From: Larry Chang To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: bin/72381: ifconfig lladdr does not set interface MAC address X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2004 13:00:23 -0000 >Number: 72381 >Category: bin >Synopsis: ifconfig lladdr does not set interface MAC address >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Oct 06 13:00:23 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Larry Chang >Release: FreeBSD 4.9 RELEASE >Organization: UTStarcom >Environment: FreeBSD mobomom.nj.us.utstar.com 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Mon Dec 8 19:07:51 EST 2003 root@x7.nj.us.utstar.com:/usr/src/sys/compile/GENERIC_ROCKETPORT i386 >Description: The ifconfig does not set MAC address (lladdr) as specified. The implementation changed between 4.1.1 and 4.9. For R4.9, ifconfig(8) states addr_family 'link' is synonyms for 'ether' and 'lladdr'. It also states the link-level address can be set. For R4.1.1, the lladdr is handled as a command parameter instead as addr_family. >How-To-Repeat: On R4.9 system, change MAC address using commands of the form "ifconfig em0 lladdr 0:1:2:3:4:5" and read it back w/ "ifconfig em0". No changes in MAC address value. Same sequences on R4.1.1 should result in new MAC address for the interface. >Fix: FILE: /usr/src/sbin/ifconfig/ifconfig.c Remove the entry from struct afswtch afs[] { "lladdr", AF_LINK, link_status, link_getaddr, NULL, 0, SIOCSIFLLADDR, NULL, C(ridreq) }, Add new entry to struct cmd cmds[] { "lladdr", NEXTARG, setiflladdr }, Also, add the following lines as in R4.1.1 ifconfig.c c_func setiflladdr; /** after the c_func setifmtu **/ void setiflladdr(val, dummy, s, afp) const char *val; int dummy __unused; int s; const struct afswtch *afp; { struct ether_addr *ea; printf("lhc: entered setiflladdr()\n"); ea = ether_aton(val); if (ea == NULL) { warn("malformed link-level address"); return; } strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_addr.sa_len = ETHER_ADDR_LEN; ifr.ifr_addr.sa_family = AF_LINK; bcopy(ea, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) warn("ioctl (set lladdr)"); return; } Another way to fix the problem is increment both newaddr and setaddr in link_getaddr(). This should invoke ioctl() after parsing lladdr. I tried it, the command prints a "Network is unreachable" message. There was an automatic ARP and ping does work. >Release-Note: >Audit-Trail: >Unformatted: