Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Dec 2002 08:30:42 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        kalts@estpak.ee
Cc:        Sam Leffler <sam@errno.com>, Hiten Pandya <hiten@unixdaemons.com>, Darren Reed <darrenr@reed.wattle.id.au>, current@FreeBSD.ORG, darrenr@FreeBSD.ORG
Subject:   Re: PFIL_HOOKS should be made default in 5.0
Message-ID:  <3E0345B2.9E7D4C74@mindspring.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
Vallo Kallaste wrote:
> On Thu, Dec 19, 2002 at 08:46:44PM -0800, Sam Leffler <sam@errno.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E0345B2.9E7D4C74>