Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2000 09:07:19 -0400
From:      "Yevmenkin, Maksim N, CSCIO" <myevmenkin@att.com>
To:        "'Archie Cobbs'" <archie@whistle.com>, Julian Elischer <julian@elischer.org>
Cc:        "'freebsd-current@freebsd.org'" <freebsd-current@FreeBSD.ORG>
Subject:   RE: possible NETGRAPH/NG_ETHER bug
Message-ID:  <E598F159668DD311B9C700902799EAF4473463@njb140po01.ems.att.com>

next in thread | raw e-mail | index | archive | help
[...]

> From: Archie Cobbs [mailto:archie@whistle.com]
> Julian Elischer writes:
> > > i was working on integration of Ethernet TAP driver and NETGRAPH
> > > and found strange thing. the problem is that NG_ETHER nodes do not
> > > detach correctly when interface is gone. i was taking a very quick
> > > look at it, and, it seems to me that we are missing one reference
> > > to a node. i think it is ng_name_node/ng_unname pair.
> > 
> > This is quite possible because until recently interfaces could never
> > be removed. Therefore the act of removing a node was really
> > just a case of RESETTING the node. It was not removed.
> 
> Here's some more info that may be helpful.

[...]

the problem still exists :( i tried to collect some information that,
i think, could be helpful.

first, my system

fly# uname -a
FreeBSD fly.private.org 5.0-CURRENT FreeBSD 5.0-CURRENT #2: Tue Jul 18
20:21:57
EST 2000     root@fly.private.org:/usr/src/sys/compile/FLY  i386

now modules and interfaces

fly# kldstat
Id Refs Address    Size     Name
 1    3 0xc0100000 1cd99c   kernel
 2    1 0xc0974000 4000     logo_saver.ko
fly# ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet 127.0.0.1 netmask 0xff000000

now i will load if_tap module and create virtual interface

fly# kldload -v ./if_tap.ko
Loaded ./if_tap.ko, id=3
fly# cat /dev/tap0
^C
fly# ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet 127.0.0.1 netmask 0xff000000
tap0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        ether 00:bd:dd:25:00:00

now i will load ng_ether and check NETGRAPH nodes

fly# kldload -v ng_ether
Loaded ng_ether, id=4
fly# ngctl list
There are 2 total nodes:
  Name: ngctl183        Type: socket          ID: 00000002   Num hooks: 0
  Name: tap0            Type: ether           ID: 00000001   Num hooks: 0
fly# ngctl types
There are 2 total types:
      Type name   Number of living nodes
      ---------   ----------------------
         socket       1
          ether       1

so far so good :) now i will unload if_tap module

fly# kldunload if_tap
fly# ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet 127.0.0.1 netmask 0xff000000
fly# cat /dev/tap0
cat: /dev/tap0: Device not configured

ok, both device and interface are gone, what about NETGRAPH nodes

fly# ngctl list
There are 1 total nodes:
  Name: ngctl210        Type: socket          ID: 00000004   Num hooks: 0
fly# ngctl types
There are 2 total types:
      Type name   Number of living nodes
      ---------   ----------------------
         socket       1
          ether       1
fly# kldunload ng_ether
kldunload: can't unload file: Device busy

ooops :( there is still 1 ``ether'' node :( 

i did put some debug printf in ng_base and ng_ether. here is an output

ng_ether_detach: start node->refs = 2 --- ng_ether_detach()
ng_unref: node->refs = 3 --- ng_unfer(). ng_rmnode() it will add one extra
reference
ng_ether_detach: before final ng_unref() node->refs = 2 ---
ng_ether_detach() just before last ng_unref()
ng_unref: node->refs  = 2	--- ng_unref()

so i think that shows that last ng_unref() was called with node->refs 
equal to 2, and, i think, that is not correct :(

again, here is one of the millions of possible patches that works for me :)

*** ng_ether.c.old      Tue Jul 18 21:17:54 2000
--- ng_ether.c  Tue Jul 18 21:48:46 2000
***************
*** 293,298 ****
--- 293,299 ----
        bzero(priv, sizeof(*priv));
        FREE(priv, M_NETGRAPH);
        node->private = NULL;
+       ng_unname(node);                /* remove node name */
        ng_unref(node);                 /* free node itself */
  }


if_tap module sources can be found at

http://home.earthlink.net/~evmax/tap-fbsd5b1.tar.gz


sorry for long letter :) hope that helps :)
thanks,
emax


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E598F159668DD311B9C700902799EAF4473463>