bin/41647: ifconfig doesn't accept lladdr along with inet
address family
Jason Young
jyoung8607 at hotmail.com
Fri Aug 29 12:50:22 PDT 2003
The following reply was made to PR bin/41647; it has been noted by GNATS.
From: "Jason Young" <jyoung8607 at hotmail.com>
To: freebsd-gnats-submit at freebsd.org
Cc: ru at freebsd.org, jyoung at 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
More information about the freebsd-bugs
mailing list