summaryrefslogtreecommitdiff
path: root/net/hsr/hsr_main.c
diff options
context:
space:
mode:
authorArvid Brodin <arvid.brodin@alten.se>2014-07-04 23:37:27 +0200
committerDavid S. Miller <davem@davemloft.net>2014-07-08 11:35:31 -0700
commit51f3c605318b056ac5deb9079bbef2a976558827 (patch)
tree892ae91481ed018ce84f70a9b1c49ee0972d9406 /net/hsr/hsr_main.c
parente9aae56ea43ef4a32527b9d86c1f6b5eebfbd223 (diff)
net/hsr: Move slave init to hsr_slave.c.
Also try to prevent some possible slave dereference race conditions. This is finalized in the next patch, which abandons the slave array in favour of a list_head list and list RCU. Signed-off-by: Arvid Brodin <arvid.brodin@alten.se> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/hsr/hsr_main.c')
-rw-r--r--net/hsr/hsr_main.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
index 431b528c2447..b5abe26f7b4c 100644
--- a/net/hsr/hsr_main.c
+++ b/net/hsr/hsr_main.c
@@ -17,6 +17,7 @@
#include "hsr_device.h"
#include "hsr_netlink.h"
#include "hsr_framereg.h"
+#include "hsr_slave.h"
/* List of all registered virtual HSR devices */
@@ -124,22 +125,21 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
if (dev == hsr->dev)
break;
- if (dev == hsr->slave[0])
- ether_addr_copy(hsr->dev->dev_addr,
- hsr->slave[0]->dev_addr);
+ if (dev == hsr->slave[0]) {
+ ether_addr_copy(hsr->dev->dev_addr, dev->dev_addr);
+ call_netdevice_notifiers(NETDEV_CHANGEADDR, hsr->dev);
+ }
/* Make sure we recognize frames from ourselves in hsr_rcv() */
+ other_slave = hsr->slave[1];
res = hsr_create_self_node(&hsr->self_node_db,
hsr->dev->dev_addr,
- hsr->slave[1] ?
- hsr->slave[1]->dev_addr :
+ other_slave ?
+ other_slave->dev_addr :
hsr->dev->dev_addr);
if (res)
netdev_warn(hsr->dev,
"Could not update HSR node address.\n");
-
- if (dev == hsr->slave[0])
- call_netdevice_notifiers(NETDEV_CHANGEADDR, hsr->dev);
break;
case NETDEV_CHANGEMTU:
if (dev == hsr->dev)
@@ -149,10 +149,14 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
dev_set_mtu(hsr->dev, mtu_max);
break;
case NETDEV_UNREGISTER:
- if (dev == hsr->slave[0])
+ if (dev == hsr->slave[0]) {
hsr->slave[0] = NULL;
- if (dev == hsr->slave[1])
+ hsr_del_slave(hsr, 0);
+ }
+ if (dev == hsr->slave[1]) {
hsr->slave[1] = NULL;
+ hsr_del_slave(hsr, 1);
+ }
/* There should really be a way to set a new slave device... */