From owner-freebsd-net@FreeBSD.ORG Thu Apr 29 03:12:22 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 085AF16A4CE for ; Thu, 29 Apr 2004 03:12:22 -0700 (PDT) Received: from artis.latnet.lv (artis.latnet.lv [159.148.107.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7751D43D2D for ; Thu, 29 Apr 2004 03:12:21 -0700 (PDT) (envelope-from artis@fbsd.lv) Received: from artis.latnet.lv (localhost [127.0.0.1]) by artis.latnet.lv (Postfix) with ESMTP id D5B5CC109 for ; Thu, 29 Apr 2004 13:12:17 +0300 (EEST) To: net@freebsd.org From: Artis Caune Content-Type: text/plain; format=flowed; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Thu, 29 Apr 2004 13:12:17 +0300 Message-ID: User-Agent: Opera7.23/FreeBSD M2 build 518 Subject: 'struct ifnet' question! 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, 29 Apr 2004 10:12:22 -0000 I'm writing kld module for traffic shaping (5.x only). It use PFIL hooks. There will be seperate decision trees for every interface + IN/OUT pair. Let's say we have rules: shape in on fxp0 ... shape out on fxp0 ... shape in on vlan0 ... in this example we have 3 decision trees: - rules with 'fxp0 in' - rules with 'fxp0 out' - rules with 'vlan0 in' When PFIL pass packet, I need find pointer to right decision tree: tree = find_decision_tree(ifp->if_xname, direction); Yeh, this works as expected, but I wonder if I can use ifp->index instead of ifp->if_xname. Using 'index + array pointer feature' I can find decision tree in just one? memory access step, compared to if_xname where I should make expensive strcmp() calls. ;) I'm worried about 'dynamic' interfaces. e.x: # ifconfig vlan0 create; ... # load rules with 'shape in on vlan0' # ifconfig vlan0 destroy # ifconfig vlan0 create; ... I belive at this point if_index is not the same when rules was loaded. How safe is to use if_index instead of if_xname? How safe is to use if_xname with interface renaming feature (-current)? Is there some way to track interface changes events? thanks, -- Artis