[RFC] ifconfig description support in rc.d

From: pluknet <pluknet_at_gmail.com>
Date: Thu, 26 Aug 2010 23:53:44 +0400
[cc'ing current_at_ as rc_at_ 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)
_at__at_ -75,6 +75,9 _at__at_

                # 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)
_at__at_ -1187,6 +1187,24 _at__at_
        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)
_at__at_ -215,6 +215,7 _at__at_
 #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

Received on Thu Aug 26 2010 - 17:53:45 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:06 UTC