From owner-freebsd-current@FreeBSD.ORG Fri Aug 27 09:17:18 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E0FA1065670; Fri, 27 Aug 2010 09:17:18 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0B7488FC12; Fri, 27 Aug 2010 09:17:17 +0000 (UTC) Received: by qwg5 with SMTP id 5so2806554qwg.13 for ; Fri, 27 Aug 2010 02:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=6qpRf0y73wJhfdDgBA9ZiHoZG3msbNmLWHbC6Q/l+E0=; b=Fw94O2+DYD9Aq5+7Kr4f7Avylg1GcL0uwTSrWHaxG1vJkt5URbx3cTqQp2yMC6+Rbj o/1G2XUOIXvGCJd5oR4UQRSPhZqw47HYBg6UA5tC58YYxeGh/+TWhATIgioo+h8PpcGX mS0bNVMU0/WjOViJP2cWRQgEIX2ak5UbZuTZk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=pHe83f31en4z5KSseu9IQ1Sil+wiYC5zXkPqIRc+3dnkDBmN8UUz88Sr76Ybun6Bvh LBi9rZPf1IYiXngDIscmMeSWxe424CJjMlUoAhDlZnByW2QVKyGsx2941N9rl5/tJh3x h/ad08nTQ7+TSgXpYVnTD/7IpN/UNc3jb7gIA= MIME-Version: 1.0 Received: by 10.224.64.167 with SMTP id e39mr127007qai.271.1282900637299; Fri, 27 Aug 2010 02:17:17 -0700 (PDT) Received: by 10.229.26.81 with HTTP; Fri, 27 Aug 2010 02:17:17 -0700 (PDT) In-Reply-To: <4C76CA06.5010001@FreeBSD.org> References: <4C76CA06.5010001@FreeBSD.org> Date: Fri, 27 Aug 2010 13:17:17 +0400 Message-ID: From: pluknet To: Doug Barton Content-Type: multipart/mixed; boundary=0016e64bbf02c4b4e7048eca940d Cc: FreeBSD Current , freebsd-rc@freebsd.org Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2010 09:17:18 -0000 --0016e64bbf02c4b4e7048eca940d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 27 August 2010 00:09, Doug Barton wrote: > On 08/26/2010 12:53 PM, pluknet wrote: >> >> [cc'ing current@ as rc@ looks too quite] >> >> Hi. >> >> Since ifconfig has grown to label interfaces with >> ifconfig $ifname description "foobar", what about >> to give it more life and store i/face descriptions >> semi-permanently, so they will survive between reboots? >> >> This patch adds a functionality to rc.d to label >> interfaces at boot time. >> >> Comments are welcome. > > This seems like a good addition, thanks. Please also write a patch for > rc.conf.5 to describe this new functionality and I'll be happy to commit = it. Xin Li helped me with updating rc.conf.5 (thanks!). It's included in attached patch. > =A0One note below. > > >> --- etc/network.subr =A0 =A0(revision 211280) >> +++ etc/network.subr =A0 =A0(working copy) >> @@ -1187,6 +1187,24 @@ >> =A0 =A0 =A0 =A0 return 0 >> =A0} >> >> +# ifnet_descr >> +# =A0 =A0 =A0Add description to all requested interfaces. >> +# >> +ifnet_descr() >> +{ >> + =A0 =A0 =A0 local _if _ifdescr >> + >> + =A0 =A0 =A0 # ifconfig_IF_descr >> + =A0 =A0 =A0 for _if in `ifconfig -l`; do >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 _ifdescr=3D"`get_if_var $_if ifconfig_IF_d= escr`" >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ ! -z "$_ifdescr" ]; then > > This is probably better as [ -n "$_ifdescr" ] > This was blindly copy&pasted after ifnet_rename(). So, it makes sense probably to change test expression there as well. [see ifnet_rename() proposed change below inline] This change to ifnet_rename() is not included in attached patch to not complicate things unnecessarily for now. Index: etc/network.subr =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- etc/network.subr (revision 211280) +++ etc/network.subr (working copy) @@ -1179,7 +1179,7 @@ # ifconfig_IF_name for _if in `ifconfig -l`; do _ifname=3D`get_if_var $_if ifconfig_IF_name` - if [ ! -z "$_ifname" ]; then + if [ -n "$_ifname" ]; then ifconfig $_if name $_ifname fi done --=20 wbr, pluknet --0016e64bbf02c4b4e7048eca940d Content-Type: application/octet-stream; name="descr.rc.d.2.diff" Content-Disposition: attachment; filename="descr.rc.d.2.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gdctruj10 SW5kZXg6IGV0Yy9yYy5kL25ldGlmCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGV0Yy9yYy5kL25ldGlmCShyZXZp c2lvbiAyMTEyODApCisrKyBldGMvcmMuZC9uZXRpZgkod29ya2luZyBjb3B5KQpAQCAtNzUsNiAr NzUsOSBAQAogCiAJCSMgUmVuYW1lIGludGVyZmFjZXMuCiAJCWlmbmV0X3JlbmFtZQorCisJCSMg R2l2ZSBkZXNjcmlwdGlvbiB0byBpbnRlcmZhY2VzLgorCQlpZm5ldF9kZXNjcgogCWZpCiAKIAkj IENvbmZpZ3VyZSB0aGUgaW50ZXJmYWNlKHMpLgpJbmRleDogZXRjL25ldHdvcmsuc3Vicgo9PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09Ci0tLSBldGMvbmV0d29yay5zdWJyCShyZXZpc2lvbiAyMTEyODApCisrKyBldGMvbmV0 d29yay5zdWJyCSh3b3JraW5nIGNvcHkpCkBAIC0xMTg3LDYgKzExODcsMjQgQEAKIAlyZXR1cm4g MAogfQogCisjIGlmbmV0X2Rlc2NyCisjCUFkZCBkZXNjcmlwdGlvbiB0byBhbGwgcmVxdWVzdGVk IGludGVyZmFjZXMuCisjCitpZm5ldF9kZXNjcigpCit7CisJbG9jYWwgX2lmIF9pZmRlc2NyCisK KwkjIGlmY29uZmlnX0lGX2Rlc2NyCisJZm9yIF9pZiBpbiBgaWZjb25maWcgLWxgOyBkbworCQlf aWZkZXNjcj0iYGdldF9pZl92YXIgJF9pZiBpZmNvbmZpZ19JRl9kZXNjcmAiCisJCWlmIFsgLW4g IiRfaWZkZXNjciIgXTsgdGhlbgorCQkJaWZjb25maWcgJF9pZiBkZXNjciAiJF9pZmRlc2NyIgor CQlmaQorCWRvbmUKKworCXJldHVybiAwCit9CisKICMgbGlzdF9uZXRfaW50ZXJmYWNlcyB0eXBl CiAjCUxpc3QgYWxsIG5ldHdvcmsgaW50ZXJmYWNlcy4gVGhlIHR5cGUgb2YgaW50ZXJmYWNlIHJl dHVybmVkCiAjCWNhbiBiZSBjb250cm9sbGVkIGJ5IHRoZSB0eXBlIGFyZ3VtZW50LiBUaGUgdHlw ZQpJbmRleDogZXRjL2RlZmF1bHRzL3JjLmNvbmYKPT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gZXRjL2RlZmF1bHRz L3JjLmNvbmYJKHJldmlzaW9uIDIxMTI4MCkKKysrIGV0Yy9kZWZhdWx0cy9yYy5jb25mCSh3b3Jr aW5nIGNvcHkpCkBAIC0yMTUsNiArMjE1L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