Re: [PATCH] virtio_net: add link status handling

Rusty Russell
2008-12-09T23:56:40Z

On Tuesday 09 December 2008 20:49:33 Mark McLoughlin wrote:
> Allow the host to inform us that the link is down by adding
> a VIRTIO_NET_F_STATUS which indicates that device status is
> available in virtio_net config.

This has been a TODO for a while, thanks!

> + if (vi->status == v)
> + return;
> +
> + vi->status = v;
> +
> + if (vi->status & VIRTIO_NET_S_LINK_UP) {
> + netif_carrier_on(vi->dev);
> + netif_wake_queue(vi->dev);
> + } else {
> + netif_carrier_off(vi->dev);
> + netif_stop_queue(vi->dev);
> + }

New status bits will screw this logic unless we count
on the host not to set them. I suggest:

/* Ignore unknown (future) status bits */
v &= VIRTIO_NET_S_LINK_UP;

Cheers,
Rusty.