From owner-freebsd-current Fri Dec 20 8:33: 2 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A538F37B401; Fri, 20 Dec 2002 08:33:00 -0800 (PST) Received: from bluejay.mail.pas.earthlink.net (bluejay.mail.pas.earthlink.net [207.217.120.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 22C8643ED8; Fri, 20 Dec 2002 08:33:00 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from [216.20.231.174] (helo=mindspring.com) by bluejay.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 18PQ4N-0006Ac-00; Fri, 20 Dec 2002 08:32:15 -0800 Message-ID: <3E0345B2.9E7D4C74@mindspring.com> Date: Fri, 20 Dec 2002 08:30:42 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: kalts@estpak.ee Cc: Sam Leffler , Hiten Pandya , Darren Reed , current@FreeBSD.ORG, darrenr@FreeBSD.ORG Subject: Re: PFIL_HOOKS should be made default in 5.0 References: <0a6201c2a6f9$42cfd720$52557f42@errno.com> <200212200127.MAA20942@avalon.reed.wattle.id.au> <20021220032930.GA67469@unixdaemons.com> <0e5401c2a7e1$37149090$52557f42@errno.com> <0e9701c2a7e2$cbe1de20$52557f42@errno.com> <20021220105251.GA1296@tiiu.internal> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a44f733c015be53a896dced6307a3d0ec1a7ce0e8f8d31aa3f350badd9bab72f9c350badd9bab72f9c Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Vallo Kallaste wrote: > On Thu, Dec 19, 2002 at 08:46:44PM -0800, Sam Leffler wrote: > > > #ifndef PFIL_HOOKS > > > #error "You must specify PFIL_HOOKS when using ipfilter" > > > #endif > > > > > > Unfortunately there's no way that I know to express this if ipfilter is > > > loaded as a module. > > > > Duh, there'll probably be unresolved symbols if you try to load ipl.ko w/o > > PFIL_HOOKS defined in the kernel. > > Yes, and this "undefined symbols" message will make no sense from > user perspective. Then fix it. The fix is trivial: 1) Create accessor/mutator functions which are *not* protected by "#ifndef PFIL_HOOKS". 2) Use the accessor/mutator functions from within the ipfilter code to register and deregister use of the hooks. 3) In the case of the "#ifndef PFIL_HOOKS", cause the accessor/mutator functions to return errors. Like so: #ifdef PFIL_HOOKS pfil_hook_t *pfil_hook_func; #endif int pfil_set_hook( pfil_hook_t *func) { #ifdef PFIL_HOOKS pfil_hook_func = func; return( 0); #else /* !PFIL_HOOKS */ return( -1); #endif /* !PFIL_HOOKS */ } ...the (in this example) mutator function will always be defined, and the error in a kernel without "PFIL_HOOKS" defined can be trapped by the caller during the module registration phase, at which point a console error can be printed. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message