Subject: kern/26369: Fix address change support for pf(4)
To: None <gnats-bugs@gnats.NetBSD.org>
From: Peter Postma <peter@pointless.nl>
List: netbsd-bugs
Date: 07/19/2004 16:07:58
>Number: 26369
>Category: kern
>Synopsis: Fix address change support for pf(4)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 19 14:09:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Peter Postma
>Release: NetBSD 2.0G
>Organization:
>Environment:
System: NetBSD mercury.pointless.nl 2.0G NetBSD 2.0G (mercury) #16: Mon Jul 19 03:41:25 CEST 2004 peter@mercury.pointless.nl:/usr/obj/sys/arch/sparc64/compile/mercury sparc64
Architecture: sparc64
Machine: sparc64
>Description:
Patch below fixes address change support (interface syntax) for pf(4).
Also includes the two ioctls for IPv6 (see PR kern/26368).
>How-To-Repeat:
>Fix:
Index: pf_if.c
===================================================================
RCS file: /cvsroot/src/sys/dist/pf/net/pf_if.c,v
retrieving revision 1.3
diff -u -r1.3 pf_if.c
--- pf_if.c 29 Jun 2004 04:42:55 -0000 1.3
+++ pf_if.c 19 Jul 2004 13:21:44 -0000
@@ -87,6 +87,9 @@
void pfi_dynaddr_update(void *);
void pfi_kifaddr_update(void *);
+#ifdef __NetBSD__
+void pfi_kifaddr_update_if(struct ifnet *);
+#endif
void pfi_table_update(struct pfr_ktable *, struct pfi_kif *,
int, int);
void pfi_instance_add(struct ifnet *, int, int);
@@ -111,6 +114,7 @@
static void *hook_establish(struct hook_desc_head *, int, void (*)(void *),
void *);
static void hook_disestablish(struct hook_desc_head *, void *);
+static void dohooks(struct hook_desc_head *, int);
#define HOOK_REMOVE 0x01
#define HOOK_FREE 0x02
@@ -580,6 +584,19 @@
splx(s);
}
+#ifdef __NetBSD__
+void
+pfi_kifaddr_update_if(struct ifnet *ifp)
+{
+ struct pfi_kif *p;
+
+ p = pfi_lookup_if(ifp->if_xname);
+ if (p == NULL)
+ panic("can't find interface");
+ pfi_kifaddr_update(p);
+}
+#endif
+
int
pfi_if_compare(struct pfi_kif *p, struct pfi_kif *q)
{
@@ -869,11 +886,8 @@
void
pfi_dohooks(struct pfi_kif *p)
{
-
-#ifdef __OpenBSD__
for (; p != NULL; p = p->pfik_parent)
dohooks(p->pfik_ah_head, 0);
-#endif
}
int
@@ -905,11 +919,8 @@
/* from openbsd/sys/kern/kern_subr.c */
#ifdef __NetBSD__
static void *
-hook_establish(head, tail, fn, arg)
- struct hook_desc_head *head;
- int tail;
- void (*fn)(void *);
- void *arg;
+hook_establish(struct hook_desc_head *head, int tail, void (*fn)(void *),
+ void *arg)
{
struct hook_desc *hdp;
@@ -928,9 +939,7 @@
}
static void
-hook_disestablish(head, vhook)
- struct hook_desc_head *head;
- void *vhook;
+hook_disestablish(struct hook_desc_head *head, void *vhook)
{
struct hook_desc *hdp;
@@ -946,4 +955,23 @@
TAILQ_REMOVE(head, hdp, hd_list);
free(hdp, M_DEVBUF);
}
+
+static void
+dohooks(struct hook_desc_head *head, int flags)
+{
+ struct hook_desc *hdp;
+
+ if ((flags & HOOK_REMOVE) == 0) {
+ TAILQ_FOREACH(hdp, head, hd_list) {
+ (*hdp->hd_fn)(hdp->hd_arg);
+ }
+ } else {
+ while ((hdp = TAILQ_FIRST(head)) != NULL) {
+ TAILQ_REMOVE(head, hdp, hd_list);
+ (*hdp->hd_fn)(hdp->hd_arg);
+ if ((flags & HOOK_FREE) != 0)
+ free(hdp, M_DEVBUF);
+ }
+ }
+}
#endif
Index: pf_ioctl.c
===================================================================
RCS file: /cvsroot/src/sys/dist/pf/net/pf_ioctl.c,v
retrieving revision 1.6
diff -u -r1.6 pf_ioctl.c
--- pf_ioctl.c 29 Jun 2004 04:42:55 -0000 1.6
+++ pf_ioctl.c 19 Jul 2004 13:21:46 -0000
@@ -2797,7 +2797,7 @@
}
#endif
-extern void pfi_kifaddr_update(void *);
+extern void pfi_kifaddr_update_if(struct ifnet *);
int
pfil_if_wrapper(void *arg, struct mbuf **mp, struct ifnet *ifp, int dir)
@@ -2811,7 +2811,9 @@
case SIOCSIFADDR:
case SIOCGIFALIAS:
case SIOCDIFADDR:
- pfi_kifaddr_update((struct ifnet *)arg);
+ case SIOCAIFADDR_IN6:
+ case SIOCDIFADDR_IN6:
+ pfi_kifaddr_update_if(ifp);
break;
default:
panic("unexpected ioctl");
>Release-Note:
>Audit-Trail:
>Unformatted: