o Appletalk: convert aarp_lock from spinlock to rwlock

- CodingStyle cleanups
- make aarp_cleanup_module always present, as needed by DDP.
parent 8eda1204
...@@ -76,7 +76,7 @@ static struct aarp_entry *proxies[AARP_HASH_SIZE]; ...@@ -76,7 +76,7 @@ static struct aarp_entry *proxies[AARP_HASH_SIZE];
static int unresolved_count; static int unresolved_count;
/* One lock protects it all. */ /* One lock protects it all. */
static spinlock_t aarp_lock = SPIN_LOCK_UNLOCKED; static rwlock_t aarp_lock = RW_LOCK_UNLOCKED;
/* Used to walk the list and purge/kick entries. */ /* Used to walk the list and purge/kick entries. */
static struct timer_list aarp_timer; static struct timer_list aarp_timer;
...@@ -97,7 +97,6 @@ static void __aarp_expire(struct aarp_entry *a) ...@@ -97,7 +97,6 @@ static void __aarp_expire(struct aarp_entry *a)
* *
* Must run under aarp_lock. * Must run under aarp_lock.
*/ */
static void __aarp_send_query(struct aarp_entry *a) static void __aarp_send_query(struct aarp_entry *a)
{ {
static unsigned char aarp_eth_multicast[ETH_ALEN] = static unsigned char aarp_eth_multicast[ETH_ALEN] =
...@@ -264,7 +263,6 @@ static void __aarp_expire_timer(struct aarp_entry **n) ...@@ -264,7 +263,6 @@ static void __aarp_expire_timer(struct aarp_entry **n)
* *
* Must run under the aarp_lock. * Must run under the aarp_lock.
*/ */
static void __aarp_kick(struct aarp_entry **n) static void __aarp_kick(struct aarp_entry **n)
{ {
struct aarp_entry *t; struct aarp_entry *t;
...@@ -287,7 +285,6 @@ static void __aarp_kick(struct aarp_entry **n) ...@@ -287,7 +285,6 @@ static void __aarp_kick(struct aarp_entry **n)
* *
* Must run under the aarp_lock. * Must run under the aarp_lock.
*/ */
static void __aarp_expire_device(struct aarp_entry **n, struct net_device *dev) static void __aarp_expire_device(struct aarp_entry **n, struct net_device *dev)
{ {
struct aarp_entry *t; struct aarp_entry *t;
...@@ -306,7 +303,7 @@ static void aarp_expire_timeout(unsigned long unused) ...@@ -306,7 +303,7 @@ static void aarp_expire_timeout(unsigned long unused)
{ {
int ct; int ct;
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
__aarp_expire_timer(&resolved[ct]); __aarp_expire_timer(&resolved[ct]);
...@@ -315,7 +312,7 @@ static void aarp_expire_timeout(unsigned long unused) ...@@ -315,7 +312,7 @@ static void aarp_expire_timeout(unsigned long unused)
__aarp_expire_timer(&proxies[ct]); __aarp_expire_timer(&proxies[ct]);
} }
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
mod_timer(&aarp_timer, jiffies + mod_timer(&aarp_timer, jiffies +
(unresolved_count ? sysctl_aarp_tick_time : (unresolved_count ? sysctl_aarp_tick_time :
sysctl_aarp_expiry_time)); sysctl_aarp_expiry_time));
...@@ -328,7 +325,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event, ...@@ -328,7 +325,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event,
int ct; int ct;
if (event == NETDEV_DOWN) { if (event == NETDEV_DOWN) {
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
__aarp_expire_device(&resolved[ct], ptr); __aarp_expire_device(&resolved[ct], ptr);
...@@ -336,7 +333,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event, ...@@ -336,7 +333,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event,
__aarp_expire_device(&proxies[ct], ptr); __aarp_expire_device(&proxies[ct], ptr);
} }
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
} }
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -345,7 +342,6 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event, ...@@ -345,7 +342,6 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event,
* Create a new aarp entry. This must use GFP_ATOMIC because it * Create a new aarp entry. This must use GFP_ATOMIC because it
* runs while holding spinlocks. * runs while holding spinlocks.
*/ */
static struct aarp_entry *aarp_alloc(void) static struct aarp_entry *aarp_alloc(void)
{ {
struct aarp_entry *a = kmalloc(sizeof(*a), GFP_ATOMIC); struct aarp_entry *a = kmalloc(sizeof(*a), GFP_ATOMIC);
...@@ -382,13 +378,13 @@ void aarp_proxy_remove(struct net_device *dev, struct atalk_addr *sa) ...@@ -382,13 +378,13 @@ void aarp_proxy_remove(struct net_device *dev, struct atalk_addr *sa)
int hash = sa->s_node % (AARP_HASH_SIZE - 1); int hash = sa->s_node % (AARP_HASH_SIZE - 1);
struct aarp_entry *a; struct aarp_entry *a;
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
a = __aarp_find_entry(proxies[hash], dev, sa); a = __aarp_find_entry(proxies[hash], dev, sa);
if (a) if (a)
a->expires_at = jiffies - 1; a->expires_at = jiffies - 1;
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
} }
/* This must run under aarp_lock. */ /* This must run under aarp_lock. */
...@@ -476,7 +472,7 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct atalk_addr *sa) ...@@ -476,7 +472,7 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct atalk_addr *sa)
entry->target_addr.s_net = sa->s_net; entry->target_addr.s_net = sa->s_net;
entry->dev = atif->dev; entry->dev = atif->dev;
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
hash = sa->s_node % (AARP_HASH_SIZE - 1); hash = sa->s_node % (AARP_HASH_SIZE - 1);
entry->next = proxies[hash]; entry->next = proxies[hash];
...@@ -487,9 +483,9 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct atalk_addr *sa) ...@@ -487,9 +483,9 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct atalk_addr *sa)
/* Defer 1/10th */ /* Defer 1/10th */
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
schedule_timeout(HZ / 10); schedule_timeout(HZ / 10);
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
if (entry->status & ATIF_PROBE_FAIL) if (entry->status & ATIF_PROBE_FAIL)
break; break;
...@@ -503,13 +499,13 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct atalk_addr *sa) ...@@ -503,13 +499,13 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct atalk_addr *sa)
retval = 1; retval = 1;
} }
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
out: out:
return retval; return retval;
} }
/* Send a DDP frame */ /* Send a DDP frame */
int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, int aarp_send_ddp(struct net_device *dev, struct sk_buff *skb,
struct atalk_addr *sa, void *hwaddr) struct atalk_addr *sa, void *hwaddr)
{ {
static char ddp_eth_multicast[ETH_ALEN] = static char ddp_eth_multicast[ETH_ALEN] =
...@@ -534,7 +530,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -534,7 +530,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
if ((!ddp->deh_snet || at->s_net == ddp->deh_snet) && if ((!ddp->deh_snet || at->s_net == ddp->deh_snet) &&
(!ddp->deh_dnet || at->s_net == ddp->deh_dnet)) { (!ddp->deh_dnet || at->s_net == ddp->deh_dnet)) {
skb_pull(skb, sizeof(struct ddpehdr) - 4); skb_pull(skb, sizeof(*ddp) - 4);
/* /*
* The upper two remaining bytes are the port * The upper two remaining bytes are the port
...@@ -579,13 +575,13 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -579,13 +575,13 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
goto sent; goto sent;
} }
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
a = __aarp_find_entry(resolved[hash], dev, sa); a = __aarp_find_entry(resolved[hash], dev, sa);
if (a) { /* Return 1 and fill in the address */ if (a) { /* Return 1 and fill in the address */
a->expires_at = jiffies + (sysctl_aarp_expiry_time * 10); a->expires_at = jiffies + (sysctl_aarp_expiry_time * 10);
ddp_dl->request(ddp_dl, skb, a->hwaddr); ddp_dl->request(ddp_dl, skb, a->hwaddr);
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
goto sent; goto sent;
} }
...@@ -600,7 +596,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -600,7 +596,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
a = aarp_alloc(); a = aarp_alloc();
if (!a) { if (!a) {
/* Whoops slipped... good job it's an unreliable protocol 8) */ /* Whoops slipped... good job it's an unreliable protocol 8) */
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
return -1; return -1;
} }
...@@ -627,7 +623,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -627,7 +623,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
/* Now finally, it is safe to drop the lock. */ /* Now finally, it is safe to drop the lock. */
out_unlock: out_unlock:
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
/* Tell the ddp layer we have taken over for this frame. */ /* Tell the ddp layer we have taken over for this frame. */
return 0; return 0;
...@@ -723,7 +719,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -723,7 +719,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
da.s_node = ea->pa_dst_node; da.s_node = ea->pa_dst_node;
da.s_net = ea->pa_dst_net; da.s_net = ea->pa_dst_net;
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
a = __aarp_find_entry(proxies[hash], dev, &da); a = __aarp_find_entry(proxies[hash], dev, &da);
if (a && a->status & ATIF_PROBE) { if (a && a->status & ATIF_PROBE) {
...@@ -741,13 +737,13 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -741,13 +737,13 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
break; break;
/* Find the entry. */ /* Find the entry. */
a = __aarp_find_entry(unresolved[hash],dev,&sa); a = __aarp_find_entry(unresolved[hash], dev, &sa);
if (!a || dev != a->dev) if (!a || dev != a->dev)
break; break;
/* We can fill one in - this is good. */ /* We can fill one in - this is good. */
memcpy(a->hwaddr,ea->hw_src,ETH_ALEN); memcpy(a->hwaddr, ea->hw_src, ETH_ALEN);
__aarp_resolved(&unresolved[hash],a,hash); __aarp_resolved(&unresolved[hash], a, hash);
if (!unresolved_count) if (!unresolved_count)
mod_timer(&aarp_timer, mod_timer(&aarp_timer,
jiffies + sysctl_aarp_expiry_time); jiffies + sysctl_aarp_expiry_time);
...@@ -787,8 +783,9 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -787,8 +783,9 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
* address. So as a precaution flush any * address. So as a precaution flush any
* entries we have for this address. * entries we have for this address.
*/ */
struct aarp_entry *a = __aarp_find_entry( struct aarp_entry *a;
resolved[sa.s_node %
a = __aarp_find_entry(resolved[sa.s_node %
(AARP_HASH_SIZE - 1)], (AARP_HASH_SIZE - 1)],
skb->dev, &sa); skb->dev, &sa);
...@@ -821,7 +818,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -821,7 +818,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
} }
unlock: unlock:
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
out1: out1:
ret = 1; ret = 1;
out0: out0:
...@@ -830,7 +827,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -830,7 +827,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
} }
static struct notifier_block aarp_notifier = { static struct notifier_block aarp_notifier = {
.notifier_call =aarp_device_event, .notifier_call = aarp_device_event,
}; };
static unsigned char aarp_snap_id[] = { 0x00, 0x00, 0x00, 0x80, 0xF3 }; static unsigned char aarp_snap_id[] = { 0x00, 0x00, 0x00, 0x80, 0xF3 };
...@@ -853,7 +850,7 @@ void aarp_device_down(struct net_device *dev) ...@@ -853,7 +850,7 @@ void aarp_device_down(struct net_device *dev)
{ {
int ct; int ct;
spin_lock_bh(&aarp_lock); write_lock_bh(&aarp_lock);
for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
__aarp_expire_device(&resolved[ct], dev); __aarp_expire_device(&resolved[ct], dev);
...@@ -861,7 +858,7 @@ void aarp_device_down(struct net_device *dev) ...@@ -861,7 +858,7 @@ void aarp_device_down(struct net_device *dev)
__aarp_expire_device(&proxies[ct], dev); __aarp_expire_device(&proxies[ct], dev);
} }
spin_unlock_bh(&aarp_lock); write_unlock_bh(&aarp_lock);
} }
/* Called from proc fs */ /* Called from proc fs */
...@@ -875,7 +872,7 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -875,7 +872,7 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length)
"address", "device", "hw addr", "last_sent", "address", "device", "hw addr", "last_sent",
"expires"); "expires");
spin_lock_bh(&aarp_lock); read_lock_bh(&aarp_lock);
for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
for (entry = resolved[ct]; entry; entry = entry->next) { for (entry = resolved[ct]; entry; entry = entry->next) {
...@@ -950,11 +947,10 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -950,11 +947,10 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length)
} }
} }
spin_unlock_bh(&aarp_lock); read_unlock_bh(&aarp_lock);
return len; return len;
} }
#ifdef MODULE
/* General module cleanup. Called from cleanup_module() in ddp.c. */ /* General module cleanup. Called from cleanup_module() in ddp.c. */
void aarp_cleanup_module(void) void aarp_cleanup_module(void)
{ {
...@@ -962,7 +958,7 @@ void aarp_cleanup_module(void) ...@@ -962,7 +958,7 @@ void aarp_cleanup_module(void)
unregister_netdevice_notifier(&aarp_notifier); unregister_netdevice_notifier(&aarp_notifier);
unregister_snap_client(aarp_dl); unregister_snap_client(aarp_dl);
} }
#endif /* MODULE */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
void aarp_register_proc_fs(void) void aarp_register_proc_fs(void)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment