Commit d3b7f69d authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: add locking to network transport registration

The registration of host network transports needed some locking.  The
transport list itself is locked, but calls to the registration routines are
not.  This is compensated for by checking that a transport structure is not
yet on any list.

I also took the opportunity to const all fields in the transport structure
except the list, which obviously can be modified.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 190c3e45
...@@ -498,10 +498,8 @@ struct eth_init { ...@@ -498,10 +498,8 @@ struct eth_init {
int index; int index;
}; };
/* Filled in at boot time. Will need locking if the transports become static DEFINE_SPINLOCK(transports_lock);
* modular. static LIST_HEAD(transports);
*/
struct list_head transports = LIST_HEAD_INIT(transports);
/* Filled in during early boot */ /* Filled in during early boot */
struct list_head eth_cmd_line = LIST_HEAD_INIT(eth_cmd_line); struct list_head eth_cmd_line = LIST_HEAD_INIT(eth_cmd_line);
...@@ -540,7 +538,10 @@ void register_transport(struct transport *new) ...@@ -540,7 +538,10 @@ void register_transport(struct transport *new)
char *mac = NULL; char *mac = NULL;
int match; int match;
spin_lock(&transports_lock);
BUG_ON(!list_empty(&new->list));
list_add(&new->list, &transports); list_add(&new->list, &transports);
spin_unlock(&transports_lock);
list_for_each_safe(ele, next, &eth_cmd_line){ list_for_each_safe(ele, next, &eth_cmd_line){
eth = list_entry(ele, struct eth_init, list); eth = list_entry(ele, struct eth_init, list);
......
...@@ -52,12 +52,12 @@ struct net_kern_info { ...@@ -52,12 +52,12 @@ struct net_kern_info {
struct transport { struct transport {
struct list_head list; struct list_head list;
char *name; const char *name;
int (*setup)(char *, char **, void *); int (* const setup)(char *, char **, void *);
const struct net_user_info *user; const struct net_user_info *user;
const struct net_kern_info *kern; const struct net_kern_info *kern;
int private_size; const int private_size;
int setup_size; const int setup_size;
}; };
extern struct net_device *ether_init(int); extern struct net_device *ether_init(int);
......
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