ia64/linux-2.6.18-xen.hg

changeset 510:2cc4d7bf6b61

netfront: Support set_mac_address()

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 03 11:36:05 2008 +0100 (2008-04-03)
parents 636cd340e024
children 3cd6b2bef0ce
files drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/drivers/xen/netfront/netfront.c	Thu Apr 03 11:30:56 2008 +0100
     1.2 +++ b/drivers/xen/netfront/netfront.c	Thu Apr 03 11:36:05 2008 +0100
     1.3 @@ -366,10 +366,14 @@ static int talk_to_backend(struct xenbus
     1.4  	struct xenbus_transaction xbt;
     1.5  	int err;
     1.6  
     1.7 -	err = xen_net_read_mac(dev, info->mac);
     1.8 -	if (err) {
     1.9 -		xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
    1.10 -		goto out;
    1.11 +	/* Read mac only in the first setup. */
    1.12 +	if (!is_valid_ether_addr(info->mac)) {
    1.13 +		err = xen_net_read_mac(dev, info->mac);
    1.14 +		if (err) {
    1.15 +			xenbus_dev_fatal(dev, err, "parsing %s/mac",
    1.16 +					 dev->nodename);
    1.17 +			goto out;
    1.18 +		}
    1.19  	}
    1.20  
    1.21  	/* Create shared ring, alloc event channel. */
    1.22 @@ -1688,6 +1692,20 @@ static struct net_device_stats *network_
    1.23  	return &np->stats;
    1.24  }
    1.25  
    1.26 +static int xennet_set_mac_address(struct net_device *dev, void *p)
    1.27 +{
    1.28 +	struct netfront_info *np = netdev_priv(dev);
    1.29 +	struct sockaddr *addr = p;
    1.30 +
    1.31 +	if (!is_valid_ether_addr(addr->sa_data))
    1.32 +		return -EADDRNOTAVAIL;
    1.33 +	
    1.34 +	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
    1.35 +	memcpy(np->mac, addr->sa_data, ETH_ALEN);
    1.36 +
    1.37 +	return 0;
    1.38 +}
    1.39 +
    1.40  static int xennet_change_mtu(struct net_device *dev, int mtu)
    1.41  {
    1.42  	int max = xennet_can_sg(dev) ? 65535 - ETH_HLEN : ETH_DATA_LEN;
    1.43 @@ -2075,6 +2093,7 @@ static struct net_device * __devinit cre
    1.44  	netdev->poll            = netif_poll;
    1.45  	netdev->set_multicast_list = network_set_multicast_list;
    1.46  	netdev->uninit          = netif_uninit;
    1.47 +	netdev->set_mac_address	= xennet_set_mac_address;
    1.48  	netdev->change_mtu	= xennet_change_mtu;
    1.49  	netdev->weight          = 64;
    1.50  	netdev->features        = NETIF_F_IP_CSUM;