| Summary: | ifconfig's lladdr is ethernet specific | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | tinguely <tinguely> | ||||
| Component: | bin | Assignee: | ru <ru> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | CC: | tinguely | ||||
| Priority: | Normal | ||||||
| Version: | Unspecified | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
tinguely
2001-10-24 16:10:00 UTC
On Wed, Oct 24, 2001 at 10:02:50AM -0500, tinguely@web.cs.ndsu.nodak.edu wrote: > > ifconfig's lladdr feature that allows the setting of the link-level > address on an interface. lladdr is documented to not be > ethernet-specific, but the implementation uses ether_aton() which > requires the link level address to be EXACTLY ETHER_ADDR_LEN in > length. > [...] > I added a routine to ifconfig called generic_atoi that will > allow abitraty length link-level addresses. generic_atoi() will > assume ETHER_ADDR_LEN length if the caller does not include > an integer to get the count of octets in the specified link-level > address. > Can't we just use link_addr(3) for that? Here's the patch (lightly tested) for RELENG_4: Index: ifconfig.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.51.2.13 diff -u -p -r1.51.2.13 ifconfig.c --- ifconfig.c 2001/08/20 18:38:41 1.51.2.13 +++ ifconfig.c 2001/10/24 17:24:09 @@ -1066,17 +1066,24 @@ setiflladdr(val, dummy, s, afp) int s; const struct afswtch *afp; { - struct ether_addr *ea; + char *newval; + struct sockaddr_dl sdl; - ea = ether_aton(val); - if (ea == NULL) { + 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 = ETHER_ADDR_LEN; + ifr.ifr_addr.sa_len = sdl.sdl_alen; ifr.ifr_addr.sa_family = AF_LINK; - bcopy(ea, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); + bcopy(LLADDR(&sdl), ifr.ifr_addr.sa_data, sdl.sdl_alen); if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) warn("ioctl (set lladdr)"); Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age If no one has an objection to Ruslan Ermilov's Oct 24 solution using link_addr() that replaces ether_aton() to make ifconfig(8)'s lladdr option not be ethernet MAC size dependant, could the changes be committed and this bug report closed? thank you, --mark tinguely State Changed From-To: open->feedback Fixed in 5.0-CURRENT, in ifconfig.c,v 1.73 and ifconfig.8,v 1.54. Responsible Changed From-To: freebsd-bugs->ru MFC in 1 week. State Changed From-To: feedback->closed Fixed in 4.5-STABLE, in ifconfig.c,v 1.51.2.16 and ifconfig.8,v 1.27.2.18. |