[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 01/98: pfinet: fix emission on the loopback device
From: |
Samuel Thibault |
Subject: |
[hurd] 01/98: pfinet: fix emission on the loopback device |
Date: |
Tue, 14 Jan 2014 01:59:57 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 218cae5a714342b5d82a5b004d58f0a9ebbbfe5e
Author: Richard Braun <address@hidden>
Date: Wed Nov 6 01:44:09 2013 +0100
pfinet: fix emission on the loopback device
Unlike other devices, sending packets on the loopback device causes the
netif_rx() function to be called from the net_bh worker thread. Since
the thread is already running, it can't wake itself up when calling
mark_bh(). Use a new variable to indicate when net_bh work is pending.
* glue-include/linux/interrupt.h (net_bh_raised): Declare new global
variable.
(mark_bh): Set net_bh_raised to 1 before waking up net_bh worker thread.
* loopback.c (loopback_xmit): Add comment giving details about locking.
* sched.c (net_bh_raised): Define new global variable.
(net_bh_worker): Wait for net_bh_raised to become true and reset it
before processing net_bh work.
---
pfinet/glue-include/linux/interrupt.h | 2 ++
pfinet/loopback.c | 7 +++++++
pfinet/sched.c | 7 ++++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/pfinet/glue-include/linux/interrupt.h
b/pfinet/glue-include/linux/interrupt.h
index df58d2f..22312ba 100644
--- a/pfinet/glue-include/linux/interrupt.h
+++ b/pfinet/glue-include/linux/interrupt.h
@@ -21,6 +21,7 @@ extern pthread_mutex_t net_bh_lock;
/* See sched.c::net_bh_worker comments. */
extern pthread_cond_t net_bh_wakeup;
+extern int net_bh_raised;
#define NET_BH 0xb00bee51
@@ -30,6 +31,7 @@ static inline void
mark_bh (int bh)
{
assert (bh == NET_BH);
+ net_bh_raised = 1;
pthread_cond_broadcast (&net_bh_wakeup);
}
diff --git a/pfinet/loopback.c b/pfinet/loopback.c
index 068cf3c..e15e426 100644
--- a/pfinet/loopback.c
+++ b/pfinet/loopback.c
@@ -71,6 +71,13 @@ static int loopback_xmit(struct sk_buff *skb, struct device
*dev)
#ifndef LOOPBACK_MUST_CHECKSUM
skb->ip_summed = CHECKSUM_UNNECESSARY;
#endif
+
+ /*
+ * Calling netif_rx() requires locking net_bh_lock, which
+ * has already been done since this function is called by
+ * the net_bh worker thread.
+ */
+
netif_rx(skb);
stats->rx_bytes+=skb->len;
diff --git a/pfinet/sched.c b/pfinet/sched.c
index 8992774..af03ab4 100644
--- a/pfinet/sched.c
+++ b/pfinet/sched.c
@@ -26,6 +26,7 @@
pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t net_bh_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t net_bh_wakeup = PTHREAD_COND_INITIALIZER;
+int net_bh_raised = 0;
struct task_struct current_contents; /* zeros are right default values */
@@ -61,7 +62,11 @@ net_bh_worker (void *arg)
pthread_mutex_lock (&net_bh_lock);
while (1)
{
- pthread_cond_wait (&net_bh_wakeup, &net_bh_lock);
+ while (!net_bh_raised)
+ pthread_cond_wait (&net_bh_wakeup, &net_bh_lock);
+
+ net_bh_raised = 0;
+
pthread_mutex_lock (&global_lock);
net_bh ();
pthread_mutex_unlock (&global_lock);
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 96/98: libdiskfs: register passive translator startups, (continued)
- [hurd] 96/98: libdiskfs: register passive translator startups, Samuel Thibault, 2014/01/13
- [hurd] 92/98: trans/mtab: properly lock mtab objects, Samuel Thibault, 2014/01/13
- [hurd] 03/98: libports: fix the thread counts in case the thread creation fails, Samuel Thibault, 2014/01/13
- [hurd] 76/98: utils/settrans: fix the teardown of chrooted environments, Samuel Thibault, 2014/01/13
- [hurd] 16/98: libshouldbeinlibc: fix reference counting in port_name_xlator_create, Samuel Thibault, 2014/01/13
- [hurd] 95/98: libfshelp: fix the api of fshelp_set_active_translator, Samuel Thibault, 2014/01/13
- [hurd] 98/98: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2014/01/13
- [hurd] 17/98: utils: implement portinfo --search, Samuel Thibault, 2014/01/13
- [hurd] 10/98: auth: fix use of uninitialized variable err, Samuel Thibault, 2014/01/13
- [hurd] 61/98: trans: fix transparent reauthentication in fakeroot, Samuel Thibault, 2014/01/13
- [hurd] 01/98: pfinet: fix emission on the loopback device,
Samuel Thibault <=
- [hurd] 63/98: libfshelp: use a hash table in get-identity.c, Samuel Thibault, 2014/01/13
- [hurd] 90/98: trans/mtab: populate mtab objects on demand, Samuel Thibault, 2014/01/13
- [hurd] 09/98: init: fix memory leak, Samuel Thibault, 2014/01/13
- [hurd] 88/98: libports: remove the threadvars stack size hack, Samuel Thibault, 2014/01/13
- [hurd] 02/98: Normalize whitespace at the end of each file to '\n', Samuel Thibault, 2014/01/13
- [hurd] 84/98: utils/rpctrace: handle MACH_MSG_TYPE_PORT_SEND rights in trace_and_forward, Samuel Thibault, 2014/01/13
- [hurd] 82/98: utils/rpctrace: generalize code in rewrite_right, Samuel Thibault, 2014/01/13
- [hurd] 86/98: utils/rpctrace: fix output so that replies can be attributed to requests, Samuel Thibault, 2014/01/13
- [hurd] 81/98: utils/mount: fix autodetection of fat file systems, Samuel Thibault, 2014/01/13
- [hurd] 79/98: trans/fakeroot: remove dead code, Samuel Thibault, 2014/01/13