]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[linux] Set a default MAC address for tap devices
authorMichael Brown <mcb30@ipxe.org>
Wed, 5 Jul 2023 14:24:32 +0000 (15:24 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 5 Jul 2023 14:24:32 +0000 (15:24 +0100)
Avoid the need to always specify a local MAC address on the command
line by setting a default hardware MAC address (using the same default
address as for slirp devices).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/linux/tap.c

index 9b52c20ab510a1f60b7c94d1471f2ce9fbe12e0a..c1364ddb504dee3096ec16fe73312a823e0d083d 100644 (file)
@@ -56,6 +56,10 @@ struct tap_nic {
        int fd;
 };
 
+/** Default MAC address */
+static const uint8_t tap_default_mac[ETH_ALEN] =
+       { 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 };
+
 /** Open the TAP device */
 static int tap_open(struct net_device * netdev)
 {
@@ -202,6 +206,7 @@ static int tap_probe(struct linux_device *device, struct linux_device_request *r
        nic = netdev->priv;
        linux_set_drvdata(device, netdev);
        netdev->dev = &device->dev;
+       memcpy ( netdev->hw_addr, tap_default_mac, ETH_ALEN );
        memset(nic, 0, sizeof(*nic));
 
        /* Look for the mandatory if setting */