Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22272
b: refs/heads/master
c: 4a3e2f7
h: refs/heads/master
v: v3
  • Loading branch information
Arjan van de Ven authored and David S. Miller committed Mar 21, 2006
1 parent bf70158 commit a114e23
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 102 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d4ccd08cdfa8d34f4d25b62041343c52fc79385f
refs/heads/master: 4a3e2f711a00a1feb72ae12fdc749da10179d185
3 changes: 2 additions & 1 deletion trunk/include/net/xfrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/crypto.h>
#include <linux/pfkeyv2.h>
#include <linux/in6.h>
#include <linux/mutex.h>

#include <net/sock.h>
#include <net/dst.h>
Expand All @@ -24,7 +25,7 @@ extern struct sock *xfrm_nl;
extern u32 sysctl_xfrm_aevent_etime;
extern u32 sysctl_xfrm_aevent_rseqth;

extern struct semaphore xfrm_cfg_sem;
extern struct mutex xfrm_cfg_mutex;

/* Organization of SPD aka "XFRM rules"
------------------------------------
Expand Down
15 changes: 8 additions & 7 deletions trunk/net/atm/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,30 @@
#include <linux/atmmpc.h>
#include <net/atmclip.h>
#include <linux/atmlec.h>
#include <linux/mutex.h>
#include <asm/ioctls.h>

#include "resources.h"
#include "signaling.h" /* for WAITING and sigd_attach */
#include "common.h"


static DECLARE_MUTEX(ioctl_mutex);
static DEFINE_MUTEX(ioctl_mutex);
static LIST_HEAD(ioctl_list);


void register_atm_ioctl(struct atm_ioctl *ioctl)
{
down(&ioctl_mutex);
mutex_lock(&ioctl_mutex);
list_add_tail(&ioctl->list, &ioctl_list);
up(&ioctl_mutex);
mutex_unlock(&ioctl_mutex);
}

void deregister_atm_ioctl(struct atm_ioctl *ioctl)
{
down(&ioctl_mutex);
mutex_lock(&ioctl_mutex);
list_del(&ioctl->list);
up(&ioctl_mutex);
mutex_unlock(&ioctl_mutex);
}

EXPORT_SYMBOL(register_atm_ioctl);
Expand Down Expand Up @@ -137,7 +138,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)

error = -ENOIOCTLCMD;

down(&ioctl_mutex);
mutex_lock(&ioctl_mutex);
list_for_each(pos, &ioctl_list) {
struct atm_ioctl * ic = list_entry(pos, struct atm_ioctl, list);
if (try_module_get(ic->owner)) {
Expand All @@ -147,7 +148,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
break;
}
}
up(&ioctl_mutex);
mutex_unlock(&ioctl_mutex);

if (error != -ENOIOCTLCMD)
goto done;
Expand Down
8 changes: 5 additions & 3 deletions trunk/net/bluetooth/rfcomm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <linux/wait.h>
#include <linux/device.h>
#include <linux/net.h>
#include <linux/mutex.h>

#include <net/sock.h>
#include <asm/uaccess.h>
#include <asm/unaligned.h>
Expand All @@ -57,9 +59,9 @@ static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU;

static struct task_struct *rfcomm_thread;

static DECLARE_MUTEX(rfcomm_sem);
#define rfcomm_lock() down(&rfcomm_sem);
#define rfcomm_unlock() up(&rfcomm_sem);
static DEFINE_MUTEX(rfcomm_mutex);
#define rfcomm_lock() mutex_lock(&rfcomm_mutex)
#define rfcomm_unlock() mutex_unlock(&rfcomm_mutex)

static unsigned long rfcomm_event;

Expand Down
7 changes: 4 additions & 3 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mutex.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/socket.h>
Expand Down Expand Up @@ -2931,15 +2932,15 @@ static void netdev_wait_allrefs(struct net_device *dev)
* 2) Since we run with the RTNL semaphore not held, we can sleep
* safely in order to wait for the netdev refcnt to drop to zero.
*/
static DECLARE_MUTEX(net_todo_run_mutex);
static DEFINE_MUTEX(net_todo_run_mutex);
void netdev_run_todo(void)
{
struct list_head list = LIST_HEAD_INIT(list);
int err;


/* Need to guard against multiple cpu's getting out of order. */
down(&net_todo_run_mutex);
mutex_lock(&net_todo_run_mutex);

/* Not safe to do outside the semaphore. We must not return
* until all unregister events invoked by the local processor
Expand Down Expand Up @@ -2996,7 +2997,7 @@ void netdev_run_todo(void)
}

out:
up(&net_todo_run_mutex);
mutex_unlock(&net_todo_run_mutex);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions trunk/net/core/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/mutex.h>
#include <net/flow.h>
#include <asm/atomic.h>
#include <asm/semaphore.h>
Expand Down Expand Up @@ -287,11 +288,11 @@ static void flow_cache_flush_per_cpu(void *data)
void flow_cache_flush(void)
{
struct flow_flush_info info;
static DECLARE_MUTEX(flow_flush_sem);
static DEFINE_MUTEX(flow_flush_sem);

/* Don't want cpus going down or up during this. */
lock_cpu_hotplug();
down(&flow_flush_sem);
mutex_lock(&flow_flush_sem);
atomic_set(&info.cpuleft, num_online_cpus());
init_completion(&info.completion);

Expand All @@ -301,7 +302,7 @@ void flow_cache_flush(void)
local_bh_enable();

wait_for_completion(&info.completion);
up(&flow_flush_sem);
mutex_unlock(&flow_flush_sem);
unlock_cpu_hotplug();
}

Expand Down
17 changes: 9 additions & 8 deletions trunk/net/ipv4/ipcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/list.h>
#include <linux/vmalloc.h>
#include <linux/rtnetlink.h>
#include <linux/mutex.h>
#include <net/ip.h>
#include <net/xfrm.h>
#include <net/icmp.h>
Expand All @@ -36,7 +37,7 @@ struct ipcomp_tfms {
int users;
};

static DECLARE_MUTEX(ipcomp_resource_sem);
static DEFINE_MUTEX(ipcomp_resource_mutex);
static void **ipcomp_scratches;
static int ipcomp_scratch_users;
static LIST_HEAD(ipcomp_tfms_list);
Expand Down Expand Up @@ -253,7 +254,7 @@ static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
}

/*
* Must be protected by xfrm_cfg_sem. State and tunnel user references are
* Must be protected by xfrm_cfg_mutex. State and tunnel user references are
* always incremented on success.
*/
static int ipcomp_tunnel_attach(struct xfrm_state *x)
Expand Down Expand Up @@ -411,9 +412,9 @@ static void ipcomp_destroy(struct xfrm_state *x)
if (!ipcd)
return;
xfrm_state_delete_tunnel(x);
down(&ipcomp_resource_sem);
mutex_lock(&ipcomp_resource_mutex);
ipcomp_free_data(ipcd);
up(&ipcomp_resource_sem);
mutex_unlock(&ipcomp_resource_mutex);
kfree(ipcd);
}

Expand All @@ -440,14 +441,14 @@ static int ipcomp_init_state(struct xfrm_state *x)
if (x->props.mode)
x->props.header_len += sizeof(struct iphdr);

down(&ipcomp_resource_sem);
mutex_lock(&ipcomp_resource_mutex);
if (!ipcomp_alloc_scratches())
goto error;

ipcd->tfms = ipcomp_alloc_tfms(x->calg->alg_name);
if (!ipcd->tfms)
goto error;
up(&ipcomp_resource_sem);
mutex_unlock(&ipcomp_resource_mutex);

if (x->props.mode) {
err = ipcomp_tunnel_attach(x);
Expand All @@ -464,10 +465,10 @@ static int ipcomp_init_state(struct xfrm_state *x)
return err;

error_tunnel:
down(&ipcomp_resource_sem);
mutex_lock(&ipcomp_resource_mutex);
error:
ipcomp_free_data(ipcd);
up(&ipcomp_resource_sem);
mutex_unlock(&ipcomp_resource_mutex);
kfree(ipcd);
goto out;
}
Expand Down
11 changes: 6 additions & 5 deletions trunk/net/ipv4/netfilter/ip_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/security.h>
#include <linux/mutex.h>
#include <net/sock.h>
#include <net/route.h>

Expand All @@ -61,7 +62,7 @@ static unsigned int queue_dropped = 0;
static unsigned int queue_user_dropped = 0;
static struct sock *ipqnl;
static LIST_HEAD(queue_list);
static DECLARE_MUTEX(ipqnl_sem);
static DEFINE_MUTEX(ipqnl_mutex);

static void
ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
Expand Down Expand Up @@ -539,15 +540,15 @@ ipq_rcv_sk(struct sock *sk, int len)
struct sk_buff *skb;
unsigned int qlen;

down(&ipqnl_sem);
mutex_lock(&ipqnl_mutex);

for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
skb = skb_dequeue(&sk->sk_receive_queue);
ipq_rcv_skb(skb);
kfree_skb(skb);
}

up(&ipqnl_sem);
mutex_unlock(&ipqnl_mutex);
}

static int
Expand Down Expand Up @@ -708,8 +709,8 @@ init_or_cleanup(int init)

cleanup_ipqnl:
sock_release(ipqnl->sk_socket);
down(&ipqnl_sem);
up(&ipqnl_sem);
mutex_lock(&ipqnl_mutex);
mutex_unlock(&ipqnl_mutex);

cleanup_netlink_notifier:
netlink_unregister_notifier(&ipq_nl_notifier);
Expand Down
11 changes: 6 additions & 5 deletions trunk/net/ipv4/xfrm4_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <linux/skbuff.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <net/xfrm.h>
#include <net/ip.h>
#include <net/protocol.h>
Expand All @@ -26,19 +27,19 @@ static int ipip_xfrm_rcv(struct xfrm_state *x, struct xfrm_decap_state *decap, s
}

static struct xfrm_tunnel *ipip_handler;
static DECLARE_MUTEX(xfrm4_tunnel_sem);
static DEFINE_MUTEX(xfrm4_tunnel_mutex);

int xfrm4_tunnel_register(struct xfrm_tunnel *handler)
{
int ret;

down(&xfrm4_tunnel_sem);
mutex_lock(&xfrm4_tunnel_mutex);
ret = 0;
if (ipip_handler != NULL)
ret = -EINVAL;
if (!ret)
ipip_handler = handler;
up(&xfrm4_tunnel_sem);
mutex_unlock(&xfrm4_tunnel_mutex);

return ret;
}
Expand All @@ -49,13 +50,13 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler)
{
int ret;

down(&xfrm4_tunnel_sem);
mutex_lock(&xfrm4_tunnel_mutex);
ret = 0;
if (ipip_handler != handler)
ret = -EINVAL;
if (!ret)
ipip_handler = NULL;
up(&xfrm4_tunnel_sem);
mutex_unlock(&xfrm4_tunnel_mutex);

synchronize_net();

Expand Down
15 changes: 8 additions & 7 deletions trunk/net/ipv6/ipcomp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
#include <net/protocol.h>
#include <linux/ipv6.h>
#include <linux/icmpv6.h>
#include <linux/mutex.h>

struct ipcomp6_tfms {
struct list_head list;
struct crypto_tfm **tfms;
int users;
};

static DECLARE_MUTEX(ipcomp6_resource_sem);
static DEFINE_MUTEX(ipcomp6_resource_mutex);
static void **ipcomp6_scratches;
static int ipcomp6_scratch_users;
static LIST_HEAD(ipcomp6_tfms_list);
Expand Down Expand Up @@ -405,9 +406,9 @@ static void ipcomp6_destroy(struct xfrm_state *x)
if (!ipcd)
return;
xfrm_state_delete_tunnel(x);
down(&ipcomp6_resource_sem);
mutex_lock(&ipcomp6_resource_mutex);
ipcomp6_free_data(ipcd);
up(&ipcomp6_resource_sem);
mutex_unlock(&ipcomp6_resource_mutex);
kfree(ipcd);

xfrm6_tunnel_free_spi((xfrm_address_t *)&x->props.saddr);
Expand Down Expand Up @@ -436,14 +437,14 @@ static int ipcomp6_init_state(struct xfrm_state *x)
if (x->props.mode)
x->props.header_len += sizeof(struct ipv6hdr);

down(&ipcomp6_resource_sem);
mutex_lock(&ipcomp6_resource_mutex);
if (!ipcomp6_alloc_scratches())
goto error;

ipcd->tfms = ipcomp6_alloc_tfms(x->calg->alg_name);
if (!ipcd->tfms)
goto error;
up(&ipcomp6_resource_sem);
mutex_unlock(&ipcomp6_resource_mutex);

if (x->props.mode) {
err = ipcomp6_tunnel_attach(x);
Expand All @@ -459,10 +460,10 @@ static int ipcomp6_init_state(struct xfrm_state *x)
out:
return err;
error_tunnel:
down(&ipcomp6_resource_sem);
mutex_lock(&ipcomp6_resource_mutex);
error:
ipcomp6_free_data(ipcd);
up(&ipcomp6_resource_sem);
mutex_unlock(&ipcomp6_resource_mutex);
kfree(ipcd);

goto out;
Expand Down
Loading

0 comments on commit a114e23

Please sign in to comment.