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

2010-11-19 Thread Sergey Kandaurov
On 11 October 2010 14:29, Hiroki Sato h...@freebsd.org wrote:
 Hi,

 pluknet pluk...@gmail.com wrote
  in aanlktintgji3vzrb8xuuqhwp+7ydvhtd7ynp0mmv0...@mail.gmail.com:

 pl On 27 August 2010 00:09, Doug Barton do...@freebsd.org wrote:
 pl  On 08/26/2010 12:53 PM, pluknet wrote:
 pl 
 pl  [cc'ing current@ as rc@ 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.

-- 
wbr,
pluknet

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


descr.rc.d.netif.patch
Description: Binary data
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org

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

2010-11-19 Thread Garrett Cooper
On Fri, Nov 19, 2010 at 2:55 AM, Sergey Kandaurov pluk...@gmail.com wrote:
 On 11 October 2010 14:29, Hiroki Sato h...@freebsd.org wrote:
 Hi,

 pluknet pluk...@gmail.com wrote
  in aanlktintgji3vzrb8xuuqhwp+7ydvhtd7ynp0mmv0...@mail.gmail.com:

 pl On 27 August 2010 00:09, Doug Barton do...@freebsd.org wrote:
 pl  On 08/26/2010 12:53 PM, pluknet wrote:
 pl 
 pl  [cc'ing current@ as rc@ 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) :)...
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-10-11 Thread Hiroki Sato
Hi,

pluknet pluk...@gmail.com wrote
  in aanlktintgji3vzrb8xuuqhwp+7ydvhtd7ynp0mmv0...@mail.gmail.com:

pl On 27 August 2010 00:09, Doug Barton do...@freebsd.org wrote:
pl  On 08/26/2010 12:53 PM, pluknet wrote:
pl 
pl  [cc'ing current@ as rc@ 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).

-- Hiroki



pgpvMmS5Le8b3.pgp
Description: PGP signature


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

2010-10-10 Thread Sergey Kandaurov
On 10 October 2010 07:41, jhell jh...@dataix.net wrote:
 On 08/27/2010 05:17, pluknet wrote:
 On 27 August 2010 00:09, Doug Barton do...@freebsd.org wrote:
 On 08/26/2010 12:53 PM, pluknet wrote:

 [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.

 This seems like a good addition, thanks. Please also write a patch for
 rc.conf.5 to describe this new functionality and I'll be happy to commit it.

 Xin Li helped me with updating rc.conf.5 (thanks!).
 It's included in attached patch.

  One note below.


 --- 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

 This is probably better as [ -n $_ifdescr ]


 This was blindly copypasted after ifnet_rename().
 So, it makes sense probably to change test expression there as well.
 [see ifnet_rename() proposed change below inline]
 This change to ifnet_rename() is not included in attached patch
 to not complicate things unnecessarily for now.

 Index: etc/network.subr
 ===
 --- etc/network.subr    (revision 211280)
 +++ etc/network.subr    (working copy)
 @@ -1179,7 +1179,7 @@
         # ifconfig_IF_name
         for _if in `ifconfig -l`; do
                 _ifname=`get_if_var $_if ifconfig_IF_name`
 -               if [ ! -z $_ifname ]; then
 +               if [ -n $_ifname ]; then
                         ifconfig $_if name $_ifname
                 fi
         done

 Was this ever committed ? If so does anyone have any referring svn
 revisions ?

 Also if this is committed or planned to be committed is there a chance
 it could be MFC'd ?

 Would be awesome if this was available on a production release without
 patching ;)


Hi.

I'm going to commit this after a proper review.

-- 
wbr,
pluknet
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-10-10 Thread Garrett Cooper
On Sat, Oct 9, 2010 at 11:29 PM, Sergey Kandaurov pluk...@gmail.com wrote:
 On 10 October 2010 07:41, jhell jh...@dataix.net wrote:
 On 08/27/2010 05:17, pluknet wrote:
 On 27 August 2010 00:09, Doug Barton do...@freebsd.org wrote:
 On 08/26/2010 12:53 PM, pluknet wrote:

 [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.

 This seems like a good addition, thanks. Please also write a patch for
 rc.conf.5 to describe this new functionality and I'll be happy to commit 
 it.

 Xin Li helped me with updating rc.conf.5 (thanks!).
 It's included in attached patch.

  One note below.


 --- 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

 This is probably better as [ -n $_ifdescr ]


 This was blindly copypasted after ifnet_rename().
 So, it makes sense probably to change test expression there as well.
 [see ifnet_rename() proposed change below inline]
 This change to ifnet_rename() is not included in attached patch
 to not complicate things unnecessarily for now.

 Index: etc/network.subr
 ===
 --- etc/network.subr    (revision 211280)
 +++ etc/network.subr    (working copy)
 @@ -1179,7 +1179,7 @@
         # ifconfig_IF_name
         for _if in `ifconfig -l`; do
                 _ifname=`get_if_var $_if ifconfig_IF_name`
 -               if [ ! -z $_ifname ]; then
 +               if [ -n $_ifname ]; then
                         ifconfig $_if name $_ifname
                 fi
         done

 Was this ever committed ? If so does anyone have any referring svn
 revisions ?

 Also if this is committed or planned to be committed is there a chance
 it could be MFC'd ?

 Would be awesome if this was available on a production release without
 patching ;)


 Hi.

 I'm going to commit this after a proper review.

offtopic
I'm not sure it would get resolved after this commit, but one
minor annoyance is that restarting the netif rc.d script purges all
gateways set, so I have to do and restart the routing rc.d script (if
my connectivity doesn't get whacked). I think there was something else
with natd and ipfw that I've run into in the past where I've restarted
those scripts and things weren't all puppydogs and rainbows on my
CURRENT systems.
/offtopic
Thanks,
-Garrett
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-10-10 Thread jhell
On 10/10/2010 13:23, Garrett Cooper wrote:
 offtopic
 I'm not sure it would get resolved after this commit, but one
 minor annoyance is that restarting the netif rc.d script purges all
 gateways set, so I have to do and restart the routing rc.d script (if
 my connectivity doesn't get whacked). I think there was something else
 with natd and ipfw that I've run into in the past where I've restarted
 those scripts and things weren't all puppydogs and rainbows on my
 CURRENT systems.
 /offtopic
 Thanks,
 -Garrett

Is that the dynamic routes only or also the static routes ?

Either or if it would be any of the above it would be nice if these were
kept if it was only a restart of the interface, but offhand nothing
comes to mind that could prevent this from happening since the routes
are acting according to when the interface becomes inactive then the
route becomes meaningless.

Maybe if the action of 'restart' to etc/rc.d/netif could also call
etc/rc.d/routing with 'restart' if the configuration of the interface
happens to match one of the recorded routes in rc.conf(5).

Just a thought.


Regards,

-- 

 jhell,v
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-10-10 Thread Garrett Cooper
On Sun, Oct 10, 2010 at 10:30 PM, jhell jh...@dataix.net wrote:
 On 10/10/2010 13:23, Garrett Cooper wrote:
 offtopic
     I'm not sure it would get resolved after this commit, but one
 minor annoyance is that restarting the netif rc.d script purges all
 gateways set, so I have to do and restart the routing rc.d script (if
 my connectivity doesn't get whacked). I think there was something else
 with natd and ipfw that I've run into in the past where I've restarted
 those scripts and things weren't all puppydogs and rainbows on my
 CURRENT systems.
 /offtopic
 Thanks,
 -Garrett

 Is that the dynamic routes only or also the static routes ?

 Either or if it would be any of the above it would be nice if these were
 kept if it was only a restart of the interface, but offhand nothing
 comes to mind that could prevent this from happening since the routes
 are acting according to when the interface becomes inactive then the
 route becomes meaningless.

 Maybe if the action of 'restart' to etc/rc.d/netif could also call
 etc/rc.d/routing with 'restart' if the configuration of the interface
 happens to match one of the recorded routes in rc.conf(5).

I just tested it on my test machine and it happens with static
routes; dynamic routes automatically get reset by dhclient, et all. It
used to be for both though in earlier versions of FreeBSD, IIRC.
Thanks!
-Garrett
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-10-10 Thread jhell
On 10/11/2010 01:34, Garrett Cooper wrote:
 On Sun, Oct 10, 2010 at 10:30 PM, jhell jh...@dataix.net wrote:
 On 10/10/2010 13:23, Garrett Cooper wrote:
 offtopic
 I'm not sure it would get resolved after this commit, but one
 minor annoyance is that restarting the netif rc.d script purges all
 gateways set, so I have to do and restart the routing rc.d script (if
 my connectivity doesn't get whacked). I think there was something else
 with natd and ipfw that I've run into in the past where I've restarted
 those scripts and things weren't all puppydogs and rainbows on my
 CURRENT systems.
 /offtopic
 Thanks,
 -Garrett

 Is that the dynamic routes only or also the static routes ?

 Either or if it would be any of the above it would be nice if these were
 kept if it was only a restart of the interface, but offhand nothing
 comes to mind that could prevent this from happening since the routes
 are acting according to when the interface becomes inactive then the
 route becomes meaningless.

 Maybe if the action of 'restart' to etc/rc.d/netif could also call
 etc/rc.d/routing with 'restart' if the configuration of the interface
 happens to match one of the recorded routes in rc.conf(5).
 
 I just tested it on my test machine and it happens with static
 routes; dynamic routes automatically get reset by dhclient, et all. It
 used to be for both though in earlier versions of FreeBSD, IIRC.
 Thanks!
 -Garrett

That has been something that has bugged me for a while. Ill take a look
at some possibilities (with just the scripts in rc.d) that might be a
solution to this soon as I get a chance over this next week. It might
just be meaningful to merge the correct areas of the routing script into
the netif scripts restart and relevant sections. Ill look at this as
soon as I get a chance.

Unless if someone has another theory about whether those routes should
be deleted at all if the ifnet address still exists on the parent
interface ?.


Regards,

-- 

 jhell,v
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-10-09 Thread jhell
On 08/27/2010 05:17, pluknet wrote:
 On 27 August 2010 00:09, Doug Barton do...@freebsd.org wrote:
 On 08/26/2010 12:53 PM, pluknet wrote:

 [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.

 This seems like a good addition, thanks. Please also write a patch for
 rc.conf.5 to describe this new functionality and I'll be happy to commit it.
 
 Xin Li helped me with updating rc.conf.5 (thanks!).
 It's included in attached patch.
 
  One note below.


 --- 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

 This is probably better as [ -n $_ifdescr ]

 
 This was blindly copypasted after ifnet_rename().
 So, it makes sense probably to change test expression there as well.
 [see ifnet_rename() proposed change below inline]
 This change to ifnet_rename() is not included in attached patch
 to not complicate things unnecessarily for now.
 
 Index: etc/network.subr
 ===
 --- etc/network.subr(revision 211280)
 +++ etc/network.subr(working copy)
 @@ -1179,7 +1179,7 @@
 # ifconfig_IF_name
 for _if in `ifconfig -l`; do
 _ifname=`get_if_var $_if ifconfig_IF_name`
 -   if [ ! -z $_ifname ]; then
 +   if [ -n $_ifname ]; then
 ifconfig $_if name $_ifname
 fi
 done

Was this ever committed ? If so does anyone have any referring svn
revisions ?

Also if this is committed or planned to be committed is there a chance
it could be MFC'd ?

Would be awesome if this was available on a production release without
patching ;)


Thanks in advance,

-- 

 jhell,v
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-08-27 Thread pluknet
On 27 August 2010 01:09, Xin LI delp...@delphij.net wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256

 On 2010/08/26 13:09, Doug Barton wrote:
 On 08/26/2010 12:53 PM, pluknet wrote:
 [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.

 This seems like a good addition, thanks. Please also write a patch for
 rc.conf.5 to describe this new functionality and I'll be happy to commit
 it.  One note below.

 I have drafted one.

Nice, thank you! With my poor English, this is a valuable help from you.


 (Note that fxp is a 100Mbps card so it might be sensible to replace it
 with just Switch 2?)


Thanks for catching this. Will fix it.

-- 
wbr,
pluknet
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-08-27 Thread pluknet
On 27 August 2010 00:09, Doug Barton do...@freebsd.org wrote:
 On 08/26/2010 12:53 PM, pluknet wrote:

 [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.

 This seems like a good addition, thanks. Please also write a patch for
 rc.conf.5 to describe this new functionality and I'll be happy to commit it.

Xin Li helped me with updating rc.conf.5 (thanks!).
It's included in attached patch.

  One note below.


 --- 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

 This is probably better as [ -n $_ifdescr ]


This was blindly copypasted after ifnet_rename().
So, it makes sense probably to change test expression there as well.
[see ifnet_rename() proposed change below inline]
This change to ifnet_rename() is not included in attached patch
to not complicate things unnecessarily for now.

Index: etc/network.subr
===
--- etc/network.subr(revision 211280)
+++ etc/network.subr(working copy)
@@ -1179,7 +1179,7 @@
# ifconfig_IF_name
for _if in `ifconfig -l`; do
_ifname=`get_if_var $_if ifconfig_IF_name`
-   if [ ! -z $_ifname ]; then
+   if [ -n $_ifname ]; then
ifconfig $_if name $_ifname
fi
done

-- 
wbr,
pluknet


descr.rc.d.2.diff
Description: Binary data
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org

[RFC] ifconfig description support in rc.d

2010-08-26 Thread pluknet
[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
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
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org

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

2010-08-26 Thread Doug Barton

On 08/26/2010 12:53 PM, pluknet wrote:

[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.


This seems like a good addition, thanks. Please also write a patch for 
rc.conf.5 to describe this new functionality and I'll be happy to commit 
it.  One note below.




--- 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


This is probably better as [ -n $_ifdescr ]

Doug

--

Improve the effectiveness of your Internet presence with
a domain name makeover!http://SupersetSolutions.com/

Computers are useless. They can only give you answers.
-- Pablo Picasso

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


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

2010-08-26 Thread Xin LI
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 2010/08/26 13:09, Doug Barton wrote:
 On 08/26/2010 12:53 PM, pluknet wrote:
 [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.
 
 This seems like a good addition, thanks. Please also write a patch for
 rc.conf.5 to describe this new functionality and I'll be happy to commit
 it.  One note below.

I have drafted one.

(Note that fxp is a 100Mbps card so it might be sensible to replace it
with just Switch 2?)

 --- 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
 
 This is probably better as [ -n $_ifdescr ]
 
 Doug
 


- -- 
Xin LI delp...@delphij.nethttp://www.delphij.net/
FreeBSD - The Power to Serve!  Live free or die
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.16 (FreeBSD)

iQEcBAEBCAAGBQJMdtgjAAoJEATO+BI/yjfBywEIALQZMUFUKlkQ/DZjrqBgymFx
Mnj6YkLaPXcvNI5OI15Q3hy730pIZzzNPGKV9ecXLSQ1PikZUIXy5fuRfYh9iXE3
d9f4UgDId0Sn55WmD6/Sfza0oSlH3C1fus6e9NSmm/aR3ekWyLWZzW0wGTgEXFxK
bo0ZcQw7AxRxDLc7EifWUfxV/Ej5pga5YjVyhBBdCoAHl2bPJuFFuxd140Y6+Mlf
gH4zgf2rdGpCWNpWF6L8PsGoVNBoK0R1fUwJZT+GB2ANvMuuQ+jsks+R8h8XFIO6
TE4O8onVcOaoTGZ3873M3CqcO1jfaK5rBfGg3Cr9wUjOkvkQ8SL+k4uvBm4CuX4=
=VtCo
-END PGP SIGNATURE-
Index: rc.conf.5
===
--- rc.conf.5   (revision 211847)
+++ rc.conf.5   (working copy)
@@ -1128,6 +1128,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 an 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
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org