]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[linux] Give tap devices a name and bus type
authorMichael Brown <mcb30@ipxe.org>
Tue, 27 Aug 2013 15:28:54 +0000 (16:28 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 27 Aug 2013 15:39:43 +0000 (16:39 +0100)
Give tap devices a meaningful name, and avoid segmentation faults when
attempting to retrieve ${net0/bustype} by assigning a new bus type for
tap devices.

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

index 53bb16a303afaf430e1a8eaf2a92b817254f6f56..99937d74d0f06407d2a6d64ff8111359cebaf3c1 100644 (file)
@@ -216,6 +216,9 @@ static int tap_probe(struct linux_device *device, struct linux_device_request *r
        }
 
        nic->interface = if_setting->value;
+       snprintf ( device->dev.name, sizeof ( device->dev.name ), "%s",
+                  nic->interface );
+       device->dev.desc.bus_type = BUS_TYPE_TAP;
        if_setting->applied = 1;
 
        /* Apply rest of the settings */
index 435af6ecfb6f198196ac6bbe3785991e6c7581e4..c59697c03a015ab548c00d317f7181bb9ef0909f 100644 (file)
@@ -54,6 +54,9 @@ struct device_description {
 /** ISA bus type */
 #define BUS_TYPE_ISA 5
 
+/** TAP bus type */
+#define BUS_TYPE_TAP 6
+
 /** A hardware device */
 struct device {
        /** Name */
index 52e8007dd0d73c4fc4103a71525d8b1438b06166..994e0506ff5581940a0a5719e93b0cc51ff81d7e 100644 (file)
@@ -120,6 +120,7 @@ static int netdev_fetch_bustype ( struct net_device *netdev, void *data,
                [BUS_TYPE_EISA] = "EISA",
                [BUS_TYPE_MCA] = "MCA",
                [BUS_TYPE_ISA] = "ISA",
+               [BUS_TYPE_TAP] = "TAP",
        };
        struct device_description *desc = &netdev->dev->desc;
        const char *bustype;
@@ -127,7 +128,7 @@ static int netdev_fetch_bustype ( struct net_device *netdev, void *data,
        assert ( desc->bus_type < ( sizeof ( bustypes ) /
                                    sizeof ( bustypes[0] ) ) );
        bustype = bustypes[desc->bus_type];
-       assert ( bustypes != NULL );
+       assert ( bustype != NULL );
        strncpy ( data, bustype, len );
        return strlen ( bustype );
 }