Re: [RFC] ifconfig description support in rc.d

From: Garrett Cooper <gcooper_at_FreeBSD.org>
Date: Fri, 19 Nov 2010 09:43:22 -0800
On Fri, Nov 19, 2010 at 2:55 AM, Sergey Kandaurov <pluknet_at_gmail.com> wrote:
> On 11 October 2010 14:29, Hiroki Sato <hrs_at_freebsd.org> wrote:
>> Hi,
>>
>> pluknet <pluknet_at_gmail.com> wrote
>>  in <AANLkTintgji3vzrb8XuUQHWp+7YDvHtd7ynP0MmV0oZr_at_mail.gmail.com>:
>>
>> pl> On 27 August 2010 00:09, Doug Barton <dougb_at_freebsd.org> wrote:
>> pl> > On 08/26/2010 12:53 PM, pluknet wrote:
>> pl> >>
>> pl> >> [cc'ing current_at_ as rc_at_ looks too quite]
>> pl> >>
>> pl> >> Hi.
>> pl> >>
>> pl> >> Since ifconfig has grown to label interfaces with
>> pl> >> ifconfig $ifname description "foobar", what about
>> pl> >> to give it more life and store i/face descriptions
>> pl> >> semi-permanently, so they will survive between reboots?
>> pl> >>
>> pl> >> This patch adds a functionality to rc.d to label
>> pl> >> interfaces at boot time.
>> pl> >>
>> pl> >> Comments are welcome.
>> pl> >
>> pl> > This seems like a good addition, thanks. Please also write a patch for
>> pl> > rc.conf.5 to describe this new functionality and I'll be happy to commit it.
>> pl>
>> pl> Xin Li helped me with updating rc.conf.5 (thanks!).
>> pl> It's included in attached patch.
>> (snip)
>> pl> >> +       # ifconfig_IF_descr
>> pl> >> +       for _if in `ifconfig -l`; do
>>
>>  I think using "ifconfig -l" here is not a good idea.  Setting a
>>  description for each interface in a function invoked by ifn_start()
>>  would be better.
>>
>>  This is beacuse the netif script can be run not only at boottime but
>>  also via devd or by hand for a specific interface.  So, if the
>>  ifnet_descr is there, "/etc/rc.d/netif start IF" does not make it
>>  run.  Since the description is a per-interface property,
>>  "/etc/rc.d/netif start IF" should set one, and "/etc/rc.d/netif stop
>>  IF" should clear one, IMHO.
>>
>>  Also, "ifconfig -l" is not compatible with $network_interfaces, so
>>  you need to use list_net_interface() for that purpose instead (if you
>>  move ifnet_descr() into ifn_start() it is useless, though).
>>
>
> Actually, both versions were developed at the same time.
> This one follows "netif" approach. Somehow it was rejected
> by me for some reasons which I don't remember for now.
> That's why I didn't include it to my original message.
>
> Please, see attached.

+	_ifdescr="`get_if_var $_if ifconfig_IF_descr`"
+	if [ ! -z "$_ifdescr" ]; then
+		ifconfig $_if descr "$_ifdescr"
+	fi
+
+	return 0

    What if the above fails?
    There are other potential problem areas as well in network.subr
(ifscript_up for instance).
Thanks,
-Garrett

> P.S.
> Google marks patches as (application/octet-stream). Bad Google.

Only if the extension isn't .patch (and it's not just Google -- blame
it on other software like Mailman as well) :)...
Received on Fri Nov 19 2010 - 16:43:26 UTC

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