提交 108db736 编写于 作者: D dingtianhong 提交者: David S. Miller

bonding: protect port for bond_3ad_handle_link_change()

The bond_3ad_handle_link_change is called with RTNL only,
and the function will modify the port's information with
no further locking, it will not mutex against bond state
machine and incoming LACPDU which do not hold RTNL, So I
add __get_state_machine_lock to protect the port.

But it is not a critical bug, it exist since day one, and till
now it has never been hit and reported, because changes to
speed is very rare, and will not occur critical problem.

The comments in the function is very old, cleanup it and
add a new pr_debug to debug the port message.
Signed-off-by: NDing Tianhong <dingtianhong@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 bca44a73
...@@ -2268,15 +2268,21 @@ void bond_3ad_handle_link_change(struct slave *slave, char link) ...@@ -2268,15 +2268,21 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
port = &(SLAVE_AD_INFO(slave).port); port = &(SLAVE_AD_INFO(slave).port);
// if slave is null, the whole port is not initialized /* if slave is null, the whole port is not initialized */
if (!port->slave) { if (!port->slave) {
pr_warning("Warning: %s: link status changed for uninitialized port on %s\n", pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
slave->bond->dev->name, slave->dev->name); slave->bond->dev->name, slave->dev->name);
return; return;
} }
// on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed) __get_state_machine_lock(port);
// on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report /* on link down we are zeroing duplex and speed since
* some of the adaptors(ce1000.lan) report full duplex/speed
* instead of N/A(duplex) / 0(speed).
*
* on link up we are forcing recheck on the duplex and speed since
* some of he adaptors(ce1000.lan) report.
*/
if (link == BOND_LINK_UP) { if (link == BOND_LINK_UP) {
port->is_enabled = true; port->is_enabled = true;
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS; port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
...@@ -2292,10 +2298,15 @@ void bond_3ad_handle_link_change(struct slave *slave, char link) ...@@ -2292,10 +2298,15 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
port->actor_oper_port_key = (port->actor_admin_port_key &= port->actor_oper_port_key = (port->actor_admin_port_key &=
~AD_SPEED_KEY_BITS); ~AD_SPEED_KEY_BITS);
} }
//BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN"))); pr_debug("Port %d changed link status to %s",
// there is no need to reselect a new aggregator, just signal the port->actor_port_number,
// state machines to reinitialize (link == BOND_LINK_UP) ? "UP" : "DOWN");
/* there is no need to reselect a new aggregator, just signal the
* state machines to reinitialize
*/
port->sm_vars |= AD_PORT_BEGIN; port->sm_vars |= AD_PORT_BEGIN;
__release_state_machine_lock(port);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册