From owner-freebsd-rc@FreeBSD.ORG Sat Jun 11 16:58:20 2011 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99EF9106564A; Sat, 11 Jun 2011 16:58:20 +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 45AA68FC08; Sat, 11 Jun 2011 16:58:19 +0000 (UTC) Received: by qwc9 with SMTP id 9so2469596qwc.13 for ; Sat, 11 Jun 2011 09:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to:cc :content-type; bh=WBSd4avKfRKtd4u3QhbMORr3jIChIKPPp2XBcWWnLqg=; b=nUd3guecShUkelQCSSzRdYY/LbOlUFY8v4/rPGCBa6uIpscVQA1FtQTcWEaaUZ2ob8 nuRZsXyKyGXAQ1BE5gCMxd+FnykiVxv2x0uiO1Qm7KG1UTrDCRxAKgdzOy+c/hQUZxlW bFXdVDyo3wGTahJGzE+jPj7jlwBbFqL6JbpdQ= 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=T95ad0pZrMIr2oK3CjGNnIh9NEUQY7DEyo4WyOy0OZtl9F6DfLpr6aMlsPc5hVxubq DgLyoyAtAjvTjXP8HyYX/kr2j43aAwbKHuCTp0Vi5ffww6rXKHcszXCbl7q9PKWV6p/o lGc8DMs5+wKVfH0J69Jf2Vn0ddAFNTEbOmWOI= MIME-Version: 1.0 Received: by 10.229.142.11 with SMTP id o11mr2546475qcu.46.1307809840415; Sat, 11 Jun 2011 09:30:40 -0700 (PDT) Received: by 10.229.99.197 with HTTP; Sat, 11 Jun 2011 09:30:40 -0700 (PDT) Date: Sat, 11 Jun 2011 20:30:40 +0400 Message-ID: From: Sergey Kandaurov To: freebsd-rc@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: "Alexander V. Chernikov" , Doug Barton Subject: [CFR] rc.conf interface description X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jun 2011 16:58:20 -0000 Hello. Some time ago there was a discussion about ifconfig descr integration into rc. That means you can store interface descriptions in rc.conf file, so that the descriptions survive between system reboots. To achieve it, you need to place one-line option into rc.conf, e.g. like this: ifconfig_em0_descr="Uplink to Gigabit Switch 1", or ifconfig_vlan8_descr="description '1 2 3' vlan 255 vlandev IFACE" so after reboot or manual `rc.d/netif restart $iface` invocation, you''ll see something like this: vlan8: flags=8843 metric 0 mtu 1500 description: description '1 2 3' vlan 255 vlandev IFACE [...] And rc.d/netif stop $iface removes description from a network interface. You can see the previous discussion in -current@ and -rc@ mail archives: http://www.mail-archive.com/freebsd-current@freebsd.org/msg124513.html However, that time it went nowhere due to luck of time/interest. Recently I learned that this patch is actually used. I was requested to integrate it into the head. I'd like to collect your opinions/objections/thoughts to ensure whether there are might be issues preventing from committing it. Index: etc/network.subr =================================================================== --- etc/network.subr (revision 222893) +++ etc/network.subr (working copy) @@ -47,6 +47,7 @@ afexists inet && ipv4_up ${ifn} && cfg=0 afexists inet6 && ipv6_up ${ifn} && cfg=0 afexists ipx && ipx_up ${ifn} && cfg=0 + ifdescr_up ${ifn} && cfg=0 childif_create ${ifn} && cfg=0 return $cfg @@ -69,6 +70,7 @@ afexists inet && ipv4_down ${ifn} && cfg=0 ifconfig_down ${ifn} && cfg=0 ifscript_down ${ifn} && cfg=0 + ifdescr_down ${ifn} && cfg=0 childif_destroy ${ifn} && cfg=0 return $cfg @@ -1220,6 +1222,35 @@ return 0 } +# ifdescr_up if +# Add description to the interface $if. +# +ifdescr_up() +{ + local _if _ifdescr + + _if=$1 + _ifdescr="`get_if_var $_if ifconfig_IF_descr`" + if [ ! -z "$_ifdescr" ]; then + ifconfig $_if descr "$_ifdescr" + fi + + return 0 +} + +# ifdescr_down if +# Remove description from the interface $if. +# +ifdescr_down() +{ + local _if _ifdescr + + _if=$1 + ifconfig $_if -descr + + 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 222893) +++ etc/defaults/rc.conf (working copy) @@ -216,6 +216,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 Switch 2" # Label fxp0 interface #vlans_fxp0="101 vlan0" # vlan(4) interfaces for fxp0 device #create_args_vlan0="vlan 102" # vlan tag for vlan0 device #wlans_ath0="wlan0" # wlan(4) interfaces for ath0 device Index: share/man/man5/rc.conf.5 =================================================================== --- share/man/man5/rc.conf.5 (revision 222893) +++ share/man/man5/rc.conf.5 (working copy) @@ -1140,6 +1141,19 @@ variables. .Pp If a +.Va ifconfig_ Ns Ao Ar interface Ac Ns Va _descr +variable is set, the interface would be assigned the description +specified by the variable. +.Pp +To assign a description of +.Dq Uplink to Gigabit Switch 1 +on the interface named +.Li em0 : +.Bd -literal +ifconfig_em0_descr="Uplink to Gigabit Switch 1" +.Ed +.Pp +If a .Va vlans_ Ns Aq Ar interface variable is set, a -- wbr, pluknet