Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 219897
b: refs/heads/master
c: af2ac7b
h: refs/heads/master
i:
  219895: 875efcd
v: v3
  • Loading branch information
Sven Eckelmann authored and Greg Kroah-Hartman committed Sep 20, 2010
1 parent 0a485f1 commit 97bec9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 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: 67c3b705934af93a09a0f369346c2561499b73c4
refs/heads/master: af2ac7bfec4176cad5e04402d116b5242d759bf8
17 changes: 15 additions & 2 deletions trunk/drivers/staging/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#define MIN(x, y) ((x) < (y) ? (x) : (y))

/* protect update critical side of if_list - but not the content */
static DEFINE_SPINLOCK(if_list_lock);

struct batman_if *get_batman_if_by_netdev(struct net_device *net_dev)
{
struct batman_if *batman_if;
Expand Down Expand Up @@ -400,7 +403,11 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
INIT_LIST_HEAD(&batman_if->list);

check_known_mac_addr(batman_if->net_dev->dev_addr);

spin_lock(&if_list_lock);
list_add_tail_rcu(&batman_if->list, &if_list);
spin_unlock(&if_list_lock);

return batman_if;

free_if:
Expand Down Expand Up @@ -428,6 +435,8 @@ static void hardif_remove_interface(struct batman_if *batman_if)
return;

batman_if->if_status = IF_TO_BE_REMOVED;

/* caller must take if_list_lock */
list_del_rcu(&batman_if->list);
sysfs_del_hardif(&batman_if->hardif_obj);
dev_put(batman_if->net_dev);
Expand All @@ -438,11 +447,13 @@ void hardif_remove_interfaces(void)
{
struct batman_if *batman_if, *batman_if_tmp;

rtnl_lock();
spin_lock(&if_list_lock);
list_for_each_entry_safe(batman_if, batman_if_tmp, &if_list, list) {
rtnl_lock();
hardif_remove_interface(batman_if);
rtnl_unlock();
}
spin_unlock(&if_list_lock);
rtnl_unlock();
}

static int hard_if_event(struct notifier_block *this,
Expand All @@ -467,7 +478,9 @@ static int hard_if_event(struct notifier_block *this,
hardif_deactivate_interface(batman_if);
break;
case NETDEV_UNREGISTER:
spin_lock(&if_list_lock);
hardif_remove_interface(batman_if);
spin_unlock(&if_list_lock);
break;
case NETDEV_CHANGEMTU:
if (batman_if->soft_iface)
Expand Down

0 comments on commit 97bec9c

Please sign in to comment.