diff mbox series

[v3,1/2] virtio_net: disable VIRTIO_NET_F_STANDBY if VIRTIO_NET_F_MAC is not set

Message ID 20230127204500.51930-2-lvivier@redhat.com (mailing list archive)
State Accepted
Commit 7c06458c102ee66068c03780527fcfc9b954ad91
Delegated to: Netdev Maintainers
Headers show
Series virtio_net: vdpa: update MAC address when it is generated by virtio-net | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 3 maintainers not CCed: edumazet@google.com kuba@kernel.org pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Laurent Vivier Jan. 27, 2023, 8:44 p.m. UTC
failover relies on the MAC address to pair the primary and the standby
devices:

  "[...] the hypervisor needs to enable VIRTIO_NET_F_STANDBY
   feature on the virtio-net interface and assign the same MAC address
   to both virtio-net and VF interfaces."

  Documentation/networking/net_failover.rst

This patch disables the STANDBY feature if the MAC address is not
provided by the hypervisor.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 drivers/net/virtio_net.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Michael S. Tsirkin Jan. 31, 2023, 10:09 p.m. UTC | #1
On Fri, Jan 27, 2023 at 09:44:59PM +0100, Laurent Vivier wrote:
> failover relies on the MAC address to pair the primary and the standby
> devices:
> 
>   "[...] the hypervisor needs to enable VIRTIO_NET_F_STANDBY
>    feature on the virtio-net interface and assign the same MAC address
>    to both virtio-net and VF interfaces."
> 
>   Documentation/networking/net_failover.rst
> 
> This patch disables the STANDBY feature if the MAC address is not
> provided by the hypervisor.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  drivers/net/virtio_net.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7723b2a49d8e..7d700f8e545a 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -3688,6 +3688,12 @@ static int virtnet_validate(struct virtio_device *vdev)
>  			__virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
>  	}
>  
> +	if (virtio_has_feature(vdev, VIRTIO_NET_F_STANDBY) &&
> +	    !virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
> +		dev_warn(&vdev->dev, "device advertises feature VIRTIO_NET_F_STANDBY but not VIRTIO_NET_F_MAC, disabling standby");
> +		__virtio_clear_bit(vdev, VIRTIO_NET_F_STANDBY);
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.39.1
diff mbox series

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7723b2a49d8e..7d700f8e545a 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -3688,6 +3688,12 @@  static int virtnet_validate(struct virtio_device *vdev)
 			__virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
 	}
 
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_STANDBY) &&
+	    !virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
+		dev_warn(&vdev->dev, "device advertises feature VIRTIO_NET_F_STANDBY but not VIRTIO_NET_F_MAC, disabling standby");
+		__virtio_clear_bit(vdev, VIRTIO_NET_F_STANDBY);
+	}
+
 	return 0;
 }