Commit 81390d0c authored by Taehee Yoo's avatar Taehee Yoo Committed by David S. Miller

hsr: remove unnecessary rcu_read_lock() in hsr module

In order to access the port list, the hsr_port_get_hsr() is used.
And this is protected by RTNL and RCU.
The hsr_fill_info(), hsr_check_carrier(), hsr_dev_open() and
hsr_get_max_mtu() are protected by RTNL.
So, rcu_read_lock() in these functions are not necessary.
The hsr_handle_frame() also uses rcu_read_lock() but this function
is called by packet path.
It's already protected by RCU.
So, the rcu_read_lock() in hsr_handle_frame() can be removed.
Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4b793acd
...@@ -57,24 +57,19 @@ static void hsr_set_operstate(struct hsr_port *master, bool has_carrier) ...@@ -57,24 +57,19 @@ static void hsr_set_operstate(struct hsr_port *master, bool has_carrier)
static bool hsr_check_carrier(struct hsr_port *master) static bool hsr_check_carrier(struct hsr_port *master)
{ {
struct hsr_port *port; struct hsr_port *port;
bool has_carrier;
has_carrier = false; ASSERT_RTNL();
rcu_read_lock(); hsr_for_each_port(master->hsr, port) {
hsr_for_each_port(master->hsr, port)
if (port->type != HSR_PT_MASTER && is_slave_up(port->dev)) { if (port->type != HSR_PT_MASTER && is_slave_up(port->dev)) {
has_carrier = true; netif_carrier_on(master->dev);
break; return true;
}
} }
rcu_read_unlock();
if (has_carrier)
netif_carrier_on(master->dev);
else
netif_carrier_off(master->dev); netif_carrier_off(master->dev);
return has_carrier; return false;
} }
static void hsr_check_announce(struct net_device *hsr_dev, static void hsr_check_announce(struct net_device *hsr_dev,
...@@ -118,11 +113,9 @@ int hsr_get_max_mtu(struct hsr_priv *hsr) ...@@ -118,11 +113,9 @@ int hsr_get_max_mtu(struct hsr_priv *hsr)
struct hsr_port *port; struct hsr_port *port;
mtu_max = ETH_DATA_LEN; mtu_max = ETH_DATA_LEN;
rcu_read_lock();
hsr_for_each_port(hsr, port) hsr_for_each_port(hsr, port)
if (port->type != HSR_PT_MASTER) if (port->type != HSR_PT_MASTER)
mtu_max = min(port->dev->mtu, mtu_max); mtu_max = min(port->dev->mtu, mtu_max);
rcu_read_unlock();
if (mtu_max < HSR_HLEN) if (mtu_max < HSR_HLEN)
return 0; return 0;
...@@ -157,7 +150,6 @@ static int hsr_dev_open(struct net_device *dev) ...@@ -157,7 +150,6 @@ static int hsr_dev_open(struct net_device *dev)
hsr = netdev_priv(dev); hsr = netdev_priv(dev);
designation = '\0'; designation = '\0';
rcu_read_lock();
hsr_for_each_port(hsr, port) { hsr_for_each_port(hsr, port) {
if (port->type == HSR_PT_MASTER) if (port->type == HSR_PT_MASTER)
continue; continue;
...@@ -175,7 +167,6 @@ static int hsr_dev_open(struct net_device *dev) ...@@ -175,7 +167,6 @@ static int hsr_dev_open(struct net_device *dev)
netdev_warn(dev, "Slave %c (%s) is not up; please bring it up to get a fully working HSR network\n", netdev_warn(dev, "Slave %c (%s) is not up; please bring it up to get a fully working HSR network\n",
designation, port->dev->name); designation, port->dev->name);
} }
rcu_read_unlock();
if (designation == '\0') if (designation == '\0')
netdev_warn(dev, "No slave devices configured\n"); netdev_warn(dev, "No slave devices configured\n");
......
...@@ -79,29 +79,20 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev, ...@@ -79,29 +79,20 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev) static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
{ {
struct hsr_priv *hsr; struct hsr_priv *hsr = netdev_priv(dev);
struct hsr_port *port; struct hsr_port *port;
int res;
hsr = netdev_priv(dev);
res = 0;
rcu_read_lock();
port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A); port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
if (port) if (port) {
res = nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex); if (nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex))
rcu_read_unlock();
if (res)
goto nla_put_failure; goto nla_put_failure;
}
rcu_read_lock();
port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B); port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
if (port) if (port) {
res = nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex); if (nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex))
rcu_read_unlock();
if (res)
goto nla_put_failure; goto nla_put_failure;
}
if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN, if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN,
hsr->sup_multicast_addr) || hsr->sup_multicast_addr) ||
......
...@@ -25,7 +25,6 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb) ...@@ -25,7 +25,6 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
return RX_HANDLER_PASS; return RX_HANDLER_PASS;
} }
rcu_read_lock(); /* hsr->node_db, hsr->ports */
port = hsr_port_get_rcu(skb->dev); port = hsr_port_get_rcu(skb->dev);
if (!port) if (!port)
goto finish_pass; goto finish_pass;
...@@ -45,11 +44,9 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb) ...@@ -45,11 +44,9 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
hsr_forward_skb(skb, port); hsr_forward_skb(skb, port);
finish_consume: finish_consume:
rcu_read_unlock(); /* hsr->node_db, hsr->ports */
return RX_HANDLER_CONSUMED; return RX_HANDLER_CONSUMED;
finish_pass: finish_pass:
rcu_read_unlock(); /* hsr->node_db, hsr->ports */
return RX_HANDLER_PASS; return RX_HANDLER_PASS;
} }
......
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