Skip to content

Commit f2edaa4

Browse files
committed
net: virtio: use eth_hw_addr_set()
Commit 406f42f ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it go through appropriate helpers. Even though the current code uses dev->addr_len the we can switch to eth_hw_addr_set() instead of dev_addr_set(). The netdev is always allocated by alloc_etherdev_mq() and there are at least two places which assume Ethernet address: - the line below calling eth_hw_addr_random() - virtnet_set_mac_address() -> eth_commit_mac_addr_change() Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Link: https://lore.kernel.org/r/20211027152012.3393077-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ee775b5 commit f2edaa4

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎drivers/net/virtio_net.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,12 +3177,16 @@ static int virtnet_probe(struct virtio_device *vdev)
31773177
dev->max_mtu = MAX_MTU;
31783178

31793179
/* Configuration may specify what MAC to use. Otherwise random. */
3180-
if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
3180+
if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
3181+
u8 addr[ETH_ALEN];
3182+
31813183
virtio_cread_bytes(vdev,
31823184
offsetof(struct virtio_net_config, mac),
3183-
dev->dev_addr, dev->addr_len);
3184-
else
3185+
addr, ETH_ALEN);
3186+
eth_hw_addr_set(dev, addr);
3187+
} else {
31853188
eth_hw_addr_random(dev);
3189+
}
31863190

31873191
/* Set up our device-specific information */
31883192
vi = netdev_priv(dev);

0 commit comments

Comments
 (0)