From owner-freebsd-net@FreeBSD.ORG Thu May 27 13:42:25 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8DF1916A4CE; Thu, 27 May 2004 13:42:25 -0700 (PDT) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 870E443D2F; Thu, 27 May 2004 13:42:24 -0700 (PDT) (envelope-from glebius@cell.sick.ru) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.12.9/8.12.8) with ESMTP id i4RKgJvw039077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 28 May 2004 00:42:20 +0400 (MSD) (envelope-from glebius@cell.sick.ru) Received: (from glebius@localhost) by cell.sick.ru (8.12.9/8.12.6/Submit) id i4RKgITO039076; Fri, 28 May 2004 00:42:18 +0400 (MSD) Date: Fri, 28 May 2004 00:42:18 +0400 From: Gleb Smirnoff To: julian@freebsd.org, ru@freebsd.org Message-ID: <20040527204218.GA38818@cell.sick.ru> Mail-Followup-To: Gleb Smirnoff , julian@freebsd.org, ru@freebsd.org, freebsd-net@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.5.6i cc: freebsd-net@freebsd.org Subject: shutdown node VS disconnect all hooks X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2004 20:42:25 -0000 Hi collegues, I'm again with the issue about node destruction process. If you already forgot the problem, I'll remind you: in RELENG_4 node cuts down all its hooks itself from shutdown method, while in HEAD it is done in ng_rmnode() _before_ calling shutdown method. This breaks ng_tee behavior, and as I have noted, having hooks connected in shutdown method may be useful sometimes. OK, If we destroy node in such a sequence 1. nodes shutdown method 2. ng_destroy_hook() on all hooks 3. ng_flush_input_queue() in some cases we may have node be lost when its shutdown method calls NG_NODE_UNREF. Ok, I have tried to put one more ref on node just before calling its shutdown method. Seems like it works! However we may catch panic in nodes which do not expect that ng_type_disconnect() may be called after ng_type_shutdown(). Since RELENG_4 the following nodes had been changed to don't expect this sequence: ng_socket ng_atmllc ng_bridge ng_eiface ng_etf ng_ether ng_frame_relay ng_gif ng_gif_demux ng_iface ng_l2tp ng_lmi ng_mppc ng_one2many ng_ppp ng_pppoe ng_pptpgre ng_rfc1490 ng_source ng_sppp ng_tty ng_vjc ng_vlan They all FREE priv in shutdown method, but use it in disconnect method. The problem can be solved by inserting ng_cutlinks() into beginning of shutdown method for each of above nodes like it is done in RELENG_4. Ok, we need to edit more than 20 nodes to get back ng_tees behavior. I'm sure you don't like it :) So, what about adding one more netgraph method into struct ng_type, say ng_preshutdown_t? This method is called first in ng_rmnode(), and then current shutdown sequence is followed. We will set it to NULL in all existing nodes, and create a method in ng_tee, which calls ng_bypass(). Future implementations may use this method to send "goodbye" messages down hooks when shutting down. And this will be a POLA-friendly solution - we will not lose functionality of RELENG_4 (which mpd relies on), and we will not break nodes which rely on current shutdown sequence. What's your opinion? If it is positive - I'll send patches. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE