diff options
author | David S. Miller <davem@davemloft.net> | 2009-03-05 02:46:25 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-05 02:46:25 -0500 |
commit | 9d40bbda599def1e1d155d7f7dca14fe8744bd2b (patch) | |
tree | d246fbaec294830ecab0bb4b3b38d925abb5ffd8 /net | |
parent | 54acd0efab072cb70e87206329d561b297f93bbb (diff) |
vlan: Fix vlan-in-vlan crashes.
As analyzed by Patrick McHardy, vlan needs to reset it's
netdev_ops pointer in it's ->init() function but this
leaves the compat method pointers stale.
Add a netdev_resync_ops() and call it from the vlan code.
Any other driver which changes ->netdev_ops after register_netdevice()
will need to call this new function after doing so too.
With help from Patrick McHardy.
Tested-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/8021q/vlan_dev.c | 3 | ||||
-rw-r--r-- | net/core/dev.c | 56 |
2 files changed, 36 insertions, 23 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 4a19acd3a32b..1b34135cf990 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -553,7 +553,7 @@ static int vlan_dev_neigh_setup(struct net_device *dev, struct neigh_parms *pa) | |||
553 | int err = 0; | 553 | int err = 0; |
554 | 554 | ||
555 | if (netif_device_present(real_dev) && ops->ndo_neigh_setup) | 555 | if (netif_device_present(real_dev) && ops->ndo_neigh_setup) |
556 | err = ops->ndo_neigh_setup(dev, pa); | 556 | err = ops->ndo_neigh_setup(real_dev, pa); |
557 | 557 | ||
558 | return err; | 558 | return err; |
559 | } | 559 | } |
@@ -639,6 +639,7 @@ static int vlan_dev_init(struct net_device *dev) | |||
639 | dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN; | 639 | dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN; |
640 | dev->netdev_ops = &vlan_netdev_ops; | 640 | dev->netdev_ops = &vlan_netdev_ops; |
641 | } | 641 | } |
642 | netdev_resync_ops(dev); | ||
642 | 643 | ||
643 | if (is_vlan_dev(real_dev)) | 644 | if (is_vlan_dev(real_dev)) |
644 | subclass = 1; | 645 | subclass = 1; |
diff --git a/net/core/dev.c b/net/core/dev.c index 2dd484ed3dbb..f1129706ce7b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4282,6 +4282,39 @@ unsigned long netdev_fix_features(unsigned long features, const char *name) | |||
4282 | } | 4282 | } |
4283 | EXPORT_SYMBOL(netdev_fix_features); | 4283 | EXPORT_SYMBOL(netdev_fix_features); |
4284 | 4284 | ||
4285 | /* Some devices need to (re-)set their netdev_ops inside | ||
4286 | * ->init() or similar. If that happens, we have to setup | ||
4287 | * the compat pointers again. | ||
4288 | */ | ||
4289 | void netdev_resync_ops(struct net_device *dev) | ||
4290 | { | ||
4291 | #ifdef CONFIG_COMPAT_NET_DEV_OPS | ||
4292 | const struct net_device_ops *ops = dev->netdev_ops; | ||
4293 | |||
4294 | dev->init = ops->ndo_init; | ||
4295 | dev->uninit = ops->ndo_uninit; | ||
4296 | dev->open = ops->ndo_open; | ||
4297 | dev->change_rx_flags = ops->ndo_change_rx_flags; | ||
4298 | dev->set_rx_mode = ops->ndo_set_rx_mode; | ||
4299 | dev->set_multicast_list = ops->ndo_set_multicast_list; | ||
4300 | dev->set_mac_address = ops->ndo_set_mac_address; | ||
4301 | dev->validate_addr = ops->ndo_validate_addr; | ||
4302 | dev->do_ioctl = ops->ndo_do_ioctl; | ||
4303 | dev->set_config = ops->ndo_set_config; | ||
4304 | dev->change_mtu = ops->ndo_change_mtu; | ||
4305 | dev->neigh_setup = ops->ndo_neigh_setup; | ||
4306 | dev->tx_timeout = ops->ndo_tx_timeout; | ||
4307 | dev->get_stats = ops->ndo_get_stats; | ||
4308 | dev->vlan_rx_register = ops->ndo_vlan_rx_register; | ||
4309 | dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid; | ||
4310 | dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid; | ||
4311 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
4312 | dev->poll_controller = ops->ndo_poll_controller; | ||
4313 | #endif | ||
4314 | #endif | ||
4315 | } | ||
4316 | EXPORT_SYMBOL(netdev_resync_ops); | ||
4317 | |||
4285 | /** | 4318 | /** |
4286 | * register_netdevice - register a network device | 4319 | * register_netdevice - register a network device |
4287 | * @dev: device to register | 4320 | * @dev: device to register |
@@ -4326,28 +4359,7 @@ int register_netdevice(struct net_device *dev) | |||
4326 | * This is temporary until all network devices are converted. | 4359 | * This is temporary until all network devices are converted. |
4327 | */ | 4360 | */ |
4328 | if (dev->netdev_ops) { | 4361 | if (dev->netdev_ops) { |
4329 | const struct net_device_ops *ops = dev->netdev_ops; | 4362 | netdev_resync_ops(dev); |
4330 | |||
4331 | dev->init = ops->ndo_init; | ||
4332 | dev->uninit = ops->ndo_uninit; | ||
4333 | dev->open = ops->ndo_open; | ||
4334 | dev->change_rx_flags = ops->ndo_change_rx_flags; | ||
4335 | dev->set_rx_mode = ops->ndo_set_rx_mode; | ||
4336 | dev->set_multicast_list = ops->ndo_set_multicast_list; | ||
4337 | dev->set_mac_address = ops->ndo_set_mac_address; | ||
4338 | dev->validate_addr = ops->ndo_validate_addr; | ||
4339 | dev->do_ioctl = ops->ndo_do_ioctl; | ||
4340 | dev->set_config = ops->ndo_set_config; | ||
4341 | dev->change_mtu = ops->ndo_change_mtu; | ||
4342 | dev->neigh_setup = ops->ndo_neigh_setup; | ||
4343 | dev->tx_timeout = ops->ndo_tx_timeout; | ||
4344 | dev->get_stats = ops->ndo_get_stats; | ||
4345 | dev->vlan_rx_register = ops->ndo_vlan_rx_register; | ||
4346 | dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid; | ||
4347 | dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid; | ||
4348 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
4349 | dev->poll_controller = ops->ndo_poll_controller; | ||
4350 | #endif | ||
4351 | } else { | 4363 | } else { |
4352 | char drivername[64]; | 4364 | char drivername[64]; |
4353 | pr_info("%s (%s): not using net_device_ops yet\n", | 4365 | pr_info("%s (%s): not using net_device_ops yet\n", |