aboutsummaryrefslogtreecommitdiff
path: root/contrib/ipfilter/lib
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2017-01-26 01:24:05 +0000
committerCy Schubert <cy@FreeBSD.org>2017-01-26 01:24:05 +0000
commit971fa117c030648537a7be8755e7620587e3ae4e (patch)
treecb4b04ffa64c27929da20d50b6f4fe8237f646f2 /contrib/ipfilter/lib
parentcbf1505df9e64a9a4473c09ca0e5e6c0346b5791 (diff)
downloadsrc-971fa117c030648537a7be8755e7620587e3ae4e.tar.gz
src-971fa117c030648537a7be8755e7620587e3ae4e.zip
Currently the fragment info is placed at the top of the linked list
under a shared read lock. This patch attempts to upgrade the lock to an exclusive write lock. If the exclusive write lock fails to be obtained, the current fragment is not placed at the head of the list. This portion of the patch was inspired by NetBSD ip_frag.c r1.4 (which effectively removed the section of code that performed the reordering). The patch to sys/contrib/ipfilter/netinet/ip_compat.h adds the MUTEX_TRY_UPGRADE macro to support the patch to ip_frag.c. The patch to contrib/ipfilter/lib/rwlock_emul.c supports this patch by emulating the mutex in userspace when exercised by ipftest(1). Inspired by: NetBSD ip_frag.c r1.4 MFC after: 1 month
Notes
Notes: svn path=/head/; revision=312787
Diffstat (limited to 'contrib/ipfilter/lib')
-rw-r--r--contrib/ipfilter/lib/rwlock_emul.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/ipfilter/lib/rwlock_emul.c b/contrib/ipfilter/lib/rwlock_emul.c
index 24d00a5772f5..f2f2ed19532a 100644
--- a/contrib/ipfilter/lib/rwlock_emul.c
+++ b/contrib/ipfilter/lib/rwlock_emul.c
@@ -56,6 +56,27 @@ void eMrwlock_write_enter(rw, file, line)
}
+void eMrwlock_try_upgrade(rw, file, line)
+ eMrwlock_t *rw;
+ char *file;
+ int line;
+{
+ if (rw->eMrw_magic != EMM_MAGIC) {
+ fprintf(stderr, "%s:eMrwlock_write_enter(%p): bad magic: %#x\n",
+ rw->eMrw_owner, rw, rw->eMrw_magic);
+ abort();
+ }
+ if (rw->eMrw_read != 0 || rw->eMrw_write != 0) {
+ fprintf(stderr,
+ "%s:eMrwlock_try_upgrade(%p): already locked: %d/%d\n",
+ rw->eMrw_owner, rw, rw->eMrw_read, rw->eMrw_write);
+ abort();
+ }
+ rw->eMrw_write++;
+ rw->eMrw_heldin = file;
+ rw->eMrw_heldat = line;
+}
+
void eMrwlock_downgrade(rw, file, line)
eMrwlock_t *rw;
char *file;