2 * Copyright (C) 2007 Luca Bigliardi (shammash@artha.org).
3 * Licensed under the GPL.
6 * ethN=vde,<vde_switch>,<mac addr>,<port>,<group>,<mode>,<description>
10 #include "linux/init.h"
11 #include <linux/netdevice.h>
16 static void vde_init(struct net_device *dev, void *data)
18 struct vde_init *init = data;
19 struct uml_net_private *pri;
20 struct vde_data *vpri;
23 vpri = (struct vde_data *) pri->user;
25 vpri->vde_switch = init->vde_switch;
26 vpri->descr = init->descr ? init->descr : "UML vde_transport";
31 printk("vde backend - %s, ", vpri->vde_switch ?
32 vpri->vde_switch : "(default socket)");
34 vde_init_libstuff(vpri, init);
39 static int vde_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
41 struct vde_data *pri = (struct vde_data *) &lp->user;
43 if (pri->conn != NULL) {
44 *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
48 return vde_user_read(pri->conn, skb_mac_header(*skb),
49 (*skb)->dev->mtu + ETH_HEADER_OTHER);
52 printk(KERN_ERR "vde_read - we have no VDECONN to read from");
56 static int vde_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
58 struct vde_data *pri = (struct vde_data *) &lp->user;
60 if (pri->conn != NULL)
61 return vde_user_write((void *)pri->conn, (*skb)->data,
64 printk(KERN_ERR "vde_write - we have no VDECONN to write to");
68 static const struct net_kern_info vde_kern_info = {
70 .protocol = eth_protocol,
75 static int vde_setup(char *str, char **mac_out, void *data)
77 struct vde_init *init = data;
78 char *remain, *port_str = NULL, *mode_str = NULL, *last;
80 *init = ((struct vde_init)
87 remain = split_if_spec(str, &init->vde_switch, mac_out, &port_str,
88 &init->group, &mode_str, &init->descr, NULL);
91 printk(KERN_WARNING "vde_setup - Ignoring extra data :"
94 if (port_str != NULL) {
95 init->port = simple_strtoul(port_str, &last, 10);
96 if ((*last != '\0') || (last == port_str)) {
97 printk(KERN_ERR "vde_setup - Bad port : '%s'\n",
103 if (mode_str != NULL) {
104 init->mode = simple_strtoul(mode_str, &last, 8);
105 if ((*last != '\0') || (last == mode_str)) {
106 printk(KERN_ERR "vde_setup - Bad mode : '%s'\n",
112 printk(KERN_INFO "Configured vde device: %s\n", init->vde_switch ?
113 init->vde_switch : "(default socket)");
118 static struct transport vde_transport = {
119 .list = LIST_HEAD_INIT(vde_transport.list),
122 .user = &vde_user_info,
123 .kern = &vde_kern_info,
124 .private_size = sizeof(struct vde_data),
125 .setup_size = sizeof(struct vde_init),
128 static int register_vde(void)
130 register_transport(&vde_transport);
134 late_initcall(register_vde);