From owner-freebsd-net@FreeBSD.ORG Thu May 27 16:34:05 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 3CE8516A4CE; Thu, 27 May 2004 16:34:05 -0700 (PDT) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id E848943D3F; Thu, 27 May 2004 16:34:03 -0700 (PDT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([24.7.73.28]) by comcast.net (rwcrmhc11) with ESMTP id <2004052723332901300f78tce>; Thu, 27 May 2004 23:33:30 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id QAA72249; Thu, 27 May 2004 16:33:29 -0700 (PDT) Date: Thu, 27 May 2004 16:33:28 -0700 (PDT) From: Julian Elischer To: Gleb Smirnoff In-Reply-To: <20040527204218.GA38818@cell.sick.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@freebsd.org Subject: Re: 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 23:34:05 -0000 On Fri, 28 May 2004, Gleb Smirnoff wrote: > 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 :) there are other reasons why this can not work. That is why it was changed from 4.x. > > 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. That sounds like a much better solution. Node shutdown is done in 2 parts just as node connection is done in 2 parts. > 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. > That is a very workable solution. ng_warn_shutdown() ng_cutlinks() ng_shutdown() > -- > Totus tuus, Glebius. > GLEBIUS-RIPN GLEB-RIPE >