[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] netfront: Support set_mac_address()



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1207218965 -3600
# Node ID 2cc4d7bf6b61649e97d2d26d9105e66aa53c546b
# Parent  636cd340e024e921ffd8f3575e6775d4cb6dc48c
netfront: Support set_mac_address()

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx>
---
 drivers/xen/netfront/netfront.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff -r 636cd340e024 -r 2cc4d7bf6b61 drivers/xen/netfront/netfront.c
--- a/drivers/xen/netfront/netfront.c   Thu Apr 03 11:30:56 2008 +0100
+++ b/drivers/xen/netfront/netfront.c   Thu Apr 03 11:36:05 2008 +0100
@@ -366,10 +366,14 @@ static int talk_to_backend(struct xenbus
        struct xenbus_transaction xbt;
        int err;
 
-       err = xen_net_read_mac(dev, info->mac);
-       if (err) {
-               xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
-               goto out;
+       /* Read mac only in the first setup. */
+       if (!is_valid_ether_addr(info->mac)) {
+               err = xen_net_read_mac(dev, info->mac);
+               if (err) {
+                       xenbus_dev_fatal(dev, err, "parsing %s/mac",
+                                        dev->nodename);
+                       goto out;
+               }
        }
 
        /* Create shared ring, alloc event channel. */
@@ -1688,6 +1692,20 @@ static struct net_device_stats *network_
        return &np->stats;
 }
 
+static int xennet_set_mac_address(struct net_device *dev, void *p)
+{
+       struct netfront_info *np = netdev_priv(dev);
+       struct sockaddr *addr = p;
+
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EADDRNOTAVAIL;
+       
+       memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+       memcpy(np->mac, addr->sa_data, ETH_ALEN);
+
+       return 0;
+}
+
 static int xennet_change_mtu(struct net_device *dev, int mtu)
 {
        int max = xennet_can_sg(dev) ? 65535 - ETH_HLEN : ETH_DATA_LEN;
@@ -2075,6 +2093,7 @@ static struct net_device * __devinit cre
        netdev->poll            = netif_poll;
        netdev->set_multicast_list = network_set_multicast_list;
        netdev->uninit          = netif_uninit;
+       netdev->set_mac_address = xennet_set_mac_address;
        netdev->change_mtu      = xennet_change_mtu;
        netdev->weight          = 64;
        netdev->features        = NETIF_F_IP_CSUM;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.