John Baldwin <> wrote
  in <>:

jh> I also tested vlans created via vlans_<if> and they should use the same fix 
jh> well.  Note that this model is more consistent with how cloned_interfaces
jh> works where ifn_start is not explicitly run when each interface is created.
jh> Instead, we rely on devd kicking off pccard_ether for those as well.

 No, for cloned_interfaces, the ifn_start will be kicked even when
 devd is unavailable because rc.d/netif calls clone_up() and then
 ifn_start() sequentially.  Since an IFNET ATTACH event is generated
 upon clone_up(), so actually the ifn_start() runs twice on every boot
 time (or rc.d/netif restart ifn).

 Since childif_*() is invoked at the end of ifn_*(), configuration of
 the child interfaces does not happen.  This is the reason why there
 was ifn_start() in childif_create().

 It is not efficient and it is reasonable to leave ifn_start() to devd
 if available, but it is difficult to detect it correctly because the
 IFNET ATTACH handler may be disabled in devd.conf.  "pgrep devd" is
 not reliable enough.

 As pointed out, this duplication can be a problem when configuration
 is performed by a program because multiple instances of the program
 are invoked.  In the other cases, there is no problem because
 ifn_start() is idempotent, though.

 As a workaround, dhclient is not invoked from ifconfig_up() like

   222          if wpaif $1; then
   223                  /etc/rc.d/wpa_supplicant start $1
   224                  _cfg=0          # XXX: not sure this should count
   225          elif hostapif $1; then
   226                  /etc/rc.d/hostapd start $1
   227                  _cfg=0
   228          fi
   230          if dhcpif $1; then
   231                  if [ $_cfg -ne 0 ] ; then
   232                          ${IFCONFIG_CMD} $1 up
   233                  fi
   234                  if syncdhcpif $1; then
   235                          /etc/rc.d/dhclient start $1
   236                  fi
   237                  _cfg=0
   238          fi

 ifconfig_IF="DHCP" means to leave invoking dhclient to devd, and
 ifconfig_IF="SYNCDHCP" means rc.d/netif calls dhclient directly.  I
 think similar workaround can be implemented for WPA and HOSTAP and
 solve the originally-reported problem.

 For inconsistency childif_*(), what do you think about integrating
 vlans_IF and wlans_IF into cloned_interfaces and removing the
 childif_*() stage in ifn_*()?  We can keep vlans_IF and wlans_IF as
 well as introduce a new syntax into cloned_interfaces like

  cloned_interfaces="em0.100 em0.110 em0.myvlan ath0.wlan0"

 which is equivalent to

  vlans_em0="100 110 myvlan"

 The rc.d/netif does clone_up() for the child interfaces first and
 then does ifn_start() for them, so

 # service netif restart wlan0

 works as expected (tear down, recreate, and reconfigure the

 Of course, this does not solve the duplicate invocation of the netif
 script.  To solve it, I think we need a knob to disable IFNET events
 in a per-interface basis temporarily.

-- Hiroki

Attachment: pgp9LxVpsrqy5.pgp
Description: PGP signature

Reply via email to