|
27 | 27 | #include <init.h>
|
28 | 28 | #include <irq_kern.h>
|
29 | 29 | #include <irq_user.h>
|
30 |
| -#include <net_kern.h> |
31 | 30 | #include <os.h>
|
32 | 31 | #include "mconsole_kern.h"
|
33 | 32 | #include "vector_user.h"
|
@@ -1539,7 +1538,56 @@ static void vector_timer_expire(struct timer_list *t)
|
1539 | 1538 | napi_schedule(&vp->napi);
|
1540 | 1539 | }
|
1541 | 1540 |
|
| 1541 | +static void vector_setup_etheraddr(struct net_device *dev, char *str) |
| 1542 | +{ |
| 1543 | + u8 addr[ETH_ALEN]; |
| 1544 | + char *end; |
| 1545 | + int i; |
1542 | 1546 |
|
| 1547 | + if (str == NULL) |
| 1548 | + goto random; |
| 1549 | + |
| 1550 | + for (i = 0; i < 6; i++) { |
| 1551 | + addr[i] = simple_strtoul(str, &end, 16); |
| 1552 | + if ((end == str) || |
| 1553 | + ((*end != ':') && (*end != ',') && (*end != '\0'))) { |
| 1554 | + printk(KERN_ERR |
| 1555 | + "setup_etheraddr: failed to parse '%s' " |
| 1556 | + "as an ethernet address\n", str); |
| 1557 | + goto random; |
| 1558 | + } |
| 1559 | + str = end + 1; |
| 1560 | + } |
| 1561 | + if (is_multicast_ether_addr(addr)) { |
| 1562 | + printk(KERN_ERR |
| 1563 | + "Attempt to assign a multicast ethernet address to a " |
| 1564 | + "device disallowed\n"); |
| 1565 | + goto random; |
| 1566 | + } |
| 1567 | + if (!is_valid_ether_addr(addr)) { |
| 1568 | + printk(KERN_ERR |
| 1569 | + "Attempt to assign an invalid ethernet address to a " |
| 1570 | + "device disallowed\n"); |
| 1571 | + goto random; |
| 1572 | + } |
| 1573 | + if (!is_local_ether_addr(addr)) { |
| 1574 | + printk(KERN_WARNING |
| 1575 | + "Warning: Assigning a globally valid ethernet " |
| 1576 | + "address to a device\n"); |
| 1577 | + printk(KERN_WARNING "You should set the 2nd rightmost bit in " |
| 1578 | + "the first byte of the MAC,\n"); |
| 1579 | + printk(KERN_WARNING "i.e. %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 1580 | + addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4], |
| 1581 | + addr[5]); |
| 1582 | + } |
| 1583 | + eth_hw_addr_set(dev, addr); |
| 1584 | + return; |
| 1585 | + |
| 1586 | +random: |
| 1587 | + printk(KERN_INFO |
| 1588 | + "Choosing a random ethernet address for device %s\n", dev->name); |
| 1589 | + eth_hw_addr_random(dev); |
| 1590 | +} |
1543 | 1591 |
|
1544 | 1592 | static void vector_eth_configure(
|
1545 | 1593 | int n,
|
@@ -1574,7 +1622,7 @@ static void vector_eth_configure(
|
1574 | 1622 | * and fail.
|
1575 | 1623 | */
|
1576 | 1624 | snprintf(dev->name, sizeof(dev->name), "vec%d", n);
|
1577 |
| - uml_net_setup_etheraddr(dev, uml_vector_fetch_arg(def, "mac")); |
| 1625 | + vector_setup_etheraddr(dev, uml_vector_fetch_arg(def, "mac")); |
1578 | 1626 | vp = netdev_priv(dev);
|
1579 | 1627 |
|
1580 | 1628 | /* sysfs register */
|
|
0 commit comments