From nick@van-laarhoven.org  Thu Jun  9 10:08:36 2011
Return-Path: <nick@van-laarhoven.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 439D8106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  9 Jun 2011 10:08:36 +0000 (UTC)
	(envelope-from nick@van-laarhoven.org)
Received: from cpsmtpb-ews05.kpnxchange.com (cpsmtpb-ews05.kpnxchange.com [213.75.39.8])
	by mx1.freebsd.org (Postfix) with ESMTP id C22CB8FC19
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  9 Jun 2011 10:08:35 +0000 (UTC)
Received: from cpbrm-ews31.kpnxchange.com ([10.94.84.162]) by cpsmtpb-ews05.kpnxchange.com with Microsoft SMTPSVC(6.0.3790.4675);
	 Thu, 9 Jun 2011 11:56:31 +0200
Received: from CPSMTPM-CMT105.kpnxchange.com ([195.121.3.21]) by cpbrm-ews31.kpnxchange.com with Microsoft SMTPSVC(6.0.3790.4675);
	 Thu, 9 Jun 2011 11:56:30 +0200
Received: from uitsmijter.van-laarhoven.org ([81.207.207.222]) by CPSMTPM-CMT105.kpnxchange.com with Microsoft SMTPSVC(7.0.6002.18264);
	 Thu, 9 Jun 2011 11:55:59 +0200
Received: by uitsmijter.van-laarhoven.org (Postfix, from userid 1001)
	id AD8DFAC815; Thu,  9 Jun 2011 11:55:59 +0200 (CEST)
Message-Id: <20110609095559.AD8DFAC815@uitsmijter.van-laarhoven.org>
Date: Thu,  9 Jun 2011 11:55:59 +0200 (CEST)
From: Nick Hibma <nick@anywi.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: devd does not stop dhclient on removing cable from vr ethernet port
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         157725
>Category:       kern
>Synopsis:       devd(8) does not stop dhclient on removing cable from vr ethernet port
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 09 10:10:11 UTC 2011
>Closed-Date:    Mon Jul 04 11:21:28 UTC 2011
>Last-Modified:  Mon Jul 04 11:21:28 UTC 2011
>Originator:     Nick Hibma
>Release:        FreeBSD 8.2-STABLE i386
>Organization:
AnyWi Technologies
>Environment:
FreeBSD AWSniffer 8.0-STABLE FreeBSD 8.0-STABLE #2: Tue Feb 22 13:49:20 CET 2011     root@billary.localdomain:/usr/obj/nanobsd.8/usr/src/sys/SOEKRIS8  i386

>Description:
In /etc/devd.conf it says:

  # Try to start dhclient on Ethernet like interfaces when the link comes
  # up.  Only devices that are configured to support DHCP will actually
  # run it.  No link down rule exists because dhclient automaticly exits
  # when the link goes down.

but this is not true. dhclient does not exit.
>How-To-Repeat:
On a SOEKRIS board (hm, they use vr chips now as well ...):

  # ifconfig vr2
  vr2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	  options=8280b<RXCSUM,TXCSUM,VLAN_MTU,WOL_UCAST,WOL_MAGIC,LINKSTATE>
	  ether 00:00:24:cd:95:2a
	  inet 192.168.1.92 netmask 0xffffff00 broadcast 192.168.1.255
	  inet 172.17.17.17 netmask 0xfffffff0 broadcast 172.17.17.31
	  media: Ethernet autoselect (100baseTX <full-duplex>)
	  status: active
  # ps ax|grep dhclient
   1661  ??  Ss     0:00.00 dhclient: vr2 [priv] (dhclient)
   1679  ??  Ss     0:00.00 dhclient: vr2 (dhclient)
  # ifconfig vr2
  vr2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	  options=8280b<RXCSUM,TXCSUM,VLAN_MTU,WOL_UCAST,WOL_MAGIC,LINKSTATE>
	  ether 00:00:24:cd:95:2a
	  inet 192.168.1.92 netmask 0xffffff00 broadcast 192.168.1.255
	  inet 172.17.17.17 netmask 0xfffffff0 broadcast 172.17.17.31
	  media: Ethernet autoselect (none)
	  status: no carrier
  # ps ax | grep dhclient
   1661  ??  Ss     0:00.00 dhclient: vr2 [priv] (dhclient)
   1679  ??  Ss     0:00.00 dhclient: vr2 (dhclient)

On an ALIX board:

  # ifconfig vr0
  vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	  options=8280b<RXCSUM,TXCSUM,VLAN_MTU,WOL_UCAST,WOL_MAGIC,LINKSTATE>
	  ether 00:0d:b9:1b:57:28
	  inet 192.168.1.94 netmask 0xffffff00 broadcast 192.168.1.255
	  inet 192.168.1.2 netmask 0xfffffffc broadcast 192.168.1.3
	  media: Ethernet autoselect (100baseTX <full-duplex>)
	  status: active
  # ps ax|grep dhclient
   3633  ??  Ss     0:00.00 dhclient: vr0 [priv] (dhclient)
   3652  ??  Ss     0:00.00 dhclient: vr0 (dhclient)
  # ifconfig vr0
  vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	  options=8280b<RXCSUM,TXCSUM,VLAN_MTU,WOL_UCAST,WOL_MAGIC,LINKSTATE>
	  ether 00:0d:b9:1b:57:28
	  inet 192.168.1.94 netmask 0xffffff00 broadcast 192.168.1.255
	  inet 192.168.1.2 netmask 0xfffffffc broadcast 192.168.1.3
	  media: Ethernet autoselect (none)
	  status: no carrier
  # ps ax | grep dhclient
   3633  ??  Is     0:00.00 dhclient: vr0 [priv] (dhclient)
   3652  ??  Ss     0:00.00 dhclient: vr0 (dhclient)
>Fix:

Adding the following additional configuration fixes this:

  notify 10 {
	  match "system"          "IFNET";
	  match "type"            "LINK_DOWN";
	  media-type              "ethernet";
	  action "/etc/rc.d/dhclient quietstop $subsystem";
  };

Notes:
- I have not tested this with other priority values.
- I have not tested this in a setup with interfaces with no DHCP in their
config lines.

Output of devd and console:

  Processing event '!system=IFNET subsystem=vr2 type=LINK_DOWN'
  Pushing table
  setting system=IFNET
  setting subsystem=vr2
  setting type=LINK_DOWN
  Processing notify event
  Testing system=IFNET against ^IFNET
  Testing type=LINK_DOWN against ^LINK_UP
  Testing system=IFNET against ^IFNET
  Testing type=LINK_DOWN against ^LINK_DOWN
  Testing media type of vr2 against 0x20
  vr2 has media type 0x20
  Executing '/etc/rc.d/dhclient quietstop vr2'
  Jun  1 12:13:12 AWSniffer dhclient[1661]: connection closed
  Jun  1 12:13:12 AWSniffer dhclient[1661]: exiting.
  Popping table
>Release-Note:
>Audit-Trail:

From: Nick Hibma <nick@anywi.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/157725: devd does not stop dhclient on removing cable from vr ethernet port
Date: Thu, 9 Jun 2011 12:23:01 +0200

 On a SOEKRIS unit with sis hardware:
 
   # Processing event '!system=IFNET subsystem=sis2 type=LINK_DOWN'
   Pushing table
   setting system=IFNET
   setting subsystem=sis2
   setting type=LINK_DOWN
   Processing notify event
   ...
   Testing system=IFNET against ^IFNET
   Testing type=LINK_DOWN against ^ATTACH
   Popping table
   # ifconfig sis2
   sis2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
           options=80008<VLAN_MTU,LINKSTATE>
           ether 00:00:24:c6:1f:f2
           inet 192.168.1.93 netmask 0xffffff00 broadcast 192.168.1.255
           inet 172.17.17.17 netmask 0xfffffff0 broadcast 172.17.17.31
           media: Ethernet autoselect (none)
           status: no carrier
   # ps ax | grep dhclient
    1514  ??  Is     0:00.01 dhclient: sis2 [priv] (dhclient)
    1541  ??  Is     0:00.00 dhclient: sis2 (dhclient)
    1554  u0  S+     0:00.02 grep dhclient
State-Changed-From-To: open->closed 
State-Changed-By: n_hibma 
State-Changed-When: Mon Jul 4 11:20:55 UTC 2011 
State-Changed-Why:  
Resolved in r223405. MFCed in r223681. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=157725 
>Unformatted:
