Commit 2908a20e authored by David S. Miller's avatar David S. Miller

[NET]: Eliminate init_etherdev usage from arch/um drivers.

parent bea71ef2
...@@ -24,18 +24,13 @@ void daemon_init(struct net_device *dev, void *data) ...@@ -24,18 +24,13 @@ void daemon_init(struct net_device *dev, void *data)
struct daemon_data *dpri; struct daemon_data *dpri;
struct daemon_init *init = data; struct daemon_init *init = data;
init_etherdev(dev, 0);
pri = dev->priv; pri = dev->priv;
dpri = (struct daemon_data *) pri->user; dpri = (struct daemon_data *) pri->user;
*dpri = ((struct daemon_data) dpri->sock_type = init->sock_type;
{ .sock_type = init->sock_type, dpri->ctl_sock = init->ctl_sock;
.ctl_sock = init->ctl_sock, dpri->fd = -1;
.ctl_addr = NULL, dpri->control = -1;
.data_addr = NULL, dpri->dev = dev;
.local_addr = NULL,
.fd = -1,
.control = -1,
.dev = dev });
printk("daemon backend (uml_switch version %d) - %s:%s", printk("daemon backend (uml_switch version %d) - %s:%s",
SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock); SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock);
......
...@@ -32,15 +32,13 @@ void mcast_init(struct net_device *dev, void *data) ...@@ -32,15 +32,13 @@ void mcast_init(struct net_device *dev, void *data)
struct mcast_data *dpri; struct mcast_data *dpri;
struct mcast_init *init = data; struct mcast_init *init = data;
init_etherdev(dev, 0);
pri = dev->priv; pri = dev->priv;
dpri = (struct mcast_data *) pri->user; dpri = (struct mcast_data *) pri->user;
*dpri = ((struct mcast_data) dpri->addr = init->addr;
{ .addr = init->addr, dpri->port = init->port;
.port = init->port, dpri->ttl = init->ttl;
.ttl = init->ttl, dpri->dev = dev;
.mcast_addr = NULL,
.dev = dev });
printk("mcast backend "); printk("mcast backend ");
printk("multicast adddress: %s:%u, TTL:%u ", printk("multicast adddress: %s:%u, TTL:%u ",
dpri->addr, dpri->port, dpri->ttl); dpri->addr, dpri->port, dpri->ttl);
......
...@@ -292,45 +292,46 @@ static int eth_configure(int n, void *init, char *mac, ...@@ -292,45 +292,46 @@ static int eth_configure(int n, void *init, char *mac,
struct uml_net *device; struct uml_net *device;
struct net_device *dev; struct net_device *dev;
struct uml_net_private *lp; struct uml_net_private *lp;
int save, err, size; int err, size;
size = transport->private_size + sizeof(struct uml_net_private) + size = transport->private_size + sizeof(struct uml_net_private) +
sizeof(((struct uml_net_private *) 0)->user); sizeof(((struct uml_net_private *) 0)->user);
device = kmalloc(sizeof(*device), GFP_KERNEL); device = kmalloc(sizeof(*device), GFP_KERNEL);
if(device == NULL){ if (device == NULL) {
printk(KERN_ERR "eth_configure failed to allocate uml_net\n"); printk(KERN_ERR "eth_configure failed to allocate uml_net\n");
return(1); return(1);
} }
*device = ((struct uml_net) { .list = LIST_HEAD_INIT(device->list), memset(device, 0, sizeof(*device));
.dev = NULL, device->list = LIST_HEAD_INIT(device->list);
.index = n, device->index = n;
.mac = { [ 0 ... 5 ] = 0 },
.have_mac = 0 });
spin_lock(&devices_lock); spin_lock(&devices_lock);
list_add(&device->list, &devices); list_add(&device->list, &devices);
spin_unlock(&devices_lock); spin_unlock(&devices_lock);
if(setup_etheraddr(mac, device->mac)) if (setup_etheraddr(mac, device->mac))
device->have_mac = 1; device->have_mac = 1;
printk(KERN_INFO "Netdevice %d ", n); printk(KERN_INFO "Netdevice %d ", n);
if(device->have_mac) printk("(%02x:%02x:%02x:%02x:%02x:%02x) ", if (device->have_mac)
printk("(%02x:%02x:%02x:%02x:%02x:%02x) ",
device->mac[0], device->mac[1], device->mac[0], device->mac[1],
device->mac[2], device->mac[3], device->mac[2], device->mac[3],
device->mac[4], device->mac[5]); device->mac[4], device->mac[5]);
printk(": "); printk(": ");
dev = kmalloc(sizeof(*dev) + size, GFP_KERNEL); dev = alloc_etherdev(size);
if(dev == NULL){ if (dev == NULL) {
printk(KERN_ERR "eth_configure: failed to allocate device\n"); printk(KERN_ERR "eth_configure: failed to allocate device\n");
return(1); return 1;
} }
memset(dev, 0, sizeof(*dev) + size);
/* 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); snprintf(dev->name, sizeof(dev->name), "eth%d", n);
dev->priv = (void *) &dev[1];
device->dev = dev; device->dev = dev;
dev->hard_header = uml_net_hard_header; dev->hard_header = uml_net_hard_header;
...@@ -357,42 +358,35 @@ static int eth_configure(int n, void *init, char *mac, ...@@ -357,42 +358,35 @@ static int eth_configure(int n, void *init, char *mac,
rtnl_lock(); rtnl_lock();
err = register_netdevice(dev); err = register_netdevice(dev);
rtnl_unlock(); rtnl_unlock();
if(err) if (err)
return(1); return 1;
lp = dev->priv; lp = dev->priv;
/* lp.user is the first four bytes of the transport data, which lp->list = LIST_HEAD_INIT(lp->list);
* has already been initialized. This structure assignment will spin_lock_init(&lp->lock);
* overwrite that, so we make sure that .user gets overwritten with lp->dev = dev;
* what it already has. lp->fd = -1;
*/ lp->mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0 };
save = lp->user[0]; lp->have_mac = device->have_mac;
*lp = ((struct uml_net_private) lp->protocol = transport->kern->protocol;
{ .list = LIST_HEAD_INIT(lp->list), lp->open = transport->user->open;
.lock = SPIN_LOCK_UNLOCKED, lp->close = transport->user->close;
.dev = dev, lp->remove = transport->user->remove;
.fd = -1, lp->read = transport->kern->read;
.mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0}, lp->write = transport->kern->write;
.have_mac = device->have_mac, lp->add_address = transport->user->add_address;
.protocol = transport->kern->protocol, lp->delete_address = transport->user->delete_address;
.open = transport->user->open, lp->set_mtu = transport->user->set_mtu;
.close = transport->user->close,
.remove = transport->user->remove,
.read = transport->kern->read,
.write = transport->kern->write,
.add_address = transport->user->add_address,
.delete_address = transport->user->delete_address,
.set_mtu = transport->user->set_mtu,
.user = { save } });
init_timer(&lp->tl); init_timer(&lp->tl);
lp->tl.function = uml_net_user_timer_expire; lp->tl.function = uml_net_user_timer_expire;
memset(&lp->stats, 0, sizeof(lp->stats)); if (lp->have_mac)
if(lp->have_mac) memcpy(lp->mac, device->mac, sizeof(lp->mac)); memcpy(lp->mac, device->mac, sizeof(lp->mac));
if(transport->user->init) if (transport->user->init)
(*transport->user->init)(&lp->user, dev); (*transport->user->init)(&lp->user, dev);
if(device->have_mac) if (device->have_mac)
set_ether_mac(dev, device->mac); set_ether_mac(dev, device->mac);
return(0); return(0);
} }
...@@ -538,13 +532,15 @@ static int eth_setup(char *str) ...@@ -538,13 +532,15 @@ static int eth_setup(char *str)
if(err) return(1); if(err) return(1);
new = alloc_bootmem(sizeof(new)); new = alloc_bootmem(sizeof(new));
if(new == NULL){ if (new == NULL){
printk("eth_init : alloc_bootmem failed\n"); printk("eth_init : alloc_bootmem failed\n");
return(1); return(1);
} }
*new = ((struct eth_init) { .list = LIST_HEAD_INIT(new->list),
.index = n, new->list = LIST_HEAD_INIT(new->list);
.init = str }); new->index = n;
new->init = str;
list_add_tail(&new->list, &eth_cmd_line); list_add_tail(&new->list, &eth_cmd_line);
return(1); return(1);
} }
......
...@@ -23,16 +23,12 @@ void pcap_init(struct net_device *dev, void *data) ...@@ -23,16 +23,12 @@ void pcap_init(struct net_device *dev, void *data)
struct pcap_data *ppri; struct pcap_data *ppri;
struct pcap_init *init = data; struct pcap_init *init = data;
init_etherdev(dev, 0);
pri = dev->priv; pri = dev->priv;
ppri = (struct pcap_data *) pri->user; ppri = (struct pcap_data *) pri->user;
*ppri = ((struct pcap_data) ppri->host_if = init->host_if;
{ .host_if = init->host_if, ppri->promisc = init->promisc;
.promisc = init->promisc, ppri->optimize = init->optimize;
.optimize = init->optimize, ppri->filter = init->filter;
.filter = init->filter,
.compiled = NULL,
.pcap = NULL });
} }
static int pcap_read(int fd, struct sk_buff **skb, static int pcap_read(int fd, struct sk_buff **skb,
......
...@@ -24,18 +24,16 @@ static void etap_init(struct net_device *dev, void *data) ...@@ -24,18 +24,16 @@ static void etap_init(struct net_device *dev, void *data)
struct ethertap_data *epri; struct ethertap_data *epri;
struct ethertap_init *init = data; struct ethertap_init *init = data;
init_etherdev(dev, 0);
pri = dev->priv; pri = dev->priv;
epri = (struct ethertap_data *) pri->user; epri = (struct ethertap_data *) pri->user;
*epri = ((struct ethertap_data) epri->dev_name = init->dev_name;
{ .dev_name = init->dev_name, epri->gate_addr = init->gate_addr;
.gate_addr = init->gate_addr, epri->data_fd = -1;
.data_fd = -1, epri->control_fd = -1;
.control_fd = -1, epri->dev = dev;
.dev = dev });
printk("ethertap backend - %s", epri->dev_name); printk("ethertap backend - %s", epri->dev_name);
if(epri->gate_addr != NULL) if (epri->gate_addr != NULL)
printk(", IP = %s", epri->gate_addr); printk(", IP = %s", epri->gate_addr);
printk("\n"); printk("\n");
} }
......
...@@ -24,17 +24,16 @@ static void tuntap_init(struct net_device *dev, void *data) ...@@ -24,17 +24,16 @@ static void tuntap_init(struct net_device *dev, void *data)
struct tuntap_data *tpri; struct tuntap_data *tpri;
struct tuntap_init *init = data; struct tuntap_init *init = data;
init_etherdev(dev, 0);
pri = dev->priv; pri = dev->priv;
tpri = (struct tuntap_data *) pri->user; tpri = (struct tuntap_data *) pri->user;
*tpri = ((struct tuntap_data) tpri->dev_name = init->dev_name;
{ .dev_name = init->dev_name, tpri->fixed_config = (init->dev_name != NULL);
.fixed_config = (init->dev_name != NULL), tpri->gate_addr = init->gate_addr;
.gate_addr = init->gate_addr, tpri->fd = -1;
.fd = -1, tpri->dev = dev;
.dev = dev });
printk("TUN/TAP backend - "); printk("TUN/TAP backend - ");
if(tpri->gate_addr != NULL) if (tpri->gate_addr != NULL)
printk("IP = %s", tpri->gate_addr); printk("IP = %s", tpri->gate_addr);
printk("\n"); printk("\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment