提交 b4a488d1 编写于 作者: S Stephen Hemminger 提交者: David S. Miller

[BRIDGE]: Fix OOPS when bridging device without ethtool.

Bridge code calls ethtool to get speed. The conversion to using
only ethtool_ops broke the case of devices without ethtool_ops.
This is a new regression in 2.6.23.

Rearranged the switch to a logical order, and use gcc initializer.

Ps: speed should have been part of the network device structure from
    the start rather than burying it in ethtool.
Signed-off-by: NStephen Hemminger <shemminger@linux-foundation.org>
Acked-by: NMatthew Wilcox <matthew@wil.cx>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 df1c0b84
...@@ -33,17 +33,17 @@ ...@@ -33,17 +33,17 @@
*/ */
static int port_cost(struct net_device *dev) static int port_cost(struct net_device *dev)
{ {
if (dev->ethtool_ops->get_settings) { if (dev->ethtool_ops && dev->ethtool_ops->get_settings) {
struct ethtool_cmd ecmd = { ETHTOOL_GSET }; struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET, };
int err = dev->ethtool_ops->get_settings(dev, &ecmd);
if (!err) { if (!dev->ethtool_ops->get_settings(dev, &ecmd)) {
switch(ecmd.speed) { switch(ecmd.speed) {
case SPEED_100:
return 19;
case SPEED_1000:
return 4;
case SPEED_10000: case SPEED_10000:
return 2; return 2;
case SPEED_1000:
return 4;
case SPEED_100:
return 19;
case SPEED_10: case SPEED_10:
return 100; return 100;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册