Commit 07211edd authored by David S. Miller's avatar David S. Miller

Merge bk://kernel.bkbits.net/acme/net-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 89c03538 93996134
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/brlock.h>
LIST_HEAD(snap_list); static LIST_HEAD(snap_list);
static spinlock_t snap_lock = SPIN_LOCK_UNLOCKED;
static struct llc_sap *snap_sap; static struct llc_sap *snap_sap;
/* /*
...@@ -34,17 +34,13 @@ static struct datalink_proto *find_snap_client(unsigned char *desc) ...@@ -34,17 +34,13 @@ static struct datalink_proto *find_snap_client(unsigned char *desc)
struct list_head *entry; struct list_head *entry;
struct datalink_proto *proto = NULL, *p; struct datalink_proto *proto = NULL, *p;
if (list_empty(&snap_list)) list_for_each_rcu(entry, &snap_list) {
goto out;
list_for_each(entry, &snap_list) {
p = list_entry(entry, struct datalink_proto, node); p = list_entry(entry, struct datalink_proto, node);
if (!memcmp(p->type, desc, 5)) { if (!memcmp(p->type, desc, 5)) {
proto = p; proto = p;
break; break;
} }
} }
out:
return proto; return proto;
} }
...@@ -55,11 +51,13 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -55,11 +51,13 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt) struct packet_type *pt)
{ {
int rc = 1; int rc = 1;
struct datalink_proto *proto = find_snap_client(skb->h.raw); struct datalink_proto *proto;
static struct packet_type snap_packet_type = { static struct packet_type snap_packet_type = {
.type = __constant_htons(ETH_P_SNAP), .type = __constant_htons(ETH_P_SNAP),
}; };
rcu_read_lock();
proto = find_snap_client(skb->h.raw);
if (proto) { if (proto) {
/* Pass the frame on. */ /* Pass the frame on. */
skb->h.raw += 5; skb->h.raw += 5;
...@@ -71,6 +69,7 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -71,6 +69,7 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
rc = 1; rc = 1;
} }
rcu_read_unlock();
return rc; return rc;
} }
...@@ -124,7 +123,7 @@ struct datalink_proto *register_snap_client(unsigned char *desc, ...@@ -124,7 +123,7 @@ struct datalink_proto *register_snap_client(unsigned char *desc,
{ {
struct datalink_proto *proto = NULL; struct datalink_proto *proto = NULL;
br_write_lock_bh(BR_NETPROTO_LOCK); spin_lock_bh(&snap_lock);
if (find_snap_client(desc)) if (find_snap_client(desc))
goto out; goto out;
...@@ -135,10 +134,12 @@ struct datalink_proto *register_snap_client(unsigned char *desc, ...@@ -135,10 +134,12 @@ struct datalink_proto *register_snap_client(unsigned char *desc,
proto->rcvfunc = rcvfunc; proto->rcvfunc = rcvfunc;
proto->header_length = 5 + 3; /* snap + 802.2 */ proto->header_length = 5 + 3; /* snap + 802.2 */
proto->request = snap_request; proto->request = snap_request;
list_add(&proto->node, &snap_list); list_add_rcu(&proto->node, &snap_list);
} }
out: out:
br_write_unlock_bh(BR_NETPROTO_LOCK); spin_unlock_bh(&snap_lock);
synchronize_net();
return proto; return proto;
} }
...@@ -147,12 +148,13 @@ struct datalink_proto *register_snap_client(unsigned char *desc, ...@@ -147,12 +148,13 @@ struct datalink_proto *register_snap_client(unsigned char *desc,
*/ */
void unregister_snap_client(struct datalink_proto *proto) void unregister_snap_client(struct datalink_proto *proto)
{ {
br_write_lock_bh(BR_NETPROTO_LOCK); spin_lock_bh(&snap_lock);
list_del_rcu(&proto->node);
spin_unlock_bh(&snap_lock);
list_del(&proto->node); synchronize_net();
kfree(proto);
br_write_unlock_bh(BR_NETPROTO_LOCK); kfree(proto);
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
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