NetBSD Problem Report #51941

From ryo@nerv.org  Fri Feb  3 07:07:59 2017
Return-Path: <ryo@nerv.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 4AC997A21A
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  3 Feb 2017 07:07:59 +0000 (UTC)
Message-Id: <20170203070754.264851CC0D2@yaml.nerv.org>
Date: Fri,  3 Feb 2017 16:07:54 +0900 (JST)
From: ryo@nerv.org
Reply-To: ryo@nerv.org
To: gnats-bugs@NetBSD.org
Subject: pfil_{add,remove}_ihook, pfil_run_{addr,if}hooks are not exist in pfil.9
X-Send-Pr-Version: 3.95

>Number:         51941
>Category:       bin
>Synopsis:       pfil_{add,remove}_ihook, pfil_run_{addr,if}hooks are not exist in pfil.9
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 03 07:10:00 +0000 2017
>Closed-Date:    Wed Jan 17 10:32:23 +0000 2018
>Last-Modified:  Wed Jan 17 10:32:23 +0000 2018
>Originator:     Ryo Shimizu
>Release:        NetBSD 7.99.59
>Organization:
>Environment:
System: NetBSD n 7.99.59 NetBSD 7.99.59 (GENERIC-PF) #5: Wed Feb  1 20:30:04 JST 2017  ryo@n:/usr/src/sys/arch/amd64/compile/GENERIC-PF amd64
Architecture: x86_64
Machine: amd64
>Description:
Descriptions for pfil_{add,remove}_ihook, pfil_run_{addr,if}hooks are not exist in pfil.9
>How-To-Repeat:
>Fix:
Apply this patch.
but my english is poor, please correct appropriately.

diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi
index 0af2a62..f49a489 100644
--- a/distrib/sets/lists/comp/mi
+++ b/distrib/sets/lists/comp/mi
@@ -10799,13 +10799,17 @@
 ./usr/share/man/cat9/percpu_putref.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil_add_hook.0		comp-sys-catman		.cat
+./usr/share/man/cat9/pfil_add_ihook.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil_get_head.0		comp-obsolete		obsolete
 ./usr/share/man/cat9/pfil_head_get.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil_head_register.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil_head_unregister.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil_hook_get.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil_remove_hook.0		comp-sys-catman		.cat
+./usr/share/man/cat9/pfil_remove_ihook.0	comp-sys-catman		.cat
+./usr/share/man/cat9/pfil_run_addrhooks.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/pfil_run_hooks.0		comp-sys-catman		.cat
+./usr/share/man/cat9/pfil_run_ifhooks.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pfind.0			comp-obsolete		obsolete
 ./usr/share/man/cat9/pg_find.0			comp-obsolete		obsolete
 ./usr/share/man/cat9/pgfind.0			comp-obsolete		obsolete
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index 719a315..d9bbe36 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -641,10 +641,14 @@ MLINKS+=percpu.9 percpu_alloc.9 \
 MLINKS+=pfil.9 pfil_hook_get.9 \
 	pfil.9 pfil_add_hook.9 \
 	pfil.9 pfil_remove_hook.9 \
+	pfil.9 pfil_add_ihook.9 \
+	pfil.9 pfil_remove_ihook.9 \
 	pfil.9 pfil_head_register.9 \
 	pfil.9 pfil_head_unregister.9 \
 	pfil.9 pfil_head_get.9 \
-	pfil.9 pfil_run_hooks.9
+	pfil.9 pfil_run_hooks.9 \
+	pfil.9 pfil_run_addrhooks.9 \
+	pfil.9 pfil_run_ifhooks.9
 MLINKS+=pmap.9 pmap_init.9 \
 	pmap.9 pmap_virtual_space.9 \
 	pmap.9 pmap_steal_memory.9 \
diff --git a/share/man/man9/pfil.9 b/share/man/man9/pfil.9
index b823f03..a39ac60 100644
--- a/share/man/man9/pfil.9
+++ b/share/man/man9/pfil.9
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 1, 2016
+.Dd February 3, 2017
 .Dt PFIL 9
 .Os
 .Sh NAME
@@ -35,7 +35,11 @@
 .Nm pfil_hook_get ,
 .Nm pfil_add_hook ,
 .Nm pfil_remove_hook ,
-.Nm pfil_run_hooks
+.Nm pfil_run_hooks ,
+.Nm pfil_add_ihook ,
+.Nm pfil_remove_ihook ,
+.Nm pfil_run_addrhooks ,
+.Nm pfil_run_ifhooks
 .Nd packet filter interface
 .Sh SYNOPSIS
 .In sys/param.h
@@ -58,6 +62,16 @@
 .Fn (*func) "void *arg" "struct mbuf **mp" "struct ifnet *" "int dir"
 .Ft int
 .Fn pfil_run_hooks "struct pfil_head *ph" "struct mbuf **mp" "struct ifnet *ifp" "int dir"
+.Ft int
+.Fn pfil_add_ihook "void (*ifunc)()" "void *arg" "int flags" "struct pfil_head *ph"
+.Ft int
+.Fn pfil_remove_ihook "void (*ifunc)()" "void *arg" "int flags" "struct pfil_head *ph"
+.Ft void
+.Fn (*ifunc) "void *arg" "unsigned long cmd" "void *ptr"
+.Ft void
+.Fn pfil_run_addrhooks "struct pfil_head *ph" "unsigned long" "struct ifaddr *ifa"
+.Ft void
+.Fn pfil_run_ifhooks "struct pfil_head *ph" "unsigned long" "struct ifnet *ifp"
 .Sh DESCRIPTION
 The
 .Nm
@@ -120,22 +134,45 @@ and
 .Fn pfil_remove_hook
 functions, indicates when the filter should be called.
 The flags are:
-.Bl -tag -offset indent -width PFIL_WAITOK -compact
+.Bl -tag -offset indent -width PFIL_ALL -compact
 .It PFIL_IN
 call me on incoming packets
 .It PFIL_OUT
 call me on outgoing packets
 .It PFIL_ALL
 call me on all of the above
+.Pp
+.El
+.Pp
+By the same token, Event handlers register/unregister themselves
+with the
+.Fn pfil_add_ihook
+and
+.Fn pfil_remove_ihook
+functions, respectively.
+The event handler is called with its specified argument, the event id
+.Dv ( PFIL_IFNET_ATTACH
+or
+.Dv PFIL_IFNET_DETACH ,
+see also below) or ioctl number, and the pointer
+to the network interface or the pointer to the ifaddr.
+.Pp
+The
+.Em flags
+parameter, used in the
+.Fn pfil_add_ihook
+and
+.Fn pfil_remove_ihook
+functions, indicates when the filter should be called.
+The flags are:
+.Bl -tag -offset indent -width PFIL_IFADDR -compact
 .It PFIL_IFADDR
-call me on interface reconfig (mbuf ** is ioctl #)
+call me on interface reconfig (cmd is ioctl #)
 .It PFIL_IFNET
-call me on interface attach/detach (mbuf ** is either
+call me on interface attach/detach (cmd is either
 .Dv PFIL_IFNET_ATTACH
 or
 .Dv PFIL_IFNET_DETACH )
-.It PFIL_WAITOK
-OK to call malloc with M_WAITOK.
 .El
 .Sh SEE ALSO
 .Xr bpf 4
@@ -171,6 +208,12 @@ In 1.5K, the
 .Nm
 framework was changed to work with an arbitrary number of filtering points,
 as well as be less IP-centric.
+.Pp
+In 8.0,
+.Fn pfil_add_ihook
+and
+.Fn pfil_remove_ihook
+were added.
 .Sh AUTHORS
 .An -nosplit
 The

>Release-Note:

>Audit-Trail:
From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51941 CVS commit: src
Date: Wed, 17 Jan 2018 02:45:39 +0000

 Module Name:	src
 Committed By:	maya
 Date:		Wed Jan 17 02:45:38 UTC 2018

 Modified Files:
 	src/distrib/sets/lists/comp: mi
 	src/share/man/man9: Makefile pfil.9

 Log Message:
 document pfil_{add,remove}_ihook, pfil_run_{addr,if}hooks

 from ryo shimizu in PR bin/51941

 changes by myself: fix mdoc -Tlint, add missing set lists, adjust date
 to today, reword history addition.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2169 -r1.2170 src/distrib/sets/lists/comp/mi
 cvs rdiff -u -r1.417 -r1.418 src/share/man/man9/Makefile
 cvs rdiff -u -r1.35 -r1.36 src/share/man/man9/pfil.9

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Wed, 17 Jan 2018 10:32:23 +0000
State-Changed-Why:
I added it with the changes mentioned in the commit message. thanks for the patch!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.