diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:08 -0400 |
commit | cd1ae0e49bdd814cfaa2e5ab28cff21a30e20085 (patch) | |
tree | 1b993b9de4cb9a8578022a4014063c3e87ec996e /arch | |
parent | 1a80521990a0e30e61a92994a009adc52161b070 (diff) |
uml: network formatting
Style and other non-functional changes in the UML networking code, including
include tidying
style violations
copyright updates
printks getting severities
userspace code calling libc directly rather than using the os_*
wrappers
There's also a exit path cleanup in the pcap driver.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/drivers/daemon.h | 20 | ||||
-rw-r--r-- | arch/um/drivers/daemon_kern.c | 31 | ||||
-rw-r--r-- | arch/um/drivers/daemon_user.c | 81 | ||||
-rw-r--r-- | arch/um/drivers/mcast.h | 16 | ||||
-rw-r--r-- | arch/um/drivers/mcast_kern.c | 55 | ||||
-rw-r--r-- | arch/um/drivers/mcast_user.c | 62 | ||||
-rw-r--r-- | arch/um/drivers/net_kern.c | 197 | ||||
-rw-r--r-- | arch/um/drivers/net_user.c | 126 | ||||
-rw-r--r-- | arch/um/drivers/pcap_kern.c | 27 | ||||
-rw-r--r-- | arch/um/drivers/pcap_user.c | 49 | ||||
-rw-r--r-- | arch/um/drivers/slip_kern.c | 34 | ||||
-rw-r--r-- | arch/um/drivers/slip_user.c | 122 | ||||
-rw-r--r-- | arch/um/drivers/slirp_kern.c | 55 | ||||
-rw-r--r-- | arch/um/drivers/slirp_user.c | 67 | ||||
-rw-r--r-- | arch/um/drivers/vde_kern.c | 8 | ||||
-rw-r--r-- | arch/um/drivers/vde_user.c | 8 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/etap.h | 16 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/ethertap_kern.c | 36 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/ethertap_user.c | 86 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/tuntap.h | 13 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/tuntap_kern.c | 34 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/tuntap_user.c | 75 |
22 files changed, 602 insertions, 616 deletions
diff --git a/arch/um/drivers/daemon.h b/arch/um/drivers/daemon.h index 3bc3cf6b94aa..6e0e891f8a00 100644 --- a/arch/um/drivers/daemon.h +++ b/arch/um/drivers/daemon.h | |||
@@ -1,8 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef __DAEMON_H__ | ||
7 | #define __DAEMON_H__ | ||
8 | |||
6 | #include "net_user.h" | 9 | #include "net_user.h" |
7 | 10 | ||
8 | #define SWITCH_VERSION 3 | 11 | #define SWITCH_VERSION 3 |
@@ -20,16 +23,7 @@ struct daemon_data { | |||
20 | 23 | ||
21 | extern const struct net_user_info daemon_user_info; | 24 | extern const struct net_user_info daemon_user_info; |
22 | 25 | ||
23 | extern int daemon_user_write(int fd, void *buf, int len, | 26 | extern int daemon_user_write(int fd, void *buf, int len, |
24 | struct daemon_data *pri); | 27 | struct daemon_data *pri); |
25 | 28 | ||
26 | /* | 29 | #endif |
27 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
28 | * Emacs will notice this stuff at the end of the file and automatically | ||
29 | * adjust the settings for this buffer only. This must remain at the end | ||
30 | * of the file. | ||
31 | * --------------------------------------------------------------------------- | ||
32 | * Local variables: | ||
33 | * c-file-style: "linux" | ||
34 | * End: | ||
35 | */ | ||
diff --git a/arch/um/drivers/daemon_kern.c b/arch/um/drivers/daemon_kern.c index adeece11e596..ac507bb87fea 100644 --- a/arch/um/drivers/daemon_kern.c +++ b/arch/um/drivers/daemon_kern.c | |||
@@ -1,16 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and |
3 | * James Leu (jleu@mindspring.net). | 3 | * James Leu (jleu@mindspring.net). |
4 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
4 | * Copyright (C) 2001 by various other people who didn't put their name here. | 5 | * Copyright (C) 2001 by various other people who didn't put their name here. |
5 | * Licensed under the GPL. | 6 | * Licensed under the GPL. |
6 | */ | 7 | */ |
7 | 8 | ||
8 | #include "linux/kernel.h" | ||
9 | #include "linux/init.h" | 9 | #include "linux/init.h" |
10 | #include "linux/netdevice.h" | 10 | #include <linux/netdevice.h> |
11 | #include "linux/etherdevice.h" | ||
12 | #include "net_kern.h" | 11 | #include "net_kern.h" |
13 | #include "net_user.h" | ||
14 | #include "daemon.h" | 12 | #include "daemon.h" |
15 | 13 | ||
16 | struct daemon_init { | 14 | struct daemon_init { |
@@ -36,25 +34,26 @@ static void daemon_init(struct net_device *dev, void *data) | |||
36 | dpri->data_addr = NULL; | 34 | dpri->data_addr = NULL; |
37 | dpri->local_addr = NULL; | 35 | dpri->local_addr = NULL; |
38 | 36 | ||
39 | printk("daemon backend (uml_switch version %d) - %s:%s", | 37 | printk("daemon backend (uml_switch version %d) - %s:%s", |
40 | SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock); | 38 | SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock); |
41 | printk("\n"); | 39 | printk("\n"); |
42 | } | 40 | } |
43 | 41 | ||
44 | static int daemon_read(int fd, struct sk_buff **skb, | 42 | static int daemon_read(int fd, struct sk_buff **skb, |
45 | struct uml_net_private *lp) | 43 | struct uml_net_private *lp) |
46 | { | 44 | { |
47 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); | 45 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); |
48 | if(*skb == NULL) return(-ENOMEM); | 46 | if (*skb == NULL) |
49 | return(net_recvfrom(fd, skb_mac_header(*skb), | 47 | return -ENOMEM; |
50 | (*skb)->dev->mtu + ETH_HEADER_OTHER)); | 48 | return net_recvfrom(fd, skb_mac_header(*skb), |
49 | (*skb)->dev->mtu + ETH_HEADER_OTHER); | ||
51 | } | 50 | } |
52 | 51 | ||
53 | static int daemon_write(int fd, struct sk_buff **skb, | 52 | static int daemon_write(int fd, struct sk_buff **skb, |
54 | struct uml_net_private *lp) | 53 | struct uml_net_private *lp) |
55 | { | 54 | { |
56 | return(daemon_user_write(fd, (*skb)->data, (*skb)->len, | 55 | return daemon_user_write(fd, (*skb)->data, (*skb)->len, |
57 | (struct daemon_data *) &lp->user)); | 56 | (struct daemon_data *) &lp->user); |
58 | } | 57 | } |
59 | 58 | ||
60 | static const struct net_kern_info daemon_kern_info = { | 59 | static const struct net_kern_info daemon_kern_info = { |
@@ -72,14 +71,14 @@ static int daemon_setup(char *str, char **mac_out, void *data) | |||
72 | *init = ((struct daemon_init) | 71 | *init = ((struct daemon_init) |
73 | { .sock_type = "unix", | 72 | { .sock_type = "unix", |
74 | .ctl_sock = "/tmp/uml.ctl" }); | 73 | .ctl_sock = "/tmp/uml.ctl" }); |
75 | 74 | ||
76 | remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock, | 75 | remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock, |
77 | NULL); | 76 | NULL); |
78 | if(remain != NULL) | 77 | if (remain != NULL) |
79 | printk(KERN_WARNING "daemon_setup : Ignoring data socket " | 78 | printk(KERN_WARNING "daemon_setup : Ignoring data socket " |
80 | "specification\n"); | 79 | "specification\n"); |
81 | 80 | ||
82 | return(1); | 81 | return 1; |
83 | } | 82 | } |
84 | 83 | ||
85 | static struct transport daemon_transport = { | 84 | static struct transport daemon_transport = { |
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c index 8d2008f06682..90983d480ac6 100644 --- a/arch/um/drivers/daemon_user.c +++ b/arch/um/drivers/daemon_user.c | |||
@@ -1,22 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | ||
3 | * James Leu (jleu@mindspring.net). | 4 | * James Leu (jleu@mindspring.net). |
4 | * Copyright (C) 2001 by various other people who didn't put their name here. | 5 | * Copyright (C) 2001 by various other people who didn't put their name here. |
5 | * Licensed under the GPL. | 6 | * Licensed under the GPL. |
6 | */ | 7 | */ |
7 | 8 | ||
8 | #include <errno.h> | ||
9 | #include <unistd.h> | ||
10 | #include <stdint.h> | 9 | #include <stdint.h> |
10 | #include <unistd.h> | ||
11 | #include <errno.h> | ||
12 | #include <sys/types.h> | ||
11 | #include <sys/socket.h> | 13 | #include <sys/socket.h> |
12 | #include <sys/un.h> | ||
13 | #include <sys/time.h> | 14 | #include <sys/time.h> |
14 | #include "net_user.h" | 15 | #include <sys/un.h> |
15 | #include "daemon.h" | 16 | #include "daemon.h" |
16 | #include "kern_util.h" | 17 | #include "net_user.h" |
17 | #include "user.h" | ||
18 | #include "os.h" | 18 | #include "os.h" |
19 | #include "um_malloc.h" | 19 | #include "um_malloc.h" |
20 | #include "user.h" | ||
20 | 21 | ||
21 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) | 22 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) |
22 | 23 | ||
@@ -36,8 +37,9 @@ static struct sockaddr_un *new_addr(void *name, int len) | |||
36 | struct sockaddr_un *sun; | 37 | struct sockaddr_un *sun; |
37 | 38 | ||
38 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); | 39 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); |
39 | if(sun == NULL){ | 40 | if (sun == NULL) { |
40 | printk("new_addr: allocation of sockaddr_un failed\n"); | 41 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " |
42 | "failed\n"); | ||
41 | return NULL; | 43 | return NULL; |
42 | } | 44 | } |
43 | sun->sun_family = AF_UNIX; | 45 | sun->sun_family = AF_UNIX; |
@@ -54,38 +56,39 @@ static int connect_to_switch(struct daemon_data *pri) | |||
54 | int fd, n, err; | 56 | int fd, n, err; |
55 | 57 | ||
56 | pri->control = socket(AF_UNIX, SOCK_STREAM, 0); | 58 | pri->control = socket(AF_UNIX, SOCK_STREAM, 0); |
57 | if(pri->control < 0){ | 59 | if (pri->control < 0) { |
58 | err = -errno; | 60 | err = -errno; |
59 | printk("daemon_open : control socket failed, errno = %d\n", | 61 | printk(UM_KERN_ERR "daemon_open : control socket failed, " |
60 | -err); | 62 | "errno = %d\n", -err); |
61 | return err; | 63 | return err; |
62 | } | 64 | } |
63 | 65 | ||
64 | if(connect(pri->control, (struct sockaddr *) ctl_addr, | 66 | if (connect(pri->control, (struct sockaddr *) ctl_addr, |
65 | sizeof(*ctl_addr)) < 0){ | 67 | sizeof(*ctl_addr)) < 0) { |
66 | err = -errno; | 68 | err = -errno; |
67 | printk("daemon_open : control connect failed, errno = %d\n", | 69 | printk(UM_KERN_ERR "daemon_open : control connect failed, " |
68 | -err); | 70 | "errno = %d\n", -err); |
69 | goto out; | 71 | goto out; |
70 | } | 72 | } |
71 | 73 | ||
72 | fd = socket(AF_UNIX, SOCK_DGRAM, 0); | 74 | fd = socket(AF_UNIX, SOCK_DGRAM, 0); |
73 | if(fd < 0){ | 75 | if (fd < 0) { |
74 | err = -errno; | 76 | err = -errno; |
75 | printk("daemon_open : data socket failed, errno = %d\n", | 77 | printk(UM_KERN_ERR "daemon_open : data socket failed, " |
76 | -err); | 78 | "errno = %d\n", -err); |
77 | goto out; | 79 | goto out; |
78 | } | 80 | } |
79 | if(bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0){ | 81 | if (bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0) { |
80 | err = -errno; | 82 | err = -errno; |
81 | printk("daemon_open : data bind failed, errno = %d\n", | 83 | printk(UM_KERN_ERR "daemon_open : data bind failed, " |
82 | -err); | 84 | "errno = %d\n", -err); |
83 | goto out_close; | 85 | goto out_close; |
84 | } | 86 | } |
85 | 87 | ||
86 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); | 88 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); |
87 | if(sun == NULL){ | 89 | if (sun == NULL) { |
88 | printk("new_addr: allocation of sockaddr_un failed\n"); | 90 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " |
91 | "failed\n"); | ||
89 | err = -ENOMEM; | 92 | err = -ENOMEM; |
90 | goto out_close; | 93 | goto out_close; |
91 | } | 94 | } |
@@ -94,18 +97,18 @@ static int connect_to_switch(struct daemon_data *pri) | |||
94 | req.version = SWITCH_VERSION; | 97 | req.version = SWITCH_VERSION; |
95 | req.type = REQ_NEW_CONTROL; | 98 | req.type = REQ_NEW_CONTROL; |
96 | req.sock = *local_addr; | 99 | req.sock = *local_addr; |
97 | n = os_write_file(pri->control, &req, sizeof(req)); | 100 | n = write(pri->control, &req, sizeof(req)); |
98 | if(n != sizeof(req)){ | 101 | if (n != sizeof(req)) { |
99 | printk("daemon_open : control setup request failed, err = %d\n", | 102 | printk(UM_KERN_ERR "daemon_open : control setup request " |
100 | -n); | 103 | "failed, err = %d\n", -errno); |
101 | err = -ENOTCONN; | 104 | err = -ENOTCONN; |
102 | goto out_free; | 105 | goto out_free; |
103 | } | 106 | } |
104 | 107 | ||
105 | n = os_read_file(pri->control, sun, sizeof(*sun)); | 108 | n = read(pri->control, sun, sizeof(*sun)); |
106 | if(n != sizeof(*sun)){ | 109 | if (n != sizeof(*sun)) { |
107 | printk("daemon_open : read of data socket failed, err = %d\n", | 110 | printk(UM_KERN_ERR "daemon_open : read of data socket failed, " |
108 | -n); | 111 | "err = %d\n", -errno); |
109 | err = -ENOTCONN; | 112 | err = -ENOTCONN; |
110 | goto out_free; | 113 | goto out_free; |
111 | } | 114 | } |
@@ -116,9 +119,9 @@ static int connect_to_switch(struct daemon_data *pri) | |||
116 | out_free: | 119 | out_free: |
117 | kfree(sun); | 120 | kfree(sun); |
118 | out_close: | 121 | out_close: |
119 | os_close_file(fd); | 122 | close(fd); |
120 | out: | 123 | out: |
121 | os_close_file(pri->control); | 124 | close(pri->control); |
122 | return err; | 125 | return err; |
123 | } | 126 | } |
124 | 127 | ||
@@ -132,8 +135,8 @@ static int daemon_user_init(void *data, void *dev) | |||
132 | int usecs; | 135 | int usecs; |
133 | } name; | 136 | } name; |
134 | 137 | ||
135 | if(!strcmp(pri->sock_type, "unix")) | 138 | if (!strcmp(pri->sock_type, "unix")) |
136 | pri->ctl_addr = new_addr(pri->ctl_sock, | 139 | pri->ctl_addr = new_addr(pri->ctl_sock, |
137 | strlen(pri->ctl_sock) + 1); | 140 | strlen(pri->ctl_sock) + 1); |
138 | name.zero = 0; | 141 | name.zero = 0; |
139 | name.pid = os_getpid(); | 142 | name.pid = os_getpid(); |
@@ -142,7 +145,7 @@ static int daemon_user_init(void *data, void *dev) | |||
142 | pri->local_addr = new_addr(&name, sizeof(name)); | 145 | pri->local_addr = new_addr(&name, sizeof(name)); |
143 | pri->dev = dev; | 146 | pri->dev = dev; |
144 | pri->fd = connect_to_switch(pri); | 147 | pri->fd = connect_to_switch(pri); |
145 | if(pri->fd < 0){ | 148 | if (pri->fd < 0) { |
146 | kfree(pri->local_addr); | 149 | kfree(pri->local_addr); |
147 | pri->local_addr = NULL; | 150 | pri->local_addr = NULL; |
148 | return pri->fd; | 151 | return pri->fd; |
@@ -161,9 +164,9 @@ static void daemon_remove(void *data) | |||
161 | { | 164 | { |
162 | struct daemon_data *pri = data; | 165 | struct daemon_data *pri = data; |
163 | 166 | ||
164 | os_close_file(pri->fd); | 167 | close(pri->fd); |
165 | pri->fd = -1; | 168 | pri->fd = -1; |
166 | os_close_file(pri->control); | 169 | close(pri->control); |
167 | pri->control = -1; | 170 | pri->control = -1; |
168 | 171 | ||
169 | kfree(pri->data_addr); | 172 | kfree(pri->data_addr); |
diff --git a/arch/um/drivers/mcast.h b/arch/um/drivers/mcast.h index bc56af9d3e53..6fa282e896be 100644 --- a/arch/um/drivers/mcast.h +++ b/arch/um/drivers/mcast.h | |||
@@ -1,8 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef __DRIVERS_MCAST_H | ||
7 | #define __DRIVERS_MCAST_H | ||
8 | |||
6 | #include "net_user.h" | 9 | #include "net_user.h" |
7 | 10 | ||
8 | struct mcast_data { | 11 | struct mcast_data { |
@@ -18,13 +21,4 @@ extern const struct net_user_info mcast_user_info; | |||
18 | extern int mcast_user_write(int fd, void *buf, int len, | 21 | extern int mcast_user_write(int fd, void *buf, int len, |
19 | struct mcast_data *pri); | 22 | struct mcast_data *pri); |
20 | 23 | ||
21 | /* | 24 | #endif |
22 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
23 | * Emacs will notice this stuff at the end of the file and automatically | ||
24 | * adjust the settings for this buffer only. This must remain at the end | ||
25 | * of the file. | ||
26 | * --------------------------------------------------------------------------- | ||
27 | * Local variables: | ||
28 | * c-file-style: "linux" | ||
29 | * End: | ||
30 | */ | ||
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c index e6b8e0dd72a8..5027b870d11d 100644 --- a/arch/um/drivers/mcast_kern.c +++ b/arch/um/drivers/mcast_kern.c | |||
@@ -1,24 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * user-mode-linux networking multicast transport | 2 | * user-mode-linux networking multicast transport |
3 | * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> | 3 | * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> |
4 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
4 | * | 5 | * |
5 | * based on the existing uml-networking code, which is | 6 | * based on the existing uml-networking code, which is |
6 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 7 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and |
7 | * James Leu (jleu@mindspring.net). | 8 | * James Leu (jleu@mindspring.net). |
8 | * Copyright (C) 2001 by various other people who didn't put their name here. | 9 | * Copyright (C) 2001 by various other people who didn't put their name here. |
9 | * | 10 | * |
10 | * Licensed under the GPL. | 11 | * Licensed under the GPL. |
11 | */ | 12 | */ |
12 | 13 | ||
13 | #include "linux/kernel.h" | ||
14 | #include "linux/init.h" | 14 | #include "linux/init.h" |
15 | #include "linux/netdevice.h" | 15 | #include <linux/netdevice.h> |
16 | #include "linux/etherdevice.h" | ||
17 | #include "linux/in.h" | ||
18 | #include "linux/inet.h" | ||
19 | #include "net_kern.h" | ||
20 | #include "net_user.h" | ||
21 | #include "mcast.h" | 16 | #include "mcast.h" |
17 | #include "net_kern.h" | ||
22 | 18 | ||
23 | struct mcast_init { | 19 | struct mcast_init { |
24 | char *addr; | 20 | char *addr; |
@@ -39,26 +35,23 @@ static void mcast_init(struct net_device *dev, void *data) | |||
39 | dpri->ttl = init->ttl; | 35 | dpri->ttl = init->ttl; |
40 | dpri->dev = dev; | 36 | dpri->dev = dev; |
41 | 37 | ||
42 | printk("mcast backend "); | 38 | printk("mcast backend multicast address: %s:%u, TTL:%u\n", |
43 | printk("multicast address: %s:%u, TTL:%u ", | ||
44 | dpri->addr, dpri->port, dpri->ttl); | 39 | dpri->addr, dpri->port, dpri->ttl); |
45 | |||
46 | printk("\n"); | ||
47 | } | 40 | } |
48 | 41 | ||
49 | static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) | 42 | static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) |
50 | { | 43 | { |
51 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); | 44 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); |
52 | if(*skb == NULL) return(-ENOMEM); | 45 | if (*skb == NULL) |
53 | return(net_recvfrom(fd, skb_mac_header(*skb), | 46 | return -ENOMEM; |
54 | (*skb)->dev->mtu + ETH_HEADER_OTHER)); | 47 | return net_recvfrom(fd, skb_mac_header(*skb), |
48 | (*skb)->dev->mtu + ETH_HEADER_OTHER); | ||
55 | } | 49 | } |
56 | 50 | ||
57 | static int mcast_write(int fd, struct sk_buff **skb, | 51 | static int mcast_write(int fd, struct sk_buff **skb, struct uml_net_private *lp) |
58 | struct uml_net_private *lp) | ||
59 | { | 52 | { |
60 | return mcast_user_write(fd, (*skb)->data, (*skb)->len, | 53 | return mcast_user_write(fd, (*skb)->data, (*skb)->len, |
61 | (struct mcast_data *) &lp->user); | 54 | (struct mcast_data *) &lp->user); |
62 | } | 55 | } |
63 | 56 | ||
64 | static const struct net_kern_info mcast_kern_info = { | 57 | static const struct net_kern_info mcast_kern_info = { |
@@ -81,34 +74,34 @@ int mcast_setup(char *str, char **mac_out, void *data) | |||
81 | 74 | ||
82 | remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str, | 75 | remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str, |
83 | NULL); | 76 | NULL); |
84 | if(remain != NULL){ | 77 | if (remain != NULL) { |
85 | printk(KERN_ERR "mcast_setup - Extra garbage on " | 78 | printk(KERN_ERR "mcast_setup - Extra garbage on " |
86 | "specification : '%s'\n", remain); | 79 | "specification : '%s'\n", remain); |
87 | return(0); | 80 | return 0; |
88 | } | 81 | } |
89 | 82 | ||
90 | if(port_str != NULL){ | 83 | if (port_str != NULL) { |
91 | init->port = simple_strtoul(port_str, &last, 10); | 84 | init->port = simple_strtoul(port_str, &last, 10); |
92 | if((*last != '\0') || (last == port_str)){ | 85 | if ((*last != '\0') || (last == port_str)) { |
93 | printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", | 86 | printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", |
94 | port_str); | 87 | port_str); |
95 | return(0); | 88 | return 0; |
96 | } | 89 | } |
97 | } | 90 | } |
98 | 91 | ||
99 | if(ttl_str != NULL){ | 92 | if (ttl_str != NULL) { |
100 | init->ttl = simple_strtoul(ttl_str, &last, 10); | 93 | init->ttl = simple_strtoul(ttl_str, &last, 10); |
101 | if((*last != '\0') || (last == ttl_str)){ | 94 | if ((*last != '\0') || (last == ttl_str)) { |
102 | printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n", | 95 | printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n", |
103 | ttl_str); | 96 | ttl_str); |
104 | return(0); | 97 | return 0; |
105 | } | 98 | } |
106 | } | 99 | } |
107 | 100 | ||
108 | printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr, | 101 | printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr, |
109 | init->port, init->ttl); | 102 | init->port, init->ttl); |
110 | 103 | ||
111 | return(1); | 104 | return 1; |
112 | } | 105 | } |
113 | 106 | ||
114 | static struct transport mcast_transport = { | 107 | static struct transport mcast_transport = { |
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 236a3dfc297d..e427b5322a36 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
@@ -1,9 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * user-mode-linux networking multicast transport | 2 | * user-mode-linux networking multicast transport |
3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> | 4 | * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> |
4 | * | 5 | * |
5 | * based on the existing uml-networking code, which is | 6 | * based on the existing uml-networking code, which is |
6 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 7 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and |
7 | * James Leu (jleu@mindspring.net). | 8 | * James Leu (jleu@mindspring.net). |
8 | * Copyright (C) 2001 by various other people who didn't put their name here. | 9 | * Copyright (C) 2001 by various other people who didn't put their name here. |
9 | * | 10 | * |
@@ -11,18 +12,13 @@ | |||
11 | * | 12 | * |
12 | */ | 13 | */ |
13 | 14 | ||
14 | #include <errno.h> | ||
15 | #include <unistd.h> | 15 | #include <unistd.h> |
16 | #include <sys/socket.h> | 16 | #include <errno.h> |
17 | #include <sys/un.h> | ||
18 | #include <sys/time.h> | ||
19 | #include <netinet/in.h> | 17 | #include <netinet/in.h> |
20 | #include "net_user.h" | ||
21 | #include "mcast.h" | 18 | #include "mcast.h" |
22 | #include "kern_util.h" | 19 | #include "net_user.h" |
23 | #include "user.h" | ||
24 | #include "os.h" | ||
25 | #include "um_malloc.h" | 20 | #include "um_malloc.h" |
21 | #include "user.h" | ||
26 | 22 | ||
27 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) | 23 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) |
28 | 24 | ||
@@ -31,8 +27,9 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port) | |||
31 | struct sockaddr_in *sin; | 27 | struct sockaddr_in *sin; |
32 | 28 | ||
33 | sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL); | 29 | sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL); |
34 | if(sin == NULL){ | 30 | if (sin == NULL) { |
35 | printk("new_addr: allocation of sockaddr_in failed\n"); | 31 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in " |
32 | "failed\n"); | ||
36 | return NULL; | 33 | return NULL; |
37 | } | 34 | } |
38 | sin->sin_family = AF_INET; | 35 | sin->sin_family = AF_INET; |
@@ -71,17 +68,17 @@ static int mcast_open(void *data) | |||
71 | 68 | ||
72 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 69 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
73 | 70 | ||
74 | if (fd < 0){ | 71 | if (fd < 0) { |
75 | err = -errno; | 72 | err = -errno; |
76 | printk("mcast_open : data socket failed, errno = %d\n", | 73 | printk(UM_KERN_ERR "mcast_open : data socket failed, " |
77 | errno); | 74 | "errno = %d\n", errno); |
78 | goto out; | 75 | goto out; |
79 | } | 76 | } |
80 | 77 | ||
81 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { | 78 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { |
82 | err = -errno; | 79 | err = -errno; |
83 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", | 80 | printk(UM_KERN_ERR "mcast_open: SO_REUSEADDR failed, " |
84 | errno); | 81 | "errno = %d\n", errno); |
85 | goto out_close; | 82 | goto out_close; |
86 | } | 83 | } |
87 | 84 | ||
@@ -89,45 +86,46 @@ static int mcast_open(void *data) | |||
89 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl, | 86 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl, |
90 | sizeof(pri->ttl)) < 0) { | 87 | sizeof(pri->ttl)) < 0) { |
91 | err = -errno; | 88 | err = -errno; |
92 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", | 89 | printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_TTL failed, " |
93 | errno); | 90 | "error = %d\n", errno); |
94 | goto out_close; | 91 | goto out_close; |
95 | } | 92 | } |
96 | 93 | ||
97 | /* set LOOP, so data does get fed back to local sockets */ | 94 | /* set LOOP, so data does get fed back to local sockets */ |
98 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { | 95 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { |
99 | err = -errno; | 96 | err = -errno; |
100 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", | 97 | printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_LOOP failed, " |
101 | errno); | 98 | "error = %d\n", errno); |
102 | goto out_close; | 99 | goto out_close; |
103 | } | 100 | } |
104 | 101 | ||
105 | /* bind socket to mcast address */ | 102 | /* bind socket to mcast address */ |
106 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { | 103 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { |
107 | err = -errno; | 104 | err = -errno; |
108 | printk("mcast_open : data bind failed, errno = %d\n", errno); | 105 | printk(UM_KERN_ERR "mcast_open : data bind failed, " |
106 | "errno = %d\n", errno); | ||
109 | goto out_close; | 107 | goto out_close; |
110 | } | 108 | } |
111 | 109 | ||
112 | /* subscribe to the multicast group */ | 110 | /* subscribe to the multicast group */ |
113 | mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr; | 111 | mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr; |
114 | mreq.imr_interface.s_addr = 0; | 112 | mreq.imr_interface.s_addr = 0; |
115 | if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, | 113 | if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, |
116 | &mreq, sizeof(mreq)) < 0) { | 114 | &mreq, sizeof(mreq)) < 0) { |
117 | err = -errno; | 115 | err = -errno; |
118 | printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n", | 116 | printk(UM_KERN_ERR "mcast_open: IP_ADD_MEMBERSHIP failed, " |
119 | errno); | 117 | "error = %d\n", errno); |
120 | printk("There appears not to be a multicast-capable network " | 118 | printk(UM_KERN_ERR "There appears not to be a multicast-" |
121 | "interface on the host.\n"); | 119 | "capable network interface on the host.\n"); |
122 | printk("eth0 should be configured in order to use the " | 120 | printk(UM_KERN_ERR "eth0 should be configured in order to use " |
123 | "multicast transport.\n"); | 121 | "the multicast transport.\n"); |
124 | goto out_close; | 122 | goto out_close; |
125 | } | 123 | } |
126 | 124 | ||
127 | return fd; | 125 | return fd; |
128 | 126 | ||
129 | out_close: | 127 | out_close: |
130 | os_close_file(fd); | 128 | close(fd); |
131 | out: | 129 | out: |
132 | return err; | 130 | return err; |
133 | } | 131 | } |
@@ -142,11 +140,11 @@ static void mcast_close(int fd, void *data) | |||
142 | mreq.imr_interface.s_addr = 0; | 140 | mreq.imr_interface.s_addr = 0; |
143 | if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP, | 141 | if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP, |
144 | &mreq, sizeof(mreq)) < 0) { | 142 | &mreq, sizeof(mreq)) < 0) { |
145 | printk("mcast_open: IP_DROP_MEMBERSHIP failed, error = %d\n", | 143 | printk(UM_KERN_ERR "mcast_open: IP_DROP_MEMBERSHIP failed, " |
146 | errno); | 144 | "error = %d\n", errno); |
147 | } | 145 | } |
148 | 146 | ||
149 | os_close_file(fd); | 147 | close(fd); |
150 | } | 148 | } |
151 | 149 | ||
152 | int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri) | 150 | int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri) |
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index d35d0c1ee7f4..b097a24c1496 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c | |||
@@ -1,33 +1,28 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 3 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and |
3 | * James Leu (jleu@mindspring.net). | 4 | * James Leu (jleu@mindspring.net). |
4 | * Copyright (C) 2001 by various other people who didn't put their name here. | 5 | * Copyright (C) 2001 by various other people who didn't put their name here. |
5 | * Licensed under the GPL. | 6 | * Licensed under the GPL. |
6 | */ | 7 | */ |
7 | 8 | ||
8 | #include "linux/kernel.h" | 9 | #include <linux/bootmem.h> |
9 | #include "linux/netdevice.h" | 10 | #include <linux/etherdevice.h> |
10 | #include "linux/rtnetlink.h" | 11 | #include <linux/ethtool.h> |
11 | #include "linux/skbuff.h" | 12 | #include <linux/inetdevice.h> |
12 | #include "linux/socket.h" | 13 | #include <linux/init.h> |
13 | #include "linux/spinlock.h" | 14 | #include <linux/list.h> |
14 | #include "linux/module.h" | 15 | #include <linux/netdevice.h> |
15 | #include "linux/init.h" | 16 | #include <linux/platform_device.h> |
16 | #include "linux/etherdevice.h" | 17 | #include <linux/rtnetlink.h> |
17 | #include "linux/list.h" | 18 | #include <linux/skbuff.h> |
18 | #include "linux/inetdevice.h" | 19 | #include <linux/spinlock.h> |
19 | #include "linux/ctype.h" | ||
20 | #include "linux/bootmem.h" | ||
21 | #include "linux/ethtool.h" | ||
22 | #include "linux/platform_device.h" | ||
23 | #include "asm/uaccess.h" | ||
24 | #include "kern_util.h" | ||
25 | #include "net_kern.h" | ||
26 | #include "net_user.h" | ||
27 | #include "mconsole_kern.h" | ||
28 | #include "init.h" | 20 | #include "init.h" |
29 | #include "irq_user.h" | ||
30 | #include "irq_kern.h" | 21 | #include "irq_kern.h" |
22 | #include "irq_user.h" | ||
23 | #include "mconsole_kern.h" | ||
24 | #include "net_kern.h" | ||
25 | #include "net_user.h" | ||
31 | 26 | ||
32 | static inline void set_ether_mac(struct net_device *dev, unsigned char *addr) | 27 | static inline void set_ether_mac(struct net_device *dev, unsigned char *addr) |
33 | { | 28 | { |
@@ -84,12 +79,12 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id) | |||
84 | struct uml_net_private *lp = dev->priv; | 79 | struct uml_net_private *lp = dev->priv; |
85 | int err; | 80 | int err; |
86 | 81 | ||
87 | if(!netif_running(dev)) | 82 | if (!netif_running(dev)) |
88 | return(IRQ_NONE); | 83 | return IRQ_NONE; |
89 | 84 | ||
90 | spin_lock(&lp->lock); | 85 | spin_lock(&lp->lock); |
91 | while((err = uml_net_rx(dev)) > 0) ; | 86 | while ((err = uml_net_rx(dev)) > 0) ; |
92 | if(err < 0) { | 87 | if (err < 0) { |
93 | printk(KERN_ERR | 88 | printk(KERN_ERR |
94 | "Device '%s' read returned %d, shutting it down\n", | 89 | "Device '%s' read returned %d, shutting it down\n", |
95 | dev->name, err); | 90 | dev->name, err); |
@@ -115,20 +110,20 @@ static int uml_net_open(struct net_device *dev) | |||
115 | struct uml_net_private *lp = dev->priv; | 110 | struct uml_net_private *lp = dev->priv; |
116 | int err; | 111 | int err; |
117 | 112 | ||
118 | if(lp->fd >= 0){ | 113 | if (lp->fd >= 0) { |
119 | err = -ENXIO; | 114 | err = -ENXIO; |
120 | goto out; | 115 | goto out; |
121 | } | 116 | } |
122 | 117 | ||
123 | lp->fd = (*lp->open)(&lp->user); | 118 | lp->fd = (*lp->open)(&lp->user); |
124 | if(lp->fd < 0){ | 119 | if (lp->fd < 0) { |
125 | err = lp->fd; | 120 | err = lp->fd; |
126 | goto out; | 121 | goto out; |
127 | } | 122 | } |
128 | 123 | ||
129 | err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt, | 124 | err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt, |
130 | IRQF_DISABLED | IRQF_SHARED, dev->name, dev); | 125 | IRQF_DISABLED | IRQF_SHARED, dev->name, dev); |
131 | if(err != 0){ | 126 | if (err != 0) { |
132 | printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err); | 127 | printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err); |
133 | err = -ENETUNREACH; | 128 | err = -ENETUNREACH; |
134 | goto out_close; | 129 | goto out_close; |
@@ -141,7 +136,7 @@ static int uml_net_open(struct net_device *dev) | |||
141 | * is full when we get here. In this case, new data is never queued, | 136 | * is full when we get here. In this case, new data is never queued, |
142 | * SIGIOs never arrive, and the net never works. | 137 | * SIGIOs never arrive, and the net never works. |
143 | */ | 138 | */ |
144 | while((err = uml_net_rx(dev)) > 0) ; | 139 | while ((err = uml_net_rx(dev)) > 0) ; |
145 | 140 | ||
146 | spin_lock(&opened_lock); | 141 | spin_lock(&opened_lock); |
147 | list_add(&lp->list, &opened); | 142 | list_add(&lp->list, &opened); |
@@ -149,7 +144,7 @@ static int uml_net_open(struct net_device *dev) | |||
149 | 144 | ||
150 | return 0; | 145 | return 0; |
151 | out_close: | 146 | out_close: |
152 | if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user); | 147 | if (lp->close != NULL) (*lp->close)(lp->fd, &lp->user); |
153 | lp->fd = -1; | 148 | lp->fd = -1; |
154 | out: | 149 | out: |
155 | return err; | 150 | return err; |
@@ -162,7 +157,7 @@ static int uml_net_close(struct net_device *dev) | |||
162 | netif_stop_queue(dev); | 157 | netif_stop_queue(dev); |
163 | 158 | ||
164 | free_irq(dev->irq, dev); | 159 | free_irq(dev->irq, dev); |
165 | if(lp->close != NULL) | 160 | if (lp->close != NULL) |
166 | (*lp->close)(lp->fd, &lp->user); | 161 | (*lp->close)(lp->fd, &lp->user); |
167 | lp->fd = -1; | 162 | lp->fd = -1; |
168 | 163 | ||
@@ -185,7 +180,7 @@ static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
185 | 180 | ||
186 | len = (*lp->write)(lp->fd, &skb, lp); | 181 | len = (*lp->write)(lp->fd, &skb, lp); |
187 | 182 | ||
188 | if(len == skb->len) { | 183 | if (len == skb->len) { |
189 | lp->stats.tx_packets++; | 184 | lp->stats.tx_packets++; |
190 | lp->stats.tx_bytes += skb->len; | 185 | lp->stats.tx_bytes += skb->len; |
191 | dev->trans_start = jiffies; | 186 | dev->trans_start = jiffies; |
@@ -194,7 +189,7 @@ static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
194 | /* this is normally done in the interrupt when tx finishes */ | 189 | /* this is normally done in the interrupt when tx finishes */ |
195 | netif_wake_queue(dev); | 190 | netif_wake_queue(dev); |
196 | } | 191 | } |
197 | else if(len == 0){ | 192 | else if (len == 0) { |
198 | netif_start_queue(dev); | 193 | netif_start_queue(dev); |
199 | lp->stats.tx_dropped++; | 194 | lp->stats.tx_dropped++; |
200 | } | 195 | } |
@@ -218,8 +213,10 @@ static struct net_device_stats *uml_net_get_stats(struct net_device *dev) | |||
218 | 213 | ||
219 | static void uml_net_set_multicast_list(struct net_device *dev) | 214 | static void uml_net_set_multicast_list(struct net_device *dev) |
220 | { | 215 | { |
221 | if (dev->flags & IFF_PROMISC) return; | 216 | if (dev->flags & IFF_PROMISC) |
222 | else if (dev->mc_count) dev->flags |= IFF_ALLMULTI; | 217 | return; |
218 | else if (dev->mc_count) | ||
219 | dev->flags |= IFF_ALLMULTI; | ||
223 | else dev->flags &= ~IFF_ALLMULTI; | 220 | else dev->flags &= ~IFF_ALLMULTI; |
224 | } | 221 | } |
225 | 222 | ||
@@ -249,7 +246,7 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu) | |||
249 | spin_lock_irq(&lp->lock); | 246 | spin_lock_irq(&lp->lock); |
250 | 247 | ||
251 | new_mtu = (*lp->set_mtu)(new_mtu, &lp->user); | 248 | new_mtu = (*lp->set_mtu)(new_mtu, &lp->user); |
252 | if(new_mtu < 0){ | 249 | if (new_mtu < 0) { |
253 | err = new_mtu; | 250 | err = new_mtu; |
254 | goto out; | 251 | goto out; |
255 | } | 252 | } |
@@ -288,13 +285,13 @@ static void setup_etheraddr(char *str, unsigned char *addr, char *name) | |||
288 | char *end; | 285 | char *end; |
289 | int i; | 286 | int i; |
290 | 287 | ||
291 | if(str == NULL) | 288 | if (str == NULL) |
292 | goto random; | 289 | goto random; |
293 | 290 | ||
294 | for(i=0;i<6;i++){ | 291 | for (i = 0;i < 6; i++) { |
295 | addr[i] = simple_strtoul(str, &end, 16); | 292 | addr[i] = simple_strtoul(str, &end, 16); |
296 | if((end == str) || | 293 | if ((end == str) || |
297 | ((*end != ':') && (*end != ',') && (*end != '\0'))){ | 294 | ((*end != ':') && (*end != ',') && (*end != '\0'))) { |
298 | printk(KERN_ERR | 295 | printk(KERN_ERR |
299 | "setup_etheraddr: failed to parse '%s' " | 296 | "setup_etheraddr: failed to parse '%s' " |
300 | "as an ethernet address\n", str); | 297 | "as an ethernet address\n", str); |
@@ -349,7 +346,7 @@ static void net_device_release(struct device *dev) | |||
349 | struct net_device *netdev = device->dev; | 346 | struct net_device *netdev = device->dev; |
350 | struct uml_net_private *lp = netdev->priv; | 347 | struct uml_net_private *lp = netdev->priv; |
351 | 348 | ||
352 | if(lp->remove != NULL) | 349 | if (lp->remove != NULL) |
353 | (*lp->remove)(&lp->user); | 350 | (*lp->remove)(&lp->user); |
354 | list_del(&device->list); | 351 | list_del(&device->list); |
355 | kfree(device); | 352 | kfree(device); |
@@ -413,7 +410,7 @@ static void eth_configure(int n, void *init, char *mac, | |||
413 | device->pdev.name = DRIVER_NAME; | 410 | device->pdev.name = DRIVER_NAME; |
414 | device->pdev.dev.release = net_device_release; | 411 | device->pdev.dev.release = net_device_release; |
415 | device->pdev.dev.driver_data = device; | 412 | device->pdev.dev.driver_data = device; |
416 | if(platform_device_register(&device->pdev)) | 413 | if (platform_device_register(&device->pdev)) |
417 | goto out_free_netdev; | 414 | goto out_free_netdev; |
418 | SET_NETDEV_DEV(dev,&device->pdev.dev); | 415 | SET_NETDEV_DEV(dev,&device->pdev.dev); |
419 | 416 | ||
@@ -493,9 +490,9 @@ static struct uml_net *find_device(int n) | |||
493 | struct list_head *ele; | 490 | struct list_head *ele; |
494 | 491 | ||
495 | spin_lock(&devices_lock); | 492 | spin_lock(&devices_lock); |
496 | list_for_each(ele, &devices){ | 493 | list_for_each(ele, &devices) { |
497 | device = list_entry(ele, struct uml_net, list); | 494 | device = list_entry(ele, struct uml_net, list); |
498 | if(device->index == n) | 495 | if (device->index == n) |
499 | goto out; | 496 | goto out; |
500 | } | 497 | } |
501 | device = NULL; | 498 | device = NULL; |
@@ -511,19 +508,19 @@ static int eth_parse(char *str, int *index_out, char **str_out, | |||
511 | int n, err = -EINVAL;; | 508 | int n, err = -EINVAL;; |
512 | 509 | ||
513 | n = simple_strtoul(str, &end, 0); | 510 | n = simple_strtoul(str, &end, 0); |
514 | if(end == str){ | 511 | if (end == str) { |
515 | *error_out = "Bad device number"; | 512 | *error_out = "Bad device number"; |
516 | return err; | 513 | return err; |
517 | } | 514 | } |
518 | 515 | ||
519 | str = end; | 516 | str = end; |
520 | if(*str != '='){ | 517 | if (*str != '=') { |
521 | *error_out = "Expected '=' after device number"; | 518 | *error_out = "Expected '=' after device number"; |
522 | return err; | 519 | return err; |
523 | } | 520 | } |
524 | 521 | ||
525 | str++; | 522 | str++; |
526 | if(find_device(n)){ | 523 | if (find_device(n)) { |
527 | *error_out = "Device already configured"; | 524 | *error_out = "Device already configured"; |
528 | return err; | 525 | return err; |
529 | } | 526 | } |
@@ -551,20 +548,20 @@ static int check_transport(struct transport *transport, char *eth, int n, | |||
551 | int len; | 548 | int len; |
552 | 549 | ||
553 | len = strlen(transport->name); | 550 | len = strlen(transport->name); |
554 | if(strncmp(eth, transport->name, len)) | 551 | if (strncmp(eth, transport->name, len)) |
555 | return 0; | 552 | return 0; |
556 | 553 | ||
557 | eth += len; | 554 | eth += len; |
558 | if(*eth == ',') | 555 | if (*eth == ',') |
559 | eth++; | 556 | eth++; |
560 | else if(*eth != '\0') | 557 | else if (*eth != '\0') |
561 | return 0; | 558 | return 0; |
562 | 559 | ||
563 | *init_out = kmalloc(transport->setup_size, GFP_KERNEL); | 560 | *init_out = kmalloc(transport->setup_size, GFP_KERNEL); |
564 | if(*init_out == NULL) | 561 | if (*init_out == NULL) |
565 | return 1; | 562 | return 1; |
566 | 563 | ||
567 | if(!transport->setup(eth, mac_out, *init_out)){ | 564 | if (!transport->setup(eth, mac_out, *init_out)) { |
568 | kfree(*init_out); | 565 | kfree(*init_out); |
569 | *init_out = NULL; | 566 | *init_out = NULL; |
570 | } | 567 | } |
@@ -584,13 +581,13 @@ void register_transport(struct transport *new) | |||
584 | list_add(&new->list, &transports); | 581 | list_add(&new->list, &transports); |
585 | spin_unlock(&transports_lock); | 582 | spin_unlock(&transports_lock); |
586 | 583 | ||
587 | list_for_each_safe(ele, next, ð_cmd_line){ | 584 | list_for_each_safe(ele, next, ð_cmd_line) { |
588 | eth = list_entry(ele, struct eth_init, list); | 585 | eth = list_entry(ele, struct eth_init, list); |
589 | match = check_transport(new, eth->init, eth->index, &init, | 586 | match = check_transport(new, eth->init, eth->index, &init, |
590 | &mac); | 587 | &mac); |
591 | if(!match) | 588 | if (!match) |
592 | continue; | 589 | continue; |
593 | else if(init != NULL){ | 590 | else if (init != NULL) { |
594 | eth_configure(eth->index, init, mac, new); | 591 | eth_configure(eth->index, init, mac, new); |
595 | kfree(init); | 592 | kfree(init); |
596 | } | 593 | } |
@@ -607,11 +604,11 @@ static int eth_setup_common(char *str, int index) | |||
607 | int found = 0; | 604 | int found = 0; |
608 | 605 | ||
609 | spin_lock(&transports_lock); | 606 | spin_lock(&transports_lock); |
610 | list_for_each(ele, &transports){ | 607 | list_for_each(ele, &transports) { |
611 | transport = list_entry(ele, struct transport, list); | 608 | transport = list_entry(ele, struct transport, list); |
612 | if(!check_transport(transport, str, index, &init, &mac)) | 609 | if (!check_transport(transport, str, index, &init, &mac)) |
613 | continue; | 610 | continue; |
614 | if(init != NULL){ | 611 | if (init != NULL) { |
615 | eth_configure(index, init, mac, transport); | 612 | eth_configure(index, init, mac, transport); |
616 | kfree(init); | 613 | kfree(init); |
617 | } | 614 | } |
@@ -630,15 +627,15 @@ static int __init eth_setup(char *str) | |||
630 | int n, err; | 627 | int n, err; |
631 | 628 | ||
632 | err = eth_parse(str, &n, &str, &error); | 629 | err = eth_parse(str, &n, &str, &error); |
633 | if(err){ | 630 | if (err) { |
634 | printk(KERN_ERR "eth_setup - Couldn't parse '%s' : %s\n", | 631 | printk(KERN_ERR "eth_setup - Couldn't parse '%s' : %s\n", |
635 | str, error); | 632 | str, error); |
636 | return 1; | 633 | return 1; |
637 | } | 634 | } |
638 | 635 | ||
639 | new = alloc_bootmem(sizeof(*new)); | 636 | new = alloc_bootmem(sizeof(*new)); |
640 | if (new == NULL){ | 637 | if (new == NULL) { |
641 | printk("eth_init : alloc_bootmem failed\n"); | 638 | printk(KERN_ERR "eth_init : alloc_bootmem failed\n"); |
642 | return 1; | 639 | return 1; |
643 | } | 640 | } |
644 | 641 | ||
@@ -661,36 +658,36 @@ static int net_config(char *str, char **error_out) | |||
661 | int n, err; | 658 | int n, err; |
662 | 659 | ||
663 | err = eth_parse(str, &n, &str, error_out); | 660 | err = eth_parse(str, &n, &str, error_out); |
664 | if(err) | 661 | if (err) |
665 | return err; | 662 | return err; |
666 | 663 | ||
667 | /* This string is broken up and the pieces used by the underlying | 664 | /* This string is broken up and the pieces used by the underlying |
668 | * driver. So, it is freed only if eth_setup_common fails. | 665 | * driver. So, it is freed only if eth_setup_common fails. |
669 | */ | 666 | */ |
670 | str = kstrdup(str, GFP_KERNEL); | 667 | str = kstrdup(str, GFP_KERNEL); |
671 | if(str == NULL){ | 668 | if (str == NULL) { |
672 | *error_out = "net_config failed to strdup string"; | 669 | *error_out = "net_config failed to strdup string"; |
673 | return -ENOMEM; | 670 | return -ENOMEM; |
674 | } | 671 | } |
675 | err = !eth_setup_common(str, n); | 672 | err = !eth_setup_common(str, n); |
676 | if(err) | 673 | if (err) |
677 | kfree(str); | 674 | kfree(str); |
678 | return(err); | 675 | return err; |
679 | } | 676 | } |
680 | 677 | ||
681 | static int net_id(char **str, int *start_out, int *end_out) | 678 | static int net_id(char **str, int *start_out, int *end_out) |
682 | { | 679 | { |
683 | char *end; | 680 | char *end; |
684 | int n; | 681 | int n; |
685 | 682 | ||
686 | n = simple_strtoul(*str, &end, 0); | 683 | n = simple_strtoul(*str, &end, 0); |
687 | if((*end != '\0') || (end == *str)) | 684 | if ((*end != '\0') || (end == *str)) |
688 | return -1; | 685 | return -1; |
689 | 686 | ||
690 | *start_out = n; | 687 | *start_out = n; |
691 | *end_out = n; | 688 | *end_out = n; |
692 | *str = end; | 689 | *str = end; |
693 | return n; | 690 | return n; |
694 | } | 691 | } |
695 | 692 | ||
696 | static int net_remove(int n, char **error_out) | 693 | static int net_remove(int n, char **error_out) |
@@ -700,12 +697,12 @@ static int net_remove(int n, char **error_out) | |||
700 | struct uml_net_private *lp; | 697 | struct uml_net_private *lp; |
701 | 698 | ||
702 | device = find_device(n); | 699 | device = find_device(n); |
703 | if(device == NULL) | 700 | if (device == NULL) |
704 | return -ENODEV; | 701 | return -ENODEV; |
705 | 702 | ||
706 | dev = device->dev; | 703 | dev = device->dev; |
707 | lp = dev->priv; | 704 | lp = dev->priv; |
708 | if(lp->fd > 0) | 705 | if (lp->fd > 0) |
709 | return -EBUSY; | 706 | return -EBUSY; |
710 | unregister_netdev(dev); | 707 | unregister_netdev(dev); |
711 | platform_device_unregister(&device->pdev); | 708 | platform_device_unregister(&device->pdev); |
@@ -731,13 +728,13 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event, | |||
731 | void (*proc)(unsigned char *, unsigned char *, void *); | 728 | void (*proc)(unsigned char *, unsigned char *, void *); |
732 | unsigned char addr_buf[4], netmask_buf[4]; | 729 | unsigned char addr_buf[4], netmask_buf[4]; |
733 | 730 | ||
734 | if(dev->open != uml_net_open) | 731 | if (dev->open != uml_net_open) |
735 | return NOTIFY_DONE; | 732 | return NOTIFY_DONE; |
736 | 733 | ||
737 | lp = dev->priv; | 734 | lp = dev->priv; |
738 | 735 | ||
739 | proc = NULL; | 736 | proc = NULL; |
740 | switch (event){ | 737 | switch (event) { |
741 | case NETDEV_UP: | 738 | case NETDEV_UP: |
742 | proc = lp->add_address; | 739 | proc = lp->add_address; |
743 | break; | 740 | break; |
@@ -745,7 +742,7 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event, | |||
745 | proc = lp->delete_address; | 742 | proc = lp->delete_address; |
746 | break; | 743 | break; |
747 | } | 744 | } |
748 | if(proc != NULL){ | 745 | if (proc != NULL) { |
749 | memcpy(addr_buf, &ifa->ifa_address, sizeof(addr_buf)); | 746 | memcpy(addr_buf, &ifa->ifa_address, sizeof(addr_buf)); |
750 | memcpy(netmask_buf, &ifa->ifa_mask, sizeof(netmask_buf)); | 747 | memcpy(netmask_buf, &ifa->ifa_mask, sizeof(netmask_buf)); |
751 | (*proc)(addr_buf, netmask_buf, &lp->user); | 748 | (*proc)(addr_buf, netmask_buf, &lp->user); |
@@ -773,13 +770,13 @@ static int uml_net_init(void) | |||
773 | * addresses which have already been set up get handled properly. | 770 | * addresses which have already been set up get handled properly. |
774 | */ | 771 | */ |
775 | spin_lock(&opened_lock); | 772 | spin_lock(&opened_lock); |
776 | list_for_each(ele, &opened){ | 773 | list_for_each(ele, &opened) { |
777 | lp = list_entry(ele, struct uml_net_private, list); | 774 | lp = list_entry(ele, struct uml_net_private, list); |
778 | ip = lp->dev->ip_ptr; | 775 | ip = lp->dev->ip_ptr; |
779 | if(ip == NULL) | 776 | if (ip == NULL) |
780 | continue; | 777 | continue; |
781 | in = ip->ifa_list; | 778 | in = ip->ifa_list; |
782 | while(in != NULL){ | 779 | while (in != NULL) { |
783 | uml_inetaddr_event(NULL, NETDEV_UP, in); | 780 | uml_inetaddr_event(NULL, NETDEV_UP, in); |
784 | in = in->ifa_next; | 781 | in = in->ifa_next; |
785 | } | 782 | } |
@@ -797,12 +794,12 @@ static void close_devices(void) | |||
797 | struct uml_net_private *lp; | 794 | struct uml_net_private *lp; |
798 | 795 | ||
799 | spin_lock(&opened_lock); | 796 | spin_lock(&opened_lock); |
800 | list_for_each(ele, &opened){ | 797 | list_for_each(ele, &opened) { |
801 | lp = list_entry(ele, struct uml_net_private, list); | 798 | lp = list_entry(ele, struct uml_net_private, list); |
802 | free_irq(lp->dev->irq, lp->dev); | 799 | free_irq(lp->dev->irq, lp->dev); |
803 | if((lp->close != NULL) && (lp->fd >= 0)) | 800 | if ((lp->close != NULL) && (lp->fd >= 0)) |
804 | (*lp->close)(lp->fd, &lp->user); | 801 | (*lp->close)(lp->fd, &lp->user); |
805 | if(lp->remove != NULL) | 802 | if (lp->remove != NULL) |
806 | (*lp->remove)(&lp->user); | 803 | (*lp->remove)(&lp->user); |
807 | } | 804 | } |
808 | spin_unlock(&opened_lock); | 805 | spin_unlock(&opened_lock); |
@@ -812,15 +809,15 @@ __uml_exitcall(close_devices); | |||
812 | 809 | ||
813 | struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra) | 810 | struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra) |
814 | { | 811 | { |
815 | if((skb != NULL) && (skb_tailroom(skb) < extra)){ | 812 | if ((skb != NULL) && (skb_tailroom(skb) < extra)) { |
816 | struct sk_buff *skb2; | 813 | struct sk_buff *skb2; |
817 | 814 | ||
818 | skb2 = skb_copy_expand(skb, 0, extra, GFP_ATOMIC); | 815 | skb2 = skb_copy_expand(skb, 0, extra, GFP_ATOMIC); |
819 | dev_kfree_skb(skb); | 816 | dev_kfree_skb(skb); |
820 | skb = skb2; | 817 | skb = skb2; |
821 | } | 818 | } |
822 | if(skb != NULL) skb_put(skb, extra); | 819 | if (skb != NULL) skb_put(skb, extra); |
823 | return(skb); | 820 | return skb; |
824 | } | 821 | } |
825 | 822 | ||
826 | void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *, | 823 | void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *, |
@@ -832,9 +829,9 @@ void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *, | |||
832 | struct in_ifaddr *in; | 829 | struct in_ifaddr *in; |
833 | unsigned char address[4], netmask[4]; | 830 | unsigned char address[4], netmask[4]; |
834 | 831 | ||
835 | if(ip == NULL) return; | 832 | if (ip == NULL) return; |
836 | in = ip->ifa_list; | 833 | in = ip->ifa_list; |
837 | while(in != NULL){ | 834 | while (in != NULL) { |
838 | memcpy(address, &in->ifa_address, sizeof(address)); | 835 | memcpy(address, &in->ifa_address, sizeof(address)); |
839 | memcpy(netmask, &in->ifa_mask, sizeof(netmask)); | 836 | memcpy(netmask, &in->ifa_mask, sizeof(netmask)); |
840 | (*cb)(address, netmask, arg); | 837 | (*cb)(address, netmask, arg); |
@@ -849,15 +846,15 @@ int dev_netmask(void *d, void *m) | |||
849 | struct in_ifaddr *in; | 846 | struct in_ifaddr *in; |
850 | __be32 *mask_out = m; | 847 | __be32 *mask_out = m; |
851 | 848 | ||
852 | if(ip == NULL) | 849 | if (ip == NULL) |
853 | return(1); | 850 | return 1; |
854 | 851 | ||
855 | in = ip->ifa_list; | 852 | in = ip->ifa_list; |
856 | if(in == NULL) | 853 | if (in == NULL) |
857 | return(1); | 854 | return 1; |
858 | 855 | ||
859 | *mask_out = in->ifa_mask; | 856 | *mask_out = in->ifa_mask; |
860 | return(0); | 857 | return 0; |
861 | } | 858 | } |
862 | 859 | ||
863 | void *get_output_buffer(int *len_out) | 860 | void *get_output_buffer(int *len_out) |
@@ -865,7 +862,7 @@ void *get_output_buffer(int *len_out) | |||
865 | void *ret; | 862 | void *ret; |
866 | 863 | ||
867 | ret = (void *) __get_free_pages(GFP_KERNEL, 0); | 864 | ret = (void *) __get_free_pages(GFP_KERNEL, 0); |
868 | if(ret) *len_out = PAGE_SIZE; | 865 | if (ret) *len_out = PAGE_SIZE; |
869 | else *len_out = 0; | 866 | else *len_out = 0; |
870 | return ret; | 867 | return ret; |
871 | } | 868 | } |
@@ -881,16 +878,16 @@ int tap_setup_common(char *str, char *type, char **dev_name, char **mac_out, | |||
881 | char *remain; | 878 | char *remain; |
882 | 879 | ||
883 | remain = split_if_spec(str, dev_name, mac_out, gate_addr, NULL); | 880 | remain = split_if_spec(str, dev_name, mac_out, gate_addr, NULL); |
884 | if(remain != NULL){ | 881 | if (remain != NULL) { |
885 | printk("tap_setup_common - Extra garbage on specification : " | 882 | printk(KERN_ERR "tap_setup_common - Extra garbage on " |
886 | "'%s'\n", remain); | 883 | "specification : '%s'\n", remain); |
887 | return(1); | 884 | return 1; |
888 | } | 885 | } |
889 | 886 | ||
890 | return(0); | 887 | return 0; |
891 | } | 888 | } |
892 | 889 | ||
893 | unsigned short eth_protocol(struct sk_buff *skb) | 890 | unsigned short eth_protocol(struct sk_buff *skb) |
894 | { | 891 | { |
895 | return(eth_type_trans(skb, skb->dev)); | 892 | return eth_type_trans(skb, skb->dev); |
896 | } | 893 | } |
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c index da946e3e1bf2..90d7f2e8ead8 100644 --- a/arch/um/drivers/net_user.c +++ b/arch/um/drivers/net_user.c | |||
@@ -1,34 +1,32 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stddef.h> | ||
7 | #include <stdarg.h> | ||
8 | #include <unistd.h> | ||
9 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <unistd.h> | ||
8 | #include <stdarg.h> | ||
10 | #include <errno.h> | 9 | #include <errno.h> |
11 | #include <stdlib.h> | 10 | #include <stddef.h> |
12 | #include <string.h> | 11 | #include <string.h> |
13 | #include <sys/socket.h> | 12 | #include <sys/socket.h> |
14 | #include <sys/wait.h> | 13 | #include <sys/wait.h> |
15 | #include <sys/time.h> | ||
16 | #include "user.h" | ||
17 | #include "kern_util.h" | ||
18 | #include "net_user.h" | 14 | #include "net_user.h" |
15 | #include "kern_constants.h" | ||
19 | #include "os.h" | 16 | #include "os.h" |
20 | #include "um_malloc.h" | 17 | #include "um_malloc.h" |
21 | #include "kern_constants.h" | 18 | #include "user.h" |
22 | 19 | ||
23 | int tap_open_common(void *dev, char *gate_addr) | 20 | int tap_open_common(void *dev, char *gate_addr) |
24 | { | 21 | { |
25 | int tap_addr[4]; | 22 | int tap_addr[4]; |
26 | 23 | ||
27 | if(gate_addr == NULL) | 24 | if (gate_addr == NULL) |
28 | return 0; | 25 | return 0; |
29 | if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], | 26 | if (sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], |
30 | &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){ | 27 | &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4) { |
31 | printk("Invalid tap IP address - '%s'\n", gate_addr); | 28 | printk(UM_KERN_ERR "Invalid tap IP address - '%s'\n", |
29 | gate_addr); | ||
32 | return -EINVAL; | 30 | return -EINVAL; |
33 | } | 31 | } |
34 | return 0; | 32 | return 0; |
@@ -38,15 +36,15 @@ void tap_check_ips(char *gate_addr, unsigned char *eth_addr) | |||
38 | { | 36 | { |
39 | int tap_addr[4]; | 37 | int tap_addr[4]; |
40 | 38 | ||
41 | if((gate_addr != NULL) && | 39 | if ((gate_addr != NULL) && |
42 | (sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], | 40 | (sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], |
43 | &tap_addr[1], &tap_addr[2], &tap_addr[3]) == 4) && | 41 | &tap_addr[1], &tap_addr[2], &tap_addr[3]) == 4) && |
44 | (eth_addr[0] == tap_addr[0]) && | 42 | (eth_addr[0] == tap_addr[0]) && |
45 | (eth_addr[1] == tap_addr[1]) && | 43 | (eth_addr[1] == tap_addr[1]) && |
46 | (eth_addr[2] == tap_addr[2]) && | 44 | (eth_addr[2] == tap_addr[2]) && |
47 | (eth_addr[3] == tap_addr[3])){ | 45 | (eth_addr[3] == tap_addr[3])) { |
48 | printk("The tap IP address and the UML eth IP address" | 46 | printk(UM_KERN_ERR "The tap IP address and the UML eth IP " |
49 | " must be different\n"); | 47 | "address must be different\n"); |
50 | } | 48 | } |
51 | } | 49 | } |
52 | 50 | ||
@@ -57,24 +55,28 @@ void read_output(int fd, char *output, int len) | |||
57 | char c; | 55 | char c; |
58 | char *str; | 56 | char *str; |
59 | 57 | ||
60 | if(output == NULL){ | 58 | if (output == NULL) { |
61 | output = &c; | 59 | output = &c; |
62 | len = sizeof(c); | 60 | len = sizeof(c); |
63 | } | 61 | } |
64 | 62 | ||
65 | *output = '\0'; | 63 | *output = '\0'; |
66 | ret = os_read_file(fd, &remain, sizeof(remain)); | 64 | ret = read(fd, &remain, sizeof(remain)); |
67 | 65 | ||
68 | if (ret != sizeof(remain)) { | 66 | if (ret != sizeof(remain)) { |
67 | if (ret < 0) | ||
68 | ret = -errno; | ||
69 | expected = sizeof(remain); | 69 | expected = sizeof(remain); |
70 | str = "length"; | 70 | str = "length"; |
71 | goto err; | 71 | goto err; |
72 | } | 72 | } |
73 | 73 | ||
74 | while(remain != 0){ | 74 | while (remain != 0) { |
75 | expected = (remain < len) ? remain : len; | 75 | expected = (remain < len) ? remain : len; |
76 | ret = os_read_file(fd, output, expected); | 76 | ret = read(fd, output, expected); |
77 | if (ret != expected) { | 77 | if (ret != expected) { |
78 | if (ret < 0) | ||
79 | ret = -errno; | ||
78 | str = "data"; | 80 | str = "data"; |
79 | goto err; | 81 | goto err; |
80 | } | 82 | } |
@@ -85,20 +87,22 @@ void read_output(int fd, char *output, int len) | |||
85 | 87 | ||
86 | err: | 88 | err: |
87 | if (ret < 0) | 89 | if (ret < 0) |
88 | printk("read_output - read of %s failed, errno = %d\n", str, -ret); | 90 | printk(UM_KERN_ERR "read_output - read of %s failed, " |
91 | "errno = %d\n", str, -ret); | ||
89 | else | 92 | else |
90 | printk("read_output - read of %s failed, read only %d of %d bytes\n", str, ret, expected); | 93 | printk(UM_KERN_ERR "read_output - read of %s failed, read only " |
94 | "%d of %d bytes\n", str, ret, expected); | ||
91 | } | 95 | } |
92 | 96 | ||
93 | int net_read(int fd, void *buf, int len) | 97 | int net_read(int fd, void *buf, int len) |
94 | { | 98 | { |
95 | int n; | 99 | int n; |
96 | 100 | ||
97 | n = os_read_file(fd, buf, len); | 101 | n = read(fd, buf, len); |
98 | 102 | ||
99 | if(n == -EAGAIN) | 103 | if ((n < 0) && (errno == EAGAIN)) |
100 | return 0; | 104 | return 0; |
101 | else if(n == 0) | 105 | else if (n == 0) |
102 | return -ENOTCONN; | 106 | return -ENOTCONN; |
103 | return n; | 107 | return n; |
104 | } | 108 | } |
@@ -108,12 +112,12 @@ int net_recvfrom(int fd, void *buf, int len) | |||
108 | int n; | 112 | int n; |
109 | 113 | ||
110 | CATCH_EINTR(n = recvfrom(fd, buf, len, 0, NULL, NULL)); | 114 | CATCH_EINTR(n = recvfrom(fd, buf, len, 0, NULL, NULL)); |
111 | if(n < 0){ | 115 | if (n < 0) { |
112 | if(errno == EAGAIN) | 116 | if (errno == EAGAIN) |
113 | return 0; | 117 | return 0; |
114 | return -errno; | 118 | return -errno; |
115 | } | 119 | } |
116 | else if(n == 0) | 120 | else if (n == 0) |
117 | return -ENOTCONN; | 121 | return -ENOTCONN; |
118 | return n; | 122 | return n; |
119 | } | 123 | } |
@@ -122,11 +126,11 @@ int net_write(int fd, void *buf, int len) | |||
122 | { | 126 | { |
123 | int n; | 127 | int n; |
124 | 128 | ||
125 | n = os_write_file(fd, buf, len); | 129 | n = write(fd, buf, len); |
126 | 130 | ||
127 | if(n == -EAGAIN) | 131 | if ((n < 0) && (errno == EAGAIN)) |
128 | return 0; | 132 | return 0; |
129 | else if(n == 0) | 133 | else if (n == 0) |
130 | return -ENOTCONN; | 134 | return -ENOTCONN; |
131 | return n; | 135 | return n; |
132 | } | 136 | } |
@@ -136,12 +140,12 @@ int net_send(int fd, void *buf, int len) | |||
136 | int n; | 140 | int n; |
137 | 141 | ||
138 | CATCH_EINTR(n = send(fd, buf, len, 0)); | 142 | CATCH_EINTR(n = send(fd, buf, len, 0)); |
139 | if(n < 0){ | 143 | if (n < 0) { |
140 | if(errno == EAGAIN) | 144 | if (errno == EAGAIN) |
141 | return 0; | 145 | return 0; |
142 | return -errno; | 146 | return -errno; |
143 | } | 147 | } |
144 | else if(n == 0) | 148 | else if (n == 0) |
145 | return -ENOTCONN; | 149 | return -ENOTCONN; |
146 | return n; | 150 | return n; |
147 | } | 151 | } |
@@ -152,12 +156,12 @@ int net_sendto(int fd, void *buf, int len, void *to, int sock_len) | |||
152 | 156 | ||
153 | CATCH_EINTR(n = sendto(fd, buf, len, 0, (struct sockaddr *) to, | 157 | CATCH_EINTR(n = sendto(fd, buf, len, 0, (struct sockaddr *) to, |
154 | sock_len)); | 158 | sock_len)); |
155 | if(n < 0){ | 159 | if (n < 0) { |
156 | if(errno == EAGAIN) | 160 | if (errno == EAGAIN) |
157 | return 0; | 161 | return 0; |
158 | return -errno; | 162 | return -errno; |
159 | } | 163 | } |
160 | else if(n == 0) | 164 | else if (n == 0) |
161 | return -ENOTCONN; | 165 | return -ENOTCONN; |
162 | return n; | 166 | return n; |
163 | } | 167 | } |
@@ -171,7 +175,7 @@ static void change_pre_exec(void *arg) | |||
171 | { | 175 | { |
172 | struct change_pre_exec_data *data = arg; | 176 | struct change_pre_exec_data *data = arg; |
173 | 177 | ||
174 | os_close_file(data->close_me); | 178 | close(data->close_me); |
175 | dup2(data->stdout, 1); | 179 | dup2(data->stdout, 1); |
176 | } | 180 | } |
177 | 181 | ||
@@ -181,8 +185,9 @@ static int change_tramp(char **argv, char *output, int output_len) | |||
181 | struct change_pre_exec_data pe_data; | 185 | struct change_pre_exec_data pe_data; |
182 | 186 | ||
183 | err = os_pipe(fds, 1, 0); | 187 | err = os_pipe(fds, 1, 0); |
184 | if(err < 0){ | 188 | if (err < 0) { |
185 | printk("change_tramp - pipe failed, err = %d\n", -err); | 189 | printk(UM_KERN_ERR "change_tramp - pipe failed, err = %d\n", |
190 | -err); | ||
186 | return err; | 191 | return err; |
187 | } | 192 | } |
188 | pe_data.close_me = fds[0]; | 193 | pe_data.close_me = fds[0]; |
@@ -192,8 +197,8 @@ static int change_tramp(char **argv, char *output, int output_len) | |||
192 | if (pid > 0) /* Avoid hang as we won't get data in failure case. */ | 197 | if (pid > 0) /* Avoid hang as we won't get data in failure case. */ |
193 | read_output(fds[0], output, output_len); | 198 | read_output(fds[0], output, output_len); |
194 | 199 | ||
195 | os_close_file(fds[0]); | 200 | close(fds[0]); |
196 | os_close_file(fds[1]); | 201 | close(fds[1]); |
197 | 202 | ||
198 | if (pid > 0) | 203 | if (pid > 0) |
199 | CATCH_EINTR(err = waitpid(pid, NULL, 0)); | 204 | CATCH_EINTR(err = waitpid(pid, NULL, 0)); |
@@ -206,25 +211,26 @@ static void change(char *dev, char *what, unsigned char *addr, | |||
206 | char addr_buf[sizeof("255.255.255.255\0")]; | 211 | char addr_buf[sizeof("255.255.255.255\0")]; |
207 | char netmask_buf[sizeof("255.255.255.255\0")]; | 212 | char netmask_buf[sizeof("255.255.255.255\0")]; |
208 | char version[sizeof("nnnnn\0")]; | 213 | char version[sizeof("nnnnn\0")]; |
209 | char *argv[] = { "uml_net", version, what, dev, addr_buf, | 214 | char *argv[] = { "uml_net", version, what, dev, addr_buf, |
210 | netmask_buf, NULL }; | 215 | netmask_buf, NULL }; |
211 | char *output; | 216 | char *output; |
212 | int output_len, pid; | 217 | int output_len, pid; |
213 | 218 | ||
214 | sprintf(version, "%d", UML_NET_VERSION); | 219 | sprintf(version, "%d", UML_NET_VERSION); |
215 | sprintf(addr_buf, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); | 220 | sprintf(addr_buf, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); |
216 | sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1], | 221 | sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1], |
217 | netmask[2], netmask[3]); | 222 | netmask[2], netmask[3]); |
218 | 223 | ||
219 | output_len = UM_KERN_PAGE_SIZE; | 224 | output_len = UM_KERN_PAGE_SIZE; |
220 | output = kmalloc(output_len, UM_GFP_KERNEL); | 225 | output = kmalloc(output_len, UM_GFP_KERNEL); |
221 | if(output == NULL) | 226 | if (output == NULL) |
222 | printk("change : failed to allocate output buffer\n"); | 227 | printk(UM_KERN_ERR "change : failed to allocate output " |
228 | "buffer\n"); | ||
223 | 229 | ||
224 | pid = change_tramp(argv, output, output_len); | 230 | pid = change_tramp(argv, output, output_len); |
225 | if(pid < 0) return; | 231 | if (pid < 0) return; |
226 | 232 | ||
227 | if(output != NULL){ | 233 | if (output != NULL) { |
228 | printk("%s", output); | 234 | printk("%s", output); |
229 | kfree(output); | 235 | kfree(output); |
230 | } | 236 | } |
@@ -246,13 +252,13 @@ char *split_if_spec(char *str, ...) | |||
246 | va_list ap; | 252 | va_list ap; |
247 | 253 | ||
248 | va_start(ap, str); | 254 | va_start(ap, str); |
249 | while((arg = va_arg(ap, char **)) != NULL){ | 255 | while ((arg = va_arg(ap, char **)) != NULL) { |
250 | if(*str == '\0') | 256 | if (*str == '\0') |
251 | return NULL; | 257 | return NULL; |
252 | end = strchr(str, ','); | 258 | end = strchr(str, ','); |
253 | if(end != str) | 259 | if (end != str) |
254 | *arg = str; | 260 | *arg = str; |
255 | if(end == NULL) | 261 | if (end == NULL) |
256 | return NULL; | 262 | return NULL; |
257 | *end++ = '\0'; | 263 | *end++ = '\0'; |
258 | str = end; | 264 | str = end; |
diff --git a/arch/um/drivers/pcap_kern.c b/arch/um/drivers/pcap_kern.c index c329931673d6..da0403efbc0d 100644 --- a/arch/um/drivers/pcap_kern.c +++ b/arch/um/drivers/pcap_kern.c | |||
@@ -1,13 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Jeff Dike <jdike@karaya.com> | 2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL. | 3 | * Licensed under the GPL. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/init.h" | 6 | #include "linux/init.h" |
7 | #include "linux/netdevice.h" | 7 | #include <linux/netdevice.h> |
8 | #include "linux/etherdevice.h" | ||
9 | #include "net_kern.h" | 8 | #include "net_kern.h" |
10 | #include "net_user.h" | ||
11 | #include "pcap_user.h" | 9 | #include "pcap_user.h" |
12 | 10 | ||
13 | struct pcap_init { | 11 | struct pcap_init { |
@@ -37,7 +35,7 @@ static int pcap_read(int fd, struct sk_buff **skb, | |||
37 | struct uml_net_private *lp) | 35 | struct uml_net_private *lp) |
38 | { | 36 | { |
39 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); | 37 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); |
40 | if(*skb == NULL) | 38 | if (*skb == NULL) |
41 | return -ENOMEM; | 39 | return -ENOMEM; |
42 | 40 | ||
43 | return pcap_user_read(fd, skb_mac_header(*skb), | 41 | return pcap_user_read(fd, skb_mac_header(*skb), |
@@ -71,28 +69,29 @@ int pcap_setup(char *str, char **mac_out, void *data) | |||
71 | 69 | ||
72 | remain = split_if_spec(str, &host_if, &init->filter, | 70 | remain = split_if_spec(str, &host_if, &init->filter, |
73 | &options[0], &options[1], mac_out, NULL); | 71 | &options[0], &options[1], mac_out, NULL); |
74 | if(remain != NULL){ | 72 | if (remain != NULL) { |
75 | printk(KERN_ERR "pcap_setup - Extra garbage on " | 73 | printk(KERN_ERR "pcap_setup - Extra garbage on " |
76 | "specification : '%s'\n", remain); | 74 | "specification : '%s'\n", remain); |
77 | return 0; | 75 | return 0; |
78 | } | 76 | } |
79 | 77 | ||
80 | if(host_if != NULL) | 78 | if (host_if != NULL) |
81 | init->host_if = host_if; | 79 | init->host_if = host_if; |
82 | 80 | ||
83 | for(i = 0; i < ARRAY_SIZE(options); i++){ | 81 | for (i = 0; i < ARRAY_SIZE(options); i++) { |
84 | if(options[i] == NULL) | 82 | if (options[i] == NULL) |
85 | continue; | 83 | continue; |
86 | if(!strcmp(options[i], "promisc")) | 84 | if (!strcmp(options[i], "promisc")) |
87 | init->promisc = 1; | 85 | init->promisc = 1; |
88 | else if(!strcmp(options[i], "nopromisc")) | 86 | else if (!strcmp(options[i], "nopromisc")) |
89 | init->promisc = 0; | 87 | init->promisc = 0; |
90 | else if(!strcmp(options[i], "optimize")) | 88 | else if (!strcmp(options[i], "optimize")) |
91 | init->optimize = 1; | 89 | init->optimize = 1; |
92 | else if(!strcmp(options[i], "nooptimize")) | 90 | else if (!strcmp(options[i], "nooptimize")) |
93 | init->optimize = 0; | 91 | init->optimize = 0; |
94 | else { | 92 | else { |
95 | printk("pcap_setup : bad option - '%s'\n", options[i]); | 93 | printk(KERN_ERR "pcap_setup : bad option - '%s'\n", |
94 | options[i]); | ||
96 | return 0; | 95 | return 0; |
97 | } | 96 | } |
98 | } | 97 | } |
diff --git a/arch/um/drivers/pcap_user.c b/arch/um/drivers/pcap_user.c index 1316456e2a28..cf996b82af56 100644 --- a/arch/um/drivers/pcap_user.c +++ b/arch/um/drivers/pcap_user.c | |||
@@ -1,19 +1,17 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Jeff Dike <jdike@karaya.com> | 2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL. | 3 | * Licensed under the GPL. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <unistd.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <string.h> | ||
9 | #include <errno.h> | 6 | #include <errno.h> |
10 | #include <pcap.h> | 7 | #include <pcap.h> |
8 | #include <string.h> | ||
11 | #include <asm/types.h> | 9 | #include <asm/types.h> |
12 | #include "net_user.h" | 10 | #include "net_user.h" |
13 | #include "pcap_user.h" | 11 | #include "pcap_user.h" |
14 | #include "user.h" | ||
15 | #include "um_malloc.h" | ||
16 | #include "kern_constants.h" | 12 | #include "kern_constants.h" |
13 | #include "um_malloc.h" | ||
14 | #include "user.h" | ||
17 | 15 | ||
18 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) | 16 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) |
19 | 17 | ||
@@ -26,7 +24,7 @@ static int pcap_user_init(void *data, void *dev) | |||
26 | char errors[PCAP_ERRBUF_SIZE]; | 24 | char errors[PCAP_ERRBUF_SIZE]; |
27 | 25 | ||
28 | p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors); | 26 | p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors); |
29 | if(p == NULL){ | 27 | if (p == NULL) { |
30 | printk(UM_KERN_ERR "pcap_user_init : pcap_open_live failed - " | 28 | printk(UM_KERN_ERR "pcap_user_init : pcap_open_live failed - " |
31 | "'%s'\n", errors); | 29 | "'%s'\n", errors); |
32 | return -EINVAL; | 30 | return -EINVAL; |
@@ -43,50 +41,55 @@ static int pcap_open(void *data) | |||
43 | __u32 netmask; | 41 | __u32 netmask; |
44 | int err; | 42 | int err; |
45 | 43 | ||
46 | if(pri->pcap == NULL) | 44 | if (pri->pcap == NULL) |
47 | return -ENODEV; | 45 | return -ENODEV; |
48 | 46 | ||
49 | if(pri->filter != NULL){ | 47 | if (pri->filter != NULL) { |
50 | err = dev_netmask(pri->dev, &netmask); | 48 | err = dev_netmask(pri->dev, &netmask); |
51 | if(err < 0){ | 49 | if (err < 0) { |
52 | printk(UM_KERN_ERR "pcap_open : dev_netmask failed\n"); | 50 | printk(UM_KERN_ERR "pcap_open : dev_netmask failed\n"); |
53 | return -EIO; | 51 | return -EIO; |
54 | } | 52 | } |
55 | 53 | ||
56 | pri->compiled = kmalloc(sizeof(struct bpf_program), UM_GFP_KERNEL); | 54 | pri->compiled = kmalloc(sizeof(struct bpf_program), |
57 | if(pri->compiled == NULL){ | 55 | UM_GFP_KERNEL); |
56 | if (pri->compiled == NULL) { | ||
58 | printk(UM_KERN_ERR "pcap_open : kmalloc failed\n"); | 57 | printk(UM_KERN_ERR "pcap_open : kmalloc failed\n"); |
59 | return -ENOMEM; | 58 | return -ENOMEM; |
60 | } | 59 | } |
61 | 60 | ||
62 | err = pcap_compile(pri->pcap, | 61 | err = pcap_compile(pri->pcap, |
63 | (struct bpf_program *) pri->compiled, | 62 | (struct bpf_program *) pri->compiled, |
64 | pri->filter, pri->optimize, netmask); | 63 | pri->filter, pri->optimize, netmask); |
65 | if(err < 0){ | 64 | if (err < 0) { |
66 | printk(UM_KERN_ERR "pcap_open : pcap_compile failed - " | 65 | printk(UM_KERN_ERR "pcap_open : pcap_compile failed - " |
67 | "'%s'\n", pcap_geterr(pri->pcap)); | 66 | "'%s'\n", pcap_geterr(pri->pcap)); |
68 | return -EIO; | 67 | goto out; |
69 | } | 68 | } |
70 | 69 | ||
71 | err = pcap_setfilter(pri->pcap, pri->compiled); | 70 | err = pcap_setfilter(pri->pcap, pri->compiled); |
72 | if(err < 0){ | 71 | if (err < 0) { |
73 | printk(UM_KERN_ERR "pcap_open : pcap_setfilter " | 72 | printk(UM_KERN_ERR "pcap_open : pcap_setfilter " |
74 | "failed - '%s'\n", pcap_geterr(pri->pcap)); | 73 | "failed - '%s'\n", pcap_geterr(pri->pcap)); |
75 | return -EIO; | 74 | goto out; |
76 | } | 75 | } |
77 | } | 76 | } |
78 | 77 | ||
79 | return PCAP_FD(pri->pcap); | 78 | return PCAP_FD(pri->pcap); |
79 | |||
80 | out: | ||
81 | kfree(pri->compiled); | ||
82 | return -EIO; | ||
80 | } | 83 | } |
81 | 84 | ||
82 | static void pcap_remove(void *data) | 85 | static void pcap_remove(void *data) |
83 | { | 86 | { |
84 | struct pcap_data *pri = data; | 87 | struct pcap_data *pri = data; |
85 | 88 | ||
86 | if(pri->compiled != NULL) | 89 | if (pri->compiled != NULL) |
87 | pcap_freecode(pri->compiled); | 90 | pcap_freecode(pri->compiled); |
88 | 91 | ||
89 | if(pri->pcap != NULL) | 92 | if (pri->pcap != NULL) |
90 | pcap_close(pri->pcap); | 93 | pcap_close(pri->pcap); |
91 | } | 94 | } |
92 | 95 | ||
@@ -95,7 +98,7 @@ struct pcap_handler_data { | |||
95 | int len; | 98 | int len; |
96 | }; | 99 | }; |
97 | 100 | ||
98 | static void handler(u_char *data, const struct pcap_pkthdr *header, | 101 | static void handler(u_char *data, const struct pcap_pkthdr *header, |
99 | const u_char *packet) | 102 | const u_char *packet) |
100 | { | 103 | { |
101 | int len; | 104 | int len; |
@@ -115,12 +118,12 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) | |||
115 | int n; | 118 | int n; |
116 | 119 | ||
117 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); | 120 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); |
118 | if(n < 0){ | 121 | if (n < 0) { |
119 | printk(UM_KERN_ERR "pcap_dispatch failed - %s\n", | 122 | printk(UM_KERN_ERR "pcap_dispatch failed - %s\n", |
120 | pcap_geterr(pri->pcap)); | 123 | pcap_geterr(pri->pcap)); |
121 | return -EIO; | 124 | return -EIO; |
122 | } | 125 | } |
123 | else if(n == 0) | 126 | else if (n == 0) |
124 | return 0; | 127 | return 0; |
125 | return hdata.len; | 128 | return hdata.len; |
126 | } | 129 | } |
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c index 125c44f77638..05ed351de6b5 100644 --- a/arch/um/drivers/slip_kern.c +++ b/arch/um/drivers/slip_kern.c | |||
@@ -1,11 +1,12 @@ | |||
1 | #include "linux/kernel.h" | 1 | /* |
2 | #include "linux/stddef.h" | 2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | #include "linux/init.h" | 3 | * Licensed under the GPL. |
4 | #include "linux/netdevice.h" | 4 | */ |
5 | #include "linux/if_arp.h" | 5 | |
6 | #include <linux/if_arp.h> | ||
7 | #include <linux/init.h> | ||
8 | #include <linux/netdevice.h> | ||
6 | #include "net_kern.h" | 9 | #include "net_kern.h" |
7 | #include "net_user.h" | ||
8 | #include "kern.h" | ||
9 | #include "slip.h" | 10 | #include "slip.h" |
10 | 11 | ||
11 | struct slip_init { | 12 | struct slip_init { |
@@ -43,21 +44,21 @@ void slip_init(struct net_device *dev, void *data) | |||
43 | 44 | ||
44 | static unsigned short slip_protocol(struct sk_buff *skbuff) | 45 | static unsigned short slip_protocol(struct sk_buff *skbuff) |
45 | { | 46 | { |
46 | return(htons(ETH_P_IP)); | 47 | return htons(ETH_P_IP); |
47 | } | 48 | } |
48 | 49 | ||
49 | static int slip_read(int fd, struct sk_buff **skb, | 50 | static int slip_read(int fd, struct sk_buff **skb, |
50 | struct uml_net_private *lp) | 51 | struct uml_net_private *lp) |
51 | { | 52 | { |
52 | return(slip_user_read(fd, skb_mac_header(*skb), (*skb)->dev->mtu, | 53 | return slip_user_read(fd, skb_mac_header(*skb), (*skb)->dev->mtu, |
53 | (struct slip_data *) &lp->user)); | 54 | (struct slip_data *) &lp->user); |
54 | } | 55 | } |
55 | 56 | ||
56 | static int slip_write(int fd, struct sk_buff **skb, | 57 | static int slip_write(int fd, struct sk_buff **skb, |
57 | struct uml_net_private *lp) | 58 | struct uml_net_private *lp) |
58 | { | 59 | { |
59 | return(slip_user_write(fd, (*skb)->data, (*skb)->len, | 60 | return slip_user_write(fd, (*skb)->data, (*skb)->len, |
60 | (struct slip_data *) &lp->user)); | 61 | (struct slip_data *) &lp->user); |
61 | } | 62 | } |
62 | 63 | ||
63 | const struct net_kern_info slip_kern_info = { | 64 | const struct net_kern_info slip_kern_info = { |
@@ -71,12 +72,11 @@ static int slip_setup(char *str, char **mac_out, void *data) | |||
71 | { | 72 | { |
72 | struct slip_init *init = data; | 73 | struct slip_init *init = data; |
73 | 74 | ||
74 | *init = ((struct slip_init) | 75 | *init = ((struct slip_init) { .gate_addr = NULL }); |
75 | { .gate_addr = NULL }); | ||
76 | 76 | ||
77 | if(str[0] != '\0') | 77 | if (str[0] != '\0') |
78 | init->gate_addr = str; | 78 | init->gate_addr = str; |
79 | return(1); | 79 | return 1; |
80 | } | 80 | } |
81 | 81 | ||
82 | static struct transport slip_transport = { | 82 | static struct transport slip_transport = { |
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c index c0b73c28cff0..d78f324e7298 100644 --- a/arch/um/drivers/slip_user.c +++ b/arch/um/drivers/slip_user.c | |||
@@ -1,21 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL. | ||
4 | */ | ||
5 | |||
1 | #include <stdio.h> | 6 | #include <stdio.h> |
2 | #include <stdlib.h> | 7 | #include <stdlib.h> |
3 | #include <unistd.h> | 8 | #include <unistd.h> |
4 | #include <stddef.h> | ||
5 | #include <sched.h> | ||
6 | #include <string.h> | ||
7 | #include <errno.h> | 9 | #include <errno.h> |
10 | #include <fcntl.h> | ||
11 | #include <string.h> | ||
8 | #include <sys/termios.h> | 12 | #include <sys/termios.h> |
9 | #include <sys/wait.h> | 13 | #include <sys/wait.h> |
10 | #include <sys/signal.h> | 14 | #include "kern_constants.h" |
11 | #include "kern_util.h" | ||
12 | #include "user.h" | ||
13 | #include "net_user.h" | 15 | #include "net_user.h" |
14 | #include "slip.h" | ||
15 | #include "slip_common.h" | ||
16 | #include "os.h" | 16 | #include "os.h" |
17 | #include "slip.h" | ||
17 | #include "um_malloc.h" | 18 | #include "um_malloc.h" |
18 | #include "kern_constants.h" | 19 | #include "user.h" |
19 | 20 | ||
20 | static int slip_user_init(void *data, void *dev) | 21 | static int slip_user_init(void *data, void *dev) |
21 | { | 22 | { |
@@ -31,8 +32,9 @@ static int set_up_tty(int fd) | |||
31 | struct termios tios; | 32 | struct termios tios; |
32 | 33 | ||
33 | if (tcgetattr(fd, &tios) < 0) { | 34 | if (tcgetattr(fd, &tios) < 0) { |
34 | printk("could not get initial terminal attributes\n"); | 35 | printk(UM_KERN_ERR "could not get initial terminal " |
35 | return(-1); | 36 | "attributes\n"); |
37 | return -1; | ||
36 | } | 38 | } |
37 | 39 | ||
38 | tios.c_cflag = CS8 | CREAD | HUPCL | CLOCAL; | 40 | tios.c_cflag = CS8 | CREAD | HUPCL | CLOCAL; |
@@ -48,10 +50,10 @@ static int set_up_tty(int fd) | |||
48 | cfsetispeed(&tios, B38400); | 50 | cfsetispeed(&tios, B38400); |
49 | 51 | ||
50 | if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) { | 52 | if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) { |
51 | printk("failed to set terminal attributes\n"); | 53 | printk(UM_KERN_ERR "failed to set terminal attributes\n"); |
52 | return(-1); | 54 | return -1; |
53 | } | 55 | } |
54 | return(0); | 56 | return 0; |
55 | } | 57 | } |
56 | 58 | ||
57 | struct slip_pre_exec_data { | 59 | struct slip_pre_exec_data { |
@@ -64,9 +66,11 @@ static void slip_pre_exec(void *arg) | |||
64 | { | 66 | { |
65 | struct slip_pre_exec_data *data = arg; | 67 | struct slip_pre_exec_data *data = arg; |
66 | 68 | ||
67 | if(data->stdin >= 0) dup2(data->stdin, 0); | 69 | if (data->stdin >= 0) |
70 | dup2(data->stdin, 0); | ||
68 | dup2(data->stdout, 1); | 71 | dup2(data->stdout, 1); |
69 | if(data->close_me >= 0) os_close_file(data->close_me); | 72 | if (data->close_me >= 0) |
73 | close(data->close_me); | ||
70 | } | 74 | } |
71 | 75 | ||
72 | static int slip_tramp(char **argv, int fd) | 76 | static int slip_tramp(char **argv, int fd) |
@@ -76,8 +80,9 @@ static int slip_tramp(char **argv, int fd) | |||
76 | int status, pid, fds[2], err, output_len; | 80 | int status, pid, fds[2], err, output_len; |
77 | 81 | ||
78 | err = os_pipe(fds, 1, 0); | 82 | err = os_pipe(fds, 1, 0); |
79 | if(err < 0){ | 83 | if (err < 0) { |
80 | printk("slip_tramp : pipe failed, err = %d\n", -err); | 84 | printk(UM_KERN_ERR "slip_tramp : pipe failed, err = %d\n", |
85 | -err); | ||
81 | goto out; | 86 | goto out; |
82 | } | 87 | } |
83 | 88 | ||
@@ -86,41 +91,42 @@ static int slip_tramp(char **argv, int fd) | |||
86 | pe_data.stdout = fds[1]; | 91 | pe_data.stdout = fds[1]; |
87 | pe_data.close_me = fds[0]; | 92 | pe_data.close_me = fds[0]; |
88 | err = run_helper(slip_pre_exec, &pe_data, argv); | 93 | err = run_helper(slip_pre_exec, &pe_data, argv); |
89 | if(err < 0) | 94 | if (err < 0) |
90 | goto out_close; | 95 | goto out_close; |
91 | pid = err; | 96 | pid = err; |
92 | 97 | ||
93 | output_len = UM_KERN_PAGE_SIZE; | 98 | output_len = UM_KERN_PAGE_SIZE; |
94 | output = kmalloc(output_len, UM_GFP_KERNEL); | 99 | output = kmalloc(output_len, UM_GFP_KERNEL); |
95 | if(output == NULL){ | 100 | if (output == NULL) { |
96 | printk("slip_tramp : failed to allocate output buffer\n"); | 101 | printk(UM_KERN_ERR "slip_tramp : failed to allocate output " |
102 | "buffer\n"); | ||
97 | os_kill_process(pid, 1); | 103 | os_kill_process(pid, 1); |
98 | err = -ENOMEM; | 104 | err = -ENOMEM; |
99 | goto out_free; | 105 | goto out_free; |
100 | } | 106 | } |
101 | 107 | ||
102 | os_close_file(fds[1]); | 108 | close(fds[1]); |
103 | read_output(fds[0], output, output_len); | 109 | read_output(fds[0], output, output_len); |
104 | printk("%s", output); | 110 | printk("%s", output); |
105 | 111 | ||
106 | CATCH_EINTR(err = waitpid(pid, &status, 0)); | 112 | CATCH_EINTR(err = waitpid(pid, &status, 0)); |
107 | if(err < 0) | 113 | if (err < 0) |
108 | err = errno; | 114 | err = errno; |
109 | else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){ | 115 | else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) { |
110 | printk("'%s' didn't exit with status 0\n", argv[0]); | 116 | printk(UM_KERN_ERR "'%s' didn't exit with status 0\n", argv[0]); |
111 | err = -EINVAL; | 117 | err = -EINVAL; |
112 | } | 118 | } |
113 | else err = 0; | 119 | else err = 0; |
114 | 120 | ||
115 | os_close_file(fds[0]); | 121 | close(fds[0]); |
116 | 122 | ||
117 | out_free: | 123 | out_free: |
118 | kfree(output); | 124 | kfree(output); |
119 | return err; | 125 | return err; |
120 | 126 | ||
121 | out_close: | 127 | out_close: |
122 | os_close_file(fds[0]); | 128 | close(fds[0]); |
123 | os_close_file(fds[1]); | 129 | close(fds[1]); |
124 | out: | 130 | out: |
125 | return err; | 131 | return err; |
126 | } | 132 | } |
@@ -130,60 +136,64 @@ static int slip_open(void *data) | |||
130 | struct slip_data *pri = data; | 136 | struct slip_data *pri = data; |
131 | char version_buf[sizeof("nnnnn\0")]; | 137 | char version_buf[sizeof("nnnnn\0")]; |
132 | char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")]; | 138 | char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")]; |
133 | char *argv[] = { "uml_net", version_buf, "slip", "up", gate_buf, | 139 | char *argv[] = { "uml_net", version_buf, "slip", "up", gate_buf, |
134 | NULL }; | 140 | NULL }; |
135 | int sfd, mfd, err; | 141 | int sfd, mfd, err; |
136 | 142 | ||
137 | err = get_pty(); | 143 | err = get_pty(); |
138 | if(err < 0){ | 144 | if (err < 0) { |
139 | printk("slip-open : Failed to open pty, err = %d\n", -err); | 145 | printk(UM_KERN_ERR "slip-open : Failed to open pty, err = %d\n", |
146 | -err); | ||
140 | goto out; | 147 | goto out; |
141 | } | 148 | } |
142 | mfd = err; | 149 | mfd = err; |
143 | 150 | ||
144 | err = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0); | 151 | err = open(ptsname(mfd), O_RDWR, 0); |
145 | if(err < 0){ | 152 | if (err < 0) { |
146 | printk("Couldn't open tty for slip line, err = %d\n", -err); | 153 | printk(UM_KERN_ERR "Couldn't open tty for slip line, " |
154 | "err = %d\n", -err); | ||
147 | goto out_close; | 155 | goto out_close; |
148 | } | 156 | } |
149 | sfd = err; | 157 | sfd = err; |
150 | 158 | ||
151 | if(set_up_tty(sfd)) | 159 | if (set_up_tty(sfd)) |
152 | goto out_close2; | 160 | goto out_close2; |
153 | 161 | ||
154 | pri->slave = sfd; | 162 | pri->slave = sfd; |
155 | pri->slip.pos = 0; | 163 | pri->slip.pos = 0; |
156 | pri->slip.esc = 0; | 164 | pri->slip.esc = 0; |
157 | if(pri->gate_addr != NULL){ | 165 | if (pri->gate_addr != NULL) { |
158 | sprintf(version_buf, "%d", UML_NET_VERSION); | 166 | sprintf(version_buf, "%d", UML_NET_VERSION); |
159 | strcpy(gate_buf, pri->gate_addr); | 167 | strcpy(gate_buf, pri->gate_addr); |
160 | 168 | ||
161 | err = slip_tramp(argv, sfd); | 169 | err = slip_tramp(argv, sfd); |
162 | 170 | ||
163 | if(err < 0){ | 171 | if (err < 0) { |
164 | printk("slip_tramp failed - err = %d\n", -err); | 172 | printk(UM_KERN_ERR "slip_tramp failed - err = %d\n", |
173 | -err); | ||
165 | goto out_close2; | 174 | goto out_close2; |
166 | } | 175 | } |
167 | err = os_get_ifname(pri->slave, pri->name); | 176 | err = os_get_ifname(pri->slave, pri->name); |
168 | if(err < 0){ | 177 | if (err < 0) { |
169 | printk("get_ifname failed, err = %d\n", -err); | 178 | printk(UM_KERN_ERR "get_ifname failed, err = %d\n", |
179 | -err); | ||
170 | goto out_close2; | 180 | goto out_close2; |
171 | } | 181 | } |
172 | iter_addresses(pri->dev, open_addr, pri->name); | 182 | iter_addresses(pri->dev, open_addr, pri->name); |
173 | } | 183 | } |
174 | else { | 184 | else { |
175 | err = os_set_slip(sfd); | 185 | err = os_set_slip(sfd); |
176 | if(err < 0){ | 186 | if (err < 0) { |
177 | printk("Failed to set slip discipline encapsulation - " | 187 | printk(UM_KERN_ERR "Failed to set slip discipline " |
178 | "err = %d\n", -err); | 188 | "encapsulation - err = %d\n", -err); |
179 | goto out_close2; | 189 | goto out_close2; |
180 | } | 190 | } |
181 | } | 191 | } |
182 | return(mfd); | 192 | return mfd; |
183 | out_close2: | 193 | out_close2: |
184 | os_close_file(sfd); | 194 | close(sfd); |
185 | out_close: | 195 | out_close: |
186 | os_close_file(mfd); | 196 | close(mfd); |
187 | out: | 197 | out: |
188 | return err; | 198 | return err; |
189 | } | 199 | } |
@@ -192,21 +202,21 @@ static void slip_close(int fd, void *data) | |||
192 | { | 202 | { |
193 | struct slip_data *pri = data; | 203 | struct slip_data *pri = data; |
194 | char version_buf[sizeof("nnnnn\0")]; | 204 | char version_buf[sizeof("nnnnn\0")]; |
195 | char *argv[] = { "uml_net", version_buf, "slip", "down", pri->name, | 205 | char *argv[] = { "uml_net", version_buf, "slip", "down", pri->name, |
196 | NULL }; | 206 | NULL }; |
197 | int err; | 207 | int err; |
198 | 208 | ||
199 | if(pri->gate_addr != NULL) | 209 | if (pri->gate_addr != NULL) |
200 | iter_addresses(pri->dev, close_addr, pri->name); | 210 | iter_addresses(pri->dev, close_addr, pri->name); |
201 | 211 | ||
202 | sprintf(version_buf, "%d", UML_NET_VERSION); | 212 | sprintf(version_buf, "%d", UML_NET_VERSION); |
203 | 213 | ||
204 | err = slip_tramp(argv, pri->slave); | 214 | err = slip_tramp(argv, pri->slave); |
205 | 215 | ||
206 | if(err != 0) | 216 | if (err != 0) |
207 | printk("slip_tramp failed - errno = %d\n", -err); | 217 | printk(UM_KERN_ERR "slip_tramp failed - errno = %d\n", -err); |
208 | os_close_file(fd); | 218 | close(fd); |
209 | os_close_file(pri->slave); | 219 | close(pri->slave); |
210 | pri->slave = -1; | 220 | pri->slave = -1; |
211 | } | 221 | } |
212 | 222 | ||
@@ -222,7 +232,7 @@ int slip_user_write(int fd, void *buf, int len, struct slip_data *pri) | |||
222 | 232 | ||
223 | static int slip_set_mtu(int mtu, void *data) | 233 | static int slip_set_mtu(int mtu, void *data) |
224 | { | 234 | { |
225 | return(mtu); | 235 | return mtu; |
226 | } | 236 | } |
227 | 237 | ||
228 | static void slip_add_addr(unsigned char *addr, unsigned char *netmask, | 238 | static void slip_add_addr(unsigned char *addr, unsigned char *netmask, |
@@ -230,7 +240,8 @@ static void slip_add_addr(unsigned char *addr, unsigned char *netmask, | |||
230 | { | 240 | { |
231 | struct slip_data *pri = data; | 241 | struct slip_data *pri = data; |
232 | 242 | ||
233 | if(pri->slave < 0) return; | 243 | if (pri->slave < 0) |
244 | return; | ||
234 | open_addr(addr, netmask, pri->name); | 245 | open_addr(addr, netmask, pri->name); |
235 | } | 246 | } |
236 | 247 | ||
@@ -239,7 +250,8 @@ static void slip_del_addr(unsigned char *addr, unsigned char *netmask, | |||
239 | { | 250 | { |
240 | struct slip_data *pri = data; | 251 | struct slip_data *pri = data; |
241 | 252 | ||
242 | if(pri->slave < 0) return; | 253 | if (pri->slave < 0) |
254 | return; | ||
243 | close_addr(addr, netmask, pri->name); | 255 | close_addr(addr, netmask, pri->name); |
244 | } | 256 | } |
245 | 257 | ||
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c index 0a0324a6d290..b208d5e4a405 100644 --- a/arch/um/drivers/slirp_kern.c +++ b/arch/um/drivers/slirp_kern.c | |||
@@ -1,11 +1,14 @@ | |||
1 | #include "linux/kernel.h" | 1 | /* |
2 | #include "linux/stddef.h" | 2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL. | ||
4 | */ | ||
5 | |||
6 | #include <linux/if_arp.h> | ||
3 | #include "linux/init.h" | 7 | #include "linux/init.h" |
4 | #include "linux/netdevice.h" | 8 | #include <linux/netdevice.h> |
5 | #include "linux/if_arp.h" | 9 | #include <linux/string.h> |
6 | #include "net_kern.h" | 10 | #include "net_kern.h" |
7 | #include "net_user.h" | 11 | #include "net_user.h" |
8 | #include "kern.h" | ||
9 | #include "slirp.h" | 12 | #include "slirp.h" |
10 | 13 | ||
11 | struct slirp_init { | 14 | struct slirp_init { |
@@ -39,29 +42,28 @@ void slirp_init(struct net_device *dev, void *data) | |||
39 | dev->tx_queue_len = 256; | 42 | dev->tx_queue_len = 256; |
40 | dev->flags = IFF_NOARP; | 43 | dev->flags = IFF_NOARP; |
41 | printk("SLIRP backend - command line:"); | 44 | printk("SLIRP backend - command line:"); |
42 | for(i=0;spri->argw.argv[i]!=NULL;i++) { | 45 | for (i = 0; spri->argw.argv[i] != NULL; i++) |
43 | printk(" '%s'",spri->argw.argv[i]); | 46 | printk(" '%s'",spri->argw.argv[i]); |
44 | } | ||
45 | printk("\n"); | 47 | printk("\n"); |
46 | } | 48 | } |
47 | 49 | ||
48 | static unsigned short slirp_protocol(struct sk_buff *skbuff) | 50 | static unsigned short slirp_protocol(struct sk_buff *skbuff) |
49 | { | 51 | { |
50 | return(htons(ETH_P_IP)); | 52 | return htons(ETH_P_IP); |
51 | } | 53 | } |
52 | 54 | ||
53 | static int slirp_read(int fd, struct sk_buff **skb, | 55 | static int slirp_read(int fd, struct sk_buff **skb, |
54 | struct uml_net_private *lp) | 56 | struct uml_net_private *lp) |
55 | { | 57 | { |
56 | return(slirp_user_read(fd, skb_mac_header(*skb), (*skb)->dev->mtu, | 58 | return slirp_user_read(fd, skb_mac_header(*skb), (*skb)->dev->mtu, |
57 | (struct slirp_data *) &lp->user)); | 59 | (struct slirp_data *) &lp->user); |
58 | } | 60 | } |
59 | 61 | ||
60 | static int slirp_write(int fd, struct sk_buff **skb, | 62 | static int slirp_write(int fd, struct sk_buff **skb, |
61 | struct uml_net_private *lp) | 63 | struct uml_net_private *lp) |
62 | { | 64 | { |
63 | return(slirp_user_write(fd, (*skb)->data, (*skb)->len, | 65 | return slirp_user_write(fd, (*skb)->data, (*skb)->len, |
64 | (struct slirp_data *) &lp->user)); | 66 | (struct slirp_data *) &lp->user); |
65 | } | 67 | } |
66 | 68 | ||
67 | const struct net_kern_info slirp_kern_info = { | 69 | const struct net_kern_info slirp_kern_info = { |
@@ -76,31 +78,32 @@ static int slirp_setup(char *str, char **mac_out, void *data) | |||
76 | struct slirp_init *init = data; | 78 | struct slirp_init *init = data; |
77 | int i=0; | 79 | int i=0; |
78 | 80 | ||
79 | *init = ((struct slirp_init) | 81 | *init = ((struct slirp_init) { .argw = { { "slirp", NULL } } }); |
80 | { .argw = { { "slirp", NULL } } }); | ||
81 | 82 | ||
82 | str = split_if_spec(str, mac_out, NULL); | 83 | str = split_if_spec(str, mac_out, NULL); |
83 | 84 | ||
84 | if(str == NULL) { /* no command line given after MAC addr */ | 85 | if (str == NULL) /* no command line given after MAC addr */ |
85 | return(1); | 86 | return 1; |
86 | } | ||
87 | 87 | ||
88 | do { | 88 | do { |
89 | if(i>=SLIRP_MAX_ARGS-1) { | 89 | if (i >= SLIRP_MAX_ARGS - 1) { |
90 | printk("slirp_setup: truncating slirp arguments\n"); | 90 | printk(KERN_WARNING "slirp_setup: truncating slirp " |
91 | "arguments\n"); | ||
91 | break; | 92 | break; |
92 | } | 93 | } |
93 | init->argw.argv[i++] = str; | 94 | init->argw.argv[i++] = str; |
94 | while(*str && *str!=',') { | 95 | while(*str && *str!=',') { |
95 | if(*str=='_') *str=' '; | 96 | if (*str == '_') |
97 | *str=' '; | ||
96 | str++; | 98 | str++; |
97 | } | 99 | } |
98 | if(*str!=',') | 100 | if (*str != ',') |
99 | break; | 101 | break; |
100 | *str++='\0'; | 102 | *str++ = '\0'; |
101 | } while(1); | 103 | } while (1); |
102 | init->argw.argv[i]=NULL; | 104 | |
103 | return(1); | 105 | init->argw.argv[i] = NULL; |
106 | return 1; | ||
104 | } | 107 | } |
105 | 108 | ||
106 | static struct transport slirp_transport = { | 109 | static struct transport slirp_transport = { |
diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c index 0e462f64f227..a4755bc33e1e 100644 --- a/arch/um/drivers/slirp_user.c +++ b/arch/um/drivers/slirp_user.c | |||
@@ -1,18 +1,17 @@ | |||
1 | #include <stdio.h> | 1 | /* |
2 | #include <stdlib.h> | 2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL. | ||
4 | */ | ||
5 | |||
3 | #include <unistd.h> | 6 | #include <unistd.h> |
4 | #include <stddef.h> | ||
5 | #include <sched.h> | ||
6 | #include <string.h> | ||
7 | #include <errno.h> | 7 | #include <errno.h> |
8 | #include <string.h> | ||
8 | #include <sys/wait.h> | 9 | #include <sys/wait.h> |
9 | #include <sys/signal.h> | 10 | #include "kern_constants.h" |
10 | #include "kern_util.h" | ||
11 | #include "user.h" | ||
12 | #include "net_user.h" | 11 | #include "net_user.h" |
13 | #include "slirp.h" | ||
14 | #include "slip_common.h" | ||
15 | #include "os.h" | 12 | #include "os.h" |
13 | #include "slirp.h" | ||
14 | #include "user.h" | ||
16 | 15 | ||
17 | static int slirp_user_init(void *data, void *dev) | 16 | static int slirp_user_init(void *data, void *dev) |
18 | { | 17 | { |
@@ -31,8 +30,10 @@ static void slirp_pre_exec(void *arg) | |||
31 | { | 30 | { |
32 | struct slirp_pre_exec_data *data = arg; | 31 | struct slirp_pre_exec_data *data = arg; |
33 | 32 | ||
34 | if(data->stdin != -1) dup2(data->stdin, 0); | 33 | if (data->stdin != -1) |
35 | if(data->stdout != -1) dup2(data->stdout, 1); | 34 | dup2(data->stdin, 0); |
35 | if (data->stdout != -1) | ||
36 | dup2(data->stdout, 1); | ||
36 | } | 37 | } |
37 | 38 | ||
38 | static int slirp_tramp(char **argv, int fd) | 39 | static int slirp_tramp(char **argv, int fd) |
@@ -44,7 +45,7 @@ static int slirp_tramp(char **argv, int fd) | |||
44 | pe_data.stdout = fd; | 45 | pe_data.stdout = fd; |
45 | pid = run_helper(slirp_pre_exec, &pe_data, argv); | 46 | pid = run_helper(slirp_pre_exec, &pe_data, argv); |
46 | 47 | ||
47 | return(pid); | 48 | return pid; |
48 | } | 49 | } |
49 | 50 | ||
50 | static int slirp_open(void *data) | 51 | static int slirp_open(void *data) |
@@ -53,12 +54,12 @@ static int slirp_open(void *data) | |||
53 | int fds[2], pid, err; | 54 | int fds[2], pid, err; |
54 | 55 | ||
55 | err = os_pipe(fds, 1, 1); | 56 | err = os_pipe(fds, 1, 1); |
56 | if(err) | 57 | if (err) |
57 | return(err); | 58 | return err; |
58 | 59 | ||
59 | err = slirp_tramp(pri->argw.argv, fds[1]); | 60 | err = slirp_tramp(pri->argw.argv, fds[1]); |
60 | if(err < 0){ | 61 | if (err < 0) { |
61 | printk("slirp_tramp failed - errno = %d\n", -err); | 62 | printk(UM_KERN_ERR "slirp_tramp failed - errno = %d\n", -err); |
62 | goto out; | 63 | goto out; |
63 | } | 64 | } |
64 | pid = err; | 65 | pid = err; |
@@ -68,10 +69,10 @@ static int slirp_open(void *data) | |||
68 | pri->slip.esc = 0; | 69 | pri->slip.esc = 0; |
69 | pri->pid = err; | 70 | pri->pid = err; |
70 | 71 | ||
71 | return(fds[0]); | 72 | return fds[0]; |
72 | out: | 73 | out: |
73 | os_close_file(fds[0]); | 74 | close(fds[0]); |
74 | os_close_file(fds[1]); | 75 | close(fds[1]); |
75 | return err; | 76 | return err; |
76 | } | 77 | } |
77 | 78 | ||
@@ -80,31 +81,33 @@ static void slirp_close(int fd, void *data) | |||
80 | struct slirp_data *pri = data; | 81 | struct slirp_data *pri = data; |
81 | int status,err; | 82 | int status,err; |
82 | 83 | ||
83 | os_close_file(fd); | 84 | close(fd); |
84 | os_close_file(pri->slave); | 85 | close(pri->slave); |
85 | 86 | ||
86 | pri->slave = -1; | 87 | pri->slave = -1; |
87 | 88 | ||
88 | if(pri->pid<1) { | 89 | if (pri->pid<1) { |
89 | printk("slirp_close: no child process to shut down\n"); | 90 | printk(UM_KERN_ERR "slirp_close: no child process to shut " |
91 | "down\n"); | ||
90 | return; | 92 | return; |
91 | } | 93 | } |
92 | 94 | ||
93 | #if 0 | 95 | #if 0 |
94 | if(kill(pri->pid, SIGHUP)<0) { | 96 | if (kill(pri->pid, SIGHUP)<0) { |
95 | printk("slirp_close: sending hangup to %d failed (%d)\n", | 97 | printk(UM_KERN_ERR "slirp_close: sending hangup to %d failed " |
96 | pri->pid, errno); | 98 | "(%d)\n", pri->pid, errno); |
97 | } | 99 | } |
98 | #endif | 100 | #endif |
99 | 101 | ||
100 | CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG)); | 102 | CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG)); |
101 | if(err < 0) { | 103 | if (err < 0) { |
102 | printk("slirp_close: waitpid returned %d\n", errno); | 104 | printk(UM_KERN_ERR "slirp_close: waitpid returned %d\n", errno); |
103 | return; | 105 | return; |
104 | } | 106 | } |
105 | 107 | ||
106 | if(err == 0) { | 108 | if (err == 0) { |
107 | printk("slirp_close: process %d has not exited\n", pri->pid); | 109 | printk(UM_KERN_ERR "slirp_close: process %d has not exited\n", |
110 | pri->pid); | ||
108 | return; | 111 | return; |
109 | } | 112 | } |
110 | 113 | ||
@@ -123,7 +126,7 @@ int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri) | |||
123 | 126 | ||
124 | static int slirp_set_mtu(int mtu, void *data) | 127 | static int slirp_set_mtu(int mtu, void *data) |
125 | { | 128 | { |
126 | return(mtu); | 129 | return mtu; |
127 | } | 130 | } |
128 | 131 | ||
129 | const struct net_user_info slirp_user_info = { | 132 | const struct net_user_info slirp_user_info = { |
diff --git a/arch/um/drivers/vde_kern.c b/arch/um/drivers/vde_kern.c index eb8cf31b820d..c5d01685d2b5 100644 --- a/arch/um/drivers/vde_kern.c +++ b/arch/um/drivers/vde_kern.c | |||
@@ -7,10 +7,8 @@ | |||
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "linux/kernel.h" | ||
11 | #include "linux/init.h" | 10 | #include "linux/init.h" |
12 | #include "linux/netdevice.h" | 11 | #include <linux/netdevice.h> |
13 | #include "linux/etherdevice.h" | ||
14 | #include "net_kern.h" | 12 | #include "net_kern.h" |
15 | #include "net_user.h" | 13 | #include "net_user.h" |
16 | #include "vde.h" | 14 | #include "vde.h" |
@@ -30,12 +28,12 @@ static void vde_init(struct net_device *dev, void *data) | |||
30 | vpri->conn = NULL; | 28 | vpri->conn = NULL; |
31 | vpri->dev = dev; | 29 | vpri->dev = dev; |
32 | 30 | ||
33 | printk(KERN_INFO "vde backend - %s, ", vpri->vde_switch ? | 31 | printk("vde backend - %s, ", vpri->vde_switch ? |
34 | vpri->vde_switch : "(default socket)"); | 32 | vpri->vde_switch : "(default socket)"); |
35 | 33 | ||
36 | vde_init_libstuff(vpri, init); | 34 | vde_init_libstuff(vpri, init); |
37 | 35 | ||
38 | printk(KERN_INFO "\n"); | 36 | printk("\n"); |
39 | } | 37 | } |
40 | 38 | ||
41 | static int vde_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) | 39 | static int vde_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) |
diff --git a/arch/um/drivers/vde_user.c b/arch/um/drivers/vde_user.c index d3b5a065fc52..7533cd3cbba4 100644 --- a/arch/um/drivers/vde_user.c +++ b/arch/um/drivers/vde_user.c | |||
@@ -3,15 +3,13 @@ | |||
3 | * Licensed under the GPL. | 3 | * Licensed under the GPL. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stddef.h> | ||
6 | #include <errno.h> | 7 | #include <errno.h> |
7 | #include <unistd.h> | ||
8 | #include <libvdeplug.h> | 8 | #include <libvdeplug.h> |
9 | #include "net_user.h" | ||
10 | #include "kern_util.h" | ||
11 | #include "kern_constants.h" | 9 | #include "kern_constants.h" |
12 | #include "user.h" | 10 | #include "net_user.h" |
13 | #include "os.h" | ||
14 | #include "um_malloc.h" | 11 | #include "um_malloc.h" |
12 | #include "user.h" | ||
15 | #include "vde.h" | 13 | #include "vde.h" |
16 | 14 | ||
17 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) | 15 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) |
diff --git a/arch/um/os-Linux/drivers/etap.h b/arch/um/os-Linux/drivers/etap.h index 57ecdaf2f67e..ddffd41c3f3f 100644 --- a/arch/um/os-Linux/drivers/etap.h +++ b/arch/um/os-Linux/drivers/etap.h | |||
@@ -1,8 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef __DRIVERS_ETAP_H | ||
7 | #define __DRIVERS_ETAP_H | ||
8 | |||
6 | #include "net_user.h" | 9 | #include "net_user.h" |
7 | 10 | ||
8 | struct ethertap_data { | 11 | struct ethertap_data { |
@@ -15,13 +18,4 @@ struct ethertap_data { | |||
15 | 18 | ||
16 | extern const struct net_user_info ethertap_user_info; | 19 | extern const struct net_user_info ethertap_user_info; |
17 | 20 | ||
18 | /* | 21 | #endif |
19 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
20 | * Emacs will notice this stuff at the end of the file and automatically | ||
21 | * adjust the settings for this buffer only. This must remain at the end | ||
22 | * of the file. | ||
23 | * --------------------------------------------------------------------------- | ||
24 | * Local variables: | ||
25 | * c-file-style: "linux" | ||
26 | * End: | ||
27 | */ | ||
diff --git a/arch/um/os-Linux/drivers/ethertap_kern.c b/arch/um/os-Linux/drivers/ethertap_kern.c index 12689141414d..542bcc58354c 100644 --- a/arch/um/os-Linux/drivers/ethertap_kern.c +++ b/arch/um/os-Linux/drivers/ethertap_kern.c | |||
@@ -1,16 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and |
3 | * James Leu (jleu@mindspring.net). | 3 | * James Leu (jleu@mindspring.net). |
4 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
4 | * Copyright (C) 2001 by various other people who didn't put their name here. | 5 | * Copyright (C) 2001 by various other people who didn't put their name here. |
5 | * Licensed under the GPL. | 6 | * Licensed under the GPL. |
6 | */ | 7 | */ |
7 | 8 | ||
8 | #include "linux/init.h" | 9 | #include "linux/init.h" |
9 | #include "linux/netdevice.h" | 10 | #include <linux/netdevice.h> |
10 | #include "linux/etherdevice.h" | ||
11 | #include "net_kern.h" | ||
12 | #include "net_user.h" | ||
13 | #include "etap.h" | 11 | #include "etap.h" |
12 | #include "net_kern.h" | ||
14 | 13 | ||
15 | struct ethertap_init { | 14 | struct ethertap_init { |
16 | char *dev_name; | 15 | char *dev_name; |
@@ -42,27 +41,30 @@ static int etap_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) | |||
42 | int len; | 41 | int len; |
43 | 42 | ||
44 | *skb = ether_adjust_skb(*skb, ETH_HEADER_ETHERTAP); | 43 | *skb = ether_adjust_skb(*skb, ETH_HEADER_ETHERTAP); |
45 | if(*skb == NULL) return(-ENOMEM); | 44 | if (*skb == NULL) |
45 | return -ENOMEM; | ||
46 | len = net_recvfrom(fd, skb_mac_header(*skb), | 46 | len = net_recvfrom(fd, skb_mac_header(*skb), |
47 | (*skb)->dev->mtu + 2 * ETH_HEADER_ETHERTAP); | 47 | (*skb)->dev->mtu + 2 * ETH_HEADER_ETHERTAP); |
48 | if(len <= 0) return(len); | 48 | if (len <= 0) |
49 | return len; | ||
49 | skb_pull(*skb, 2); | 50 | skb_pull(*skb, 2); |
50 | len -= 2; | 51 | len -= 2; |
51 | return(len); | 52 | return len; |
52 | } | 53 | } |
53 | 54 | ||
54 | static int etap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp) | 55 | static int etap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp) |
55 | { | 56 | { |
56 | if(skb_headroom(*skb) < 2){ | 57 | if (skb_headroom(*skb) < 2) { |
57 | struct sk_buff *skb2; | 58 | struct sk_buff *skb2; |
58 | 59 | ||
59 | skb2 = skb_realloc_headroom(*skb, 2); | 60 | skb2 = skb_realloc_headroom(*skb, 2); |
60 | dev_kfree_skb(*skb); | 61 | dev_kfree_skb(*skb); |
61 | if (skb2 == NULL) return(-ENOMEM); | 62 | if (skb2 == NULL) |
63 | return -ENOMEM; | ||
62 | *skb = skb2; | 64 | *skb = skb2; |
63 | } | 65 | } |
64 | skb_push(*skb, 2); | 66 | skb_push(*skb, 2); |
65 | return(net_send(fd, (*skb)->data, (*skb)->len)); | 67 | return net_send(fd, (*skb)->data, (*skb)->len); |
66 | } | 68 | } |
67 | 69 | ||
68 | const struct net_kern_info ethertap_kern_info = { | 70 | const struct net_kern_info ethertap_kern_info = { |
@@ -79,15 +81,15 @@ int ethertap_setup(char *str, char **mac_out, void *data) | |||
79 | *init = ((struct ethertap_init) | 81 | *init = ((struct ethertap_init) |
80 | { .dev_name = NULL, | 82 | { .dev_name = NULL, |
81 | .gate_addr = NULL }); | 83 | .gate_addr = NULL }); |
82 | if(tap_setup_common(str, "ethertap", &init->dev_name, mac_out, | 84 | if (tap_setup_common(str, "ethertap", &init->dev_name, mac_out, |
83 | &init->gate_addr)) | 85 | &init->gate_addr)) |
84 | return(0); | 86 | return 0; |
85 | if(init->dev_name == NULL){ | 87 | if (init->dev_name == NULL) { |
86 | printk("ethertap_setup : Missing tap device name\n"); | 88 | printk(KERN_ERR "ethertap_setup : Missing tap device name\n"); |
87 | return(0); | 89 | return 0; |
88 | } | 90 | } |
89 | 91 | ||
90 | return(1); | 92 | return 1; |
91 | } | 93 | } |
92 | 94 | ||
93 | static struct transport ethertap_transport = { | 95 | static struct transport ethertap_transport = { |
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c index d74eedb7e682..29404b955f18 100644 --- a/arch/um/os-Linux/drivers/ethertap_user.c +++ b/arch/um/os-Linux/drivers/ethertap_user.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 3 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and |
3 | * James Leu (jleu@mindspring.net). | 4 | * James Leu (jleu@mindspring.net). |
4 | * Copyright (C) 2001 by various other people who didn't put their name here. | 5 | * Copyright (C) 2001 by various other people who didn't put their name here. |
@@ -7,20 +8,16 @@ | |||
7 | 8 | ||
8 | #include <stdio.h> | 9 | #include <stdio.h> |
9 | #include <unistd.h> | 10 | #include <unistd.h> |
10 | #include <stddef.h> | 11 | #include <errno.h> |
11 | #include <stdlib.h> | 12 | #include <string.h> |
12 | #include <sys/errno.h> | ||
13 | #include <sys/socket.h> | 13 | #include <sys/socket.h> |
14 | #include <sys/wait.h> | 14 | #include <sys/wait.h> |
15 | #include <sys/un.h> | ||
16 | #include <net/if.h> | ||
17 | #include "user.h" | ||
18 | #include "kern_util.h" | ||
19 | #include "net_user.h" | ||
20 | #include "etap.h" | 15 | #include "etap.h" |
16 | #include "kern_constants.h" | ||
21 | #include "os.h" | 17 | #include "os.h" |
18 | #include "net_user.h" | ||
22 | #include "um_malloc.h" | 19 | #include "um_malloc.h" |
23 | #include "kern_constants.h" | 20 | #include "user.h" |
24 | 21 | ||
25 | #define MAX_PACKET ETH_MAX_PACKET | 22 | #define MAX_PACKET ETH_MAX_PACKET |
26 | 23 | ||
@@ -49,16 +46,18 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask, | |||
49 | memcpy(change.addr, addr, sizeof(change.addr)); | 46 | memcpy(change.addr, addr, sizeof(change.addr)); |
50 | memcpy(change.netmask, netmask, sizeof(change.netmask)); | 47 | memcpy(change.netmask, netmask, sizeof(change.netmask)); |
51 | CATCH_EINTR(n = write(fd, &change, sizeof(change))); | 48 | CATCH_EINTR(n = write(fd, &change, sizeof(change))); |
52 | if(n != sizeof(change)){ | 49 | if (n != sizeof(change)) { |
53 | printk("etap_change - request failed, err = %d\n", errno); | 50 | printk(UM_KERN_ERR "etap_change - request failed, err = %d\n", |
51 | errno); | ||
54 | return; | 52 | return; |
55 | } | 53 | } |
56 | 54 | ||
57 | output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL); | 55 | output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL); |
58 | if(output == NULL) | 56 | if (output == NULL) |
59 | printk("etap_change : Failed to allocate output buffer\n"); | 57 | printk(UM_KERN_ERR "etap_change : Failed to allocate output " |
58 | "buffer\n"); | ||
60 | read_output(fd, output, UM_KERN_PAGE_SIZE); | 59 | read_output(fd, output, UM_KERN_PAGE_SIZE); |
61 | if(output != NULL){ | 60 | if (output != NULL) { |
62 | printk("%s", output); | 61 | printk("%s", output); |
63 | kfree(output); | 62 | kfree(output); |
64 | } | 63 | } |
@@ -107,7 +106,7 @@ static int etap_tramp(char *dev, char *gate, int control_me, | |||
107 | 106 | ||
108 | sprintf(data_fd_buf, "%d", data_remote); | 107 | sprintf(data_fd_buf, "%d", data_remote); |
109 | sprintf(version_buf, "%d", UML_NET_VERSION); | 108 | sprintf(version_buf, "%d", UML_NET_VERSION); |
110 | if(gate != NULL){ | 109 | if (gate != NULL) { |
111 | strcpy(gate_buf, gate); | 110 | strcpy(gate_buf, gate); |
112 | args = setup_args; | 111 | args = setup_args; |
113 | } | 112 | } |
@@ -119,24 +118,26 @@ static int etap_tramp(char *dev, char *gate, int control_me, | |||
119 | pe_data.data_me = data_me; | 118 | pe_data.data_me = data_me; |
120 | pid = run_helper(etap_pre_exec, &pe_data, args); | 119 | pid = run_helper(etap_pre_exec, &pe_data, args); |
121 | 120 | ||
122 | if(pid < 0) | 121 | if (pid < 0) |
123 | err = pid; | 122 | err = pid; |
124 | close(data_remote); | 123 | close(data_remote); |
125 | close(control_remote); | 124 | close(control_remote); |
126 | CATCH_EINTR(n = read(control_me, &c, sizeof(c))); | 125 | CATCH_EINTR(n = read(control_me, &c, sizeof(c))); |
127 | if(n != sizeof(c)){ | 126 | if (n != sizeof(c)) { |
128 | err = -errno; | 127 | err = -errno; |
129 | printk("etap_tramp : read of status failed, err = %d\n", -err); | 128 | printk(UM_KERN_ERR "etap_tramp : read of status failed, " |
129 | "err = %d\n", -err); | ||
130 | return err; | 130 | return err; |
131 | } | 131 | } |
132 | if(c != 1){ | 132 | if (c != 1) { |
133 | printk("etap_tramp : uml_net failed\n"); | 133 | printk(UM_KERN_ERR "etap_tramp : uml_net failed\n"); |
134 | err = -EINVAL; | 134 | err = -EINVAL; |
135 | CATCH_EINTR(n = waitpid(pid, &status, 0)); | 135 | CATCH_EINTR(n = waitpid(pid, &status, 0)); |
136 | if(n < 0) | 136 | if (n < 0) |
137 | err = -errno; | 137 | err = -errno; |
138 | else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1)) | 138 | else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 1)) |
139 | printk("uml_net didn't exit with status 1\n"); | 139 | printk(UM_KERN_ERR "uml_net didn't exit with " |
140 | "status 1\n"); | ||
140 | } | 141 | } |
141 | return err; | 142 | return err; |
142 | } | 143 | } |
@@ -148,22 +149,22 @@ static int etap_open(void *data) | |||
148 | int data_fds[2], control_fds[2], err, output_len; | 149 | int data_fds[2], control_fds[2], err, output_len; |
149 | 150 | ||
150 | err = tap_open_common(pri->dev, pri->gate_addr); | 151 | err = tap_open_common(pri->dev, pri->gate_addr); |
151 | if(err) | 152 | if (err) |
152 | return err; | 153 | return err; |
153 | 154 | ||
154 | err = socketpair(AF_UNIX, SOCK_DGRAM, 0, data_fds); | 155 | err = socketpair(AF_UNIX, SOCK_DGRAM, 0, data_fds); |
155 | if(err){ | 156 | if (err) { |
156 | err = -errno; | 157 | err = -errno; |
157 | printk("etap_open - data socketpair failed - err = %d\n", | 158 | printk(UM_KERN_ERR "etap_open - data socketpair failed - " |
158 | errno); | 159 | "err = %d\n", errno); |
159 | return err; | 160 | return err; |
160 | } | 161 | } |
161 | 162 | ||
162 | err = socketpair(AF_UNIX, SOCK_STREAM, 0, control_fds); | 163 | err = socketpair(AF_UNIX, SOCK_STREAM, 0, control_fds); |
163 | if(err){ | 164 | if (err) { |
164 | err = -errno; | 165 | err = -errno; |
165 | printk("etap_open - control socketpair failed - err = %d\n", | 166 | printk(UM_KERN_ERR "etap_open - control socketpair failed - " |
166 | errno); | 167 | "err = %d\n", errno); |
167 | goto out_close_data; | 168 | goto out_close_data; |
168 | } | 169 | } |
169 | 170 | ||
@@ -173,15 +174,16 @@ static int etap_open(void *data) | |||
173 | output = kmalloc(output_len, UM_GFP_KERNEL); | 174 | output = kmalloc(output_len, UM_GFP_KERNEL); |
174 | read_output(control_fds[0], output, output_len); | 175 | read_output(control_fds[0], output, output_len); |
175 | 176 | ||
176 | if(output == NULL) | 177 | if (output == NULL) |
177 | printk("etap_open : failed to allocate output buffer\n"); | 178 | printk(UM_KERN_ERR "etap_open : failed to allocate output " |
179 | "buffer\n"); | ||
178 | else { | 180 | else { |
179 | printk("%s", output); | 181 | printk("%s", output); |
180 | kfree(output); | 182 | kfree(output); |
181 | } | 183 | } |
182 | 184 | ||
183 | if(err < 0){ | 185 | if (err < 0) { |
184 | printk("etap_tramp failed - err = %d\n", -err); | 186 | printk(UM_KERN_ERR "etap_tramp failed - err = %d\n", -err); |
185 | goto out_close_control; | 187 | goto out_close_control; |
186 | } | 188 | } |
187 | 189 | ||
@@ -206,14 +208,14 @@ static void etap_close(int fd, void *data) | |||
206 | iter_addresses(pri->dev, etap_close_addr, &pri->control_fd); | 208 | iter_addresses(pri->dev, etap_close_addr, &pri->control_fd); |
207 | close(fd); | 209 | close(fd); |
208 | 210 | ||
209 | if(shutdown(pri->data_fd, SHUT_RDWR) < 0) | 211 | if (shutdown(pri->data_fd, SHUT_RDWR) < 0) |
210 | printk("etap_close - shutdown data socket failed, errno = %d\n", | 212 | printk(UM_KERN_ERR "etap_close - shutdown data socket failed, " |
211 | errno); | ||
212 | |||
213 | if(shutdown(pri->control_fd, SHUT_RDWR) < 0) | ||
214 | printk("etap_close - shutdown control socket failed, " | ||
215 | "errno = %d\n", errno); | 213 | "errno = %d\n", errno); |
216 | 214 | ||
215 | if (shutdown(pri->control_fd, SHUT_RDWR) < 0) | ||
216 | printk(UM_KERN_ERR "etap_close - shutdown control socket " | ||
217 | "failed, errno = %d\n", errno); | ||
218 | |||
217 | close(pri->data_fd); | 219 | close(pri->data_fd); |
218 | pri->data_fd = -1; | 220 | pri->data_fd = -1; |
219 | close(pri->control_fd); | 221 | close(pri->control_fd); |
@@ -231,7 +233,7 @@ static void etap_add_addr(unsigned char *addr, unsigned char *netmask, | |||
231 | struct ethertap_data *pri = data; | 233 | struct ethertap_data *pri = data; |
232 | 234 | ||
233 | tap_check_ips(pri->gate_addr, addr); | 235 | tap_check_ips(pri->gate_addr, addr); |
234 | if(pri->control_fd == -1) | 236 | if (pri->control_fd == -1) |
235 | return; | 237 | return; |
236 | etap_open_addr(addr, netmask, &pri->control_fd); | 238 | etap_open_addr(addr, netmask, &pri->control_fd); |
237 | } | 239 | } |
@@ -241,7 +243,7 @@ static void etap_del_addr(unsigned char *addr, unsigned char *netmask, | |||
241 | { | 243 | { |
242 | struct ethertap_data *pri = data; | 244 | struct ethertap_data *pri = data; |
243 | 245 | ||
244 | if(pri->control_fd == -1) | 246 | if (pri->control_fd == -1) |
245 | return; | 247 | return; |
246 | 248 | ||
247 | etap_close_addr(addr, netmask, &pri->control_fd); | 249 | etap_close_addr(addr, netmask, &pri->control_fd); |
diff --git a/arch/um/os-Linux/drivers/tuntap.h b/arch/um/os-Linux/drivers/tuntap.h index d3e8d3af6245..f17c31586c84 100644 --- a/arch/um/os-Linux/drivers/tuntap.h +++ b/arch/um/os-Linux/drivers/tuntap.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -19,14 +19,3 @@ struct tuntap_data { | |||
19 | extern const struct net_user_info tuntap_user_info; | 19 | extern const struct net_user_info tuntap_user_info; |
20 | 20 | ||
21 | #endif | 21 | #endif |
22 | |||
23 | /* | ||
24 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
25 | * Emacs will notice this stuff at the end of the file and automatically | ||
26 | * adjust the settings for this buffer only. This must remain at the end | ||
27 | * of the file. | ||
28 | * --------------------------------------------------------------------------- | ||
29 | * Local variables: | ||
30 | * c-file-style: "linux" | ||
31 | * End: | ||
32 | */ | ||
diff --git a/arch/um/os-Linux/drivers/tuntap_kern.c b/arch/um/os-Linux/drivers/tuntap_kern.c index f1714e7fb1d0..9ade1f892ac8 100644 --- a/arch/um/os-Linux/drivers/tuntap_kern.c +++ b/arch/um/os-Linux/drivers/tuntap_kern.c | |||
@@ -1,16 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/stddef.h" | 6 | #include <linux/netdevice.h> |
7 | #include "linux/netdevice.h" | 7 | #include <linux/init.h> |
8 | #include "linux/etherdevice.h" | 8 | #include <linux/skbuff.h> |
9 | #include "linux/skbuff.h" | 9 | #include <asm/errno.h> |
10 | #include "linux/init.h" | ||
11 | #include "asm/errno.h" | ||
12 | #include "net_kern.h" | 10 | #include "net_kern.h" |
13 | #include "net_user.h" | ||
14 | #include "tuntap.h" | 11 | #include "tuntap.h" |
15 | 12 | ||
16 | struct tuntap_init { | 13 | struct tuntap_init { |
@@ -38,19 +35,20 @@ static void tuntap_init(struct net_device *dev, void *data) | |||
38 | printk("\n"); | 35 | printk("\n"); |
39 | } | 36 | } |
40 | 37 | ||
41 | static int tuntap_read(int fd, struct sk_buff **skb, | 38 | static int tuntap_read(int fd, struct sk_buff **skb, |
42 | struct uml_net_private *lp) | 39 | struct uml_net_private *lp) |
43 | { | 40 | { |
44 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); | 41 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); |
45 | if(*skb == NULL) return(-ENOMEM); | 42 | if (*skb == NULL) |
46 | return(net_read(fd, skb_mac_header(*skb), | 43 | return -ENOMEM; |
47 | (*skb)->dev->mtu + ETH_HEADER_OTHER)); | 44 | return net_read(fd, skb_mac_header(*skb), |
45 | (*skb)->dev->mtu + ETH_HEADER_OTHER); | ||
48 | } | 46 | } |
49 | 47 | ||
50 | static int tuntap_write(int fd, struct sk_buff **skb, | 48 | static int tuntap_write(int fd, struct sk_buff **skb, |
51 | struct uml_net_private *lp) | 49 | struct uml_net_private *lp) |
52 | { | 50 | { |
53 | return(net_write(fd, (*skb)->data, (*skb)->len)); | 51 | return net_write(fd, (*skb)->data, (*skb)->len); |
54 | } | 52 | } |
55 | 53 | ||
56 | const struct net_kern_info tuntap_kern_info = { | 54 | const struct net_kern_info tuntap_kern_info = { |
@@ -67,11 +65,11 @@ int tuntap_setup(char *str, char **mac_out, void *data) | |||
67 | *init = ((struct tuntap_init) | 65 | *init = ((struct tuntap_init) |
68 | { .dev_name = NULL, | 66 | { .dev_name = NULL, |
69 | .gate_addr = NULL }); | 67 | .gate_addr = NULL }); |
70 | if(tap_setup_common(str, "tuntap", &init->dev_name, mac_out, | 68 | if (tap_setup_common(str, "tuntap", &init->dev_name, mac_out, |
71 | &init->gate_addr)) | 69 | &init->gate_addr)) |
72 | return(0); | 70 | return 0; |
73 | 71 | ||
74 | return(1); | 72 | return 1; |
75 | } | 73 | } |
76 | 74 | ||
77 | static struct transport tuntap_transport = { | 75 | static struct transport tuntap_transport = { |
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 72a2ff61556d..10714a413cfd 100644 --- a/arch/um/os-Linux/drivers/tuntap_user.c +++ b/arch/um/os-Linux/drivers/tuntap_user.c | |||
@@ -1,25 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stddef.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <unistd.h> | 7 | #include <unistd.h> |
10 | #include <errno.h> | 8 | #include <errno.h> |
11 | #include <sys/wait.h> | 9 | #include <string.h> |
10 | #include <linux/if_tun.h> | ||
11 | #include <net/if.h> | ||
12 | #include <sys/ioctl.h> | ||
12 | #include <sys/socket.h> | 13 | #include <sys/socket.h> |
13 | #include <sys/un.h> | 14 | #include <sys/wait.h> |
14 | #include <sys/uio.h> | 15 | #include <sys/uio.h> |
15 | #include <sys/ioctl.h> | 16 | #include "kern_constants.h" |
16 | #include <net/if.h> | 17 | #include "os.h" |
17 | #include <linux/if_tun.h> | ||
18 | #include "net_user.h" | ||
19 | #include "tuntap.h" | 18 | #include "tuntap.h" |
20 | #include "kern_util.h" | ||
21 | #include "user.h" | 19 | #include "user.h" |
22 | #include "os.h" | ||
23 | 20 | ||
24 | #define MAX_PACKET ETH_MAX_PACKET | 21 | #define MAX_PACKET ETH_MAX_PACKET |
25 | 22 | ||
@@ -37,7 +34,7 @@ static void tuntap_add_addr(unsigned char *addr, unsigned char *netmask, | |||
37 | struct tuntap_data *pri = data; | 34 | struct tuntap_data *pri = data; |
38 | 35 | ||
39 | tap_check_ips(pri->gate_addr, addr); | 36 | tap_check_ips(pri->gate_addr, addr); |
40 | if((pri->fd == -1) || pri->fixed_config) | 37 | if ((pri->fd == -1) || pri->fixed_config) |
41 | return; | 38 | return; |
42 | open_addr(addr, netmask, pri->dev_name); | 39 | open_addr(addr, netmask, pri->dev_name); |
43 | } | 40 | } |
@@ -47,7 +44,7 @@ static void tuntap_del_addr(unsigned char *addr, unsigned char *netmask, | |||
47 | { | 44 | { |
48 | struct tuntap_data *pri = data; | 45 | struct tuntap_data *pri = data; |
49 | 46 | ||
50 | if((pri->fd == -1) || pri->fixed_config) | 47 | if ((pri->fd == -1) || pri->fixed_config) |
51 | return; | 48 | return; |
52 | close_addr(addr, netmask, pri->dev_name); | 49 | close_addr(addr, netmask, pri->dev_name); |
53 | } | 50 | } |
@@ -85,14 +82,14 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
85 | 82 | ||
86 | pid = run_helper(tuntap_pre_exec, &data, argv); | 83 | pid = run_helper(tuntap_pre_exec, &data, argv); |
87 | 84 | ||
88 | if(pid < 0) | 85 | if (pid < 0) |
89 | return -pid; | 86 | return -pid; |
90 | 87 | ||
91 | close(remote); | 88 | close(remote); |
92 | 89 | ||
93 | msg.msg_name = NULL; | 90 | msg.msg_name = NULL; |
94 | msg.msg_namelen = 0; | 91 | msg.msg_namelen = 0; |
95 | if(buffer != NULL){ | 92 | if (buffer != NULL) { |
96 | iov = ((struct iovec) { buffer, buffer_len }); | 93 | iov = ((struct iovec) { buffer, buffer_len }); |
97 | msg.msg_iov = &iov; | 94 | msg.msg_iov = &iov; |
98 | msg.msg_iovlen = 1; | 95 | msg.msg_iovlen = 1; |
@@ -106,22 +103,24 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
106 | msg.msg_flags = 0; | 103 | msg.msg_flags = 0; |
107 | n = recvmsg(me, &msg, 0); | 104 | n = recvmsg(me, &msg, 0); |
108 | *used_out = n; | 105 | *used_out = n; |
109 | if(n < 0){ | 106 | if (n < 0) { |
110 | err = -errno; | 107 | err = -errno; |
111 | printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", | 108 | printk(UM_KERN_ERR "tuntap_open_tramp : recvmsg failed - " |
112 | errno); | 109 | "errno = %d\n", errno); |
113 | return err; | 110 | return err; |
114 | } | 111 | } |
115 | CATCH_EINTR(waitpid(pid, NULL, 0)); | 112 | CATCH_EINTR(waitpid(pid, NULL, 0)); |
116 | 113 | ||
117 | cmsg = CMSG_FIRSTHDR(&msg); | 114 | cmsg = CMSG_FIRSTHDR(&msg); |
118 | if(cmsg == NULL){ | 115 | if (cmsg == NULL) { |
119 | printk("tuntap_open_tramp : didn't receive a message\n"); | 116 | printk(UM_KERN_ERR "tuntap_open_tramp : didn't receive a " |
117 | "message\n"); | ||
120 | return -EINVAL; | 118 | return -EINVAL; |
121 | } | 119 | } |
122 | if((cmsg->cmsg_level != SOL_SOCKET) || | 120 | if ((cmsg->cmsg_level != SOL_SOCKET) || |
123 | (cmsg->cmsg_type != SCM_RIGHTS)){ | 121 | (cmsg->cmsg_type != SCM_RIGHTS)) { |
124 | printk("tuntap_open_tramp : didn't receive a descriptor\n"); | 122 | printk(UM_KERN_ERR "tuntap_open_tramp : didn't receive a " |
123 | "descriptor\n"); | ||
125 | return -EINVAL; | 124 | return -EINVAL; |
126 | } | 125 | } |
127 | *fd_out = ((int *) CMSG_DATA(cmsg))[0]; | 126 | *fd_out = ((int *) CMSG_DATA(cmsg))[0]; |
@@ -137,38 +136,39 @@ static int tuntap_open(void *data) | |||
137 | int err, fds[2], len, used; | 136 | int err, fds[2], len, used; |
138 | 137 | ||
139 | err = tap_open_common(pri->dev, pri->gate_addr); | 138 | err = tap_open_common(pri->dev, pri->gate_addr); |
140 | if(err < 0) | 139 | if (err < 0) |
141 | return err; | 140 | return err; |
142 | 141 | ||
143 | if(pri->fixed_config){ | 142 | if (pri->fixed_config) { |
144 | pri->fd = os_open_file("/dev/net/tun", | 143 | pri->fd = os_open_file("/dev/net/tun", |
145 | of_cloexec(of_rdwr(OPENFLAGS())), 0); | 144 | of_cloexec(of_rdwr(OPENFLAGS())), 0); |
146 | if(pri->fd < 0){ | 145 | if (pri->fd < 0) { |
147 | printk("Failed to open /dev/net/tun, err = %d\n", | 146 | printk(UM_KERN_ERR "Failed to open /dev/net/tun, " |
148 | -pri->fd); | 147 | "err = %d\n", -pri->fd); |
149 | return pri->fd; | 148 | return pri->fd; |
150 | } | 149 | } |
151 | memset(&ifr, 0, sizeof(ifr)); | 150 | memset(&ifr, 0, sizeof(ifr)); |
152 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; | 151 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; |
153 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); | 152 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); |
154 | if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ | 153 | if (ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0) { |
155 | err = -errno; | 154 | err = -errno; |
156 | printk("TUNSETIFF failed, errno = %d\n", errno); | 155 | printk(UM_KERN_ERR "TUNSETIFF failed, errno = %d\n", |
156 | errno); | ||
157 | close(pri->fd); | 157 | close(pri->fd); |
158 | return err; | 158 | return err; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | else { | 161 | else { |
162 | err = socketpair(AF_UNIX, SOCK_DGRAM, 0, fds); | 162 | err = socketpair(AF_UNIX, SOCK_DGRAM, 0, fds); |
163 | if(err){ | 163 | if (err) { |
164 | err = -errno; | 164 | err = -errno; |
165 | printk("tuntap_open : socketpair failed - errno = %d\n", | 165 | printk(UM_KERN_ERR "tuntap_open : socketpair failed - " |
166 | errno); | 166 | "errno = %d\n", errno); |
167 | return err; | 167 | return err; |
168 | } | 168 | } |
169 | 169 | ||
170 | buffer = get_output_buffer(&len); | 170 | buffer = get_output_buffer(&len); |
171 | if(buffer != NULL) | 171 | if (buffer != NULL) |
172 | len--; | 172 | len--; |
173 | used = 0; | 173 | used = 0; |
174 | 174 | ||
@@ -176,10 +176,11 @@ static int tuntap_open(void *data) | |||
176 | fds[1], buffer, len, &used); | 176 | fds[1], buffer, len, &used); |
177 | 177 | ||
178 | output = buffer; | 178 | output = buffer; |
179 | if(err < 0) { | 179 | if (err < 0) { |
180 | printk("%s", output); | 180 | printk("%s", output); |
181 | free_output_buffer(buffer); | 181 | free_output_buffer(buffer); |
182 | printk("tuntap_open_tramp failed - err = %d\n", -err); | 182 | printk(UM_KERN_ERR "tuntap_open_tramp failed - " |
183 | "err = %d\n", -err); | ||
183 | return err; | 184 | return err; |
184 | } | 185 | } |
185 | 186 | ||
@@ -199,7 +200,7 @@ static void tuntap_close(int fd, void *data) | |||
199 | { | 200 | { |
200 | struct tuntap_data *pri = data; | 201 | struct tuntap_data *pri = data; |
201 | 202 | ||
202 | if(!pri->fixed_config) | 203 | if (!pri->fixed_config) |
203 | iter_addresses(pri->dev, close_addr, pri->dev_name); | 204 | iter_addresses(pri->dev, close_addr, pri->dev_name); |
204 | close(fd); | 205 | close(fd); |
205 | pri->fd = -1; | 206 | pri->fd = -1; |