Date: Thu, 27 May 2004 16:33:28 -0700 (PDT) From: Julian Elischer <julian@elischer.org> To: Gleb Smirnoff <glebius@cell.sick.ru> Cc: freebsd-net@freebsd.org Subject: Re: shutdown node VS disconnect all hooks Message-ID: <Pine.BSF.4.21.0405271628360.69401-100000@InterJet.elischer.org> In-Reply-To: <20040527204218.GA38818@cell.sick.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
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 >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0405271628360.69401-100000>