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