summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/lib
diff options
context:
space:
mode:
authorcy <cy@FreeBSD.org>2017-02-25 08:07:28 +0000
committercy <cy@FreeBSD.org>2017-02-25 08:07:28 +0000
commit0fd4791f489330f590c942d369d6a65289f8562b (patch)
tree5302b6d4bbff4baf8339fe8266f05416478d8cd3 /contrib/ipfilter/lib
parent0849c1ca0a522335f3fd659afe2e3f39e3b3e0f1 (diff)
downloadFreeBSD-src-0fd4791f489330f590c942d369d6a65289f8562b.zip
FreeBSD-src-0fd4791f489330f590c942d369d6a65289f8562b.tar.gz
MFC r312787:
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
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 24d00a5..f2f2ed1 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;
OpenPOWER on IntegriCloud