Browse Source

[linux] Give tap devices a name and bus type

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>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
ae0124cd40
3 changed files with 8 additions and 1 deletions
  1. 3
    0
      src/drivers/linux/tap.c
  2. 3
    0
      src/include/ipxe/device.h
  3. 2
    1
      src/net/netdev_settings.c

+ 3
- 0
src/drivers/linux/tap.c View File

216
 	}
216
 	}
217
 
217
 
218
 	nic->interface = if_setting->value;
218
 	nic->interface = if_setting->value;
219
+	snprintf ( device->dev.name, sizeof ( device->dev.name ), "%s",
220
+		   nic->interface );
221
+	device->dev.desc.bus_type = BUS_TYPE_TAP;
219
 	if_setting->applied = 1;
222
 	if_setting->applied = 1;
220
 
223
 
221
 	/* Apply rest of the settings */
224
 	/* Apply rest of the settings */

+ 3
- 0
src/include/ipxe/device.h View File

54
 /** ISA bus type */
54
 /** ISA bus type */
55
 #define BUS_TYPE_ISA 5
55
 #define BUS_TYPE_ISA 5
56
 
56
 
57
+/** TAP bus type */
58
+#define BUS_TYPE_TAP 6
59
+
57
 /** A hardware device */
60
 /** A hardware device */
58
 struct device {
61
 struct device {
59
 	/** Name */
62
 	/** Name */

+ 2
- 1
src/net/netdev_settings.c View File

120
 		[BUS_TYPE_EISA] = "EISA",
120
 		[BUS_TYPE_EISA] = "EISA",
121
 		[BUS_TYPE_MCA] = "MCA",
121
 		[BUS_TYPE_MCA] = "MCA",
122
 		[BUS_TYPE_ISA] = "ISA",
122
 		[BUS_TYPE_ISA] = "ISA",
123
+		[BUS_TYPE_TAP] = "TAP",
123
 	};
124
 	};
124
 	struct device_description *desc = &netdev->dev->desc;
125
 	struct device_description *desc = &netdev->dev->desc;
125
 	const char *bustype;
126
 	const char *bustype;
127
 	assert ( desc->bus_type < ( sizeof ( bustypes ) /
128
 	assert ( desc->bus_type < ( sizeof ( bustypes ) /
128
 				    sizeof ( bustypes[0] ) ) );
129
 				    sizeof ( bustypes[0] ) ) );
129
 	bustype = bustypes[desc->bus_type];
130
 	bustype = bustypes[desc->bus_type];
130
-	assert ( bustypes != NULL );
131
+	assert ( bustype != NULL );
131
 	strncpy ( data, bustype, len );
132
 	strncpy ( data, bustype, len );
132
 	return strlen ( bustype );
133
 	return strlen ( bustype );
133
 }
134
 }

Loading…
Cancel
Save