tech-net archive

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

Re: Wait for interface existence?



 ---- On Thu, 07 Sep 2023 12:42:16 +0100  Mouse  wrote --- 
 > >> The use case is /etc/rc.conf setting up (in the specific case at
 > >> hand) bridge0, fxp0, and tap0.  As soon as fxp0 and bridge0 both
 > >> exist, I want to run brconfig bridge0 add fxp0; as soon as tap0 and
 > >> bridge0 both exist, I want to run brconfig bridge0 add tap0.
 > 
 > >> Historically, I've dealt with this by careful ordering of
 > >> $net_interfaces, with comments in rc.conf to keep future edits from
 > >> breaking that ordering.
 > 
 > >> I could have [...]
 > 
 > > OK, so this is just an overly complex solution to the simple fact you
 > > sometimes struggle to setup rc.conf for bridging.
 > 
 > If that's how you choose to see it, sure.  I consider a hundred lines
 > of code in ifconfig a relatively cheap price for the benefit of
 > robustness of rc.conf against reordering of interfaces.  (For that
 > matter, is it documented - and committed to - that $net_interfaces is
 > processed in order?  If not, depending on it is a Bad Idea.)
 > 
 > > Common sense tells me that we should create the virtual interfaces
 > > before adding them to the bridge so they should appear first, but heh
 > > ho.
 > 
 > That's what I used to do.  It feels unpleasantly fragile, though.

But that's what your solution also does, but the ordering is not as obvious.
It's even more fragile as if anything went wrong, you don't get any errors as it waits indefinitely.

> ifsetup_post_bridge0="((ifconfig -W bridge0 tap0; brconfig bridge0 add tap0) &); ((ifconfig -W bridge0 fxp0; brconfig bridge0 add fxp0) &)"

I don't see anything for ifsetup_post_$interface in our rc system?
brconfig relies on both interfaces being available so by definition the bridge is last.

Why not add this to /etc/rc.conf?

network_poststart() {
        brconfig bridge0 add fxp0
        brconfig bridge0 add tap0
}

if [ "$name" = network ]; then
        start_postcmd="network_poststart"
fi

Roy


Home | Main Index | Thread Index | Old Index