aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/veth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/veth.c')
-rw-r--r--drivers/net/veth.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 31cd817f33f9..852d0e7c4e62 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -8,7 +8,6 @@
8 * 8 *
9 */ 9 */
10 10
11#include <linux/list.h>
12#include <linux/netdevice.h> 11#include <linux/netdevice.h>
13#include <linux/ethtool.h> 12#include <linux/ethtool.h>
14#include <linux/etherdevice.h> 13#include <linux/etherdevice.h>
@@ -30,14 +29,10 @@ struct veth_net_stats {
30 29
31struct veth_priv { 30struct veth_priv {
32 struct net_device *peer; 31 struct net_device *peer;
33 struct net_device *dev;
34 struct list_head list;
35 struct veth_net_stats *stats; 32 struct veth_net_stats *stats;
36 unsigned ip_summed; 33 unsigned ip_summed;
37}; 34};
38 35
39static LIST_HEAD(veth_list);
40
41/* 36/*
42 * ethtool interface 37 * ethtool interface
43 */ 38 */
@@ -267,16 +262,20 @@ static void veth_dev_free(struct net_device *dev)
267 free_netdev(dev); 262 free_netdev(dev);
268} 263}
269 264
265static const struct net_device_ops veth_netdev_ops = {
266 .ndo_init = veth_dev_init,
267 .ndo_open = veth_open,
268 .ndo_start_xmit = veth_xmit,
269 .ndo_get_stats = veth_get_stats,
270};
271
270static void veth_setup(struct net_device *dev) 272static void veth_setup(struct net_device *dev)
271{ 273{
272 ether_setup(dev); 274 ether_setup(dev);
273 275
274 dev->hard_start_xmit = veth_xmit; 276 dev->netdev_ops = &veth_netdev_ops;
275 dev->get_stats = veth_get_stats;
276 dev->open = veth_open;
277 dev->ethtool_ops = &veth_ethtool_ops; 277 dev->ethtool_ops = &veth_ethtool_ops;
278 dev->features |= NETIF_F_LLTX; 278 dev->features |= NETIF_F_LLTX;
279 dev->init = veth_dev_init;
280 dev->destructor = veth_dev_free; 279 dev->destructor = veth_dev_free;
281} 280}
282 281
@@ -302,7 +301,7 @@ static int veth_device_event(struct notifier_block *unused,
302{ 301{
303 struct net_device *dev = ptr; 302 struct net_device *dev = ptr;
304 303
305 if (dev->open != veth_open) 304 if (dev->netdev_ops->ndo_open != veth_open)
306 goto out; 305 goto out;
307 306
308 switch (event) { 307 switch (event) {
@@ -420,14 +419,10 @@ static int veth_newlink(struct net_device *dev,
420 */ 419 */
421 420
422 priv = netdev_priv(dev); 421 priv = netdev_priv(dev);
423 priv->dev = dev;
424 priv->peer = peer; 422 priv->peer = peer;
425 list_add(&priv->list, &veth_list);
426 423
427 priv = netdev_priv(peer); 424 priv = netdev_priv(peer);
428 priv->dev = peer;
429 priv->peer = dev; 425 priv->peer = dev;
430 INIT_LIST_HEAD(&priv->list);
431 return 0; 426 return 0;
432 427
433err_register_dev: 428err_register_dev:
@@ -449,13 +444,6 @@ static void veth_dellink(struct net_device *dev)
449 priv = netdev_priv(dev); 444 priv = netdev_priv(dev);
450 peer = priv->peer; 445 peer = priv->peer;
451 446
452 if (!list_empty(&priv->list))
453 list_del(&priv->list);
454
455 priv = netdev_priv(peer);
456 if (!list_empty(&priv->list))
457 list_del(&priv->list);
458
459 unregister_netdevice(dev); 447 unregister_netdevice(dev);
460 unregister_netdevice(peer); 448 unregister_netdevice(peer);
461} 449}