Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54296
b: refs/heads/master
c: e024715
h: refs/heads/master
v: v3
  • Loading branch information
Paolo 'Blaisorblade' Giarrusso authored and Linus Torvalds committed May 7, 2007
1 parent 2de5348 commit bc6d027
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 85ee2ce8ae7d6716beffc84451dd65cd217dbf7a
refs/heads/master: e024715f5f6250179a31716a898800a48cf23b39
38 changes: 29 additions & 9 deletions trunk/arch/um/drivers/net_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void uml_net_user_timer_expire(unsigned long _conn)
#endif
}

static void setup_etheraddr(char *str, unsigned char *addr)
static void setup_etheraddr(char *str, unsigned char *addr, char *name)
{
char *end;
int i;
Expand All @@ -302,15 +302,32 @@ static void setup_etheraddr(char *str, unsigned char *addr)
}
str = end + 1;
}
if(addr[0] & 1){
if (is_multicast_ether_addr(addr)) {
printk(KERN_ERR
"Attempt to assign a broadcast ethernet address to a "
"Attempt to assign a multicast ethernet address to a "
"device disallowed\n");
goto random;
}
if (!is_valid_ether_addr(addr)) {
printk(KERN_ERR
"Attempt to assign an invalid ethernet address to a "
"device disallowed\n");
goto random;
}
if (!is_local_ether_addr(addr)) {
printk(KERN_WARNING
"Warning: attempt to assign a globally valid ethernet address to a "
"device\n");
printk(KERN_WARNING "You should better enable the 2nd rightmost bit "
"in the first byte of the MAC, i.e. "
"%02x:%02x:%02x:%02x:%02x:%02x\n",
addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4], addr[5]);
}
return;

random:
printk(KERN_INFO
"Choosing a random ethernet address for device %s\n", name);
random_ether_addr(addr);
}

Expand All @@ -331,6 +348,7 @@ static void eth_configure(int n, void *init, char *mac,
struct net_device *dev;
struct uml_net_private *lp;
int save, err, size;
char name[sizeof(dev->name)];

size = transport->private_size + sizeof(struct uml_net_private) +
sizeof(((struct uml_net_private *) 0)->user);
Expand All @@ -344,7 +362,13 @@ static void eth_configure(int n, void *init, char *mac,
INIT_LIST_HEAD(&device->list);
device->index = n;

setup_etheraddr(mac, device->mac);
/* If this name ends up conflicting with an existing registered
* netdevice, that is OK, register_netdev{,ice}() will notice this
* and fail.
*/
snprintf(name, sizeof(name), "eth%d", n);

setup_etheraddr(mac, device->mac, name);

printk(KERN_INFO "Netdevice %d ", n);
printk("(%02x:%02x:%02x:%02x:%02x:%02x) ",
Expand Down Expand Up @@ -375,11 +399,7 @@ static void eth_configure(int n, void *init, char *mac,
goto out_free_netdev;
SET_NETDEV_DEV(dev,&device->pdev.dev);

/* If this name ends up conflicting with an existing registered
* netdevice, that is OK, register_netdev{,ice}() will notice this
* and fail.
*/
snprintf(dev->name, sizeof(dev->name), "eth%d", n);
strcpy(dev->name, name);
device->dev = dev;

/*
Expand Down
12 changes: 12 additions & 0 deletions trunk/include/linux/etherdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ static inline int is_multicast_ether_addr(const u8 *addr)
return (0x01 & addr[0]);
}

/**
* is_local_ether_addr - Determine if the Ethernet address is locally-assigned
* one (IEEE 802).
* @addr: Pointer to a six-byte array containing the Ethernet address
*
* Return true if the address is a local address.
*/
static inline int is_local_ether_addr(const u8 *addr)
{
return (0x02 & addr[0]);
}

/**
* is_broadcast_ether_addr - Determine if the Ethernet address is broadcast
* @addr: Pointer to a six-byte array containing the Ethernet address
Expand Down

0 comments on commit bc6d027

Please sign in to comment.