From owner-freebsd-net@FreeBSD.ORG Wed Oct 1 03:56:12 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DEB5016A4BF for ; Wed, 1 Oct 2003 03:56:12 -0700 (PDT) Received: from arginine.spc.org (arginine.spc.org [195.206.69.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 774BF43FAF for ; Wed, 1 Oct 2003 03:56:11 -0700 (PDT) (envelope-from bms@spc.org) Received: from localhost (localhost [127.0.0.1]) by arginine.spc.org (Postfix) with ESMTP id 8889E65298 for ; Wed, 1 Oct 2003 11:56:10 +0100 (BST) Received: from arginine.spc.org ([127.0.0.1]) by localhost (arginine.spc.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 69886-05 for ; Wed, 1 Oct 2003 11:56:10 +0100 (BST) Received: from saboteur.dek.spc.org (unknown [81.3.72.68]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by arginine.spc.org (Postfix) with ESMTP id A848565292 for ; Wed, 1 Oct 2003 11:55:58 +0100 (BST) Received: by saboteur.dek.spc.org (Postfix, from userid 1001) id BFBA01F; Wed, 1 Oct 2003 11:55:53 +0100 (BST) Date: Wed, 1 Oct 2003 11:55:53 +0100 From: Bruce M Simpson To: freebsd-net@freebsd.org Message-ID: <20031001105553.GA10462@saboteur.dek.spc.org> Mail-Followup-To: freebsd-net@freebsd.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="98e8jtXdkpgskNou" Content-Disposition: inline Subject: Review requested: revised patch for bin/41647 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2003 10:56:13 -0000 --98e8jtXdkpgskNou Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, It should be possible to set the link layer address of an interface whilst also setting the IP address. Here's a revised patch for ifconfig(8) to add this functionality (against HEAD) based on the one in the PR. There is a problem in that applying this patch modifies syntax such that statements of the form 'ifconfig xl0 ether' to view the ethernet address of an interface will no longer work. Using ifconfig(8) on its own or with the -a switch will dump this information however. Feedback anyone? BMS --98e8jtXdkpgskNou Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lladdr.diff" --- ifconfig.c.orig Tue Sep 30 03:25:53 2003 +++ ifconfig.c Wed Oct 1 11:45:54 2003 @@ -170,7 +170,7 @@ c_func setip6eui64; #endif c_func setifipdst; -c_func setifflags, setifmetric, setifmtu, setifcap; +c_func setifflags, setiflladdr, setifmetric, setifmtu, setifcap; c_func clone_destroy; @@ -234,6 +234,6 @@ { "-link2", -IFF_LINK2, setifflags }, { "monitor", IFF_MONITOR, setifflags }, { "-monitor", -IFF_MONITOR, setifflags }, #ifdef USE_IF_MEDIA { "media", NEXTARG, setmedia }, { "mode", NEXTARG, setmediamode }, @@ -286,6 +286,9 @@ { "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 }, }; @@ -339,12 +342,6 @@ #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!! */ @@ -1036,4 +1033,17 @@ warn("ioctl (set mtu)"); } +void +setiflladdr(val, dummy, s, afp) + const char *val; + int dummy __unused; + int s; + const struct afswtch *afp; +{ + strncpy(ridreq.ifr_name, name, sizeof(ridreq.ifr_name)); + link_getaddr(val, ADDR); + if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ridreq) < 0) + warn("ioctl(SIOCSIFLLADDR)"); +} + #define IFFBITS \ --98e8jtXdkpgskNou--