Skip to content

Commit a174543

Browse files
jay-vosburghZhengShunQian
authored andcommitted
virtio-net: Fix operstate for virtio when no VIRTIO_NET_F_STATUS
[ Upstream commit bda7fab ] The operstate update logic will leave an interface in the default UNKNOWN operstate if the interface carrier state never changes from the default carrier up state set at creation. This includes the case of an explicit call to netif_carrier_on, as the carrier on to on transition has no effect on operstate. This affects virtio-net for the case that the virtio peer does not support VIRTIO_NET_F_STATUS (the feature that provides carrier state updates). Without this feature, the virtio specification states that "the link should be assumed active," so, logically, the operstate should be UP instead of UNKNOWN. This has impact on user space applications that use the operstate to make availability decisions for the interface. Resolve this by changing the virtio probe logic slightly to call netif_carrier_off for both the "with" and "without" VIRTIO_NET_F_STATUS cases, and then the existing call to netif_carrier_on for the "without" case will cause an operstate transition. Cc: "Michael S. Tsirkin" <[email protected]> Cc: Jason Wang <[email protected]> Cc: Ben Hutchings <[email protected]> Signed-off-by: Jay Vosburgh <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 89e4416 commit a174543

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/virtio_net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,8 +1912,8 @@ static int virtnet_probe(struct virtio_device *vdev)
19121912

19131913
/* Assume link up if device can't report link status,
19141914
otherwise get link status from config. */
1915+
netif_carrier_off(dev);
19151916
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) {
1916-
netif_carrier_off(dev);
19171917
schedule_work(&vi->config_work);
19181918
} else {
19191919
vi->status = VIRTIO_NET_S_LINK_UP;

0 commit comments

Comments
 (0)