From owner-freebsd-bugs@FreeBSD.ORG Fri Aug 29 12:50:22 2003 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 94F0316A4BF for ; Fri, 29 Aug 2003 12:50:22 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0536943FBF for ; Fri, 29 Aug 2003 12:50:22 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h7TJoLUp058314 for ; Fri, 29 Aug 2003 12:50:21 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h7TJoLDO058313; Fri, 29 Aug 2003 12:50:21 -0700 (PDT) Date: Fri, 29 Aug 2003 12:50:21 -0700 (PDT) Message-Id: <200308291950.h7TJoLDO058313@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Jason Young" Subject: Re: bin/41647: ifconfig doesn't accept lladdr along with inet address family X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jason Young List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2003 19:50:22 -0000 The following reply was made to PR bin/41647; it has been noted by GNATS. From: "Jason Young" To: freebsd-gnats-submit@freebsd.org Cc: ru@freebsd.org, jyoung@wantec.com Subject: Re: bin/41647: ifconfig doesn't accept lladdr along with inet address family Date: Fri, 29 Aug 2003 14:49:14 -0500 Revision 1.73 of ifconfig.c implements a fix for bin/31476, permitting link-level addresses to be of arbitrary length. In the process, it converts 'ether' into an address family instead of an option/command. While it's logical to treat 'ether' as a true address family, ifconfig doesn't lend itself to configuring multiple address families simultaneously, which is what you are doing when you are touching 'inet' and 'ether'. Since bin/41467 indicates people were using this functionality, here is a patch against HEAD that turns ether (and link, and lladdr) back into options. It is mostly an updated version of Ruslan's first fix posted to bin/31476. All of these commands work now: ifconfig xl0 inet 10.1.1.1 netmask 255.255.255.0 lladdr 00:11:22:33:44:55 ifconfig xl0 inet 10.1.1.1 netmask 255.255.255.0 link 00:11:22:33:44:55 ifconfig xl0 inet 10.1.1.1 netmask 255.255.255.0 ether 00:11:22:33:44:55 ifconfig xl0 lladdr 00:11:22:33:44:55 ifconfig xl0 link 00:11:22:33:44:55 ifconfig xl0 ether 00:11:22:33:44:55 *** ifconfig.c.orig Mon Apr 28 11:37:38 2003 --- ifconfig.c Fri Aug 29 00:59:36 2003 *************** *** 168,178 **** c_func setip6vltime; c_func2 setip6lifetime; c_func setip6eui64; #endif c_func setifipdst; ! c_func setifflags, setifmetric, setifmtu, setifcap; c_func clone_destroy; void clone_create(void); --- 168,178 ---- c_func setip6vltime; c_func2 setip6lifetime; c_func setip6eui64; #endif c_func setifipdst; ! c_func setifflags, setifmetric, setifmtu, setiflladdr, setifcap; c_func clone_destroy; void clone_create(void); *************** *** 282,291 **** --- 282,294 ---- { "-netcons", -IFCAP_NETCONS, setifcap }, { "normal", -IFF_LINK0, setifflags }, { "compress", IFF_LINK0, setifflags }, { "noicmp", IFF_LINK1, setifflags }, { "mtu", NEXTARG, setifmtu }, + { "ether", NEXTARG, setiflladdr }, + { "link", NEXTARG, setiflladdr }, + { "lladdr", NEXTARG, setiflladdr }, { 0, 0, setifaddr }, { 0, 0, setifdstaddr }, }; /* *************** *** 335,350 **** { "ipx", AF_IPX, ipx_status, ipx_getaddr, NULL, SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) }, #endif { "atalk", AF_APPLETALK, at_status, at_getaddr, NULL, SIOCDIFADDR, SIOCAIFADDR, C(addreq), C(addreq) }, - { "link", AF_LINK, link_status, link_getaddr, NULL, - 0, SIOCSIFLLADDR, NULL, C(ridreq) }, - { "ether", AF_LINK, link_status, link_getaddr, NULL, - 0, SIOCSIFLLADDR, NULL, C(ridreq) }, - { "lladdr", AF_LINK, link_status, link_getaddr, NULL, - 0, SIOCSIFLLADDR, NULL, C(ridreq) }, #if 0 /* XXX conflicts with the media command */ #ifdef USE_IF_MEDIA { "media", AF_UNSPEC, media_status, NULL, NULL, }, /* XXX not real!! */ #endif #ifdef USE_VLANS --- 338,347 ---- *************** *** 1030,1039 **** --- 1027,1068 ---- { strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_mtu = atoi(val); if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0) warn("ioctl (set mtu)"); + } + + void + setiflladdr(val, dummy, s, afp) + const char *val; + int dummy __unused; + int s; + const struct afswtch *afp; + { + struct ether_addr *ea; + char *newval; + struct sockaddr_dl sdl; + + if ((newval = malloc(strlen(val) + 1)) == NULL) + errx(1, "malloc failed"); + newval[0] = ':'; + strcpy(newval + 1, val); + sdl.sdl_len = sizeof(sdl); + link_addr(newval, &sdl); + free(newval); + if (sdl.sdl_alen > sizeof(ifr.ifr_addr.sa_data)) { + warn("malformed link-level address"); + return; + } + strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); + ifr.ifr_addr.sa_len = sdl.sdl_alen; + ifr.ifr_addr.sa_family = AF_LINK; + bcopy(LLADDR(&sdl), ifr.ifr_addr.sa_data, sdl.sdl_alen); + if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) + warn("ioctl (set lladdr)"); + + return; } #define IFFBITS \ "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \ "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \ Jason Young, CCIE #8607, MCSE Sr. Network Technician, WAN Technologies (314)817-0131 http://www.wantec.com _________________________________________________________________ Enter for your chance to IM with Bon Jovi, Seal, Bow Wow, or Mary J Blige using MSN Messenger http://entertainment.msn.com/imastar