From 7101d752b2f9f237ed44759dec3fbce42ac9d833 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sun, 28 Mar 2004 23:12:19 +0000 Subject: [PATCH] Invert the logic of NET_LOCK_GIANT(), and remove the one reference to it. Previously, Giant would be grabbed at entry to the IP local delivery code when debug.mpsafenet was set to true, as that implied Giant wouldn't be grabbed in the driver path. Now, we will use this primitive to conditionally grab Giant in the event the entire network stack isn't running MPSAFE (debug.mpsafenet == 0). --- sys/netinet/ip_input.c | 2 -- sys/sys/mutex.h | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index b79809238e3..d1c269c55df 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -936,9 +936,7 @@ DPRINTF(("ip_input: no SP, packet discarded\n"));/*XXX*/ *(struct sockaddr_in **)(mtag+1) = args.next_hop; m_tag_prepend(m, mtag); } - NET_LOCK_GIANT(); (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen); - NET_UNLOCK_GIANT(); return; bad: m_freem(m); diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index f86679d4439..d31f3ea15a1 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -354,15 +354,15 @@ do { \ */ extern int debug_mpsafenet; /* defined in net/netisr.c */ #define NET_LOCK_GIANT() do { \ - if (debug_mpsafenet) \ + if (!debug_mpsafenet) \ mtx_lock(&Giant); \ } while (0) #define NET_UNLOCK_GIANT() do { \ - if (debug_mpsafenet) \ + if (!debug_mpsafenet) \ mtx_unlock(&Giant); \ } while (0) #define NET_ASSERT_GIANT() do { \ - if (debug_mpsafenet) \ + if (!debug_mpsafenet) \ mtx_assert(&Giant, MA_OWNED); \ } while (0)