diff options
| author | Brian Feldman <green@FreeBSD.org> | 2004-10-11 03:45:57 +0000 |
|---|---|---|
| committer | Brian Feldman <green@FreeBSD.org> | 2004-10-11 03:45:57 +0000 |
| commit | e4d22827fecfaca1b471bd8c2acb193efe18cdff (patch) | |
| tree | 156bb1021f884ceaa77f2b24f80220ad04f279cc | |
| parent | a56aeb1e8c10dbd9dfb48d5939849a1d90736aa7 (diff) | |
MFC r1.11: fail closed when lock acquisition would block.
Approved by: re
Notes
svn path=/stable/5/; revision=136364
| -rw-r--r-- | sys/net/pfil.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/net/pfil.c b/sys/net/pfil.c index f5fff2a8fcab..bfd382db6bed 100644 --- a/sys/net/pfil.c +++ b/sys/net/pfil.c @@ -119,8 +119,16 @@ pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp, struct mbuf *m = *mp; int rv = 0; - if (ph->ph_busy_count == -1 || ph->ph_want_write) - return (0); + /* + * Prevent packet filtering from starving the modification of + * the packet filters. We would prefer a reader/writer locking + * mechanism with guaranteed ordering, though. + */ + if (ph->ph_busy_count == -1 || ph->ph_want_write) { + m_freem(*mp); + *mp = NULL; + return (ENOBUFS); + } PFIL_RLOCK(ph); for (pfh = pfil_hook_get(dir, ph); pfh != NULL; |
