Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys pfil(9) improvements to handle address changes:
details: https://anonhg.NetBSD.org/src/rev/2c682c760b17
branches: trunk
changeset: 349875:2c682c760b17
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 26 23:21:49 2016 +0000
description:
pfil(9) improvements to handle address changes:
Add:
PFIL_IFADDR call on interface reconfig (mbuf is ioctl #)
PFIL_IFNET call on interface attach/detach (mbuf is PFIL_IFNET_*)
from rmind@
diffstat:
sys/dist/pf/net/pf_if.c | 34 +++-----
sys/external/bsd/ipf/netinet/ip_fil_netbsd.c | 30 ++++++-
sys/net/if.c | 12 +-
sys/net/if_pppoe.c | 10 +-
sys/net/if_spppsubr.c | 10 +-
sys/net/pfil.c | 102 ++++++++++++++++++++------
sys/net/pfil.h | 12 ++-
7 files changed, 140 insertions(+), 70 deletions(-)
diffs (truncated from 553 to 300 lines):
diff -r a2e29183b53c -r 2c682c760b17 sys/dist/pf/net/pf_if.c
--- a/sys/dist/pf/net/pf_if.c Mon Dec 26 23:15:15 2016 +0000
+++ b/sys/dist/pf/net/pf_if.c Mon Dec 26 23:21:49 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pf_if.c,v 1.31 2016/07/20 07:37:51 ozaki-r Exp $ */
+/* $NetBSD: pf_if.c,v 1.32 2016/12/26 23:21:49 christos Exp $ */
/* $OpenBSD: pf_if.c,v 1.47 2007/07/13 09:17:48 markus Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.31 2016/07/20 07:37:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.32 2016/12/26 23:21:49 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -87,8 +87,8 @@
void pfi_init_groups(struct ifnet *);
void pfi_destroy_groups(struct ifnet *);
-int pfil_ifnet_wrapper(void *, struct mbuf **, struct ifnet *, int);
-int pfil_ifaddr_wrapper(void *, struct mbuf **, struct ifnet *, int);
+void pfil_ifnet_wrapper(void *, u_long, void *);
+void pfil_ifaddr_wrapper(void *, u_long, void *);
#endif
RB_PROTOTYPE(pfi_ifhead, pfi_kif, pfik_tree, pfi_if_compare);
@@ -138,8 +138,8 @@
pserialize_read_exit(s);
curlwp_bindx(bound);
- pfil_add_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
- pfil_add_hook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
+ pfil_add_ihook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
+ pfil_add_ihook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
#endif /* __NetBSD__ */
}
@@ -152,8 +152,8 @@
int s;
int bound;
- pfil_remove_hook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
- pfil_remove_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
+ pfil_remove_ihook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
+ pfil_remove_ihook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
bound = curlwp_bind();
s = pserialize_read_enter();
@@ -885,10 +885,10 @@
if_destroy_groups(ifp);
}
-int
-pfil_ifnet_wrapper(void *arg, struct mbuf **mp, struct ifnet *ifp, int dir)
+void
+pfil_ifnet_wrapper(void *arg, u_long cmd, void *arg2)
{
- u_long cmd = (u_long)mp;
+ ifnet_t *ifp = arg2;
switch (cmd) {
case PFIL_IFNET_ATTACH:
@@ -904,14 +904,12 @@
default:
panic("pfil_ifnet_wrapper: unexpected cmd %lu", cmd);
}
-
- return (0);
}
-int
-pfil_ifaddr_wrapper(void *arg, struct mbuf **mp, struct ifnet *ifp, int dir)
+void
+pfil_ifaddr_wrapper(void *arg, u_long cmd, void *arg2)
{
- u_long cmd = (u_long)mp;
+ struct ifaddr *ifa = arg2;
switch (cmd) {
case SIOCSIFADDR:
@@ -921,12 +919,10 @@
case SIOCAIFADDR_IN6:
case SIOCDIFADDR_IN6:
#endif /* INET6 */
- pfi_kifaddr_update(ifp->if_pf_kif);
+ pfi_kifaddr_update(ifa->ifa_ifp->if_pf_kif);
break;
default:
panic("pfil_ifaddr_wrapper: unexpected ioctl %lu", cmd);
}
-
- return (0);
}
#endif /* __NetBSD__ */
diff -r a2e29183b53c -r 2c682c760b17 sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
--- a/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Mon Dec 26 23:15:15 2016 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Mon Dec 26 23:21:49 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_fil_netbsd.c,v 1.19 2016/12/08 05:16:33 ozaki-r Exp $ */
+/* $NetBSD: ip_fil_netbsd.c,v 1.20 2016/12/26 23:21:49 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -8,7 +8,7 @@
#if !defined(lint)
#if defined(__NetBSD__)
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.19 2016/12/08 05:16:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.20 2016/12/26 23:21:49 christos Exp $");
#else
static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-2000 Darren Reed";
static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp";
@@ -268,10 +268,13 @@
# if defined(PFIL_TYPE_IFNET) && defined(PFIL_IFNET)
-static int ipf_pfilsync(void *, struct mbuf **, struct ifnet *, int);
+
+# if (__NetBSD_Version__ >= 799000400)
-static int
-ipf_pfilsync(void *hdr, struct mbuf **mp, struct ifnet *ifp, int dir)
+static void ipf_pfilsync(void *, unsigned long, void *);
+
+static void
+ipf_pfilsync(void *hdr, unsigned long cmd, void *arg2)
{
/*
* The interface pointer is useless for create (we have nothing to
@@ -281,8 +284,20 @@
* pointer, so it's not much use then, either.
*/
ipf_sync(&ipfmain, NULL);
+}
+
+# else
+
+static int ipf_pfilsync(void *, struct mbuf **, struct ifnet *, int);
+
+static int
+ipf_pfilsync(void *hdr, struct mbuf **mp, struct ifnet *ifp, int dir)
+{
+ ipf_sync(&ipfmain, NULL);
return 0;
}
+
+# endif
# endif
#endif /* __NetBSD_Version__ >= 105110000 */
@@ -445,8 +460,13 @@
# if defined(PFIL_TYPE_IFNET) && defined(PFIL_IFNET)
if (ph_ifsync != NULL)
+#if (__NetBSD_Version__ >= 799000400)
(void) pfil_add_hook((void *)ipf_pfilsync, NULL,
PFIL_IFNET, ph_ifsync);
+#else
+ (void) pfil_add_hook((void *)ipf_pfilsync, NULL,
+ PFIL_IFNET, ph_ifsync);
+#endif
# endif
#endif
diff -r a2e29183b53c -r 2c682c760b17 sys/net/if.c
--- a/sys/net/if.c Mon Dec 26 23:15:15 2016 +0000
+++ b/sys/net/if.c Mon Dec 26 23:21:49 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.368 2016/12/15 09:28:06 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.369 2016/12/26 23:21:49 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.368 2016/12/15 09:28:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.369 2016/12/26 23:21:49 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -194,7 +194,7 @@
static int if_cloners_count;
/* Packet filtering hook for interfaces. */
-pfil_head_t * if_pfil;
+pfil_head_t * if_pfil __read_mostly;
static kauth_listener_t if_listener;
@@ -690,8 +690,7 @@
IFQ_LOCK_INIT(&ifp->if_snd);
ifp->if_pfil = pfil_head_create(PFIL_TYPE_IFNET, ifp);
- (void)pfil_run_hooks(if_pfil,
- (struct mbuf **)PFIL_IFNET_ATTACH, ifp, PFIL_IFNET);
+ pfil_run_ifhooks(if_pfil, PFIL_IFNET_ATTACH, ifp);
IF_AFDATA_LOCK_INIT(ifp);
@@ -1433,8 +1432,7 @@
}
}
- (void)pfil_run_hooks(if_pfil,
- (struct mbuf **)PFIL_IFNET_DETACH, ifp, PFIL_IFNET);
+ pfil_run_ifhooks(if_pfil, PFIL_IFNET_DETACH, ifp);
(void)pfil_head_destroy(ifp->if_pfil);
/* Announce that the interface is gone. */
diff -r a2e29183b53c -r 2c682c760b17 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c Mon Dec 26 23:15:15 2016 +0000
+++ b/sys/net/if_pppoe.c Mon Dec 26 23:21:49 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.121 2016/12/16 08:47:36 knakahara Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.122 2016/12/26 23:21:49 christos Exp $ */
/*-
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.121 2016/12/16 08:47:36 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.122 2016/12/26 23:21:49 christos Exp $");
#ifdef _KERNEL_OPT
#include "pppoe.h"
@@ -235,7 +235,7 @@
struct ifnet *, krw_t);
static struct mbuf *pppoe_get_mbuf(size_t len);
-static int pppoe_ifattach_hook(void *, struct mbuf **, struct ifnet *, int);
+static void pppoe_ifattach_hook(void *, u_long, void *);
static LIST_HEAD(pppoe_softc_head, pppoe_softc) pppoe_softc_list;
static krwlock_t pppoe_softc_list_lock;
@@ -339,7 +339,7 @@
bpf_attach(&sc->sc_sppp.pp_if, DLT_PPP_ETHER, 0);
if (LIST_EMPTY(&pppoe_softc_list)) {
- pfil_add_hook(pppoe_ifattach_hook, NULL, PFIL_IFNET, if_pfil);
+ pfil_add_ihook(pppoe_ifattach_hook, NULL, PFIL_IFNET, if_pfil);
}
sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
@@ -364,7 +364,7 @@
LIST_REMOVE(sc, sc_list);
if (LIST_EMPTY(&pppoe_softc_list)) {
- pfil_remove_hook(pppoe_ifattach_hook, NULL, PFIL_IFNET, if_pfil);
+ pfil_remove_ihook(pppoe_ifattach_hook, NULL, PFIL_IFNET, if_pfil);
}
rw_exit(&pppoe_softc_list_lock);
diff -r a2e29183b53c -r 2c682c760b17 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c Mon Dec 26 23:15:15 2016 +0000
+++ b/sys/net/if_spppsubr.c Mon Dec 26 23:21:49 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_spppsubr.c,v 1.163 2016/12/13 00:35:11 knakahara Exp $ */
+/* $NetBSD: if_spppsubr.c,v 1.164 2016/12/26 23:21:49 christos Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.163 2016/12/13 00:35:11 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.164 2016/12/26 23:21:49 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -5290,8 +5290,7 @@
ifp->if_xname, __func__, error);
}
if (!error) {
- (void)pfil_run_hooks(if_pfil,
- (struct mbuf **)SIOCAIFADDR, ifp, PFIL_IFADDR);
+ pfil_run_addrhooks(if_pfil, SIOCAIFADDR, ifa);
}
}
@@ -5521,8 +5520,7 @@
ifp->if_xname, __func__, error);
}
if (!error) {
- (void)pfil_run_hooks(if_pfil,
- (struct mbuf **)SIOCAIFADDR_IN6, ifp, PFIL_IFADDR);
+ pfil_run_addrhooks(if_pfil, SIOCAIFADDR_IN6, ifa);
}
}
}
diff -r a2e29183b53c -r 2c682c760b17 sys/net/pfil.c
--- a/sys/net/pfil.c Mon Dec 26 23:15:15 2016 +0000
+++ b/sys/net/pfil.c Mon Dec 26 23:21:49 2016 +0000
Home |
Main Index |
Thread Index |
Old Index