From owner-freebsd-net@FreeBSD.ORG Fri Dec 14 17:02:06 2012 Return-Path: Delivered-To: freebsd-net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 31EE8E9B; Fri, 14 Dec 2012 17:02:06 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 47EEE8FC13; Fri, 14 Dec 2012 17:02:04 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id TAA29490; Fri, 14 Dec 2012 19:02:03 +0200 (EET) (envelope-from avg@FreeBSD.org) Message-ID: <50CB5B8A.8030703@FreeBSD.org> Date: Fri, 14 Dec 2012 19:02:02 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Ermal_Lu=E7i?= Subject: Re: ng_ether naming References: <50C9C012.8020306@FreeBSD.org> <50C9C55A.5090900@ipfw.ru> <50CA0161.1060000@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.4.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Cc: freebsd-net , "Alexander V. Chernikov" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 17:02:06 -0000 on 13/12/2012 20:57 Ermal Luçi said the following: > > > > On Thu, Dec 13, 2012 at 5:25 PM, Andriy Gapon > wrote: > > on 13/12/2012 14:08 Alexander V. Chernikov said the following: > > On 13.12.2012 15:46, Andriy Gapon wrote: > >> > >> ng_ether uses if_xname for naming its nodes. > >> This could be troublesome for mapping interface names to their ng_ether > companions > >> in the face of interface renaming capability. Especially given that interface > >> renaming and ng_ether _module_ loading may happen in an arbitrary order. > >> > >> I am not sure how to solve this best. > >> > >> One possibility is to use if_dname+if_dunit combination for ng_ether > naming. This > >> should be stable and available for querying. This behavior should also be > >> backward compatible with ng_ether being compiled into kernel > (if_dname+if_dunit == > >> if_xname before any renaming could occur). > >> > >> Another possibility is to do ng_ether renaming when its interface is renamed. > >> This seems nicer but appears to be more work and more intrusive, because > >> interfaces would have to know about their ng_ether nodes. > > > > Not exactly. You can register for ifnet_departure_event and ifnet_arrival_event. > > > > Interface renaming is done via sending departure event with old name and arrvial > > event with new one. > > Good to know. Thank you! > > > So which approach sounds better? > Or maybe there is even a better one? > > > The best is interface event handling. > Just recopy the new name from if_xname and should be done. There is one problem with the current code which would automatically apply to the interface renaming handling. ng_ether does not do any validation or "normalization" of if_xname and the name can contain symbols which are prohibited in a netgraph name, such as '.' for example. ng_name_node would fail and warning would be logged but a node would stay unnamed. I am a bit reluctant to write "netgraph name escaping" code myself. Perhaps it already exists in some place? -- Andriy Gapon