fix dynaddr tracking.

from Peter Postma, PR/26369.
ok'ed by itojun.
This commit is contained in:
yamt 2004-07-26 13:46:43 +00:00
parent 4f755d07b4
commit 46abcaebe4
2 changed files with 42 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pf_if.c,v 1.4 2004/07/26 13:45:40 yamt Exp $ */
/* $NetBSD: pf_if.c,v 1.5 2004/07/26 13:46:43 yamt Exp $ */
/* $OpenBSD: pf_if.c,v 1.11 2004/03/15 11:38:23 cedric Exp $ */
/*
@ -87,6 +87,9 @@ char pfi_interface_ruleset[PF_RULESET_NAME_SIZE] =
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 @@ RB_GENERATE(pfi_ifhead, pfi_kif, pfik_tree, pfi_if_compare);
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 @@ pfi_kifaddr_update(void *v)
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 @@ pfi_unmask(void *addr)
void
pfi_dohooks(struct pfi_kif *p)
{
#ifdef __OpenBSD__
for (; p != NULL; p = p->pfik_parent)
dohooks(p->pfik_ah_head, 0);
#endif
}
int
@ -941,4 +955,23 @@ hook_disestablish(struct hook_desc_head *head, void *vhook)
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

View File

@ -1,4 +1,4 @@
/* $NetBSD: pf_ioctl.c,v 1.7 2004/07/26 13:43:14 yamt Exp $ */
/* $NetBSD: pf_ioctl.c,v 1.8 2004/07/26 13:46:43 yamt Exp $ */
/* $OpenBSD: pf_ioctl.c,v 1.112 2004/03/22 04:54:18 mcbride Exp $ */
/*
@ -2797,7 +2797,7 @@ pfil6_wrapper(void *arg, struct mbuf **mp, struct ifnet *ifp, int dir)
}
#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 @@ pfil_if_wrapper(void *arg, struct mbuf **mp, struct ifnet *ifp, int dir)
case SIOCSIFADDR:
case SIOCAIFADDR:
case SIOCDIFADDR:
pfi_kifaddr_update((struct ifnet *)arg);
case SIOCAIFADDR_IN6:
case SIOCDIFADDR_IN6:
pfi_kifaddr_update_if(ifp);
break;
default:
panic("unexpected ioctl");