Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 131970
b: refs/heads/master
c: 2cf48a1
h: refs/heads/master
v: v3
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Mar 2, 2009
1 parent 5687374 commit 9f986e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cac477e8f1038c41b6f29d3161ce351462ef3df7
refs/heads/master: 2cf48a10aa1f45c7b1f1117a829f2f8a1a1309e2
51 changes: 11 additions & 40 deletions trunk/drivers/net/veth.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ static int veth_open(struct net_device *dev)
return 0;
}

static int veth_close(struct net_device *dev)
{
struct veth_priv *priv = netdev_priv(dev);

netif_carrier_off(dev);
netif_carrier_off(priv->peer);

return 0;
}

static int veth_dev_init(struct net_device *dev)
{
struct veth_net_stats *stats;
Expand All @@ -265,6 +275,7 @@ static void veth_dev_free(struct net_device *dev)
static const struct net_device_ops veth_netdev_ops = {
.ndo_init = veth_dev_init,
.ndo_open = veth_open,
.ndo_stop = veth_close,
.ndo_start_xmit = veth_xmit,
.ndo_get_stats = veth_get_stats,
.ndo_set_mac_address = eth_mac_addr,
Expand All @@ -280,44 +291,6 @@ static void veth_setup(struct net_device *dev)
dev->destructor = veth_dev_free;
}

static void veth_change_state(struct net_device *dev)
{
struct net_device *peer;
struct veth_priv *priv;

priv = netdev_priv(dev);
peer = priv->peer;

if (netif_carrier_ok(peer)) {
if (!netif_carrier_ok(dev))
netif_carrier_on(dev);
} else {
if (netif_carrier_ok(dev))
netif_carrier_off(dev);
}
}

static int veth_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = ptr;

if (dev->netdev_ops->ndo_open != veth_open)
goto out;

switch (event) {
case NETDEV_CHANGE:
veth_change_state(dev);
break;
}
out:
return NOTIFY_DONE;
}

static struct notifier_block veth_notifier_block __read_mostly = {
.notifier_call = veth_device_event,
};

/*
* netlink interface
*/
Expand Down Expand Up @@ -468,14 +441,12 @@ static struct rtnl_link_ops veth_link_ops = {

static __init int veth_init(void)
{
register_netdevice_notifier(&veth_notifier_block);
return rtnl_link_register(&veth_link_ops);
}

static __exit void veth_exit(void)
{
rtnl_link_unregister(&veth_link_ops);
unregister_netdevice_notifier(&veth_notifier_block);
}

module_init(veth_init);
Expand Down

0 comments on commit 9f986e1

Please sign in to comment.