]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Initialize MAC and IP address for uip properly
authorAsias He <asias.hejun@gmail.com>
Sun, 17 Jul 2011 08:57:04 +0000 (16:57 +0800)
committerPekka Enberg <penberg@kernel.org>
Mon, 18 Jul 2011 10:17:22 +0000 (13:17 +0300)
- Drop static initialization

- Use {host,guet}_{ip,mac} to initialize

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/virtio/net.c

index af9b7409f6baf9dcc1d82fa2b11b53324f058e0d..739f157449204403369bbd26b3718255c46d8e94 100644 (file)
@@ -93,9 +93,6 @@ static struct net_dev ndev = {
                                        | 1UL << VIRTIO_NET_F_GUEST_TSO4
                                        | 1UL << VIRTIO_NET_F_GUEST_TSO6,
        .info = {
-               .host_mac.addr          = {0x00, 0x01, 0x01, 0x01, 0x01, 0x01},
-               .guest_mac.addr         = {0x00, 0x15, 0x15, 0x15, 0x15, 0x15},
-               .host_ip                = 0xc0a82101,
                .buf_nr                 = 20,
        }
 };
@@ -455,14 +452,20 @@ void virtio_net__init(const struct virtio_net_parameters *params)
        ndev.base_addr      = net_base_addr;
        pci__register(&pci_header, dev);
 
-       for (i = 0 ; i < 6 ; i++)
-               ndev.config.mac[i] = params->guest_mac[i];
+       for (i = 0 ; i < 6 ; i++) {
+               ndev.config.mac[i]              = params->guest_mac[i];
+               ndev.info.guest_mac.addr[i]     = params->guest_mac[i];
+               ndev.info.host_mac.addr[i]      = params->host_mac[i];
+       }
 
        ndev.mode = params->mode;
        if (ndev.mode == NET_MODE_TAP) {
                virtio_net__tap_init(params);
                ndev.ops = &tap_ops;
        } else {
+               ndev.info.host_ip               = ntohl(inet_addr(params->host_ip));
+               ndev.info.guest_ip              = ntohl(inet_addr(params->guest_ip));
+               ndev.info.guest_netmask         = ntohl(inet_addr("255.255.255.0"));
                uip_init(&ndev.info);
                ndev.ops = &uip_ops;
        }