From owner-freebsd-current@FreeBSD.ORG Thu Aug 26 19:53:45 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 D402410656AB for ; Thu, 26 Aug 2010 19:53:45 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 77CF68FC08 for ; Thu, 26 Aug 2010 19:53:45 +0000 (UTC) Received: by qyk4 with SMTP id 4so2348671qyk.13 for ; Thu, 26 Aug 2010 12:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=43874TbKjj9uAt5/UKsK7RYq724oxkYCIaaSOB59+0w=; b=GvhjPOR16bwekihw15DpsGeB5xxn7wBaUiBGNVKk+rtj96NLkeDBMiYXGFO1ObY5lG f8ZRMkSOii+kNTXJ3n8qR/COZCH91bKwzXpKjW2nHMMEwVHtJqwvvq7vjZA5trEXlL1A D4DGJLt/FeWZDEqVEgZ0RFarKQi2Fa1afOBnM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=f+dK/v20tLhf+ZWQRtVD0oaQ4Xfjlppe3f5cSpc/q88A41O6Hxkt/2iVs1iA1PwNud eWYXyPRsGFOzXjSn+mgI/fOWfjKyru74Nt2UEtMahXrrG11OwtAhPdZFRlLoxHlYeyXF lq21hNNYDrzK3GiJ5f7RoLb5W2jFKtcxxaoSQ= MIME-Version: 1.0 Received: by 10.229.181.8 with SMTP id bw8mr7514151qcb.113.1282852424516; Thu, 26 Aug 2010 12:53:44 -0700 (PDT) Received: by 10.229.26.81 with HTTP; Thu, 26 Aug 2010 12:53:44 -0700 (PDT) Date: Thu, 26 Aug 2010 23:53:44 +0400 Message-ID: From: pluknet To: freebsd-rc@freebsd.org Content-Type: multipart/mixed; boundary=0016361e81a810124b048ebf5b14 Cc: FreeBSD Current Subject: [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: Thu, 26 Aug 2010 19:53:45 -0000 --0016361e81a810124b048ebf5b14 Content-Type: text/plain; charset=ISO-8859-1 [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. %%% Index: etc/rc.d/netif =================================================================== --- etc/rc.d/netif (revision 211280) +++ etc/rc.d/netif (working copy) @@ -75,6 +75,9 @@ # Rename interfaces. ifnet_rename + + # Give description to interfaces. + ifnet_descr fi # Configure the interface(s). Index: etc/network.subr =================================================================== --- etc/network.subr (revision 211280) +++ etc/network.subr (working copy) @@ -1187,6 +1187,24 @@ return 0 } +# ifnet_descr +# Add description to all requested interfaces. +# +ifnet_descr() +{ + local _if _ifdescr + + # ifconfig_IF_descr + for _if in `ifconfig -l`; do + _ifdescr="`get_if_var $_if ifconfig_IF_descr`" + if [ ! -z "$_ifdescr" ]; then + ifconfig $_if descr "$_ifdescr" + fi + done + + return 0 +} + # list_net_interfaces type # List all network interfaces. The type of interface returned # can be controlled by the type argument. The type Index: etc/defaults/rc.conf =================================================================== --- etc/defaults/rc.conf (revision 211280) +++ etc/defaults/rc.conf (working copy) @@ -215,6 +215,7 @@ #ifconfig_ed0_ipv6="inet6 2001:db8:1::1 prefixlen 64" # Sample IPv6 addr entry #ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64" # Sample IPv6 alias #ifconfig_fxp0_name="net0" # Change interface name from fxp0 to net0. +#ifconfig_fxp0_descr="Uplink to Gigabit Switch 2" # Label fxp0 interface #vlans_fxp0="101 vlan0" # vlan(4) interfaces for fxp0 device #create_arg_vlan0="vlan 102" # vlan tag for vlan0 device #wlans_ath0="wlan0" # wlan(4) interfaces for ath0 device %%% -- wbr, pluknet --0016361e81a810124b048ebf5b14 Content-Type: text/x-diff; charset=US-ASCII; name="descr.rc.d.diff" Content-Disposition: attachment; filename="descr.rc.d.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gdc15hj10 SW5kZXg6IGV0Yy9yYy5kL25ldGlmCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGV0Yy9yYy5kL25ldGlmCShyZXZp c2lvbiAyMTEyODApCisrKyBldGMvcmMuZC9uZXRpZgkod29ya2luZyBjb3B5KQpAQCAtNzUsNiAr NzUsOSBAQAogCiAJCSMgUmVuYW1lIGludGVyZmFjZXMuCiAJCWlmbmV0X3JlbmFtZQorCisJCSMg R2l2ZSBkZXNjcmlwdGlvbiB0byBpbnRlcmZhY2VzLgorCQlpZm5ldF9kZXNjcgogCWZpCiAKIAkj IENvbmZpZ3VyZSB0aGUgaW50ZXJmYWNlKHMpLgpJbmRleDogZXRjL25ldHdvcmsuc3Vicgo9PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09Ci0tLSBldGMvbmV0d29yay5zdWJyCShyZXZpc2lvbiAyMTEyODApCisrKyBldGMvbmV0 d29yay5zdWJyCSh3b3JraW5nIGNvcHkpCkBAIC0xMTg3LDYgKzExODcsMjQgQEAKIAlyZXR1cm4g MAogfQogCisjIGlmbmV0X2Rlc2NyCisjCUFkZCBkZXNjcmlwdGlvbiB0byBhbGwgcmVxdWVzdGVk IGludGVyZmFjZXMuCisjCitpZm5ldF9kZXNjcigpCit7CisJbG9jYWwgX2lmIF9pZmRlc2NyCisK KwkjIGlmY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