diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2005-11-13 19:07:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-13 21:14:14 -0500 |
commit | c50d2c4d6685db9b45cf6521046296df5bc42592 (patch) | |
tree | f02d30dff1e3ca9793c69bf6ba2b0ee01c4e1a6b /arch | |
parent | 85977376c73b7712ed3618888ade126075888c06 (diff) |
[PATCH] uml: fix mcast network driver error handling
printk clears the host errno (I verified this in debugging and it's reasonable
enough, given that it ends via a write call on some fd, especially since
printk() goes on /dev/tty0 which is often the host stdout). So save errno
earlier. There's no reason to change the printk calls to use -err rather than
errno - the assignment can't clear errno.
And in the first failure path, we used to return 0 too (and this time more
clearly), which is totally wrong. 0 is a success fd, which is then registered
and gives a "registering fd twice" warning.
Finally, fix up some whitespace.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/drivers/mcast_user.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 5db136e2651c..afe85bfa66e0 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
@@ -54,7 +54,7 @@ static int mcast_open(void *data) | |||
54 | struct mcast_data *pri = data; | 54 | struct mcast_data *pri = data; |
55 | struct sockaddr_in *sin = pri->mcast_addr; | 55 | struct sockaddr_in *sin = pri->mcast_addr; |
56 | struct ip_mreq mreq; | 56 | struct ip_mreq mreq; |
57 | int fd, yes = 1, err = 0; | 57 | int fd, yes = 1, err = -EINVAL; |
58 | 58 | ||
59 | 59 | ||
60 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) | 60 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) |
@@ -63,40 +63,40 @@ static int mcast_open(void *data) | |||
63 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 63 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
64 | 64 | ||
65 | if (fd < 0){ | 65 | if (fd < 0){ |
66 | err = -errno; | ||
66 | printk("mcast_open : data socket failed, errno = %d\n", | 67 | printk("mcast_open : data socket failed, errno = %d\n", |
67 | errno); | 68 | errno); |
68 | err = -errno; | ||
69 | goto out; | 69 | goto out; |
70 | } | 70 | } |
71 | 71 | ||
72 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { | 72 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { |
73 | err = -errno; | ||
73 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", | 74 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", |
74 | errno); | 75 | errno); |
75 | err = -errno; | ||
76 | goto out_close; | 76 | goto out_close; |
77 | } | 77 | } |
78 | 78 | ||
79 | /* set ttl according to config */ | 79 | /* set ttl according to config */ |
80 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl, | 80 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl, |
81 | sizeof(pri->ttl)) < 0) { | 81 | sizeof(pri->ttl)) < 0) { |
82 | err = -errno; | ||
82 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", | 83 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", |
83 | errno); | 84 | errno); |
84 | err = -errno; | ||
85 | goto out_close; | 85 | goto out_close; |
86 | } | 86 | } |
87 | 87 | ||
88 | /* set LOOP, so data does get fed back to local sockets */ | 88 | /* set LOOP, so data does get fed back to local sockets */ |
89 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { | 89 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { |
90 | err = -errno; | ||
90 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", | 91 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", |
91 | errno); | 92 | errno); |
92 | err = -errno; | ||
93 | goto out_close; | 93 | goto out_close; |
94 | } | 94 | } |
95 | 95 | ||
96 | /* bind socket to mcast address */ | 96 | /* bind socket to mcast address */ |
97 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { | 97 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { |
98 | printk("mcast_open : data bind failed, errno = %d\n", errno); | ||
99 | err = -errno; | 98 | err = -errno; |
99 | printk("mcast_open : data bind failed, errno = %d\n", errno); | ||
100 | goto out_close; | 100 | goto out_close; |
101 | } | 101 | } |
102 | 102 | ||
@@ -105,22 +105,22 @@ static int mcast_open(void *data) | |||
105 | mreq.imr_interface.s_addr = 0; | 105 | mreq.imr_interface.s_addr = 0; |
106 | if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, | 106 | if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, |
107 | &mreq, sizeof(mreq)) < 0) { | 107 | &mreq, sizeof(mreq)) < 0) { |
108 | err = -errno; | ||
108 | printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n", | 109 | printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n", |
109 | errno); | 110 | errno); |
110 | printk("There appears not to be a multicast-capable network " | 111 | printk("There appears not to be a multicast-capable network " |
111 | "interface on the host.\n"); | 112 | "interface on the host.\n"); |
112 | printk("eth0 should be configured in order to use the " | 113 | printk("eth0 should be configured in order to use the " |
113 | "multicast transport.\n"); | 114 | "multicast transport.\n"); |
114 | err = -errno; | 115 | goto out_close; |
115 | goto out_close; | ||
116 | } | 116 | } |
117 | 117 | ||
118 | return fd; | 118 | return fd; |
119 | 119 | ||
120 | out_close: | 120 | out_close: |
121 | os_close_file(fd); | 121 | os_close_file(fd); |
122 | out: | 122 | out: |
123 | return err; | 123 | return err; |
124 | } | 124 | } |
125 | 125 | ||
126 | static void mcast_close(int fd, void *data) | 126 | static void mcast_close(int fd, void *data) |