tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: cloner interface handling in rc.d/network



    Date:        Fri, 14 May 2021 17:17:32 +0200
    From:        Edgar =?iso-8859-1?B?RnXf?= <ef%math.uni-bonn.de@localhost>
    Message-ID:  <20210514151732.GW9457%trav.math.uni-bonn.de@localhost>


  | 1. What the code is supposed to do (I think) 
  |    is, with auto_ifconfig=YES, to add all "cloner" interfaces

Yes.

  | 2. When run later (e.g. after going single user and back multi user),

I haven't really thought about that case, there should be something when
the net goes down to destroy added cloners, but there probably isn't.

  | 3. The "[ ! -f $int ] && break" line completely confuses me
  |
  | 3a [ ! ... ]�should better be written ! [ ... ], no?

Probably yes, but it works either way.
  |
  | 3b ! [ ... ]�&& foo could be written [ ... ] ||�foo

It could, but that would alter the semantic slightly.

  | 3c What is this trying to catch? Directories called /etc/ifconfig.tun0?

Cloner interfaces that exist but have no /etc/ifconfig.* files at all.

  | 3d Why break and not continue (or && tmp=)? Why exit on the first non-file 
  |    entry?

Non-file isn't really it (-e would work) - but an /etc/ifconfig.* which isn't
a file isn't very likely, and certainly isn't likely to work.

The idea is to simply stop if the file doesn't exist.  Since the file comes
from a glob expansion, the only way it can not exist is if the pattern didn't
match, and so what "int" was set to is the pattern, ie, literally
just like  int='/etc/ifconfig.${cloner}[0-9]*'

There will be only one iteration of the loop when that happens, so whether
the code used break or continue (or even your 3b variation above) makes no
real difference - but using "break" makes it clearer that in this case, the
loop is immediately done.

  | 4 I guess the ##*. (why ## and not #?) could better be spelled out as 
  |    "#/etc/ifconfig."

It could, probably, but that's more characters for the shell to parse,
and builds the "/etc/ifconfig" string into two places in the loop instead
of just one.

Not sure why ## rather than # - in the case where an interface was
named foo3.7 or something the ## variant is likely to fail.   This bit
should probably be changed (but then again, I don't think we have any
cloner interfaces with names like that, and because of the way cloners
are generated, I don't think we ever can, so it really doesn't matter).

kre




Home | Main Index | Thread Index | Old Index