aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-03-26 18:23:24 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-26 18:23:24 -0400
commit08abe18af1f78ee80c3c3a5ac47c3e0ae0beadf6 (patch)
tree2be39bf8942edca1bcec735145e144a682ca9cd3 /net
parentf0de70f8bb56952f6e016a65a8a8d006918f5bf6 (diff)
parent0384e2959127a56d0640505d004d8dd92f9c29f5 (diff)
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Conflicts: drivers/net/wimax/i2400m/usb-notif.c
Diffstat (limited to 'net')
-rw-r--r--net/Kconfig1
-rw-r--r--net/bluetooth/hci_sysfs.c2
-rw-r--r--net/bluetooth/rfcomm/tty.c5
-rw-r--r--net/netfilter/nf_conntrack_pptp.c2
-rw-r--r--net/netlink/Makefile2
-rw-r--r--net/netlink/attr.c473
-rw-r--r--net/sunrpc/sched.c33
-rw-r--r--net/sunrpc/xprt.c2
-rw-r--r--net/sunrpc/xprtsock.c23
9 files changed, 46 insertions, 497 deletions
diff --git a/net/Kconfig b/net/Kconfig
index 93998a9c39c..ec93e7e38b3 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -4,6 +4,7 @@
4 4
5menuconfig NET 5menuconfig NET
6 bool "Networking support" 6 bool "Networking support"
7 select NLATTR
7 ---help--- 8 ---help---
8 Unless you really know what you are doing, you should say Y here. 9 Unless you really know what you are doing, you should say Y here.
9 The reason is that some programs need kernel networking support even 10 The reason is that some programs need kernel networking support even
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 1a1f916be44..ed82796d4a0 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -140,7 +140,7 @@ static void del_conn(struct work_struct *work)
140 dev = device_find_child(&conn->dev, NULL, __match_tty); 140 dev = device_find_child(&conn->dev, NULL, __match_tty);
141 if (!dev) 141 if (!dev)
142 break; 142 break;
143 device_move(dev, NULL); 143 device_move(dev, NULL, DPM_ORDER_DEV_LAST);
144 put_device(dev); 144 put_device(dev);
145 } 145 }
146 146
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index d030c69cb5a..abdc703a11d 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -731,7 +731,8 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
731 remove_wait_queue(&dev->wait, &wait); 731 remove_wait_queue(&dev->wait, &wait);
732 732
733 if (err == 0) 733 if (err == 0)
734 device_move(dev->tty_dev, rfcomm_get_device(dev)); 734 device_move(dev->tty_dev, rfcomm_get_device(dev),
735 DPM_ORDER_DEV_AFTER_PARENT);
735 736
736 rfcomm_tty_copy_pending(dev); 737 rfcomm_tty_copy_pending(dev);
737 738
@@ -751,7 +752,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
751 752
752 if (atomic_dec_and_test(&dev->opened)) { 753 if (atomic_dec_and_test(&dev->opened)) {
753 if (dev->tty_dev->parent) 754 if (dev->tty_dev->parent)
754 device_move(dev->tty_dev, NULL); 755 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
755 756
756 /* Close DLC and dettach TTY */ 757 /* Close DLC and dettach TTY */
757 rfcomm_dlc_close(dev->dlc, 0); 758 rfcomm_dlc_close(dev->dlc, 0);
diff --git a/net/netfilter/nf_conntrack_pptp.c b/net/netfilter/nf_conntrack_pptp.c
index 72cca638a82..3807ac7faf4 100644
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -66,7 +66,7 @@ void
66 struct nf_conntrack_expect *exp) __read_mostly; 66 struct nf_conntrack_expect *exp) __read_mostly;
67EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn); 67EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
68 68
69#if defined(DEBUG) || defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 69#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
70/* PptpControlMessageType names */ 70/* PptpControlMessageType names */
71const char *const pptp_msg_name[] = { 71const char *const pptp_msg_name[] = {
72 "UNKNOWN_MESSAGE", 72 "UNKNOWN_MESSAGE",
diff --git a/net/netlink/Makefile b/net/netlink/Makefile
index e3589c2de49..bdd6ddf4e95 100644
--- a/net/netlink/Makefile
+++ b/net/netlink/Makefile
@@ -2,4 +2,4 @@
2# Makefile for the netlink driver. 2# Makefile for the netlink driver.
3# 3#
4 4
5obj-y := af_netlink.o attr.o genetlink.o 5obj-y := af_netlink.o genetlink.o
diff --git a/net/netlink/attr.c b/net/netlink/attr.c
deleted file mode 100644
index 56c3ce7fe29..00000000000
--- a/net/netlink/attr.c
+++ /dev/null
@@ -1,473 +0,0 @@
1/*
2 * NETLINK Netlink attributes
3 *
4 * Authors: Thomas Graf <tgraf@suug.ch>
5 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
6 */
7
8#include <linux/module.h>
9#include <linux/kernel.h>
10#include <linux/errno.h>
11#include <linux/jiffies.h>
12#include <linux/netdevice.h>
13#include <linux/skbuff.h>
14#include <linux/string.h>
15#include <linux/types.h>
16#include <net/netlink.h>
17
18static u16 nla_attr_minlen[NLA_TYPE_MAX+1] __read_mostly = {
19 [NLA_U8] = sizeof(u8),
20 [NLA_U16] = sizeof(u16),
21 [NLA_U32] = sizeof(u32),
22 [NLA_U64] = sizeof(u64),
23 [NLA_NESTED] = NLA_HDRLEN,
24};
25
26static int validate_nla(struct nlattr *nla, int maxtype,
27 const struct nla_policy *policy)
28{
29 const struct nla_policy *pt;
30 int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla);
31
32 if (type <= 0 || type > maxtype)
33 return 0;
34
35 pt = &policy[type];
36
37 BUG_ON(pt->type > NLA_TYPE_MAX);
38
39 switch (pt->type) {
40 case NLA_FLAG:
41 if (attrlen > 0)
42 return -ERANGE;
43 break;
44
45 case NLA_NUL_STRING:
46 if (pt->len)
47 minlen = min_t(int, attrlen, pt->len + 1);
48 else
49 minlen = attrlen;
50
51 if (!minlen || memchr(nla_data(nla), '\0', minlen) == NULL)
52 return -EINVAL;
53 /* fall through */
54
55 case NLA_STRING:
56 if (attrlen < 1)
57 return -ERANGE;
58
59 if (pt->len) {
60 char *buf = nla_data(nla);
61
62 if (buf[attrlen - 1] == '\0')
63 attrlen--;
64
65 if (attrlen > pt->len)
66 return -ERANGE;
67 }
68 break;
69
70 case NLA_BINARY:
71 if (pt->len && attrlen > pt->len)
72 return -ERANGE;
73 break;
74
75 case NLA_NESTED_COMPAT:
76 if (attrlen < pt->len)
77 return -ERANGE;
78 if (attrlen < NLA_ALIGN(pt->len))
79 break;
80 if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN)
81 return -ERANGE;
82 nla = nla_data(nla) + NLA_ALIGN(pt->len);
83 if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla))
84 return -ERANGE;
85 break;
86 case NLA_NESTED:
87 /* a nested attributes is allowed to be empty; if its not,
88 * it must have a size of at least NLA_HDRLEN.
89 */
90 if (attrlen == 0)
91 break;
92 default:
93 if (pt->len)
94 minlen = pt->len;
95 else if (pt->type != NLA_UNSPEC)
96 minlen = nla_attr_minlen[pt->type];
97
98 if (attrlen < minlen)
99 return -ERANGE;
100 }
101
102 return 0;
103}
104
105/**
106 * nla_validate - Validate a stream of attributes
107 * @head: head of attribute stream
108 * @len: length of attribute stream
109 * @maxtype: maximum attribute type to be expected
110 * @policy: validation policy
111 *
112 * Validates all attributes in the specified attribute stream against the
113 * specified policy. Attributes with a type exceeding maxtype will be
114 * ignored. See documenation of struct nla_policy for more details.
115 *
116 * Returns 0 on success or a negative error code.
117 */
118int nla_validate(struct nlattr *head, int len, int maxtype,
119 const struct nla_policy *policy)
120{
121 struct nlattr *nla;
122 int rem, err;
123
124 nla_for_each_attr(nla, head, len, rem) {
125 err = validate_nla(nla, maxtype, policy);
126 if (err < 0)
127 goto errout;
128 }
129
130 err = 0;
131errout:
132 return err;
133}
134
135/**
136 * nla_parse - Parse a stream of attributes into a tb buffer
137 * @tb: destination array with maxtype+1 elements
138 * @maxtype: maximum attribute type to be expected
139 * @head: head of attribute stream
140 * @len: length of attribute stream
141 * @policy: validation policy
142 *
143 * Parses a stream of attributes and stores a pointer to each attribute in
144 * the tb array accessable via the attribute type. Attributes with a type
145 * exceeding maxtype will be silently ignored for backwards compatibility
146 * reasons. policy may be set to NULL if no validation is required.
147 *
148 * Returns 0 on success or a negative error code.
149 */
150int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
151 const struct nla_policy *policy)
152{
153 struct nlattr *nla;
154 int rem, err;
155
156 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
157
158 nla_for_each_attr(nla, head, len, rem) {
159 u16 type = nla_type(nla);
160
161 if (type > 0 && type <= maxtype) {
162 if (policy) {
163 err = validate_nla(nla, maxtype, policy);
164 if (err < 0)
165 goto errout;
166 }
167
168 tb[type] = nla;
169 }
170 }
171
172 if (unlikely(rem > 0))
173 printk(KERN_WARNING "netlink: %d bytes leftover after parsing "
174 "attributes.\n", rem);
175
176 err = 0;
177errout:
178 return err;
179}
180
181/**
182 * nla_find - Find a specific attribute in a stream of attributes
183 * @head: head of attribute stream
184 * @len: length of attribute stream
185 * @attrtype: type of attribute to look for
186 *
187 * Returns the first attribute in the stream matching the specified type.
188 */
189struct nlattr *nla_find(struct nlattr *head, int len, int attrtype)
190{
191 struct nlattr *nla;
192 int rem;
193
194 nla_for_each_attr(nla, head, len, rem)
195 if (nla_type(nla) == attrtype)
196 return nla;
197
198 return NULL;
199}
200
201/**
202 * nla_strlcpy - Copy string attribute payload into a sized buffer
203 * @dst: where to copy the string to
204 * @nla: attribute to copy the string from
205 * @dstsize: size of destination buffer
206 *
207 * Copies at most dstsize - 1 bytes into the destination buffer.
208 * The result is always a valid NUL-terminated string. Unlike
209 * strlcpy the destination buffer is always padded out.
210 *
211 * Returns the length of the source buffer.
212 */
213size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
214{
215 size_t srclen = nla_len(nla);
216 char *src = nla_data(nla);
217
218 if (srclen > 0 && src[srclen - 1] == '\0')
219 srclen--;
220
221 if (dstsize > 0) {
222 size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
223
224 memset(dst, 0, dstsize);
225 memcpy(dst, src, len);
226 }
227
228 return srclen;
229}
230
231/**
232 * nla_memcpy - Copy a netlink attribute into another memory area
233 * @dest: where to copy to memcpy
234 * @src: netlink attribute to copy from
235 * @count: size of the destination area
236 *
237 * Note: The number of bytes copied is limited by the length of
238 * attribute's payload. memcpy
239 *
240 * Returns the number of bytes copied.
241 */
242int nla_memcpy(void *dest, const struct nlattr *src, int count)
243{
244 int minlen = min_t(int, count, nla_len(src));
245
246 memcpy(dest, nla_data(src), minlen);
247
248 return minlen;
249}
250
251/**
252 * nla_memcmp - Compare an attribute with sized memory area
253 * @nla: netlink attribute
254 * @data: memory area
255 * @size: size of memory area
256 */
257int nla_memcmp(const struct nlattr *nla, const void *data,
258 size_t size)
259{
260 int d = nla_len(nla) - size;
261
262 if (d == 0)
263 d = memcmp(nla_data(nla), data, size);
264
265 return d;
266}
267
268/**
269 * nla_strcmp - Compare a string attribute against a string
270 * @nla: netlink string attribute
271 * @str: another string
272 */
273int nla_strcmp(const struct nlattr *nla, const char *str)
274{
275 int len = strlen(str) + 1;
276 int d = nla_len(nla) - len;
277
278 if (d == 0)
279 d = memcmp(nla_data(nla), str, len);
280
281 return d;
282}
283
284/**
285 * __nla_reserve - reserve room for attribute on the skb
286 * @skb: socket buffer to reserve room on
287 * @attrtype: attribute type
288 * @attrlen: length of attribute payload
289 *
290 * Adds a netlink attribute header to a socket buffer and reserves
291 * room for the payload but does not copy it.
292 *
293 * The caller is responsible to ensure that the skb provides enough
294 * tailroom for the attribute header and payload.
295 */
296struct nlattr *__nla_reserve(struct sk_buff *skb, int attrtype, int attrlen)
297{
298 struct nlattr *nla;
299
300 nla = (struct nlattr *) skb_put(skb, nla_total_size(attrlen));
301 nla->nla_type = attrtype;
302 nla->nla_len = nla_attr_size(attrlen);
303
304 memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen));
305
306 return nla;
307}
308
309/**
310 * __nla_reserve_nohdr - reserve room for attribute without header
311 * @skb: socket buffer to reserve room on
312 * @attrlen: length of attribute payload
313 *
314 * Reserves room for attribute payload without a header.
315 *
316 * The caller is responsible to ensure that the skb provides enough
317 * tailroom for the payload.
318 */
319void *__nla_reserve_nohdr(struct sk_buff *skb, int attrlen)
320{
321 void *start;
322
323 start = skb_put(skb, NLA_ALIGN(attrlen));
324 memset(start, 0, NLA_ALIGN(attrlen));
325
326 return start;
327}
328
329/**
330 * nla_reserve - reserve room for attribute on the skb
331 * @skb: socket buffer to reserve room on
332 * @attrtype: attribute type
333 * @attrlen: length of attribute payload
334 *
335 * Adds a netlink attribute header to a socket buffer and reserves
336 * room for the payload but does not copy it.
337 *
338 * Returns NULL if the tailroom of the skb is insufficient to store
339 * the attribute header and payload.
340 */
341struct nlattr *nla_reserve(struct sk_buff *skb, int attrtype, int attrlen)
342{
343 if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))
344 return NULL;
345
346 return __nla_reserve(skb, attrtype, attrlen);
347}
348
349/**
350 * nla_reserve_nohdr - reserve room for attribute without header
351 * @skb: socket buffer to reserve room on
352 * @attrlen: length of attribute payload
353 *
354 * Reserves room for attribute payload without a header.
355 *
356 * Returns NULL if the tailroom of the skb is insufficient to store
357 * the attribute payload.
358 */
359void *nla_reserve_nohdr(struct sk_buff *skb, int attrlen)
360{
361 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
362 return NULL;
363
364 return __nla_reserve_nohdr(skb, attrlen);
365}
366
367/**
368 * __nla_put - Add a netlink attribute to a socket buffer
369 * @skb: socket buffer to add attribute to
370 * @attrtype: attribute type
371 * @attrlen: length of attribute payload
372 * @data: head of attribute payload
373 *
374 * The caller is responsible to ensure that the skb provides enough
375 * tailroom for the attribute header and payload.
376 */
377void __nla_put(struct sk_buff *skb, int attrtype, int attrlen,
378 const void *data)
379{
380 struct nlattr *nla;
381
382 nla = __nla_reserve(skb, attrtype, attrlen);
383 memcpy(nla_data(nla), data, attrlen);
384}
385
386/**
387 * __nla_put_nohdr - Add a netlink attribute without header
388 * @skb: socket buffer to add attribute to
389 * @attrlen: length of attribute payload
390 * @data: head of attribute payload
391 *
392 * The caller is responsible to ensure that the skb provides enough
393 * tailroom for the attribute payload.
394 */
395void __nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data)
396{
397 void *start;
398
399 start = __nla_reserve_nohdr(skb, attrlen);
400 memcpy(start, data, attrlen);
401}
402
403/**
404 * nla_put - Add a netlink attribute to a socket buffer
405 * @skb: socket buffer to add attribute to
406 * @attrtype: attribute type
407 * @attrlen: length of attribute payload
408 * @data: head of attribute payload
409 *
410 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
411 * the attribute header and payload.
412 */
413int nla_put(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
414{
415 if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))
416 return -EMSGSIZE;
417
418 __nla_put(skb, attrtype, attrlen, data);
419 return 0;
420}
421
422/**
423 * nla_put_nohdr - Add a netlink attribute without header
424 * @skb: socket buffer to add attribute to
425 * @attrlen: length of attribute payload
426 * @data: head of attribute payload
427 *
428 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
429 * the attribute payload.
430 */
431int nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data)
432{
433 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
434 return -EMSGSIZE;
435
436 __nla_put_nohdr(skb, attrlen, data);
437 return 0;
438}
439
440/**
441 * nla_append - Add a netlink attribute without header or padding
442 * @skb: socket buffer to add attribute to
443 * @attrlen: length of attribute payload
444 * @data: head of attribute payload
445 *
446 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
447 * the attribute payload.
448 */
449int nla_append(struct sk_buff *skb, int attrlen, const void *data)
450{
451 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
452 return -EMSGSIZE;
453
454 memcpy(skb_put(skb, attrlen), data, attrlen);
455 return 0;
456}
457
458EXPORT_SYMBOL(nla_validate);
459EXPORT_SYMBOL(nla_parse);
460EXPORT_SYMBOL(nla_find);
461EXPORT_SYMBOL(nla_strlcpy);
462EXPORT_SYMBOL(__nla_reserve);
463EXPORT_SYMBOL(__nla_reserve_nohdr);
464EXPORT_SYMBOL(nla_reserve);
465EXPORT_SYMBOL(nla_reserve_nohdr);
466EXPORT_SYMBOL(__nla_put);
467EXPORT_SYMBOL(__nla_put_nohdr);
468EXPORT_SYMBOL(nla_put);
469EXPORT_SYMBOL(nla_put_nohdr);
470EXPORT_SYMBOL(nla_memcpy);
471EXPORT_SYMBOL(nla_memcmp);
472EXPORT_SYMBOL(nla_strcmp);
473EXPORT_SYMBOL(nla_append);
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 385f427beda..ff50a054686 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -293,11 +293,6 @@ static void rpc_make_runnable(struct rpc_task *task)
293 rpc_clear_queued(task); 293 rpc_clear_queued(task);
294 if (rpc_test_and_set_running(task)) 294 if (rpc_test_and_set_running(task))
295 return; 295 return;
296 /* We might have raced */
297 if (RPC_IS_QUEUED(task)) {
298 rpc_clear_running(task);
299 return;
300 }
301 if (RPC_IS_ASYNC(task)) { 296 if (RPC_IS_ASYNC(task)) {
302 int status; 297 int status;
303 298
@@ -607,7 +602,9 @@ void rpc_release_calldata(const struct rpc_call_ops *ops, void *calldata)
607 */ 602 */
608static void __rpc_execute(struct rpc_task *task) 603static void __rpc_execute(struct rpc_task *task)
609{ 604{
610 int status = 0; 605 struct rpc_wait_queue *queue;
606 int task_is_async = RPC_IS_ASYNC(task);
607 int status = 0;
611 608
612 dprintk("RPC: %5u __rpc_execute flags=0x%x\n", 609 dprintk("RPC: %5u __rpc_execute flags=0x%x\n",
613 task->tk_pid, task->tk_flags); 610 task->tk_pid, task->tk_flags);
@@ -647,15 +644,25 @@ static void __rpc_execute(struct rpc_task *task)
647 */ 644 */
648 if (!RPC_IS_QUEUED(task)) 645 if (!RPC_IS_QUEUED(task))
649 continue; 646 continue;
650 rpc_clear_running(task); 647 /*
651 if (RPC_IS_ASYNC(task)) { 648 * The queue->lock protects against races with
652 /* Careful! we may have raced... */ 649 * rpc_make_runnable().
653 if (RPC_IS_QUEUED(task)) 650 *
654 return; 651 * Note that once we clear RPC_TASK_RUNNING on an asynchronous
655 if (rpc_test_and_set_running(task)) 652 * rpc_task, rpc_make_runnable() can assign it to a
656 return; 653 * different workqueue. We therefore cannot assume that the
654 * rpc_task pointer may still be dereferenced.
655 */
656 queue = task->tk_waitqueue;
657 spin_lock_bh(&queue->lock);
658 if (!RPC_IS_QUEUED(task)) {
659 spin_unlock_bh(&queue->lock);
657 continue; 660 continue;
658 } 661 }
662 rpc_clear_running(task);
663 spin_unlock_bh(&queue->lock);
664 if (task_is_async)
665 return;
659 666
660 /* sync task: sleep here */ 667 /* sync task: sleep here */
661 dprintk("RPC: %5u sync task going to sleep\n", task->tk_pid); 668 dprintk("RPC: %5u sync task going to sleep\n", task->tk_pid);
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 29e401bb612..62098d101a1 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -663,7 +663,7 @@ void xprt_connect(struct rpc_task *task)
663 xprt, (xprt_connected(xprt) ? "is" : "is not")); 663 xprt, (xprt_connected(xprt) ? "is" : "is not"));
664 664
665 if (!xprt_bound(xprt)) { 665 if (!xprt_bound(xprt)) {
666 task->tk_status = -EIO; 666 task->tk_status = -EAGAIN;
667 return; 667 return;
668 } 668 }
669 if (!xprt_lock_write(xprt, task)) 669 if (!xprt_lock_write(xprt, task))
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index b49e434c094..568330eebbf 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -467,7 +467,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
467 int err, sent = 0; 467 int err, sent = 0;
468 468
469 if (unlikely(!sock)) 469 if (unlikely(!sock))
470 return -ENOTCONN; 470 return -ENOTSOCK;
471 471
472 clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags); 472 clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
473 if (base != 0) { 473 if (base != 0) {
@@ -577,6 +577,8 @@ static int xs_udp_send_request(struct rpc_task *task)
577 req->rq_svec->iov_base, 577 req->rq_svec->iov_base,
578 req->rq_svec->iov_len); 578 req->rq_svec->iov_len);
579 579
580 if (!xprt_bound(xprt))
581 return -ENOTCONN;
580 status = xs_sendpages(transport->sock, 582 status = xs_sendpages(transport->sock,
581 xs_addr(xprt), 583 xs_addr(xprt),
582 xprt->addrlen, xdr, 584 xprt->addrlen, xdr,
@@ -594,6 +596,10 @@ static int xs_udp_send_request(struct rpc_task *task)
594 } 596 }
595 597
596 switch (status) { 598 switch (status) {
599 case -ENOTSOCK:
600 status = -ENOTCONN;
601 /* Should we call xs_close() here? */
602 break;
597 case -EAGAIN: 603 case -EAGAIN:
598 xs_nospace(task); 604 xs_nospace(task);
599 break; 605 break;
@@ -693,6 +699,10 @@ static int xs_tcp_send_request(struct rpc_task *task)
693 } 699 }
694 700
695 switch (status) { 701 switch (status) {
702 case -ENOTSOCK:
703 status = -ENOTCONN;
704 /* Should we call xs_close() here? */
705 break;
696 case -EAGAIN: 706 case -EAGAIN:
697 xs_nospace(task); 707 xs_nospace(task);
698 break; 708 break;
@@ -1512,7 +1522,7 @@ static void xs_udp_connect_worker4(struct work_struct *work)
1512 struct socket *sock = transport->sock; 1522 struct socket *sock = transport->sock;
1513 int err, status = -EIO; 1523 int err, status = -EIO;
1514 1524
1515 if (xprt->shutdown || !xprt_bound(xprt)) 1525 if (xprt->shutdown)
1516 goto out; 1526 goto out;
1517 1527
1518 /* Start by resetting any existing state */ 1528 /* Start by resetting any existing state */
@@ -1553,7 +1563,7 @@ static void xs_udp_connect_worker6(struct work_struct *work)
1553 struct socket *sock = transport->sock; 1563 struct socket *sock = transport->sock;
1554 int err, status = -EIO; 1564 int err, status = -EIO;
1555 1565
1556 if (xprt->shutdown || !xprt_bound(xprt)) 1566 if (xprt->shutdown)
1557 goto out; 1567 goto out;
1558 1568
1559 /* Start by resetting any existing state */ 1569 /* Start by resetting any existing state */
@@ -1637,6 +1647,9 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
1637 write_unlock_bh(&sk->sk_callback_lock); 1647 write_unlock_bh(&sk->sk_callback_lock);
1638 } 1648 }
1639 1649
1650 if (!xprt_bound(xprt))
1651 return -ENOTCONN;
1652
1640 /* Tell the socket layer to start connecting... */ 1653 /* Tell the socket layer to start connecting... */
1641 xprt->stat.connect_count++; 1654 xprt->stat.connect_count++;
1642 xprt->stat.connect_start = jiffies; 1655 xprt->stat.connect_start = jiffies;
@@ -1657,7 +1670,7 @@ static void xs_tcp_connect_worker4(struct work_struct *work)
1657 struct socket *sock = transport->sock; 1670 struct socket *sock = transport->sock;
1658 int err, status = -EIO; 1671 int err, status = -EIO;
1659 1672
1660 if (xprt->shutdown || !xprt_bound(xprt)) 1673 if (xprt->shutdown)
1661 goto out; 1674 goto out;
1662 1675
1663 if (!sock) { 1676 if (!sock) {
@@ -1717,7 +1730,7 @@ static void xs_tcp_connect_worker6(struct work_struct *work)
1717 struct socket *sock = transport->sock; 1730 struct socket *sock = transport->sock;
1718 int err, status = -EIO; 1731 int err, status = -EIO;
1719 1732
1720 if (xprt->shutdown || !xprt_bound(xprt)) 1733 if (xprt->shutdown)
1721 goto out; 1734 goto out;
1722 1735
1723 if (!sock) { 1736 if (!sock) {