summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormlaier <mlaier@FreeBSD.org>2004-09-29 04:54:33 +0000
committermlaier <mlaier@FreeBSD.org>2004-09-29 04:54:33 +0000
commitb65eae4c193f1c3c9580e5ac2bad5585034743f2 (patch)
treeb760834c7691b17430788d5a6041455045da8ac1 /sys/net
parente455dd69f84961133d47cca1588021dfafac9e28 (diff)
downloadFreeBSD-src-b65eae4c193f1c3c9580e5ac2bad5585034743f2.zip
FreeBSD-src-b65eae4c193f1c3c9580e5ac2bad5585034743f2.tar.gz
Add an additional struct inpcb * argument to pfil(9) in order to enable
passing along socket information. This is required to work around a LOR with the socket code which results in an easy reproducible hard lockup with debug.mpsafenet=1. This commit does *not* fix the LOR, but enables us to do so later. The missing piece is to turn the filter locking into a leaf lock and will follow in a seperate (later) commit. This will hopefully be MT5'ed in order to fix the problem for RELENG_5 in forseeable future. Suggested by: rwatson A lot of work by: csjp (he'd be even more helpful w/o mentor-reviews ;) Reviewed by: rwatson, csjp Tested by: -pf, -ipfw, LINT, csjp and myself MFC after: 3 days LOR IDs: 14 - 17 (not fixed yet)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bridge.c2
-rw-r--r--sys/net/pfil.c12
-rw-r--r--sys/net/pfil.h9
3 files changed, 12 insertions, 11 deletions
diff --git a/sys/net/bridge.c b/sys/net/bridge.c
index 1d4472e..75f7c30 100644
--- a/sys/net/bridge.c
+++ b/sys/net/bridge.c
@@ -1009,7 +1009,7 @@ bdg_forward(struct mbuf *m0, struct ifnet *dst)
ip->ip_len = ntohs(ip->ip_len);
ip->ip_off = ntohs(ip->ip_off);
- if (pfil_run_hooks(&inet_pfil_hook, &m0, src, PFIL_IN) != 0) {
+ if (pfil_run_hooks(&inet_pfil_hook, &m0, src, PFIL_IN, NULL) != 0) {
/* NB: hook should consume packet */
return NULL;
}
diff --git a/sys/net/pfil.c b/sys/net/pfil.c
index 942607c..f5fff2a 100644
--- a/sys/net/pfil.c
+++ b/sys/net/pfil.c
@@ -52,7 +52,7 @@ MTX_SYSINIT(pfil_heads_lock, &pfil_global_lock, "pfil_head_list lock", MTX_DEF);
static int pfil_list_add(pfil_list_t *, struct packet_filter_hook *, int);
static int pfil_list_remove(pfil_list_t *,
- int (*)(void *, struct mbuf **, struct ifnet *, int), void *);
+ int (*)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *), void *);
LIST_HEAD(, pfil_head) pfil_head_list =
LIST_HEAD_INITIALIZER(&pfil_head_list);
@@ -113,7 +113,7 @@ PFIL_WUNLOCK(struct pfil_head *ph)
*/
int
pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp,
- int dir)
+ int dir, struct inpcb *inp)
{
struct packet_filter_hook *pfh;
struct mbuf *m = *mp;
@@ -126,7 +126,7 @@ pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp,
for (pfh = pfil_hook_get(dir, ph); pfh != NULL;
pfh = TAILQ_NEXT(pfh, pfil_link)) {
if (pfh->pfil_func != NULL) {
- rv = (*pfh->pfil_func)(pfh->pfil_arg, &m, ifp, dir);
+ rv = (*pfh->pfil_func)(pfh->pfil_arg, &m, ifp, dir, inp);
if (rv != 0 || m == NULL)
break;
}
@@ -233,7 +233,7 @@ pfil_head_get(int type, u_long val)
* PFIL_WAITOK OK to call malloc with M_WAITOK.
*/
int
-pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int),
+pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *),
void *arg, int flags, struct pfil_head *ph)
{
struct packet_filter_hook *pfh1 = NULL;
@@ -305,7 +305,7 @@ error:
* hook list.
*/
int
-pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int),
+pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *),
void *arg, int flags, struct pfil_head *ph)
{
int err = 0;
@@ -361,7 +361,7 @@ pfil_list_add(pfil_list_t *list, struct packet_filter_hook *pfh1, int flags)
*/
static int
pfil_list_remove(pfil_list_t *list,
- int (*func)(void *, struct mbuf **, struct ifnet *, int), void *arg)
+ int (*func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *), void *arg)
{
struct packet_filter_hook *pfh;
diff --git a/sys/net/pfil.h b/sys/net/pfil.h
index 5400a72..ed5a3d0 100644
--- a/sys/net/pfil.h
+++ b/sys/net/pfil.h
@@ -40,6 +40,7 @@
struct mbuf;
struct ifnet;
+struct inpcb;
/*
* The packet filter hooks are designed for anything to call them to
@@ -47,7 +48,7 @@ struct ifnet;
*/
struct packet_filter_hook {
TAILQ_ENTRY(packet_filter_hook) pfil_link;
- int (*pfil_func)(void *, struct mbuf **, struct ifnet *, int);
+ int (*pfil_func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *);
void *pfil_arg;
int pfil_flags;
};
@@ -84,12 +85,12 @@ struct pfil_head {
};
int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *,
- int);
+ int, struct inpcb *inp);
int pfil_add_hook(int (*func)(void *, struct mbuf **,
- struct ifnet *, int), void *, int, struct pfil_head *);
+ struct ifnet *, int, struct inpcb *), void *, int, struct pfil_head *);
int pfil_remove_hook(int (*func)(void *, struct mbuf **,
- struct ifnet *, int), void *, int, struct pfil_head *);
+ struct ifnet *, int, struct inpcb *), void *, int, struct pfil_head *);
int pfil_head_register(struct pfil_head *);
int pfil_head_unregister(struct pfil_head *);
OpenPOWER on IntegriCloud