Date: Sat, 11 Jun 2011 20:30:40 +0400 From: Sergey Kandaurov <pluknet@gmail.com> To: freebsd-rc@freebsd.org Cc: "Alexander V. Chernikov" <melifaro@ipfw.ru>, Doug Barton <dougb@freebsd.org> Subject: [CFR] rc.conf interface description Message-ID: <BANLkTikfoQtgVv2Vnkg6Fn4kq68qjqpWRw@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTikfoQtgVv2Vnkg6Fn4kq68qjqpWRw>