diff options
Diffstat (limited to 'net')
102 files changed, 1375 insertions, 876 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 2ffe40cf2f01..10e320307ec0 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
| @@ -75,7 +75,6 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
| 75 | int option; | 75 | int option; |
| 76 | int ret = 0; | 76 | int ret = 0; |
| 77 | 77 | ||
| 78 | clnt->trans_mod = v9fs_default_trans(); | ||
| 79 | clnt->dotu = 1; | 78 | clnt->dotu = 1; |
| 80 | clnt->msize = 8192; | 79 | clnt->msize = 8192; |
| 81 | 80 | ||
| @@ -108,7 +107,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
| 108 | clnt->msize = option; | 107 | clnt->msize = option; |
| 109 | break; | 108 | break; |
| 110 | case Opt_trans: | 109 | case Opt_trans: |
| 111 | clnt->trans_mod = v9fs_match_trans(&args[0]); | 110 | clnt->trans_mod = v9fs_get_trans_by_name(&args[0]); |
| 112 | break; | 111 | break; |
| 113 | case Opt_legacy: | 112 | case Opt_legacy: |
| 114 | clnt->dotu = 0; | 113 | clnt->dotu = 0; |
| @@ -117,6 +116,10 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
| 117 | continue; | 116 | continue; |
| 118 | } | 117 | } |
| 119 | } | 118 | } |
| 119 | |||
| 120 | if (!clnt->trans_mod) | ||
| 121 | clnt->trans_mod = v9fs_get_default_trans(); | ||
| 122 | |||
| 120 | kfree(options); | 123 | kfree(options); |
| 121 | return ret; | 124 | return ret; |
| 122 | } | 125 | } |
| @@ -150,6 +153,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
| 150 | if (!clnt) | 153 | if (!clnt) |
| 151 | return ERR_PTR(-ENOMEM); | 154 | return ERR_PTR(-ENOMEM); |
| 152 | 155 | ||
| 156 | clnt->trans_mod = NULL; | ||
| 153 | clnt->trans = NULL; | 157 | clnt->trans = NULL; |
| 154 | spin_lock_init(&clnt->lock); | 158 | spin_lock_init(&clnt->lock); |
| 155 | INIT_LIST_HEAD(&clnt->fidlist); | 159 | INIT_LIST_HEAD(&clnt->fidlist); |
| @@ -235,6 +239,8 @@ void p9_client_destroy(struct p9_client *clnt) | |||
| 235 | clnt->trans = NULL; | 239 | clnt->trans = NULL; |
| 236 | } | 240 | } |
| 237 | 241 | ||
| 242 | v9fs_put_trans(clnt->trans_mod); | ||
| 243 | |||
| 238 | list_for_each_entry_safe(fid, fidptr, &clnt->fidlist, flist) | 244 | list_for_each_entry_safe(fid, fidptr, &clnt->fidlist, flist) |
| 239 | p9_fid_destroy(fid); | 245 | p9_fid_destroy(fid); |
| 240 | 246 | ||
diff --git a/net/9p/conv.c b/net/9p/conv.c index 44547201f5bc..5ad3a3bd73b2 100644 --- a/net/9p/conv.c +++ b/net/9p/conv.c | |||
| @@ -451,8 +451,10 @@ p9_put_data(struct cbuf *bufp, const char *data, int count, | |||
| 451 | unsigned char **pdata) | 451 | unsigned char **pdata) |
| 452 | { | 452 | { |
| 453 | *pdata = buf_alloc(bufp, count); | 453 | *pdata = buf_alloc(bufp, count); |
| 454 | if (*pdata == NULL) | ||
| 455 | return -ENOMEM; | ||
| 454 | memmove(*pdata, data, count); | 456 | memmove(*pdata, data, count); |
| 455 | return count; | 457 | return 0; |
| 456 | } | 458 | } |
| 457 | 459 | ||
| 458 | static int | 460 | static int |
| @@ -460,6 +462,8 @@ p9_put_user_data(struct cbuf *bufp, const char __user *data, int count, | |||
| 460 | unsigned char **pdata) | 462 | unsigned char **pdata) |
| 461 | { | 463 | { |
| 462 | *pdata = buf_alloc(bufp, count); | 464 | *pdata = buf_alloc(bufp, count); |
| 465 | if (*pdata == NULL) | ||
| 466 | return -ENOMEM; | ||
| 463 | return copy_from_user(*pdata, data, count); | 467 | return copy_from_user(*pdata, data, count); |
| 464 | } | 468 | } |
| 465 | 469 | ||
diff --git a/net/9p/mod.c b/net/9p/mod.c index bdee1fb7cc62..1084feb24cb0 100644 --- a/net/9p/mod.c +++ b/net/9p/mod.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <linux/parser.h> | 31 | #include <linux/parser.h> |
| 32 | #include <net/9p/transport.h> | 32 | #include <net/9p/transport.h> |
| 33 | #include <linux/list.h> | 33 | #include <linux/list.h> |
| 34 | #include <linux/spinlock.h> | ||
| 34 | 35 | ||
| 35 | #ifdef CONFIG_NET_9P_DEBUG | 36 | #ifdef CONFIG_NET_9P_DEBUG |
| 36 | unsigned int p9_debug_level = 0; /* feature-rific global debug level */ | 37 | unsigned int p9_debug_level = 0; /* feature-rific global debug level */ |
| @@ -44,8 +45,8 @@ MODULE_PARM_DESC(debug, "9P debugging level"); | |||
| 44 | * | 45 | * |
| 45 | */ | 46 | */ |
| 46 | 47 | ||
| 48 | static DEFINE_SPINLOCK(v9fs_trans_lock); | ||
| 47 | static LIST_HEAD(v9fs_trans_list); | 49 | static LIST_HEAD(v9fs_trans_list); |
| 48 | static struct p9_trans_module *v9fs_default_transport; | ||
| 49 | 50 | ||
| 50 | /** | 51 | /** |
| 51 | * v9fs_register_trans - register a new transport with 9p | 52 | * v9fs_register_trans - register a new transport with 9p |
| @@ -54,48 +55,87 @@ static struct p9_trans_module *v9fs_default_transport; | |||
| 54 | */ | 55 | */ |
| 55 | void v9fs_register_trans(struct p9_trans_module *m) | 56 | void v9fs_register_trans(struct p9_trans_module *m) |
| 56 | { | 57 | { |
| 58 | spin_lock(&v9fs_trans_lock); | ||
| 57 | list_add_tail(&m->list, &v9fs_trans_list); | 59 | list_add_tail(&m->list, &v9fs_trans_list); |
| 58 | if (m->def) | 60 | spin_unlock(&v9fs_trans_lock); |
| 59 | v9fs_default_transport = m; | ||
| 60 | } | 61 | } |
| 61 | EXPORT_SYMBOL(v9fs_register_trans); | 62 | EXPORT_SYMBOL(v9fs_register_trans); |
| 62 | 63 | ||
| 63 | /** | 64 | /** |
| 64 | * v9fs_match_trans - match transport versus registered transports | 65 | * v9fs_unregister_trans - unregister a 9p transport |
| 66 | * @m: the transport to remove | ||
| 67 | * | ||
| 68 | */ | ||
| 69 | void v9fs_unregister_trans(struct p9_trans_module *m) | ||
| 70 | { | ||
| 71 | spin_lock(&v9fs_trans_lock); | ||
| 72 | list_del_init(&m->list); | ||
| 73 | spin_unlock(&v9fs_trans_lock); | ||
| 74 | } | ||
| 75 | EXPORT_SYMBOL(v9fs_unregister_trans); | ||
| 76 | |||
| 77 | /** | ||
| 78 | * v9fs_get_trans_by_name - get transport with the matching name | ||
| 65 | * @name: string identifying transport | 79 | * @name: string identifying transport |
| 66 | * | 80 | * |
| 67 | */ | 81 | */ |
| 68 | struct p9_trans_module *v9fs_match_trans(const substring_t *name) | 82 | struct p9_trans_module *v9fs_get_trans_by_name(const substring_t *name) |
| 69 | { | 83 | { |
| 70 | struct list_head *p; | 84 | struct p9_trans_module *t, *found = NULL; |
| 71 | struct p9_trans_module *t = NULL; | 85 | |
| 72 | 86 | spin_lock(&v9fs_trans_lock); | |
| 73 | list_for_each(p, &v9fs_trans_list) { | 87 | |
| 74 | t = list_entry(p, struct p9_trans_module, list); | 88 | list_for_each_entry(t, &v9fs_trans_list, list) |
| 75 | if (strncmp(t->name, name->from, name->to-name->from) == 0) | 89 | if (strncmp(t->name, name->from, name->to-name->from) == 0 && |
| 76 | return t; | 90 | try_module_get(t->owner)) { |
| 77 | } | 91 | found = t; |
| 78 | return NULL; | 92 | break; |
| 93 | } | ||
| 94 | |||
| 95 | spin_unlock(&v9fs_trans_lock); | ||
| 96 | return found; | ||
| 79 | } | 97 | } |
| 80 | EXPORT_SYMBOL(v9fs_match_trans); | 98 | EXPORT_SYMBOL(v9fs_get_trans_by_name); |
| 81 | 99 | ||
| 82 | /** | 100 | /** |
| 83 | * v9fs_default_trans - returns pointer to default transport | 101 | * v9fs_get_default_trans - get the default transport |
| 84 | * | 102 | * |
| 85 | */ | 103 | */ |
| 86 | 104 | ||
| 87 | struct p9_trans_module *v9fs_default_trans(void) | 105 | struct p9_trans_module *v9fs_get_default_trans(void) |
| 88 | { | 106 | { |
| 89 | if (v9fs_default_transport) | 107 | struct p9_trans_module *t, *found = NULL; |
| 90 | return v9fs_default_transport; | 108 | |
| 91 | else if (!list_empty(&v9fs_trans_list)) | 109 | spin_lock(&v9fs_trans_lock); |
| 92 | return list_first_entry(&v9fs_trans_list, | 110 | |
| 93 | struct p9_trans_module, list); | 111 | list_for_each_entry(t, &v9fs_trans_list, list) |
| 94 | else | 112 | if (t->def && try_module_get(t->owner)) { |
| 95 | return NULL; | 113 | found = t; |
| 114 | break; | ||
| 115 | } | ||
| 116 | |||
| 117 | if (!found) | ||
| 118 | list_for_each_entry(t, &v9fs_trans_list, list) | ||
| 119 | if (try_module_get(t->owner)) { | ||
| 120 | found = t; | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | |||
| 124 | spin_unlock(&v9fs_trans_lock); | ||
| 125 | return found; | ||
| 96 | } | 126 | } |
| 97 | EXPORT_SYMBOL(v9fs_default_trans); | 127 | EXPORT_SYMBOL(v9fs_get_default_trans); |
| 98 | 128 | ||
| 129 | /** | ||
| 130 | * v9fs_put_trans - put trans | ||
| 131 | * @m: transport to put | ||
| 132 | * | ||
| 133 | */ | ||
| 134 | void v9fs_put_trans(struct p9_trans_module *m) | ||
| 135 | { | ||
| 136 | if (m) | ||
| 137 | module_put(m->owner); | ||
| 138 | } | ||
| 99 | 139 | ||
| 100 | /** | 140 | /** |
| 101 | * v9fs_init - Initialize module | 141 | * v9fs_init - Initialize module |
| @@ -120,6 +160,8 @@ static int __init init_p9(void) | |||
| 120 | static void __exit exit_p9(void) | 160 | static void __exit exit_p9(void) |
| 121 | { | 161 | { |
| 122 | printk(KERN_INFO "Unloading 9P2000 support\n"); | 162 | printk(KERN_INFO "Unloading 9P2000 support\n"); |
| 163 | |||
| 164 | p9_trans_fd_exit(); | ||
| 123 | } | 165 | } |
| 124 | 166 | ||
| 125 | module_init(init_p9) | 167 | module_init(init_p9) |
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index cdf137af7adc..d652baf5ff91 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
| @@ -151,7 +151,6 @@ struct p9_mux_poll_task { | |||
| 151 | * @trans: reference to transport instance for this connection | 151 | * @trans: reference to transport instance for this connection |
| 152 | * @tagpool: id accounting for transactions | 152 | * @tagpool: id accounting for transactions |
| 153 | * @err: error state | 153 | * @err: error state |
| 154 | * @equeue: event wait_q (?) | ||
| 155 | * @req_list: accounting for requests which have been sent | 154 | * @req_list: accounting for requests which have been sent |
| 156 | * @unsent_req_list: accounting for requests that haven't been sent | 155 | * @unsent_req_list: accounting for requests that haven't been sent |
| 157 | * @rcall: current response &p9_fcall structure | 156 | * @rcall: current response &p9_fcall structure |
| @@ -178,7 +177,6 @@ struct p9_conn { | |||
| 178 | struct p9_trans *trans; | 177 | struct p9_trans *trans; |
| 179 | struct p9_idpool *tagpool; | 178 | struct p9_idpool *tagpool; |
| 180 | int err; | 179 | int err; |
| 181 | wait_queue_head_t equeue; | ||
| 182 | struct list_head req_list; | 180 | struct list_head req_list; |
| 183 | struct list_head unsent_req_list; | 181 | struct list_head unsent_req_list; |
| 184 | struct p9_fcall *rcall; | 182 | struct p9_fcall *rcall; |
| @@ -240,22 +238,6 @@ static int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, | |||
| 240 | 238 | ||
| 241 | static void p9_conn_cancel(struct p9_conn *m, int err); | 239 | static void p9_conn_cancel(struct p9_conn *m, int err); |
| 242 | 240 | ||
| 243 | static int p9_mux_global_init(void) | ||
| 244 | { | ||
| 245 | int i; | ||
| 246 | |||
| 247 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) | ||
| 248 | p9_mux_poll_tasks[i].task = NULL; | ||
| 249 | |||
| 250 | p9_mux_wq = create_workqueue("v9fs"); | ||
| 251 | if (!p9_mux_wq) { | ||
| 252 | printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n"); | ||
| 253 | return -ENOMEM; | ||
| 254 | } | ||
| 255 | |||
| 256 | return 0; | ||
| 257 | } | ||
| 258 | |||
| 259 | static u16 p9_mux_get_tag(struct p9_conn *m) | 241 | static u16 p9_mux_get_tag(struct p9_conn *m) |
| 260 | { | 242 | { |
| 261 | int tag; | 243 | int tag; |
| @@ -409,11 +391,11 @@ static void p9_mux_poll_stop(struct p9_conn *m) | |||
| 409 | static struct p9_conn *p9_conn_create(struct p9_trans *trans) | 391 | static struct p9_conn *p9_conn_create(struct p9_trans *trans) |
| 410 | { | 392 | { |
| 411 | int i, n; | 393 | int i, n; |
| 412 | struct p9_conn *m, *mtmp; | 394 | struct p9_conn *m; |
| 413 | 395 | ||
| 414 | P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans, | 396 | P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans, |
| 415 | trans->msize); | 397 | trans->msize); |
| 416 | m = kmalloc(sizeof(struct p9_conn), GFP_KERNEL); | 398 | m = kzalloc(sizeof(struct p9_conn), GFP_KERNEL); |
| 417 | if (!m) | 399 | if (!m) |
| 418 | return ERR_PTR(-ENOMEM); | 400 | return ERR_PTR(-ENOMEM); |
| 419 | 401 | ||
| @@ -424,25 +406,14 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans) | |||
| 424 | m->trans = trans; | 406 | m->trans = trans; |
| 425 | m->tagpool = p9_idpool_create(); | 407 | m->tagpool = p9_idpool_create(); |
| 426 | if (IS_ERR(m->tagpool)) { | 408 | if (IS_ERR(m->tagpool)) { |
| 427 | mtmp = ERR_PTR(-ENOMEM); | ||
| 428 | kfree(m); | 409 | kfree(m); |
| 429 | return mtmp; | 410 | return ERR_PTR(-ENOMEM); |
| 430 | } | 411 | } |
| 431 | 412 | ||
| 432 | m->err = 0; | ||
| 433 | init_waitqueue_head(&m->equeue); | ||
| 434 | INIT_LIST_HEAD(&m->req_list); | 413 | INIT_LIST_HEAD(&m->req_list); |
| 435 | INIT_LIST_HEAD(&m->unsent_req_list); | 414 | INIT_LIST_HEAD(&m->unsent_req_list); |
| 436 | m->rcall = NULL; | ||
| 437 | m->rpos = 0; | ||
| 438 | m->rbuf = NULL; | ||
| 439 | m->wpos = m->wsize = 0; | ||
| 440 | m->wbuf = NULL; | ||
| 441 | INIT_WORK(&m->rq, p9_read_work); | 415 | INIT_WORK(&m->rq, p9_read_work); |
| 442 | INIT_WORK(&m->wq, p9_write_work); | 416 | INIT_WORK(&m->wq, p9_write_work); |
| 443 | m->wsched = 0; | ||
| 444 | memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); | ||
| 445 | m->poll_task = NULL; | ||
| 446 | n = p9_mux_poll_start(m); | 417 | n = p9_mux_poll_start(m); |
| 447 | if (n) { | 418 | if (n) { |
| 448 | kfree(m); | 419 | kfree(m); |
| @@ -463,10 +434,8 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans) | |||
| 463 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { | 434 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { |
| 464 | if (IS_ERR(m->poll_waddr[i])) { | 435 | if (IS_ERR(m->poll_waddr[i])) { |
| 465 | p9_mux_poll_stop(m); | 436 | p9_mux_poll_stop(m); |
| 466 | mtmp = (void *)m->poll_waddr; /* the error code */ | ||
| 467 | kfree(m); | 437 | kfree(m); |
| 468 | m = mtmp; | 438 | return (void *)m->poll_waddr; /* the error code */ |
| 469 | break; | ||
| 470 | } | 439 | } |
| 471 | } | 440 | } |
| 472 | 441 | ||
| @@ -483,18 +452,13 @@ static void p9_conn_destroy(struct p9_conn *m) | |||
| 483 | { | 452 | { |
| 484 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, | 453 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, |
| 485 | m->mux_list.prev, m->mux_list.next); | 454 | m->mux_list.prev, m->mux_list.next); |
| 486 | p9_conn_cancel(m, -ECONNRESET); | ||
| 487 | |||
| 488 | if (!list_empty(&m->req_list)) { | ||
| 489 | /* wait until all processes waiting on this session exit */ | ||
| 490 | P9_DPRINTK(P9_DEBUG_MUX, | ||
| 491 | "mux %p waiting for empty request queue\n", m); | ||
| 492 | wait_event_timeout(m->equeue, (list_empty(&m->req_list)), 5000); | ||
| 493 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p request queue empty: %d\n", m, | ||
| 494 | list_empty(&m->req_list)); | ||
| 495 | } | ||
| 496 | 455 | ||
| 497 | p9_mux_poll_stop(m); | 456 | p9_mux_poll_stop(m); |
| 457 | cancel_work_sync(&m->rq); | ||
| 458 | cancel_work_sync(&m->wq); | ||
| 459 | |||
| 460 | p9_conn_cancel(m, -ECONNRESET); | ||
| 461 | |||
| 498 | m->trans = NULL; | 462 | m->trans = NULL; |
| 499 | p9_idpool_destroy(m->tagpool); | 463 | p9_idpool_destroy(m->tagpool); |
| 500 | kfree(m); | 464 | kfree(m); |
| @@ -840,8 +804,6 @@ static void p9_read_work(struct work_struct *work) | |||
| 840 | (*req->cb) (req, req->cba); | 804 | (*req->cb) (req, req->cba); |
| 841 | else | 805 | else |
| 842 | kfree(req->rcall); | 806 | kfree(req->rcall); |
| 843 | |||
| 844 | wake_up(&m->equeue); | ||
| 845 | } | 807 | } |
| 846 | } else { | 808 | } else { |
| 847 | if (err >= 0 && rcall->id != P9_RFLUSH) | 809 | if (err >= 0 && rcall->id != P9_RFLUSH) |
| @@ -908,8 +870,10 @@ static struct p9_req *p9_send_request(struct p9_conn *m, | |||
| 908 | else | 870 | else |
| 909 | n = p9_mux_get_tag(m); | 871 | n = p9_mux_get_tag(m); |
| 910 | 872 | ||
| 911 | if (n < 0) | 873 | if (n < 0) { |
| 874 | kfree(req); | ||
| 912 | return ERR_PTR(-ENOMEM); | 875 | return ERR_PTR(-ENOMEM); |
| 876 | } | ||
| 913 | 877 | ||
| 914 | p9_set_tag(tc, n); | 878 | p9_set_tag(tc, n); |
| 915 | 879 | ||
| @@ -984,8 +948,6 @@ static void p9_mux_flush_cb(struct p9_req *freq, void *a) | |||
| 984 | (*req->cb) (req, req->cba); | 948 | (*req->cb) (req, req->cba); |
| 985 | else | 949 | else |
| 986 | kfree(req->rcall); | 950 | kfree(req->rcall); |
| 987 | |||
| 988 | wake_up(&m->equeue); | ||
| 989 | } | 951 | } |
| 990 | 952 | ||
| 991 | kfree(freq->tcall); | 953 | kfree(freq->tcall); |
| @@ -1191,8 +1153,6 @@ void p9_conn_cancel(struct p9_conn *m, int err) | |||
| 1191 | else | 1153 | else |
| 1192 | kfree(req->rcall); | 1154 | kfree(req->rcall); |
| 1193 | } | 1155 | } |
| 1194 | |||
| 1195 | wake_up(&m->equeue); | ||
| 1196 | } | 1156 | } |
| 1197 | 1157 | ||
| 1198 | /** | 1158 | /** |
| @@ -1370,7 +1330,6 @@ p9_fd_poll(struct p9_trans *trans, struct poll_table_struct *pt) | |||
| 1370 | { | 1330 | { |
| 1371 | int ret, n; | 1331 | int ret, n; |
| 1372 | struct p9_trans_fd *ts = NULL; | 1332 | struct p9_trans_fd *ts = NULL; |
| 1373 | mm_segment_t oldfs; | ||
| 1374 | 1333 | ||
| 1375 | if (trans && trans->status == Connected) | 1334 | if (trans && trans->status == Connected) |
| 1376 | ts = trans->priv; | 1335 | ts = trans->priv; |
| @@ -1384,24 +1343,17 @@ p9_fd_poll(struct p9_trans *trans, struct poll_table_struct *pt) | |||
| 1384 | if (!ts->wr->f_op || !ts->wr->f_op->poll) | 1343 | if (!ts->wr->f_op || !ts->wr->f_op->poll) |
| 1385 | return -EIO; | 1344 | return -EIO; |
| 1386 | 1345 | ||
| 1387 | oldfs = get_fs(); | ||
| 1388 | set_fs(get_ds()); | ||
| 1389 | |||
| 1390 | ret = ts->rd->f_op->poll(ts->rd, pt); | 1346 | ret = ts->rd->f_op->poll(ts->rd, pt); |
| 1391 | if (ret < 0) | 1347 | if (ret < 0) |
| 1392 | goto end; | 1348 | return ret; |
| 1393 | 1349 | ||
| 1394 | if (ts->rd != ts->wr) { | 1350 | if (ts->rd != ts->wr) { |
| 1395 | n = ts->wr->f_op->poll(ts->wr, pt); | 1351 | n = ts->wr->f_op->poll(ts->wr, pt); |
| 1396 | if (n < 0) { | 1352 | if (n < 0) |
| 1397 | ret = n; | 1353 | return n; |
| 1398 | goto end; | ||
| 1399 | } | ||
| 1400 | ret = (ret & ~POLLOUT) | (n & ~POLLIN); | 1354 | ret = (ret & ~POLLOUT) | (n & ~POLLIN); |
| 1401 | } | 1355 | } |
| 1402 | 1356 | ||
| 1403 | end: | ||
| 1404 | set_fs(oldfs); | ||
| 1405 | return ret; | 1357 | return ret; |
| 1406 | } | 1358 | } |
| 1407 | 1359 | ||
| @@ -1629,6 +1581,7 @@ static struct p9_trans_module p9_tcp_trans = { | |||
| 1629 | .maxsize = MAX_SOCK_BUF, | 1581 | .maxsize = MAX_SOCK_BUF, |
| 1630 | .def = 1, | 1582 | .def = 1, |
| 1631 | .create = p9_trans_create_tcp, | 1583 | .create = p9_trans_create_tcp, |
| 1584 | .owner = THIS_MODULE, | ||
| 1632 | }; | 1585 | }; |
| 1633 | 1586 | ||
| 1634 | static struct p9_trans_module p9_unix_trans = { | 1587 | static struct p9_trans_module p9_unix_trans = { |
| @@ -1636,6 +1589,7 @@ static struct p9_trans_module p9_unix_trans = { | |||
| 1636 | .maxsize = MAX_SOCK_BUF, | 1589 | .maxsize = MAX_SOCK_BUF, |
| 1637 | .def = 0, | 1590 | .def = 0, |
| 1638 | .create = p9_trans_create_unix, | 1591 | .create = p9_trans_create_unix, |
| 1592 | .owner = THIS_MODULE, | ||
| 1639 | }; | 1593 | }; |
| 1640 | 1594 | ||
| 1641 | static struct p9_trans_module p9_fd_trans = { | 1595 | static struct p9_trans_module p9_fd_trans = { |
| @@ -1643,14 +1597,20 @@ static struct p9_trans_module p9_fd_trans = { | |||
| 1643 | .maxsize = MAX_SOCK_BUF, | 1597 | .maxsize = MAX_SOCK_BUF, |
| 1644 | .def = 0, | 1598 | .def = 0, |
| 1645 | .create = p9_trans_create_fd, | 1599 | .create = p9_trans_create_fd, |
| 1600 | .owner = THIS_MODULE, | ||
| 1646 | }; | 1601 | }; |
| 1647 | 1602 | ||
| 1648 | int p9_trans_fd_init(void) | 1603 | int p9_trans_fd_init(void) |
| 1649 | { | 1604 | { |
| 1650 | int ret = p9_mux_global_init(); | 1605 | int i; |
| 1651 | if (ret) { | 1606 | |
| 1652 | printk(KERN_WARNING "9p: starting mux failed\n"); | 1607 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) |
| 1653 | return ret; | 1608 | p9_mux_poll_tasks[i].task = NULL; |
| 1609 | |||
| 1610 | p9_mux_wq = create_workqueue("v9fs"); | ||
| 1611 | if (!p9_mux_wq) { | ||
| 1612 | printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n"); | ||
| 1613 | return -ENOMEM; | ||
| 1654 | } | 1614 | } |
| 1655 | 1615 | ||
| 1656 | v9fs_register_trans(&p9_tcp_trans); | 1616 | v9fs_register_trans(&p9_tcp_trans); |
| @@ -1659,4 +1619,12 @@ int p9_trans_fd_init(void) | |||
| 1659 | 1619 | ||
| 1660 | return 0; | 1620 | return 0; |
| 1661 | } | 1621 | } |
| 1662 | EXPORT_SYMBOL(p9_trans_fd_init); | 1622 | |
| 1623 | void p9_trans_fd_exit(void) | ||
| 1624 | { | ||
| 1625 | v9fs_unregister_trans(&p9_tcp_trans); | ||
| 1626 | v9fs_unregister_trans(&p9_unix_trans); | ||
| 1627 | v9fs_unregister_trans(&p9_fd_trans); | ||
| 1628 | |||
| 1629 | destroy_workqueue(p9_mux_wq); | ||
| 1630 | } | ||
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 42adc052b149..94912e077a55 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
| @@ -528,6 +528,7 @@ static struct p9_trans_module p9_virtio_trans = { | |||
| 528 | .create = p9_virtio_create, | 528 | .create = p9_virtio_create, |
| 529 | .maxsize = PAGE_SIZE*16, | 529 | .maxsize = PAGE_SIZE*16, |
| 530 | .def = 0, | 530 | .def = 0, |
| 531 | .owner = THIS_MODULE, | ||
| 531 | }; | 532 | }; |
| 532 | 533 | ||
| 533 | /* The standard init function */ | 534 | /* The standard init function */ |
| @@ -545,6 +546,7 @@ static int __init p9_virtio_init(void) | |||
| 545 | static void __exit p9_virtio_cleanup(void) | 546 | static void __exit p9_virtio_cleanup(void) |
| 546 | { | 547 | { |
| 547 | unregister_virtio_driver(&p9_virtio_drv); | 548 | unregister_virtio_driver(&p9_virtio_drv); |
| 549 | v9fs_unregister_trans(&p9_virtio_trans); | ||
| 548 | } | 550 | } |
| 549 | 551 | ||
| 550 | module_init(p9_virtio_init); | 552 | module_init(p9_virtio_init); |
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 4e59df5f8e05..f6348e078aa4 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | #define BT_DBG(D...) | 49 | #define BT_DBG(D...) |
| 50 | #endif | 50 | #endif |
| 51 | 51 | ||
| 52 | #define VERSION "2.12" | 52 | #define VERSION "2.13" |
| 53 | 53 | ||
| 54 | /* Bluetooth sockets */ | 54 | /* Bluetooth sockets */ |
| 55 | #define BT_MAX_PROTO 8 | 55 | #define BT_MAX_PROTO 8 |
| @@ -456,7 +456,7 @@ static void __exit bt_exit(void) | |||
| 456 | subsys_initcall(bt_init); | 456 | subsys_initcall(bt_init); |
| 457 | module_exit(bt_exit); | 457 | module_exit(bt_exit); |
| 458 | 458 | ||
| 459 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 459 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
| 460 | MODULE_DESCRIPTION("Bluetooth Core ver " VERSION); | 460 | MODULE_DESCRIPTION("Bluetooth Core ver " VERSION); |
| 461 | MODULE_VERSION(VERSION); | 461 | MODULE_VERSION(VERSION); |
| 462 | MODULE_LICENSE("GPL"); | 462 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 12bba6207a8d..80ba30cf4b68 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
| @@ -736,7 +736,7 @@ MODULE_PARM_DESC(compress_src, "Compress sources headers"); | |||
| 736 | module_param(compress_dst, bool, 0644); | 736 | module_param(compress_dst, bool, 0644); |
| 737 | MODULE_PARM_DESC(compress_dst, "Compress destination headers"); | 737 | MODULE_PARM_DESC(compress_dst, "Compress destination headers"); |
| 738 | 738 | ||
| 739 | MODULE_AUTHOR("David Libault <david.libault@inventel.fr>, Maxim Krasnyansky <maxk@qualcomm.com>"); | 739 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
| 740 | MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION); | 740 | MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION); |
| 741 | MODULE_VERSION(VERSION); | 741 | MODULE_VERSION(VERSION); |
| 742 | MODULE_LICENSE("GPL"); | 742 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index ca8d05245ca0..b7002429f152 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
| @@ -330,7 +330,7 @@ EXPORT_SYMBOL(hci_get_route); | |||
| 330 | 330 | ||
| 331 | /* Create SCO or ACL connection. | 331 | /* Create SCO or ACL connection. |
| 332 | * Device _must_ be locked */ | 332 | * Device _must_ be locked */ |
| 333 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst) | 333 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 auth_type) |
| 334 | { | 334 | { |
| 335 | struct hci_conn *acl; | 335 | struct hci_conn *acl; |
| 336 | struct hci_conn *sco; | 336 | struct hci_conn *sco; |
| @@ -344,8 +344,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst) | |||
| 344 | 344 | ||
| 345 | hci_conn_hold(acl); | 345 | hci_conn_hold(acl); |
| 346 | 346 | ||
| 347 | if (acl->state == BT_OPEN || acl->state == BT_CLOSED) | 347 | if (acl->state == BT_OPEN || acl->state == BT_CLOSED) { |
| 348 | acl->auth_type = auth_type; | ||
| 348 | hci_acl_connect(acl); | 349 | hci_acl_connect(acl); |
| 350 | } | ||
| 349 | 351 | ||
| 350 | if (type == ACL_LINK) | 352 | if (type == ACL_LINK) |
| 351 | return acl; | 353 | return acl; |
| @@ -374,6 +376,19 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst) | |||
| 374 | } | 376 | } |
| 375 | EXPORT_SYMBOL(hci_connect); | 377 | EXPORT_SYMBOL(hci_connect); |
| 376 | 378 | ||
| 379 | /* Check link security requirement */ | ||
| 380 | int hci_conn_check_link_mode(struct hci_conn *conn) | ||
| 381 | { | ||
| 382 | BT_DBG("conn %p", conn); | ||
| 383 | |||
| 384 | if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0 && | ||
| 385 | !(conn->link_mode & HCI_LM_ENCRYPT)) | ||
| 386 | return 0; | ||
| 387 | |||
| 388 | return 1; | ||
| 389 | } | ||
| 390 | EXPORT_SYMBOL(hci_conn_check_link_mode); | ||
| 391 | |||
| 377 | /* Authenticate remote device */ | 392 | /* Authenticate remote device */ |
| 378 | int hci_conn_auth(struct hci_conn *conn) | 393 | int hci_conn_auth(struct hci_conn *conn) |
| 379 | { | 394 | { |
| @@ -381,7 +396,7 @@ int hci_conn_auth(struct hci_conn *conn) | |||
| 381 | 396 | ||
| 382 | if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0) { | 397 | if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0) { |
| 383 | if (!(conn->auth_type & 0x01)) { | 398 | if (!(conn->auth_type & 0x01)) { |
| 384 | conn->auth_type = HCI_AT_GENERAL_BONDING_MITM; | 399 | conn->auth_type |= 0x01; |
| 385 | conn->link_mode &= ~HCI_LM_AUTH; | 400 | conn->link_mode &= ~HCI_LM_AUTH; |
| 386 | } | 401 | } |
| 387 | } | 402 | } |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f5b21cb93699..278a3ace14f6 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
| @@ -164,6 +164,9 @@ static inline int hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev * | |||
| 164 | { | 164 | { |
| 165 | int ret; | 165 | int ret; |
| 166 | 166 | ||
| 167 | if (!test_bit(HCI_UP, &hdev->flags)) | ||
| 168 | return -ENETDOWN; | ||
| 169 | |||
| 167 | /* Serialize all requests */ | 170 | /* Serialize all requests */ |
| 168 | hci_req_lock(hdev); | 171 | hci_req_lock(hdev); |
| 169 | ret = __hci_request(hdev, req, opt, timeout); | 172 | ret = __hci_request(hdev, req, opt, timeout); |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0e3db289f4be..ad7a553d7713 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
| @@ -1605,14 +1605,11 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b | |||
| 1605 | 1605 | ||
| 1606 | if (conn->state == BT_CONFIG) { | 1606 | if (conn->state == BT_CONFIG) { |
| 1607 | if (!ev->status && hdev->ssp_mode > 0 && | 1607 | if (!ev->status && hdev->ssp_mode > 0 && |
| 1608 | conn->ssp_mode > 0) { | 1608 | conn->ssp_mode > 0 && conn->out) { |
| 1609 | if (conn->out) { | 1609 | struct hci_cp_auth_requested cp; |
| 1610 | struct hci_cp_auth_requested cp; | 1610 | cp.handle = ev->handle; |
| 1611 | cp.handle = ev->handle; | 1611 | hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, |
| 1612 | hci_send_cmd(hdev, | ||
| 1613 | HCI_OP_AUTH_REQUESTED, | ||
| 1614 | sizeof(cp), &cp); | 1612 | sizeof(cp), &cp); |
| 1615 | } | ||
| 1616 | } else { | 1613 | } else { |
| 1617 | conn->state = BT_CONNECTED; | 1614 | conn->state = BT_CONNECTED; |
| 1618 | hci_proto_connect_cfm(conn, ev->status); | 1615 | hci_proto_connect_cfm(conn, ev->status); |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index c85bf8f678dc..f4f6615cad9f 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
| 4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
| 5 | 5 | ||
| 6 | #include <linux/platform_device.h> | ||
| 7 | |||
| 8 | #include <net/bluetooth/bluetooth.h> | 6 | #include <net/bluetooth/bluetooth.h> |
| 9 | #include <net/bluetooth/hci_core.h> | 7 | #include <net/bluetooth/hci_core.h> |
| 10 | 8 | ||
| @@ -12,10 +10,164 @@ | |||
| 12 | #undef BT_DBG | 10 | #undef BT_DBG |
| 13 | #define BT_DBG(D...) | 11 | #define BT_DBG(D...) |
| 14 | #endif | 12 | #endif |
| 13 | |||
| 14 | struct class *bt_class = NULL; | ||
| 15 | EXPORT_SYMBOL_GPL(bt_class); | ||
| 16 | |||
| 15 | static struct workqueue_struct *btaddconn; | 17 | static struct workqueue_struct *btaddconn; |
| 16 | static struct workqueue_struct *btdelconn; | 18 | static struct workqueue_struct *btdelconn; |
| 17 | 19 | ||
| 18 | static inline char *typetostr(int type) | 20 | static inline char *link_typetostr(int type) |
| 21 | { | ||
| 22 | switch (type) { | ||
| 23 | case ACL_LINK: | ||
| 24 | return "ACL"; | ||
| 25 | case SCO_LINK: | ||
| 26 | return "SCO"; | ||
| 27 | case ESCO_LINK: | ||
| 28 | return "eSCO"; | ||
| 29 | default: | ||
| 30 | return "UNKNOWN"; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | static ssize_t show_link_type(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 35 | { | ||
| 36 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
| 37 | return sprintf(buf, "%s\n", link_typetostr(conn->type)); | ||
| 38 | } | ||
| 39 | |||
| 40 | static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 41 | { | ||
| 42 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
| 43 | bdaddr_t bdaddr; | ||
| 44 | baswap(&bdaddr, &conn->dst); | ||
| 45 | return sprintf(buf, "%s\n", batostr(&bdaddr)); | ||
| 46 | } | ||
| 47 | |||
| 48 | static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 49 | { | ||
| 50 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
| 51 | |||
| 52 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | ||
| 53 | conn->features[0], conn->features[1], | ||
| 54 | conn->features[2], conn->features[3], | ||
| 55 | conn->features[4], conn->features[5], | ||
| 56 | conn->features[6], conn->features[7]); | ||
| 57 | } | ||
| 58 | |||
| 59 | #define LINK_ATTR(_name,_mode,_show,_store) \ | ||
| 60 | struct device_attribute link_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
| 61 | |||
| 62 | static LINK_ATTR(type, S_IRUGO, show_link_type, NULL); | ||
| 63 | static LINK_ATTR(address, S_IRUGO, show_link_address, NULL); | ||
| 64 | static LINK_ATTR(features, S_IRUGO, show_link_features, NULL); | ||
| 65 | |||
| 66 | static struct attribute *bt_link_attrs[] = { | ||
| 67 | &link_attr_type.attr, | ||
| 68 | &link_attr_address.attr, | ||
| 69 | &link_attr_features.attr, | ||
| 70 | NULL | ||
| 71 | }; | ||
| 72 | |||
| 73 | static struct attribute_group bt_link_group = { | ||
| 74 | .attrs = bt_link_attrs, | ||
| 75 | }; | ||
| 76 | |||
| 77 | static struct attribute_group *bt_link_groups[] = { | ||
| 78 | &bt_link_group, | ||
| 79 | NULL | ||
| 80 | }; | ||
| 81 | |||
| 82 | static void bt_link_release(struct device *dev) | ||
| 83 | { | ||
| 84 | void *data = dev_get_drvdata(dev); | ||
| 85 | kfree(data); | ||
| 86 | } | ||
| 87 | |||
| 88 | static struct device_type bt_link = { | ||
| 89 | .name = "link", | ||
| 90 | .groups = bt_link_groups, | ||
| 91 | .release = bt_link_release, | ||
| 92 | }; | ||
| 93 | |||
| 94 | static void add_conn(struct work_struct *work) | ||
| 95 | { | ||
| 96 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
| 97 | |||
| 98 | flush_workqueue(btdelconn); | ||
| 99 | |||
| 100 | if (device_add(&conn->dev) < 0) { | ||
| 101 | BT_ERR("Failed to register connection device"); | ||
| 102 | return; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | void hci_conn_add_sysfs(struct hci_conn *conn) | ||
| 107 | { | ||
| 108 | struct hci_dev *hdev = conn->hdev; | ||
| 109 | |||
| 110 | BT_DBG("conn %p", conn); | ||
| 111 | |||
| 112 | conn->dev.type = &bt_link; | ||
| 113 | conn->dev.class = bt_class; | ||
| 114 | conn->dev.parent = &hdev->dev; | ||
| 115 | |||
| 116 | snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", | ||
| 117 | hdev->name, conn->handle); | ||
| 118 | |||
| 119 | dev_set_drvdata(&conn->dev, conn); | ||
| 120 | |||
| 121 | device_initialize(&conn->dev); | ||
| 122 | |||
| 123 | INIT_WORK(&conn->work, add_conn); | ||
| 124 | |||
| 125 | queue_work(btaddconn, &conn->work); | ||
| 126 | } | ||
| 127 | |||
| 128 | /* | ||
| 129 | * The rfcomm tty device will possibly retain even when conn | ||
| 130 | * is down, and sysfs doesn't support move zombie device, | ||
| 131 | * so we should move the device before conn device is destroyed. | ||
| 132 | */ | ||
| 133 | static int __match_tty(struct device *dev, void *data) | ||
| 134 | { | ||
| 135 | return !strncmp(dev->bus_id, "rfcomm", 6); | ||
| 136 | } | ||
| 137 | |||
| 138 | static void del_conn(struct work_struct *work) | ||
| 139 | { | ||
| 140 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
| 141 | struct hci_dev *hdev = conn->hdev; | ||
| 142 | |||
| 143 | while (1) { | ||
| 144 | struct device *dev; | ||
| 145 | |||
| 146 | dev = device_find_child(&conn->dev, NULL, __match_tty); | ||
| 147 | if (!dev) | ||
| 148 | break; | ||
| 149 | device_move(dev, NULL); | ||
| 150 | put_device(dev); | ||
| 151 | } | ||
| 152 | |||
| 153 | device_del(&conn->dev); | ||
| 154 | put_device(&conn->dev); | ||
| 155 | hci_dev_put(hdev); | ||
| 156 | } | ||
| 157 | |||
| 158 | void hci_conn_del_sysfs(struct hci_conn *conn) | ||
| 159 | { | ||
| 160 | BT_DBG("conn %p", conn); | ||
| 161 | |||
| 162 | if (!device_is_registered(&conn->dev)) | ||
| 163 | return; | ||
| 164 | |||
| 165 | INIT_WORK(&conn->work, del_conn); | ||
| 166 | |||
| 167 | queue_work(btdelconn, &conn->work); | ||
| 168 | } | ||
| 169 | |||
| 170 | static inline char *host_typetostr(int type) | ||
| 19 | { | 171 | { |
| 20 | switch (type) { | 172 | switch (type) { |
| 21 | case HCI_VIRTUAL: | 173 | case HCI_VIRTUAL: |
| @@ -40,7 +192,7 @@ static inline char *typetostr(int type) | |||
| 40 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) | 192 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) |
| 41 | { | 193 | { |
| 42 | struct hci_dev *hdev = dev_get_drvdata(dev); | 194 | struct hci_dev *hdev = dev_get_drvdata(dev); |
| 43 | return sprintf(buf, "%s\n", typetostr(hdev->type)); | 195 | return sprintf(buf, "%s\n", host_typetostr(hdev->type)); |
| 44 | } | 196 | } |
| 45 | 197 | ||
| 46 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 198 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) |
| @@ -221,183 +373,62 @@ static DEVICE_ATTR(sniff_max_interval, S_IRUGO | S_IWUSR, | |||
| 221 | static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR, | 373 | static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR, |
| 222 | show_sniff_min_interval, store_sniff_min_interval); | 374 | show_sniff_min_interval, store_sniff_min_interval); |
| 223 | 375 | ||
| 224 | static struct device_attribute *bt_attrs[] = { | 376 | static struct attribute *bt_host_attrs[] = { |
| 225 | &dev_attr_type, | 377 | &dev_attr_type.attr, |
| 226 | &dev_attr_name, | 378 | &dev_attr_name.attr, |
| 227 | &dev_attr_class, | 379 | &dev_attr_class.attr, |
| 228 | &dev_attr_address, | 380 | &dev_attr_address.attr, |
| 229 | &dev_attr_features, | 381 | &dev_attr_features.attr, |
| 230 | &dev_attr_manufacturer, | 382 | &dev_attr_manufacturer.attr, |
| 231 | &dev_attr_hci_version, | 383 | &dev_attr_hci_version.attr, |
| 232 | &dev_attr_hci_revision, | 384 | &dev_attr_hci_revision.attr, |
| 233 | &dev_attr_inquiry_cache, | 385 | &dev_attr_inquiry_cache.attr, |
| 234 | &dev_attr_idle_timeout, | 386 | &dev_attr_idle_timeout.attr, |
| 235 | &dev_attr_sniff_max_interval, | 387 | &dev_attr_sniff_max_interval.attr, |
| 236 | &dev_attr_sniff_min_interval, | 388 | &dev_attr_sniff_min_interval.attr, |
| 237 | NULL | 389 | NULL |
| 238 | }; | 390 | }; |
| 239 | 391 | ||
| 240 | static ssize_t show_conn_type(struct device *dev, struct device_attribute *attr, char *buf) | 392 | static struct attribute_group bt_host_group = { |
| 241 | { | 393 | .attrs = bt_host_attrs, |
| 242 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
| 243 | return sprintf(buf, "%s\n", conn->type == ACL_LINK ? "ACL" : "SCO"); | ||
| 244 | } | ||
| 245 | |||
| 246 | static ssize_t show_conn_address(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 247 | { | ||
| 248 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
| 249 | bdaddr_t bdaddr; | ||
| 250 | baswap(&bdaddr, &conn->dst); | ||
| 251 | return sprintf(buf, "%s\n", batostr(&bdaddr)); | ||
| 252 | } | ||
| 253 | |||
| 254 | static ssize_t show_conn_features(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 255 | { | ||
| 256 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
| 257 | |||
| 258 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | ||
| 259 | conn->features[0], conn->features[1], | ||
| 260 | conn->features[2], conn->features[3], | ||
| 261 | conn->features[4], conn->features[5], | ||
| 262 | conn->features[6], conn->features[7]); | ||
| 263 | } | ||
| 264 | |||
| 265 | #define CONN_ATTR(_name,_mode,_show,_store) \ | ||
| 266 | struct device_attribute conn_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
| 267 | |||
| 268 | static CONN_ATTR(type, S_IRUGO, show_conn_type, NULL); | ||
| 269 | static CONN_ATTR(address, S_IRUGO, show_conn_address, NULL); | ||
| 270 | static CONN_ATTR(features, S_IRUGO, show_conn_features, NULL); | ||
| 271 | |||
| 272 | static struct device_attribute *conn_attrs[] = { | ||
| 273 | &conn_attr_type, | ||
| 274 | &conn_attr_address, | ||
| 275 | &conn_attr_features, | ||
| 276 | NULL | ||
| 277 | }; | 394 | }; |
| 278 | 395 | ||
| 279 | struct class *bt_class = NULL; | 396 | static struct attribute_group *bt_host_groups[] = { |
| 280 | EXPORT_SYMBOL_GPL(bt_class); | 397 | &bt_host_group, |
| 281 | 398 | NULL | |
| 282 | static struct bus_type bt_bus = { | ||
| 283 | .name = "bluetooth", | ||
| 284 | }; | 399 | }; |
| 285 | 400 | ||
| 286 | static struct platform_device *bt_platform; | 401 | static void bt_host_release(struct device *dev) |
| 287 | |||
| 288 | static void bt_release(struct device *dev) | ||
| 289 | { | 402 | { |
| 290 | void *data = dev_get_drvdata(dev); | 403 | void *data = dev_get_drvdata(dev); |
| 291 | kfree(data); | 404 | kfree(data); |
| 292 | } | 405 | } |
| 293 | 406 | ||
| 294 | static void add_conn(struct work_struct *work) | 407 | static struct device_type bt_host = { |
| 295 | { | 408 | .name = "host", |
| 296 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | 409 | .groups = bt_host_groups, |
| 297 | int i; | 410 | .release = bt_host_release, |
| 298 | 411 | }; | |
| 299 | flush_workqueue(btdelconn); | ||
| 300 | |||
| 301 | if (device_add(&conn->dev) < 0) { | ||
| 302 | BT_ERR("Failed to register connection device"); | ||
| 303 | return; | ||
| 304 | } | ||
| 305 | |||
| 306 | for (i = 0; conn_attrs[i]; i++) | ||
| 307 | if (device_create_file(&conn->dev, conn_attrs[i]) < 0) | ||
| 308 | BT_ERR("Failed to create connection attribute"); | ||
| 309 | } | ||
| 310 | |||
| 311 | void hci_conn_add_sysfs(struct hci_conn *conn) | ||
| 312 | { | ||
| 313 | struct hci_dev *hdev = conn->hdev; | ||
| 314 | |||
| 315 | BT_DBG("conn %p", conn); | ||
| 316 | |||
| 317 | conn->dev.bus = &bt_bus; | ||
| 318 | conn->dev.parent = &hdev->dev; | ||
| 319 | |||
| 320 | conn->dev.release = bt_release; | ||
| 321 | |||
| 322 | snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", | ||
| 323 | hdev->name, conn->handle); | ||
| 324 | |||
| 325 | dev_set_drvdata(&conn->dev, conn); | ||
| 326 | |||
| 327 | device_initialize(&conn->dev); | ||
| 328 | |||
| 329 | INIT_WORK(&conn->work, add_conn); | ||
| 330 | |||
| 331 | queue_work(btaddconn, &conn->work); | ||
| 332 | } | ||
| 333 | |||
| 334 | /* | ||
| 335 | * The rfcomm tty device will possibly retain even when conn | ||
| 336 | * is down, and sysfs doesn't support move zombie device, | ||
| 337 | * so we should move the device before conn device is destroyed. | ||
| 338 | */ | ||
| 339 | static int __match_tty(struct device *dev, void *data) | ||
| 340 | { | ||
| 341 | return !strncmp(dev->bus_id, "rfcomm", 6); | ||
| 342 | } | ||
| 343 | |||
| 344 | static void del_conn(struct work_struct *work) | ||
| 345 | { | ||
| 346 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
| 347 | struct hci_dev *hdev = conn->hdev; | ||
| 348 | |||
| 349 | while (1) { | ||
| 350 | struct device *dev; | ||
| 351 | |||
| 352 | dev = device_find_child(&conn->dev, NULL, __match_tty); | ||
| 353 | if (!dev) | ||
| 354 | break; | ||
| 355 | device_move(dev, NULL); | ||
| 356 | put_device(dev); | ||
| 357 | } | ||
| 358 | |||
| 359 | device_del(&conn->dev); | ||
| 360 | put_device(&conn->dev); | ||
| 361 | hci_dev_put(hdev); | ||
| 362 | } | ||
| 363 | |||
| 364 | void hci_conn_del_sysfs(struct hci_conn *conn) | ||
| 365 | { | ||
| 366 | BT_DBG("conn %p", conn); | ||
| 367 | |||
| 368 | if (!device_is_registered(&conn->dev)) | ||
| 369 | return; | ||
| 370 | |||
| 371 | INIT_WORK(&conn->work, del_conn); | ||
| 372 | |||
| 373 | queue_work(btdelconn, &conn->work); | ||
| 374 | } | ||
| 375 | 412 | ||
| 376 | int hci_register_sysfs(struct hci_dev *hdev) | 413 | int hci_register_sysfs(struct hci_dev *hdev) |
| 377 | { | 414 | { |
| 378 | struct device *dev = &hdev->dev; | 415 | struct device *dev = &hdev->dev; |
| 379 | unsigned int i; | ||
| 380 | int err; | 416 | int err; |
| 381 | 417 | ||
| 382 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); | 418 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); |
| 383 | 419 | ||
| 384 | dev->bus = &bt_bus; | 420 | dev->type = &bt_host; |
| 421 | dev->class = bt_class; | ||
| 385 | dev->parent = hdev->parent; | 422 | dev->parent = hdev->parent; |
| 386 | 423 | ||
| 387 | strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); | 424 | strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); |
| 388 | 425 | ||
| 389 | dev->release = bt_release; | ||
| 390 | |||
| 391 | dev_set_drvdata(dev, hdev); | 426 | dev_set_drvdata(dev, hdev); |
| 392 | 427 | ||
| 393 | err = device_register(dev); | 428 | err = device_register(dev); |
| 394 | if (err < 0) | 429 | if (err < 0) |
| 395 | return err; | 430 | return err; |
| 396 | 431 | ||
| 397 | for (i = 0; bt_attrs[i]; i++) | ||
| 398 | if (device_create_file(dev, bt_attrs[i]) < 0) | ||
| 399 | BT_ERR("Failed to create device attribute"); | ||
| 400 | |||
| 401 | return 0; | 432 | return 0; |
| 402 | } | 433 | } |
| 403 | 434 | ||
| @@ -410,59 +441,30 @@ void hci_unregister_sysfs(struct hci_dev *hdev) | |||
| 410 | 441 | ||
| 411 | int __init bt_sysfs_init(void) | 442 | int __init bt_sysfs_init(void) |
| 412 | { | 443 | { |
| 413 | int err; | ||
| 414 | |||
| 415 | btaddconn = create_singlethread_workqueue("btaddconn"); | 444 | btaddconn = create_singlethread_workqueue("btaddconn"); |
| 416 | if (!btaddconn) { | 445 | if (!btaddconn) |
| 417 | err = -ENOMEM; | 446 | return -ENOMEM; |
| 418 | goto out; | ||
| 419 | } | ||
| 420 | 447 | ||
| 421 | btdelconn = create_singlethread_workqueue("btdelconn"); | 448 | btdelconn = create_singlethread_workqueue("btdelconn"); |
| 422 | if (!btdelconn) { | 449 | if (!btdelconn) { |
| 423 | err = -ENOMEM; | 450 | destroy_workqueue(btaddconn); |
| 424 | goto out_del; | 451 | return -ENOMEM; |
| 425 | } | ||
| 426 | |||
| 427 | bt_platform = platform_device_register_simple("bluetooth", -1, NULL, 0); | ||
| 428 | if (IS_ERR(bt_platform)) { | ||
| 429 | err = PTR_ERR(bt_platform); | ||
| 430 | goto out_platform; | ||
| 431 | } | 452 | } |
| 432 | 453 | ||
| 433 | err = bus_register(&bt_bus); | ||
| 434 | if (err < 0) | ||
| 435 | goto out_bus; | ||
| 436 | |||
| 437 | bt_class = class_create(THIS_MODULE, "bluetooth"); | 454 | bt_class = class_create(THIS_MODULE, "bluetooth"); |
| 438 | if (IS_ERR(bt_class)) { | 455 | if (IS_ERR(bt_class)) { |
| 439 | err = PTR_ERR(bt_class); | 456 | destroy_workqueue(btdelconn); |
| 440 | goto out_class; | 457 | destroy_workqueue(btaddconn); |
| 458 | return PTR_ERR(bt_class); | ||
| 441 | } | 459 | } |
| 442 | 460 | ||
| 443 | return 0; | 461 | return 0; |
| 444 | |||
| 445 | out_class: | ||
| 446 | bus_unregister(&bt_bus); | ||
| 447 | out_bus: | ||
| 448 | platform_device_unregister(bt_platform); | ||
| 449 | out_platform: | ||
| 450 | destroy_workqueue(btdelconn); | ||
| 451 | out_del: | ||
| 452 | destroy_workqueue(btaddconn); | ||
| 453 | out: | ||
| 454 | return err; | ||
| 455 | } | 462 | } |
| 456 | 463 | ||
| 457 | void bt_sysfs_cleanup(void) | 464 | void bt_sysfs_cleanup(void) |
| 458 | { | 465 | { |
| 459 | destroy_workqueue(btaddconn); | 466 | destroy_workqueue(btaddconn); |
| 460 | |||
| 461 | destroy_workqueue(btdelconn); | 467 | destroy_workqueue(btdelconn); |
| 462 | 468 | ||
| 463 | class_destroy(bt_class); | 469 | class_destroy(bt_class); |
| 464 | |||
| 465 | bus_unregister(&bt_bus); | ||
| 466 | |||
| 467 | platform_device_unregister(bt_platform); | ||
| 468 | } | 470 | } |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index c1239852834a..9610a9c85b98 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
| @@ -55,7 +55,7 @@ | |||
| 55 | #define BT_DBG(D...) | 55 | #define BT_DBG(D...) |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | #define VERSION "2.10" | 58 | #define VERSION "2.11" |
| 59 | 59 | ||
| 60 | static u32 l2cap_feat_mask = 0x0000; | 60 | static u32 l2cap_feat_mask = 0x0000; |
| 61 | 61 | ||
| @@ -778,6 +778,7 @@ static int l2cap_do_connect(struct sock *sk) | |||
| 778 | struct l2cap_conn *conn; | 778 | struct l2cap_conn *conn; |
| 779 | struct hci_conn *hcon; | 779 | struct hci_conn *hcon; |
| 780 | struct hci_dev *hdev; | 780 | struct hci_dev *hdev; |
| 781 | __u8 auth_type; | ||
| 781 | int err = 0; | 782 | int err = 0; |
| 782 | 783 | ||
| 783 | BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst), l2cap_pi(sk)->psm); | 784 | BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst), l2cap_pi(sk)->psm); |
| @@ -789,7 +790,21 @@ static int l2cap_do_connect(struct sock *sk) | |||
| 789 | 790 | ||
| 790 | err = -ENOMEM; | 791 | err = -ENOMEM; |
| 791 | 792 | ||
| 792 | hcon = hci_connect(hdev, ACL_LINK, dst); | 793 | if (l2cap_pi(sk)->link_mode & L2CAP_LM_AUTH || |
| 794 | l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT || | ||
| 795 | l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE) { | ||
| 796 | if (l2cap_pi(sk)->psm == cpu_to_le16(0x0001)) | ||
| 797 | auth_type = HCI_AT_NO_BONDING_MITM; | ||
| 798 | else | ||
| 799 | auth_type = HCI_AT_GENERAL_BONDING_MITM; | ||
| 800 | } else { | ||
| 801 | if (l2cap_pi(sk)->psm == cpu_to_le16(0x0001)) | ||
| 802 | auth_type = HCI_AT_NO_BONDING; | ||
| 803 | else | ||
| 804 | auth_type = HCI_AT_GENERAL_BONDING; | ||
| 805 | } | ||
| 806 | |||
| 807 | hcon = hci_connect(hdev, ACL_LINK, dst, auth_type); | ||
| 793 | if (!hcon) | 808 | if (!hcon) |
| 794 | goto done; | 809 | goto done; |
| 795 | 810 | ||
| @@ -1553,10 +1568,10 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
| 1553 | struct l2cap_conn_req *req = (struct l2cap_conn_req *) data; | 1568 | struct l2cap_conn_req *req = (struct l2cap_conn_req *) data; |
| 1554 | struct l2cap_conn_rsp rsp; | 1569 | struct l2cap_conn_rsp rsp; |
| 1555 | struct sock *sk, *parent; | 1570 | struct sock *sk, *parent; |
| 1556 | int result, status = 0; | 1571 | int result, status = L2CAP_CS_NO_INFO; |
| 1557 | 1572 | ||
| 1558 | u16 dcid = 0, scid = __le16_to_cpu(req->scid); | 1573 | u16 dcid = 0, scid = __le16_to_cpu(req->scid); |
| 1559 | __le16 psm = req->psm; | 1574 | __le16 psm = req->psm; |
| 1560 | 1575 | ||
| 1561 | BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid); | 1576 | BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid); |
| 1562 | 1577 | ||
| @@ -1567,6 +1582,13 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
| 1567 | goto sendresp; | 1582 | goto sendresp; |
| 1568 | } | 1583 | } |
| 1569 | 1584 | ||
| 1585 | /* Check if the ACL is secure enough (if not SDP) */ | ||
| 1586 | if (psm != cpu_to_le16(0x0001) && | ||
| 1587 | !hci_conn_check_link_mode(conn->hcon)) { | ||
| 1588 | result = L2CAP_CR_SEC_BLOCK; | ||
| 1589 | goto response; | ||
| 1590 | } | ||
| 1591 | |||
| 1570 | result = L2CAP_CR_NO_MEM; | 1592 | result = L2CAP_CR_NO_MEM; |
| 1571 | 1593 | ||
| 1572 | /* Check for backlog size */ | 1594 | /* Check for backlog size */ |
| @@ -2224,7 +2246,7 @@ static int l2cap_auth_cfm(struct hci_conn *hcon, u8 status) | |||
| 2224 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); | 2246 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); |
| 2225 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); | 2247 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); |
| 2226 | rsp.result = cpu_to_le16(result); | 2248 | rsp.result = cpu_to_le16(result); |
| 2227 | rsp.status = cpu_to_le16(0); | 2249 | rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); |
| 2228 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, | 2250 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, |
| 2229 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 2251 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); |
| 2230 | } | 2252 | } |
| @@ -2296,7 +2318,7 @@ static int l2cap_encrypt_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
| 2296 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); | 2318 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); |
| 2297 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); | 2319 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); |
| 2298 | rsp.result = cpu_to_le16(result); | 2320 | rsp.result = cpu_to_le16(result); |
| 2299 | rsp.status = cpu_to_le16(0); | 2321 | rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); |
| 2300 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, | 2322 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, |
| 2301 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 2323 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); |
| 2302 | } | 2324 | } |
| @@ -2516,7 +2538,7 @@ EXPORT_SYMBOL(l2cap_load); | |||
| 2516 | module_init(l2cap_init); | 2538 | module_init(l2cap_init); |
| 2517 | module_exit(l2cap_exit); | 2539 | module_exit(l2cap_exit); |
| 2518 | 2540 | ||
| 2519 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 2541 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
| 2520 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); | 2542 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); |
| 2521 | MODULE_VERSION(VERSION); | 2543 | MODULE_VERSION(VERSION); |
| 2522 | MODULE_LICENSE("GPL"); | 2544 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 6cfc7ba611b3..ba537fae0a4c 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
| @@ -2115,7 +2115,7 @@ MODULE_PARM_DESC(channel_mtu, "Default MTU for the RFCOMM channel"); | |||
| 2115 | module_param(l2cap_mtu, uint, 0644); | 2115 | module_param(l2cap_mtu, uint, 0644); |
| 2116 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); | 2116 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); |
| 2117 | 2117 | ||
| 2118 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 2118 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
| 2119 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); | 2119 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); |
| 2120 | MODULE_VERSION(VERSION); | 2120 | MODULE_VERSION(VERSION); |
| 2121 | MODULE_LICENSE("GPL"); | 2121 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 8cda49874868..0cc91e6da76d 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
| @@ -200,7 +200,7 @@ static int sco_connect(struct sock *sk) | |||
| 200 | else | 200 | else |
| 201 | type = SCO_LINK; | 201 | type = SCO_LINK; |
| 202 | 202 | ||
| 203 | hcon = hci_connect(hdev, type, dst); | 203 | hcon = hci_connect(hdev, type, dst, HCI_AT_NO_BONDING); |
| 204 | if (!hcon) | 204 | if (!hcon) |
| 205 | goto done; | 205 | goto done; |
| 206 | 206 | ||
| @@ -1002,7 +1002,7 @@ module_exit(sco_exit); | |||
| 1002 | module_param(disable_esco, bool, 0644); | 1002 | module_param(disable_esco, bool, 0644); |
| 1003 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); | 1003 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); |
| 1004 | 1004 | ||
| 1005 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 1005 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
| 1006 | MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION); | 1006 | MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION); |
| 1007 | MODULE_VERSION(VERSION); | 1007 | MODULE_VERSION(VERSION); |
| 1008 | MODULE_LICENSE("GPL"); | 1008 | MODULE_LICENSE("GPL"); |
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 9b58d70b0e7d..4f52c3d50ebe 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
| @@ -148,11 +148,16 @@ static int br_set_tx_csum(struct net_device *dev, u32 data) | |||
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | static struct ethtool_ops br_ethtool_ops = { | 150 | static struct ethtool_ops br_ethtool_ops = { |
| 151 | .get_drvinfo = br_getinfo, | 151 | .get_drvinfo = br_getinfo, |
| 152 | .get_link = ethtool_op_get_link, | 152 | .get_link = ethtool_op_get_link, |
| 153 | .set_sg = br_set_sg, | 153 | .get_tx_csum = ethtool_op_get_tx_csum, |
| 154 | .set_tx_csum = br_set_tx_csum, | 154 | .set_tx_csum = br_set_tx_csum, |
| 155 | .set_tso = br_set_tso, | 155 | .get_sg = ethtool_op_get_sg, |
| 156 | .set_sg = br_set_sg, | ||
| 157 | .get_tso = ethtool_op_get_tso, | ||
| 158 | .set_tso = br_set_tso, | ||
| 159 | .get_ufo = ethtool_op_get_ufo, | ||
| 160 | .get_flags = ethtool_op_get_flags, | ||
| 156 | }; | 161 | }; |
| 157 | 162 | ||
| 158 | void br_dev_setup(struct net_device *dev) | 163 | void br_dev_setup(struct net_device *dev) |
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c index eeee218eed80..5bbf07362172 100644 --- a/net/bridge/br_ioctl.c +++ b/net/bridge/br_ioctl.c | |||
| @@ -188,15 +188,21 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
| 188 | return 0; | 188 | return 0; |
| 189 | 189 | ||
| 190 | case BRCTL_SET_BRIDGE_HELLO_TIME: | 190 | case BRCTL_SET_BRIDGE_HELLO_TIME: |
| 191 | { | ||
| 192 | unsigned long t = clock_t_to_jiffies(args[1]); | ||
| 191 | if (!capable(CAP_NET_ADMIN)) | 193 | if (!capable(CAP_NET_ADMIN)) |
| 192 | return -EPERM; | 194 | return -EPERM; |
| 193 | 195 | ||
| 196 | if (t < HZ) | ||
| 197 | return -EINVAL; | ||
| 198 | |||
| 194 | spin_lock_bh(&br->lock); | 199 | spin_lock_bh(&br->lock); |
| 195 | br->bridge_hello_time = clock_t_to_jiffies(args[1]); | 200 | br->bridge_hello_time = t; |
| 196 | if (br_is_root_bridge(br)) | 201 | if (br_is_root_bridge(br)) |
| 197 | br->hello_time = br->bridge_hello_time; | 202 | br->hello_time = br->bridge_hello_time; |
| 198 | spin_unlock_bh(&br->lock); | 203 | spin_unlock_bh(&br->lock); |
| 199 | return 0; | 204 | return 0; |
| 205 | } | ||
| 200 | 206 | ||
| 201 | case BRCTL_SET_BRIDGE_MAX_AGE: | 207 | case BRCTL_SET_BRIDGE_MAX_AGE: |
| 202 | if (!capable(CAP_NET_ADMIN)) | 208 | if (!capable(CAP_NET_ADMIN)) |
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index 27d6a511c8c1..158dee8b4965 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c | |||
| @@ -29,11 +29,12 @@ | |||
| 29 | */ | 29 | */ |
| 30 | static ssize_t store_bridge_parm(struct device *d, | 30 | static ssize_t store_bridge_parm(struct device *d, |
| 31 | const char *buf, size_t len, | 31 | const char *buf, size_t len, |
| 32 | void (*set)(struct net_bridge *, unsigned long)) | 32 | int (*set)(struct net_bridge *, unsigned long)) |
| 33 | { | 33 | { |
| 34 | struct net_bridge *br = to_bridge(d); | 34 | struct net_bridge *br = to_bridge(d); |
| 35 | char *endp; | 35 | char *endp; |
| 36 | unsigned long val; | 36 | unsigned long val; |
| 37 | int err; | ||
| 37 | 38 | ||
| 38 | if (!capable(CAP_NET_ADMIN)) | 39 | if (!capable(CAP_NET_ADMIN)) |
| 39 | return -EPERM; | 40 | return -EPERM; |
| @@ -43,9 +44,9 @@ static ssize_t store_bridge_parm(struct device *d, | |||
| 43 | return -EINVAL; | 44 | return -EINVAL; |
| 44 | 45 | ||
| 45 | spin_lock_bh(&br->lock); | 46 | spin_lock_bh(&br->lock); |
| 46 | (*set)(br, val); | 47 | err = (*set)(br, val); |
| 47 | spin_unlock_bh(&br->lock); | 48 | spin_unlock_bh(&br->lock); |
| 48 | return len; | 49 | return err ? err : len; |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | 52 | ||
| @@ -56,12 +57,13 @@ static ssize_t show_forward_delay(struct device *d, | |||
| 56 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay)); | 57 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay)); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | static void set_forward_delay(struct net_bridge *br, unsigned long val) | 60 | static int set_forward_delay(struct net_bridge *br, unsigned long val) |
| 60 | { | 61 | { |
| 61 | unsigned long delay = clock_t_to_jiffies(val); | 62 | unsigned long delay = clock_t_to_jiffies(val); |
| 62 | br->forward_delay = delay; | 63 | br->forward_delay = delay; |
| 63 | if (br_is_root_bridge(br)) | 64 | if (br_is_root_bridge(br)) |
| 64 | br->bridge_forward_delay = delay; | 65 | br->bridge_forward_delay = delay; |
| 66 | return 0; | ||
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | static ssize_t store_forward_delay(struct device *d, | 69 | static ssize_t store_forward_delay(struct device *d, |
| @@ -80,12 +82,17 @@ static ssize_t show_hello_time(struct device *d, struct device_attribute *attr, | |||
| 80 | jiffies_to_clock_t(to_bridge(d)->hello_time)); | 82 | jiffies_to_clock_t(to_bridge(d)->hello_time)); |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | static void set_hello_time(struct net_bridge *br, unsigned long val) | 85 | static int set_hello_time(struct net_bridge *br, unsigned long val) |
| 84 | { | 86 | { |
| 85 | unsigned long t = clock_t_to_jiffies(val); | 87 | unsigned long t = clock_t_to_jiffies(val); |
| 88 | |||
| 89 | if (t < HZ) | ||
| 90 | return -EINVAL; | ||
| 91 | |||
| 86 | br->hello_time = t; | 92 | br->hello_time = t; |
| 87 | if (br_is_root_bridge(br)) | 93 | if (br_is_root_bridge(br)) |
| 88 | br->bridge_hello_time = t; | 94 | br->bridge_hello_time = t; |
| 95 | return 0; | ||
| 89 | } | 96 | } |
| 90 | 97 | ||
| 91 | static ssize_t store_hello_time(struct device *d, | 98 | static ssize_t store_hello_time(struct device *d, |
| @@ -104,12 +111,13 @@ static ssize_t show_max_age(struct device *d, struct device_attribute *attr, | |||
| 104 | jiffies_to_clock_t(to_bridge(d)->max_age)); | 111 | jiffies_to_clock_t(to_bridge(d)->max_age)); |
| 105 | } | 112 | } |
| 106 | 113 | ||
| 107 | static void set_max_age(struct net_bridge *br, unsigned long val) | 114 | static int set_max_age(struct net_bridge *br, unsigned long val) |
| 108 | { | 115 | { |
| 109 | unsigned long t = clock_t_to_jiffies(val); | 116 | unsigned long t = clock_t_to_jiffies(val); |
| 110 | br->max_age = t; | 117 | br->max_age = t; |
| 111 | if (br_is_root_bridge(br)) | 118 | if (br_is_root_bridge(br)) |
| 112 | br->bridge_max_age = t; | 119 | br->bridge_max_age = t; |
| 120 | return 0; | ||
| 113 | } | 121 | } |
| 114 | 122 | ||
| 115 | static ssize_t store_max_age(struct device *d, struct device_attribute *attr, | 123 | static ssize_t store_max_age(struct device *d, struct device_attribute *attr, |
| @@ -126,9 +134,10 @@ static ssize_t show_ageing_time(struct device *d, | |||
| 126 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time)); | 134 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time)); |
| 127 | } | 135 | } |
| 128 | 136 | ||
| 129 | static void set_ageing_time(struct net_bridge *br, unsigned long val) | 137 | static int set_ageing_time(struct net_bridge *br, unsigned long val) |
| 130 | { | 138 | { |
| 131 | br->ageing_time = clock_t_to_jiffies(val); | 139 | br->ageing_time = clock_t_to_jiffies(val); |
| 140 | return 0; | ||
| 132 | } | 141 | } |
| 133 | 142 | ||
| 134 | static ssize_t store_ageing_time(struct device *d, | 143 | static ssize_t store_ageing_time(struct device *d, |
| @@ -180,9 +189,10 @@ static ssize_t show_priority(struct device *d, struct device_attribute *attr, | |||
| 180 | (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); | 189 | (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); |
| 181 | } | 190 | } |
| 182 | 191 | ||
| 183 | static void set_priority(struct net_bridge *br, unsigned long val) | 192 | static int set_priority(struct net_bridge *br, unsigned long val) |
| 184 | { | 193 | { |
| 185 | br_stp_set_bridge_priority(br, (u16) val); | 194 | br_stp_set_bridge_priority(br, (u16) val); |
| 195 | return 0; | ||
| 186 | } | 196 | } |
| 187 | 197 | ||
| 188 | static ssize_t store_priority(struct device *d, struct device_attribute *attr, | 198 | static ssize_t store_priority(struct device *d, struct device_attribute *attr, |
diff --git a/net/core/datagram.c b/net/core/datagram.c index dd61dcad6019..52f577a0f544 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
| @@ -339,6 +339,93 @@ fault: | |||
| 339 | return -EFAULT; | 339 | return -EFAULT; |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | /** | ||
| 343 | * skb_copy_datagram_from_iovec - Copy a datagram from an iovec. | ||
| 344 | * @skb: buffer to copy | ||
| 345 | * @offset: offset in the buffer to start copying to | ||
| 346 | * @from: io vector to copy to | ||
| 347 | * @len: amount of data to copy to buffer from iovec | ||
| 348 | * | ||
| 349 | * Returns 0 or -EFAULT. | ||
| 350 | * Note: the iovec is modified during the copy. | ||
| 351 | */ | ||
| 352 | int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset, | ||
| 353 | struct iovec *from, int len) | ||
| 354 | { | ||
| 355 | int start = skb_headlen(skb); | ||
| 356 | int i, copy = start - offset; | ||
| 357 | |||
| 358 | /* Copy header. */ | ||
| 359 | if (copy > 0) { | ||
| 360 | if (copy > len) | ||
| 361 | copy = len; | ||
| 362 | if (memcpy_fromiovec(skb->data + offset, from, copy)) | ||
| 363 | goto fault; | ||
| 364 | if ((len -= copy) == 0) | ||
| 365 | return 0; | ||
| 366 | offset += copy; | ||
| 367 | } | ||
| 368 | |||
| 369 | /* Copy paged appendix. Hmm... why does this look so complicated? */ | ||
| 370 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | ||
| 371 | int end; | ||
| 372 | |||
| 373 | WARN_ON(start > offset + len); | ||
| 374 | |||
| 375 | end = start + skb_shinfo(skb)->frags[i].size; | ||
| 376 | if ((copy = end - offset) > 0) { | ||
| 377 | int err; | ||
| 378 | u8 *vaddr; | ||
| 379 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
| 380 | struct page *page = frag->page; | ||
| 381 | |||
| 382 | if (copy > len) | ||
| 383 | copy = len; | ||
| 384 | vaddr = kmap(page); | ||
| 385 | err = memcpy_fromiovec(vaddr + frag->page_offset + | ||
| 386 | offset - start, from, copy); | ||
| 387 | kunmap(page); | ||
| 388 | if (err) | ||
| 389 | goto fault; | ||
| 390 | |||
| 391 | if (!(len -= copy)) | ||
| 392 | return 0; | ||
| 393 | offset += copy; | ||
| 394 | } | ||
| 395 | start = end; | ||
| 396 | } | ||
| 397 | |||
| 398 | if (skb_shinfo(skb)->frag_list) { | ||
| 399 | struct sk_buff *list = skb_shinfo(skb)->frag_list; | ||
| 400 | |||
| 401 | for (; list; list = list->next) { | ||
| 402 | int end; | ||
| 403 | |||
| 404 | WARN_ON(start > offset + len); | ||
| 405 | |||
| 406 | end = start + list->len; | ||
| 407 | if ((copy = end - offset) > 0) { | ||
| 408 | if (copy > len) | ||
| 409 | copy = len; | ||
| 410 | if (skb_copy_datagram_from_iovec(list, | ||
| 411 | offset - start, | ||
| 412 | from, copy)) | ||
| 413 | goto fault; | ||
| 414 | if ((len -= copy) == 0) | ||
| 415 | return 0; | ||
| 416 | offset += copy; | ||
| 417 | } | ||
| 418 | start = end; | ||
| 419 | } | ||
| 420 | } | ||
| 421 | if (!len) | ||
| 422 | return 0; | ||
| 423 | |||
| 424 | fault: | ||
| 425 | return -EFAULT; | ||
| 426 | } | ||
| 427 | EXPORT_SYMBOL(skb_copy_datagram_from_iovec); | ||
| 428 | |||
| 342 | static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | 429 | static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, |
| 343 | u8 __user *to, int len, | 430 | u8 __user *to, int len, |
| 344 | __wsum *csump) | 431 | __wsum *csump) |
diff --git a/net/core/dev.c b/net/core/dev.c index 600bb23c4c2e..e8eb2b478344 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -122,6 +122,7 @@ | |||
| 122 | #include <linux/if_arp.h> | 122 | #include <linux/if_arp.h> |
| 123 | #include <linux/if_vlan.h> | 123 | #include <linux/if_vlan.h> |
| 124 | #include <linux/ip.h> | 124 | #include <linux/ip.h> |
| 125 | #include <net/ip.h> | ||
| 125 | #include <linux/ipv6.h> | 126 | #include <linux/ipv6.h> |
| 126 | #include <linux/in.h> | 127 | #include <linux/in.h> |
| 127 | #include <linux/jhash.h> | 128 | #include <linux/jhash.h> |
| @@ -1339,19 +1340,23 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) | |||
| 1339 | } | 1340 | } |
| 1340 | 1341 | ||
| 1341 | 1342 | ||
| 1342 | void __netif_schedule(struct Qdisc *q) | 1343 | static inline void __netif_reschedule(struct Qdisc *q) |
| 1343 | { | 1344 | { |
| 1344 | if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state)) { | 1345 | struct softnet_data *sd; |
| 1345 | struct softnet_data *sd; | 1346 | unsigned long flags; |
| 1346 | unsigned long flags; | ||
| 1347 | 1347 | ||
| 1348 | local_irq_save(flags); | 1348 | local_irq_save(flags); |
| 1349 | sd = &__get_cpu_var(softnet_data); | 1349 | sd = &__get_cpu_var(softnet_data); |
| 1350 | q->next_sched = sd->output_queue; | 1350 | q->next_sched = sd->output_queue; |
| 1351 | sd->output_queue = q; | 1351 | sd->output_queue = q; |
| 1352 | raise_softirq_irqoff(NET_TX_SOFTIRQ); | 1352 | raise_softirq_irqoff(NET_TX_SOFTIRQ); |
| 1353 | local_irq_restore(flags); | 1353 | local_irq_restore(flags); |
| 1354 | } | 1354 | } |
| 1355 | |||
| 1356 | void __netif_schedule(struct Qdisc *q) | ||
| 1357 | { | ||
| 1358 | if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state)) | ||
| 1359 | __netif_reschedule(q); | ||
| 1355 | } | 1360 | } |
| 1356 | EXPORT_SYMBOL(__netif_schedule); | 1361 | EXPORT_SYMBOL(__netif_schedule); |
| 1357 | 1362 | ||
| @@ -1663,7 +1668,7 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb) | |||
| 1663 | { | 1668 | { |
| 1664 | u32 addr1, addr2, ports; | 1669 | u32 addr1, addr2, ports; |
| 1665 | u32 hash, ihl; | 1670 | u32 hash, ihl; |
| 1666 | u8 ip_proto; | 1671 | u8 ip_proto = 0; |
| 1667 | 1672 | ||
| 1668 | if (unlikely(!simple_tx_hashrnd_initialized)) { | 1673 | if (unlikely(!simple_tx_hashrnd_initialized)) { |
| 1669 | get_random_bytes(&simple_tx_hashrnd, 4); | 1674 | get_random_bytes(&simple_tx_hashrnd, 4); |
| @@ -1672,7 +1677,8 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb) | |||
| 1672 | 1677 | ||
| 1673 | switch (skb->protocol) { | 1678 | switch (skb->protocol) { |
| 1674 | case __constant_htons(ETH_P_IP): | 1679 | case __constant_htons(ETH_P_IP): |
| 1675 | ip_proto = ip_hdr(skb)->protocol; | 1680 | if (!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET))) |
| 1681 | ip_proto = ip_hdr(skb)->protocol; | ||
| 1676 | addr1 = ip_hdr(skb)->saddr; | 1682 | addr1 = ip_hdr(skb)->saddr; |
| 1677 | addr2 = ip_hdr(skb)->daddr; | 1683 | addr2 = ip_hdr(skb)->daddr; |
| 1678 | ihl = ip_hdr(skb)->ihl; | 1684 | ihl = ip_hdr(skb)->ihl; |
| @@ -1800,9 +1806,13 @@ gso: | |||
| 1800 | 1806 | ||
| 1801 | spin_lock(root_lock); | 1807 | spin_lock(root_lock); |
| 1802 | 1808 | ||
| 1803 | rc = qdisc_enqueue_root(skb, q); | 1809 | if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) { |
| 1804 | qdisc_run(q); | 1810 | kfree_skb(skb); |
| 1805 | 1811 | rc = NET_XMIT_DROP; | |
| 1812 | } else { | ||
| 1813 | rc = qdisc_enqueue_root(skb, q); | ||
| 1814 | qdisc_run(q); | ||
| 1815 | } | ||
| 1806 | spin_unlock(root_lock); | 1816 | spin_unlock(root_lock); |
| 1807 | 1817 | ||
| 1808 | goto out; | 1818 | goto out; |
| @@ -1974,15 +1984,22 @@ static void net_tx_action(struct softirq_action *h) | |||
| 1974 | 1984 | ||
| 1975 | head = head->next_sched; | 1985 | head = head->next_sched; |
| 1976 | 1986 | ||
| 1977 | smp_mb__before_clear_bit(); | ||
| 1978 | clear_bit(__QDISC_STATE_SCHED, &q->state); | ||
| 1979 | |||
| 1980 | root_lock = qdisc_lock(q); | 1987 | root_lock = qdisc_lock(q); |
| 1981 | if (spin_trylock(root_lock)) { | 1988 | if (spin_trylock(root_lock)) { |
| 1989 | smp_mb__before_clear_bit(); | ||
| 1990 | clear_bit(__QDISC_STATE_SCHED, | ||
| 1991 | &q->state); | ||
| 1982 | qdisc_run(q); | 1992 | qdisc_run(q); |
| 1983 | spin_unlock(root_lock); | 1993 | spin_unlock(root_lock); |
| 1984 | } else { | 1994 | } else { |
| 1985 | __netif_schedule(q); | 1995 | if (!test_bit(__QDISC_STATE_DEACTIVATED, |
| 1996 | &q->state)) { | ||
| 1997 | __netif_reschedule(q); | ||
| 1998 | } else { | ||
| 1999 | smp_mb__before_clear_bit(); | ||
| 2000 | clear_bit(__QDISC_STATE_SCHED, | ||
| 2001 | &q->state); | ||
| 2002 | } | ||
| 1986 | } | 2003 | } |
| 1987 | } | 2004 | } |
| 1988 | } | 2005 | } |
| @@ -2084,7 +2101,8 @@ static int ing_filter(struct sk_buff *skb) | |||
| 2084 | q = rxq->qdisc; | 2101 | q = rxq->qdisc; |
| 2085 | if (q != &noop_qdisc) { | 2102 | if (q != &noop_qdisc) { |
| 2086 | spin_lock(qdisc_lock(q)); | 2103 | spin_lock(qdisc_lock(q)); |
| 2087 | result = qdisc_enqueue_root(skb, q); | 2104 | if (likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) |
| 2105 | result = qdisc_enqueue_root(skb, q); | ||
| 2088 | spin_unlock(qdisc_lock(q)); | 2106 | spin_unlock(qdisc_lock(q)); |
| 2089 | } | 2107 | } |
| 2090 | 2108 | ||
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c index a89f32fa94f6..57abe8266be1 100644 --- a/net/core/gen_estimator.c +++ b/net/core/gen_estimator.c | |||
| @@ -99,7 +99,7 @@ struct gen_estimator_head | |||
| 99 | 99 | ||
| 100 | static struct gen_estimator_head elist[EST_MAX_INTERVAL+1]; | 100 | static struct gen_estimator_head elist[EST_MAX_INTERVAL+1]; |
| 101 | 101 | ||
| 102 | /* Protects against NULL dereference and RCU write-side */ | 102 | /* Protects against NULL dereference */ |
| 103 | static DEFINE_RWLOCK(est_lock); | 103 | static DEFINE_RWLOCK(est_lock); |
| 104 | 104 | ||
| 105 | static void est_timer(unsigned long arg) | 105 | static void est_timer(unsigned long arg) |
| @@ -185,7 +185,6 @@ int gen_new_estimator(struct gnet_stats_basic *bstats, | |||
| 185 | est->last_packets = bstats->packets; | 185 | est->last_packets = bstats->packets; |
| 186 | est->avpps = rate_est->pps<<10; | 186 | est->avpps = rate_est->pps<<10; |
| 187 | 187 | ||
| 188 | write_lock_bh(&est_lock); | ||
| 189 | if (!elist[idx].timer.function) { | 188 | if (!elist[idx].timer.function) { |
| 190 | INIT_LIST_HEAD(&elist[idx].list); | 189 | INIT_LIST_HEAD(&elist[idx].list); |
| 191 | setup_timer(&elist[idx].timer, est_timer, idx); | 190 | setup_timer(&elist[idx].timer, est_timer, idx); |
| @@ -195,7 +194,6 @@ int gen_new_estimator(struct gnet_stats_basic *bstats, | |||
| 195 | mod_timer(&elist[idx].timer, jiffies + ((HZ/4) << idx)); | 194 | mod_timer(&elist[idx].timer, jiffies + ((HZ/4) << idx)); |
| 196 | 195 | ||
| 197 | list_add_rcu(&est->list, &elist[idx].list); | 196 | list_add_rcu(&est->list, &elist[idx].list); |
| 198 | write_unlock_bh(&est_lock); | ||
| 199 | return 0; | 197 | return 0; |
| 200 | } | 198 | } |
| 201 | 199 | ||
| @@ -214,6 +212,7 @@ static void __gen_kill_estimator(struct rcu_head *head) | |||
| 214 | * Removes the rate estimator specified by &bstats and &rate_est | 212 | * Removes the rate estimator specified by &bstats and &rate_est |
| 215 | * and deletes the timer. | 213 | * and deletes the timer. |
| 216 | * | 214 | * |
| 215 | * NOTE: Called under rtnl_mutex | ||
| 217 | */ | 216 | */ |
| 218 | void gen_kill_estimator(struct gnet_stats_basic *bstats, | 217 | void gen_kill_estimator(struct gnet_stats_basic *bstats, |
| 219 | struct gnet_stats_rate_est *rate_est) | 218 | struct gnet_stats_rate_est *rate_est) |
| @@ -227,17 +226,17 @@ void gen_kill_estimator(struct gnet_stats_basic *bstats, | |||
| 227 | if (!elist[idx].timer.function) | 226 | if (!elist[idx].timer.function) |
| 228 | continue; | 227 | continue; |
| 229 | 228 | ||
| 230 | write_lock_bh(&est_lock); | ||
| 231 | list_for_each_entry_safe(e, n, &elist[idx].list, list) { | 229 | list_for_each_entry_safe(e, n, &elist[idx].list, list) { |
| 232 | if (e->rate_est != rate_est || e->bstats != bstats) | 230 | if (e->rate_est != rate_est || e->bstats != bstats) |
| 233 | continue; | 231 | continue; |
| 234 | 232 | ||
| 233 | write_lock_bh(&est_lock); | ||
| 235 | e->bstats = NULL; | 234 | e->bstats = NULL; |
| 235 | write_unlock_bh(&est_lock); | ||
| 236 | 236 | ||
| 237 | list_del_rcu(&e->list); | 237 | list_del_rcu(&e->list); |
| 238 | call_rcu(&e->e_rcu, __gen_kill_estimator); | 238 | call_rcu(&e->e_rcu, __gen_kill_estimator); |
| 239 | } | 239 | } |
| 240 | write_unlock_bh(&est_lock); | ||
| 241 | } | 240 | } |
| 242 | } | 241 | } |
| 243 | 242 | ||
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 84640172d65d..ca1ccdf1ef76 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
| @@ -2256,14 +2256,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
| 2256 | segs = nskb; | 2256 | segs = nskb; |
| 2257 | tail = nskb; | 2257 | tail = nskb; |
| 2258 | 2258 | ||
| 2259 | nskb->dev = skb->dev; | 2259 | __copy_skb_header(nskb, skb); |
| 2260 | skb_copy_queue_mapping(nskb, skb); | ||
| 2261 | nskb->priority = skb->priority; | ||
| 2262 | nskb->protocol = skb->protocol; | ||
| 2263 | nskb->vlan_tci = skb->vlan_tci; | ||
| 2264 | nskb->dst = dst_clone(skb->dst); | ||
| 2265 | memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); | ||
| 2266 | nskb->pkt_type = skb->pkt_type; | ||
| 2267 | nskb->mac_len = skb->mac_len; | 2260 | nskb->mac_len = skb->mac_len; |
| 2268 | 2261 | ||
| 2269 | skb_reserve(nskb, headroom); | 2262 | skb_reserve(nskb, headroom); |
| @@ -2274,6 +2267,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
| 2274 | skb_copy_from_linear_data(skb, skb_put(nskb, doffset), | 2267 | skb_copy_from_linear_data(skb, skb_put(nskb, doffset), |
| 2275 | doffset); | 2268 | doffset); |
| 2276 | if (!sg) { | 2269 | if (!sg) { |
| 2270 | nskb->ip_summed = CHECKSUM_NONE; | ||
| 2277 | nskb->csum = skb_copy_and_csum_bits(skb, offset, | 2271 | nskb->csum = skb_copy_and_csum_bits(skb, offset, |
| 2278 | skb_put(nskb, len), | 2272 | skb_put(nskb, len), |
| 2279 | len, 0); | 2273 | len, 0); |
| @@ -2283,8 +2277,6 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
| 2283 | frag = skb_shinfo(nskb)->frags; | 2277 | frag = skb_shinfo(nskb)->frags; |
| 2284 | k = 0; | 2278 | k = 0; |
| 2285 | 2279 | ||
| 2286 | nskb->ip_summed = CHECKSUM_PARTIAL; | ||
| 2287 | nskb->csum = skb->csum; | ||
| 2288 | skb_copy_from_linear_data_offset(skb, offset, | 2280 | skb_copy_from_linear_data_offset(skb, offset, |
| 2289 | skb_put(nskb, hsize), hsize); | 2281 | skb_put(nskb, hsize), hsize); |
| 2290 | 2282 | ||
diff --git a/net/dccp/input.c b/net/dccp/input.c index df2f110df94a..803933ab396d 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
| @@ -411,12 +411,6 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
| 411 | struct dccp_sock *dp = dccp_sk(sk); | 411 | struct dccp_sock *dp = dccp_sk(sk); |
| 412 | long tstamp = dccp_timestamp(); | 412 | long tstamp = dccp_timestamp(); |
| 413 | 413 | ||
| 414 | /* Stop the REQUEST timer */ | ||
| 415 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | ||
| 416 | WARN_ON(sk->sk_send_head == NULL); | ||
| 417 | __kfree_skb(sk->sk_send_head); | ||
| 418 | sk->sk_send_head = NULL; | ||
| 419 | |||
| 420 | if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, | 414 | if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, |
| 421 | dp->dccps_awl, dp->dccps_awh)) { | 415 | dp->dccps_awl, dp->dccps_awh)) { |
| 422 | dccp_pr_debug("invalid ackno: S.AWL=%llu, " | 416 | dccp_pr_debug("invalid ackno: S.AWL=%llu, " |
| @@ -441,6 +435,12 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
| 441 | DCCP_ACKVEC_STATE_RECEIVED)) | 435 | DCCP_ACKVEC_STATE_RECEIVED)) |
| 442 | goto out_invalid_packet; /* FIXME: change error code */ | 436 | goto out_invalid_packet; /* FIXME: change error code */ |
| 443 | 437 | ||
| 438 | /* Stop the REQUEST timer */ | ||
| 439 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | ||
| 440 | WARN_ON(sk->sk_send_head == NULL); | ||
| 441 | kfree_skb(sk->sk_send_head); | ||
| 442 | sk->sk_send_head = NULL; | ||
| 443 | |||
| 444 | dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq; | 444 | dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq; |
| 445 | dccp_update_gsr(sk, dp->dccps_isr); | 445 | dccp_update_gsr(sk, dp->dccps_isr); |
| 446 | /* | 446 | /* |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 91d3d96805d0..b12dae2b0b2d 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
| @@ -1029,6 +1029,11 @@ skip: | |||
| 1029 | } | 1029 | } |
| 1030 | } | 1030 | } |
| 1031 | 1031 | ||
| 1032 | static inline bool inetdev_valid_mtu(unsigned mtu) | ||
| 1033 | { | ||
| 1034 | return mtu >= 68; | ||
| 1035 | } | ||
| 1036 | |||
| 1032 | /* Called only under RTNL semaphore */ | 1037 | /* Called only under RTNL semaphore */ |
| 1033 | 1038 | ||
| 1034 | static int inetdev_event(struct notifier_block *this, unsigned long event, | 1039 | static int inetdev_event(struct notifier_block *this, unsigned long event, |
| @@ -1048,6 +1053,10 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
| 1048 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); | 1053 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); |
| 1049 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); | 1054 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); |
| 1050 | } | 1055 | } |
| 1056 | } else if (event == NETDEV_CHANGEMTU) { | ||
| 1057 | /* Re-enabling IP */ | ||
| 1058 | if (inetdev_valid_mtu(dev->mtu)) | ||
| 1059 | in_dev = inetdev_init(dev); | ||
| 1051 | } | 1060 | } |
| 1052 | goto out; | 1061 | goto out; |
| 1053 | } | 1062 | } |
| @@ -1058,7 +1067,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
| 1058 | dev->ip_ptr = NULL; | 1067 | dev->ip_ptr = NULL; |
| 1059 | break; | 1068 | break; |
| 1060 | case NETDEV_UP: | 1069 | case NETDEV_UP: |
| 1061 | if (dev->mtu < 68) | 1070 | if (!inetdev_valid_mtu(dev->mtu)) |
| 1062 | break; | 1071 | break; |
| 1063 | if (dev->flags & IFF_LOOPBACK) { | 1072 | if (dev->flags & IFF_LOOPBACK) { |
| 1064 | struct in_ifaddr *ifa; | 1073 | struct in_ifaddr *ifa; |
| @@ -1080,9 +1089,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
| 1080 | ip_mc_down(in_dev); | 1089 | ip_mc_down(in_dev); |
| 1081 | break; | 1090 | break; |
| 1082 | case NETDEV_CHANGEMTU: | 1091 | case NETDEV_CHANGEMTU: |
| 1083 | if (dev->mtu >= 68) | 1092 | if (inetdev_valid_mtu(dev->mtu)) |
| 1084 | break; | 1093 | break; |
| 1085 | /* MTU falled under 68, disable IP */ | 1094 | /* disable IP when MTU is not enough */ |
| 1086 | case NETDEV_UNREGISTER: | 1095 | case NETDEV_UNREGISTER: |
| 1087 | inetdev_destroy(in_dev); | 1096 | inetdev_destroy(in_dev); |
| 1088 | break; | 1097 | break; |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 860558633b2c..55c355e63234 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
| @@ -204,18 +204,22 @@ static struct sock *icmp_sk(struct net *net) | |||
| 204 | return net->ipv4.icmp_sk[smp_processor_id()]; | 204 | return net->ipv4.icmp_sk[smp_processor_id()]; |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | static inline int icmp_xmit_lock(struct sock *sk) | 207 | static inline struct sock *icmp_xmit_lock(struct net *net) |
| 208 | { | 208 | { |
| 209 | struct sock *sk; | ||
| 210 | |||
| 209 | local_bh_disable(); | 211 | local_bh_disable(); |
| 210 | 212 | ||
| 213 | sk = icmp_sk(net); | ||
| 214 | |||
| 211 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { | 215 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { |
| 212 | /* This can happen if the output path signals a | 216 | /* This can happen if the output path signals a |
| 213 | * dst_link_failure() for an outgoing ICMP packet. | 217 | * dst_link_failure() for an outgoing ICMP packet. |
| 214 | */ | 218 | */ |
| 215 | local_bh_enable(); | 219 | local_bh_enable(); |
| 216 | return 1; | 220 | return NULL; |
| 217 | } | 221 | } |
| 218 | return 0; | 222 | return sk; |
| 219 | } | 223 | } |
| 220 | 224 | ||
| 221 | static inline void icmp_xmit_unlock(struct sock *sk) | 225 | static inline void icmp_xmit_unlock(struct sock *sk) |
| @@ -354,15 +358,17 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) | |||
| 354 | struct ipcm_cookie ipc; | 358 | struct ipcm_cookie ipc; |
| 355 | struct rtable *rt = skb->rtable; | 359 | struct rtable *rt = skb->rtable; |
| 356 | struct net *net = dev_net(rt->u.dst.dev); | 360 | struct net *net = dev_net(rt->u.dst.dev); |
| 357 | struct sock *sk = icmp_sk(net); | 361 | struct sock *sk; |
| 358 | struct inet_sock *inet = inet_sk(sk); | 362 | struct inet_sock *inet; |
| 359 | __be32 daddr; | 363 | __be32 daddr; |
| 360 | 364 | ||
| 361 | if (ip_options_echo(&icmp_param->replyopts, skb)) | 365 | if (ip_options_echo(&icmp_param->replyopts, skb)) |
| 362 | return; | 366 | return; |
| 363 | 367 | ||
| 364 | if (icmp_xmit_lock(sk)) | 368 | sk = icmp_xmit_lock(net); |
| 369 | if (sk == NULL) | ||
| 365 | return; | 370 | return; |
| 371 | inet = inet_sk(sk); | ||
| 366 | 372 | ||
| 367 | icmp_param->data.icmph.checksum = 0; | 373 | icmp_param->data.icmph.checksum = 0; |
| 368 | 374 | ||
| @@ -419,7 +425,6 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
| 419 | if (!rt) | 425 | if (!rt) |
| 420 | goto out; | 426 | goto out; |
| 421 | net = dev_net(rt->u.dst.dev); | 427 | net = dev_net(rt->u.dst.dev); |
| 422 | sk = icmp_sk(net); | ||
| 423 | 428 | ||
| 424 | /* | 429 | /* |
| 425 | * Find the original header. It is expected to be valid, of course. | 430 | * Find the original header. It is expected to be valid, of course. |
| @@ -483,7 +488,8 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
| 483 | } | 488 | } |
| 484 | } | 489 | } |
| 485 | 490 | ||
| 486 | if (icmp_xmit_lock(sk)) | 491 | sk = icmp_xmit_lock(net); |
| 492 | if (sk == NULL) | ||
| 487 | return; | 493 | return; |
| 488 | 494 | ||
| 489 | /* | 495 | /* |
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index d985bd613d25..743f011b9a84 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
| @@ -409,3 +409,38 @@ out: | |||
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick); | 411 | EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick); |
| 412 | |||
| 413 | void inet_twsk_purge(struct net *net, struct inet_hashinfo *hashinfo, | ||
| 414 | struct inet_timewait_death_row *twdr, int family) | ||
| 415 | { | ||
| 416 | struct inet_timewait_sock *tw; | ||
| 417 | struct sock *sk; | ||
| 418 | struct hlist_node *node; | ||
| 419 | int h; | ||
| 420 | |||
| 421 | local_bh_disable(); | ||
| 422 | for (h = 0; h < (hashinfo->ehash_size); h++) { | ||
| 423 | struct inet_ehash_bucket *head = | ||
| 424 | inet_ehash_bucket(hashinfo, h); | ||
| 425 | rwlock_t *lock = inet_ehash_lockp(hashinfo, h); | ||
| 426 | restart: | ||
| 427 | write_lock(lock); | ||
| 428 | sk_for_each(sk, node, &head->twchain) { | ||
| 429 | |||
| 430 | tw = inet_twsk(sk); | ||
| 431 | if (!net_eq(twsk_net(tw), net) || | ||
| 432 | tw->tw_family != family) | ||
| 433 | continue; | ||
| 434 | |||
| 435 | atomic_inc(&tw->tw_refcnt); | ||
| 436 | write_unlock(lock); | ||
| 437 | inet_twsk_deschedule(tw, twdr); | ||
| 438 | inet_twsk_put(tw); | ||
| 439 | |||
| 440 | goto restart; | ||
| 441 | } | ||
| 442 | write_unlock(lock); | ||
| 443 | } | ||
| 444 | local_bh_enable(); | ||
| 445 | } | ||
| 446 | EXPORT_SYMBOL_GPL(inet_twsk_purge); | ||
diff --git a/net/ipv4/netfilter/ipt_addrtype.c b/net/ipv4/netfilter/ipt_addrtype.c index 49587a497229..462a22c97877 100644 --- a/net/ipv4/netfilter/ipt_addrtype.c +++ b/net/ipv4/netfilter/ipt_addrtype.c | |||
| @@ -70,7 +70,7 @@ addrtype_mt_v1(const struct sk_buff *skb, const struct net_device *in, | |||
| 70 | (info->flags & IPT_ADDRTYPE_INVERT_SOURCE); | 70 | (info->flags & IPT_ADDRTYPE_INVERT_SOURCE); |
| 71 | if (ret && info->dest) | 71 | if (ret && info->dest) |
| 72 | ret &= match_type(dev, iph->daddr, info->dest) ^ | 72 | ret &= match_type(dev, iph->daddr, info->dest) ^ |
| 73 | (info->flags & IPT_ADDRTYPE_INVERT_DEST); | 73 | !!(info->flags & IPT_ADDRTYPE_INVERT_DEST); |
| 74 | return ret; | 74 | return ret; |
| 75 | } | 75 | } |
| 76 | 76 | ||
diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c index 91537f11273f..6c4f11f51446 100644 --- a/net/ipv4/netfilter/nf_nat_proto_common.c +++ b/net/ipv4/netfilter/nf_nat_proto_common.c | |||
| @@ -73,9 +73,13 @@ bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
| 73 | range_size = ntohs(range->max.all) - min + 1; | 73 | range_size = ntohs(range->max.all) - min + 1; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | off = *rover; | ||
| 77 | if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) | 76 | if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) |
| 78 | off = net_random(); | 77 | off = secure_ipv4_port_ephemeral(tuple->src.u3.ip, tuple->dst.u3.ip, |
| 78 | maniptype == IP_NAT_MANIP_SRC | ||
| 79 | ? tuple->dst.u.all | ||
| 80 | : tuple->src.u.all); | ||
| 81 | else | ||
| 82 | off = *rover; | ||
| 79 | 83 | ||
| 80 | for (i = 0; i < range_size; i++, off++) { | 84 | for (i = 0; i < range_size; i++, off++) { |
| 81 | *portptr = htons(min + off % range_size); | 85 | *portptr = htons(min + off % range_size); |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 16fc6f454a31..6ee5354c9aa1 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -2914,6 +2914,68 @@ static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table, | |||
| 2914 | return 0; | 2914 | return 0; |
| 2915 | } | 2915 | } |
| 2916 | 2916 | ||
| 2917 | static void rt_secret_reschedule(int old) | ||
| 2918 | { | ||
| 2919 | struct net *net; | ||
| 2920 | int new = ip_rt_secret_interval; | ||
| 2921 | int diff = new - old; | ||
| 2922 | |||
| 2923 | if (!diff) | ||
| 2924 | return; | ||
| 2925 | |||
| 2926 | rtnl_lock(); | ||
| 2927 | for_each_net(net) { | ||
| 2928 | int deleted = del_timer_sync(&net->ipv4.rt_secret_timer); | ||
| 2929 | |||
| 2930 | if (!new) | ||
| 2931 | continue; | ||
| 2932 | |||
| 2933 | if (deleted) { | ||
| 2934 | long time = net->ipv4.rt_secret_timer.expires - jiffies; | ||
| 2935 | |||
| 2936 | if (time <= 0 || (time += diff) <= 0) | ||
| 2937 | time = 0; | ||
| 2938 | |||
| 2939 | net->ipv4.rt_secret_timer.expires = time; | ||
| 2940 | } else | ||
| 2941 | net->ipv4.rt_secret_timer.expires = new; | ||
| 2942 | |||
| 2943 | net->ipv4.rt_secret_timer.expires += jiffies; | ||
| 2944 | add_timer(&net->ipv4.rt_secret_timer); | ||
| 2945 | } | ||
| 2946 | rtnl_unlock(); | ||
| 2947 | } | ||
| 2948 | |||
| 2949 | static int ipv4_sysctl_rt_secret_interval(ctl_table *ctl, int write, | ||
| 2950 | struct file *filp, | ||
| 2951 | void __user *buffer, size_t *lenp, | ||
| 2952 | loff_t *ppos) | ||
| 2953 | { | ||
| 2954 | int old = ip_rt_secret_interval; | ||
| 2955 | int ret = proc_dointvec_jiffies(ctl, write, filp, buffer, lenp, ppos); | ||
| 2956 | |||
| 2957 | rt_secret_reschedule(old); | ||
| 2958 | |||
| 2959 | return ret; | ||
| 2960 | } | ||
| 2961 | |||
| 2962 | static int ipv4_sysctl_rt_secret_interval_strategy(ctl_table *table, | ||
| 2963 | int __user *name, | ||
| 2964 | int nlen, | ||
| 2965 | void __user *oldval, | ||
| 2966 | size_t __user *oldlenp, | ||
| 2967 | void __user *newval, | ||
| 2968 | size_t newlen) | ||
| 2969 | { | ||
| 2970 | int old = ip_rt_secret_interval; | ||
| 2971 | int ret = sysctl_jiffies(table, name, nlen, oldval, oldlenp, newval, | ||
| 2972 | newlen); | ||
| 2973 | |||
| 2974 | rt_secret_reschedule(old); | ||
| 2975 | |||
| 2976 | return ret; | ||
| 2977 | } | ||
| 2978 | |||
| 2917 | static ctl_table ipv4_route_table[] = { | 2979 | static ctl_table ipv4_route_table[] = { |
| 2918 | { | 2980 | { |
| 2919 | .ctl_name = NET_IPV4_ROUTE_GC_THRESH, | 2981 | .ctl_name = NET_IPV4_ROUTE_GC_THRESH, |
| @@ -3048,20 +3110,29 @@ static ctl_table ipv4_route_table[] = { | |||
| 3048 | .data = &ip_rt_secret_interval, | 3110 | .data = &ip_rt_secret_interval, |
| 3049 | .maxlen = sizeof(int), | 3111 | .maxlen = sizeof(int), |
| 3050 | .mode = 0644, | 3112 | .mode = 0644, |
| 3051 | .proc_handler = &proc_dointvec_jiffies, | 3113 | .proc_handler = &ipv4_sysctl_rt_secret_interval, |
| 3052 | .strategy = &sysctl_jiffies, | 3114 | .strategy = &ipv4_sysctl_rt_secret_interval_strategy, |
| 3053 | }, | 3115 | }, |
| 3054 | { .ctl_name = 0 } | 3116 | { .ctl_name = 0 } |
| 3055 | }; | 3117 | }; |
| 3056 | 3118 | ||
| 3057 | static __net_initdata struct ctl_path ipv4_route_path[] = { | 3119 | static struct ctl_table empty[1]; |
| 3120 | |||
| 3121 | static struct ctl_table ipv4_skeleton[] = | ||
| 3122 | { | ||
| 3123 | { .procname = "route", .ctl_name = NET_IPV4_ROUTE, | ||
| 3124 | .mode = 0555, .child = ipv4_route_table}, | ||
| 3125 | { .procname = "neigh", .ctl_name = NET_IPV4_NEIGH, | ||
| 3126 | .mode = 0555, .child = empty}, | ||
| 3127 | { } | ||
| 3128 | }; | ||
| 3129 | |||
| 3130 | static __net_initdata struct ctl_path ipv4_path[] = { | ||
| 3058 | { .procname = "net", .ctl_name = CTL_NET, }, | 3131 | { .procname = "net", .ctl_name = CTL_NET, }, |
| 3059 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, | 3132 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, |
| 3060 | { .procname = "route", .ctl_name = NET_IPV4_ROUTE, }, | ||
| 3061 | { }, | 3133 | { }, |
| 3062 | }; | 3134 | }; |
| 3063 | 3135 | ||
| 3064 | |||
| 3065 | static struct ctl_table ipv4_route_flush_table[] = { | 3136 | static struct ctl_table ipv4_route_flush_table[] = { |
| 3066 | { | 3137 | { |
| 3067 | .ctl_name = NET_IPV4_ROUTE_FLUSH, | 3138 | .ctl_name = NET_IPV4_ROUTE_FLUSH, |
| @@ -3074,6 +3145,13 @@ static struct ctl_table ipv4_route_flush_table[] = { | |||
| 3074 | { .ctl_name = 0 }, | 3145 | { .ctl_name = 0 }, |
| 3075 | }; | 3146 | }; |
| 3076 | 3147 | ||
| 3148 | static __net_initdata struct ctl_path ipv4_route_path[] = { | ||
| 3149 | { .procname = "net", .ctl_name = CTL_NET, }, | ||
| 3150 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, | ||
| 3151 | { .procname = "route", .ctl_name = NET_IPV4_ROUTE, }, | ||
| 3152 | { }, | ||
| 3153 | }; | ||
| 3154 | |||
| 3077 | static __net_init int sysctl_route_net_init(struct net *net) | 3155 | static __net_init int sysctl_route_net_init(struct net *net) |
| 3078 | { | 3156 | { |
| 3079 | struct ctl_table *tbl; | 3157 | struct ctl_table *tbl; |
| @@ -3126,10 +3204,12 @@ static __net_init int rt_secret_timer_init(struct net *net) | |||
| 3126 | net->ipv4.rt_secret_timer.data = (unsigned long)net; | 3204 | net->ipv4.rt_secret_timer.data = (unsigned long)net; |
| 3127 | init_timer_deferrable(&net->ipv4.rt_secret_timer); | 3205 | init_timer_deferrable(&net->ipv4.rt_secret_timer); |
| 3128 | 3206 | ||
| 3129 | net->ipv4.rt_secret_timer.expires = | 3207 | if (ip_rt_secret_interval) { |
| 3130 | jiffies + net_random() % ip_rt_secret_interval + | 3208 | net->ipv4.rt_secret_timer.expires = |
| 3131 | ip_rt_secret_interval; | 3209 | jiffies + net_random() % ip_rt_secret_interval + |
| 3132 | add_timer(&net->ipv4.rt_secret_timer); | 3210 | ip_rt_secret_interval; |
| 3211 | add_timer(&net->ipv4.rt_secret_timer); | ||
| 3212 | } | ||
| 3133 | return 0; | 3213 | return 0; |
| 3134 | } | 3214 | } |
| 3135 | 3215 | ||
| @@ -3223,7 +3303,7 @@ int __init ip_rt_init(void) | |||
| 3223 | */ | 3303 | */ |
| 3224 | void __init ip_static_sysctl_init(void) | 3304 | void __init ip_static_sysctl_init(void) |
| 3225 | { | 3305 | { |
| 3226 | register_sysctl_paths(ipv4_route_path, ipv4_route_table); | 3306 | register_sysctl_paths(ipv4_path, ipv4_skeleton); |
| 3227 | } | 3307 | } |
| 3228 | #endif | 3308 | #endif |
| 3229 | 3309 | ||
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 44c1e934824b..011478e46c40 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
| @@ -618,7 +618,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, | |||
| 618 | ]; | 618 | ]; |
| 619 | } rep; | 619 | } rep; |
| 620 | struct ip_reply_arg arg; | 620 | struct ip_reply_arg arg; |
| 621 | struct net *net = dev_net(skb->dev); | 621 | struct net *net = dev_net(skb->dst->dev); |
| 622 | 622 | ||
| 623 | memset(&rep.th, 0, sizeof(struct tcphdr)); | 623 | memset(&rep.th, 0, sizeof(struct tcphdr)); |
| 624 | memset(&arg, 0, sizeof(arg)); | 624 | memset(&arg, 0, sizeof(arg)); |
| @@ -2376,6 +2376,7 @@ static int __net_init tcp_sk_init(struct net *net) | |||
| 2376 | static void __net_exit tcp_sk_exit(struct net *net) | 2376 | static void __net_exit tcp_sk_exit(struct net *net) |
| 2377 | { | 2377 | { |
| 2378 | inet_ctl_sock_destroy(net->ipv4.tcp_sock); | 2378 | inet_ctl_sock_destroy(net->ipv4.tcp_sock); |
| 2379 | inet_twsk_purge(net, &tcp_hashinfo, &tcp_death_row, AF_INET); | ||
| 2379 | } | 2380 | } |
| 2380 | 2381 | ||
| 2381 | static struct pernet_operations __net_initdata tcp_sk_ops = { | 2382 | static struct pernet_operations __net_initdata tcp_sk_ops = { |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index a00532de2a8c..8165f5aa8c71 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -468,7 +468,8 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, | |||
| 468 | } | 468 | } |
| 469 | if (likely(sysctl_tcp_window_scaling)) { | 469 | if (likely(sysctl_tcp_window_scaling)) { |
| 470 | opts->ws = tp->rx_opt.rcv_wscale; | 470 | opts->ws = tp->rx_opt.rcv_wscale; |
| 471 | size += TCPOLEN_WSCALE_ALIGNED; | 471 | if(likely(opts->ws)) |
| 472 | size += TCPOLEN_WSCALE_ALIGNED; | ||
| 472 | } | 473 | } |
| 473 | if (likely(sysctl_tcp_sack)) { | 474 | if (likely(sysctl_tcp_sack)) { |
| 474 | opts->options |= OPTION_SACK_ADVERTISE; | 475 | opts->options |= OPTION_SACK_ADVERTISE; |
| @@ -509,7 +510,8 @@ static unsigned tcp_synack_options(struct sock *sk, | |||
| 509 | 510 | ||
| 510 | if (likely(ireq->wscale_ok)) { | 511 | if (likely(ireq->wscale_ok)) { |
| 511 | opts->ws = ireq->rcv_wscale; | 512 | opts->ws = ireq->rcv_wscale; |
| 512 | size += TCPOLEN_WSCALE_ALIGNED; | 513 | if(likely(opts->ws)) |
| 514 | size += TCPOLEN_WSCALE_ALIGNED; | ||
| 513 | } | 515 | } |
| 514 | if (likely(doing_ts)) { | 516 | if (likely(doing_ts)) { |
| 515 | opts->options |= OPTION_TS; | 517 | opts->options |= OPTION_TS; |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 8e42fbbd5761..57e26fa66185 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -951,6 +951,27 @@ int udp_disconnect(struct sock *sk, int flags) | |||
| 951 | return 0; | 951 | return 0; |
| 952 | } | 952 | } |
| 953 | 953 | ||
| 954 | static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | ||
| 955 | { | ||
| 956 | int is_udplite = IS_UDPLITE(sk); | ||
| 957 | int rc; | ||
| 958 | |||
| 959 | if ((rc = sock_queue_rcv_skb(sk, skb)) < 0) { | ||
| 960 | /* Note that an ENOMEM error is charged twice */ | ||
| 961 | if (rc == -ENOMEM) | ||
| 962 | UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS, | ||
| 963 | is_udplite); | ||
| 964 | goto drop; | ||
| 965 | } | ||
| 966 | |||
| 967 | return 0; | ||
| 968 | |||
| 969 | drop: | ||
| 970 | UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite); | ||
| 971 | kfree_skb(skb); | ||
| 972 | return -1; | ||
| 973 | } | ||
| 974 | |||
| 954 | /* returns: | 975 | /* returns: |
| 955 | * -1: error | 976 | * -1: error |
| 956 | * 0: success | 977 | * 0: success |
| @@ -989,9 +1010,7 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) | |||
| 989 | up->encap_rcv != NULL) { | 1010 | up->encap_rcv != NULL) { |
| 990 | int ret; | 1011 | int ret; |
| 991 | 1012 | ||
| 992 | bh_unlock_sock(sk); | ||
| 993 | ret = (*up->encap_rcv)(sk, skb); | 1013 | ret = (*up->encap_rcv)(sk, skb); |
| 994 | bh_lock_sock(sk); | ||
| 995 | if (ret <= 0) { | 1014 | if (ret <= 0) { |
| 996 | UDP_INC_STATS_BH(sock_net(sk), | 1015 | UDP_INC_STATS_BH(sock_net(sk), |
| 997 | UDP_MIB_INDATAGRAMS, | 1016 | UDP_MIB_INDATAGRAMS, |
| @@ -1044,17 +1063,16 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) | |||
| 1044 | goto drop; | 1063 | goto drop; |
| 1045 | } | 1064 | } |
| 1046 | 1065 | ||
| 1047 | if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { | 1066 | rc = 0; |
| 1048 | /* Note that an ENOMEM error is charged twice */ | ||
| 1049 | if (rc == -ENOMEM) { | ||
| 1050 | UDP_INC_STATS_BH(sock_net(sk), | ||
| 1051 | UDP_MIB_RCVBUFERRORS, is_udplite); | ||
| 1052 | atomic_inc(&sk->sk_drops); | ||
| 1053 | } | ||
| 1054 | goto drop; | ||
| 1055 | } | ||
| 1056 | 1067 | ||
| 1057 | return 0; | 1068 | bh_lock_sock(sk); |
| 1069 | if (!sock_owned_by_user(sk)) | ||
| 1070 | rc = __udp_queue_rcv_skb(sk, skb); | ||
| 1071 | else | ||
| 1072 | sk_add_backlog(sk, skb); | ||
| 1073 | bh_unlock_sock(sk); | ||
| 1074 | |||
| 1075 | return rc; | ||
| 1058 | 1076 | ||
| 1059 | drop: | 1077 | drop: |
| 1060 | UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite); | 1078 | UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite); |
| @@ -1092,15 +1110,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb, | |||
| 1092 | skb1 = skb_clone(skb, GFP_ATOMIC); | 1110 | skb1 = skb_clone(skb, GFP_ATOMIC); |
| 1093 | 1111 | ||
| 1094 | if (skb1) { | 1112 | if (skb1) { |
| 1095 | int ret = 0; | 1113 | int ret = udp_queue_rcv_skb(sk, skb1); |
| 1096 | |||
| 1097 | bh_lock_sock(sk); | ||
| 1098 | if (!sock_owned_by_user(sk)) | ||
| 1099 | ret = udp_queue_rcv_skb(sk, skb1); | ||
| 1100 | else | ||
| 1101 | sk_add_backlog(sk, skb1); | ||
| 1102 | bh_unlock_sock(sk); | ||
| 1103 | |||
| 1104 | if (ret > 0) | 1114 | if (ret > 0) |
| 1105 | /* we should probably re-process instead | 1115 | /* we should probably re-process instead |
| 1106 | * of dropping packets here. */ | 1116 | * of dropping packets here. */ |
| @@ -1195,13 +1205,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
| 1195 | uh->dest, inet_iif(skb), udptable); | 1205 | uh->dest, inet_iif(skb), udptable); |
| 1196 | 1206 | ||
| 1197 | if (sk != NULL) { | 1207 | if (sk != NULL) { |
| 1198 | int ret = 0; | 1208 | int ret = udp_queue_rcv_skb(sk, skb); |
| 1199 | bh_lock_sock(sk); | ||
| 1200 | if (!sock_owned_by_user(sk)) | ||
| 1201 | ret = udp_queue_rcv_skb(sk, skb); | ||
| 1202 | else | ||
| 1203 | sk_add_backlog(sk, skb); | ||
| 1204 | bh_unlock_sock(sk); | ||
| 1205 | sock_put(sk); | 1209 | sock_put(sk); |
| 1206 | 1210 | ||
| 1207 | /* a return value > 0 means to resubmit the input, but | 1211 | /* a return value > 0 means to resubmit the input, but |
| @@ -1494,7 +1498,7 @@ struct proto udp_prot = { | |||
| 1494 | .sendmsg = udp_sendmsg, | 1498 | .sendmsg = udp_sendmsg, |
| 1495 | .recvmsg = udp_recvmsg, | 1499 | .recvmsg = udp_recvmsg, |
| 1496 | .sendpage = udp_sendpage, | 1500 | .sendpage = udp_sendpage, |
| 1497 | .backlog_rcv = udp_queue_rcv_skb, | 1501 | .backlog_rcv = __udp_queue_rcv_skb, |
| 1498 | .hash = udp_lib_hash, | 1502 | .hash = udp_lib_hash, |
| 1499 | .unhash = udp_lib_unhash, | 1503 | .unhash = udp_lib_unhash, |
| 1500 | .get_port = udp_v4_get_port, | 1504 | .get_port = udp_v4_get_port, |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index a7842c54f58a..7b6a584b62dd 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
| @@ -1106,13 +1106,12 @@ out: | |||
| 1106 | return ret; | 1106 | return ret; |
| 1107 | } | 1107 | } |
| 1108 | 1108 | ||
| 1109 | int ipv6_dev_get_saddr(struct net_device *dst_dev, | 1109 | int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev, |
| 1110 | const struct in6_addr *daddr, unsigned int prefs, | 1110 | const struct in6_addr *daddr, unsigned int prefs, |
| 1111 | struct in6_addr *saddr) | 1111 | struct in6_addr *saddr) |
| 1112 | { | 1112 | { |
| 1113 | struct ipv6_saddr_score scores[2], | 1113 | struct ipv6_saddr_score scores[2], |
| 1114 | *score = &scores[0], *hiscore = &scores[1]; | 1114 | *score = &scores[0], *hiscore = &scores[1]; |
| 1115 | struct net *net = dev_net(dst_dev); | ||
| 1116 | struct ipv6_saddr_dst dst; | 1115 | struct ipv6_saddr_dst dst; |
| 1117 | struct net_device *dev; | 1116 | struct net_device *dev; |
| 1118 | int dst_type; | 1117 | int dst_type; |
| @@ -1689,6 +1688,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev, | |||
| 1689 | .fc_dst_len = plen, | 1688 | .fc_dst_len = plen, |
| 1690 | .fc_flags = RTF_UP | flags, | 1689 | .fc_flags = RTF_UP | flags, |
| 1691 | .fc_nlinfo.nl_net = dev_net(dev), | 1690 | .fc_nlinfo.nl_net = dev_net(dev), |
| 1691 | .fc_protocol = RTPROT_KERNEL, | ||
| 1692 | }; | 1692 | }; |
| 1693 | 1693 | ||
| 1694 | ipv6_addr_copy(&cfg.fc_dst, pfx); | 1694 | ipv6_addr_copy(&cfg.fc_dst, pfx); |
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 8d05527524e3..f5de3f9dc692 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
| @@ -93,7 +93,8 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp, | |||
| 93 | if (flags & RT6_LOOKUP_F_SRCPREF_COA) | 93 | if (flags & RT6_LOOKUP_F_SRCPREF_COA) |
| 94 | srcprefs |= IPV6_PREFER_SRC_COA; | 94 | srcprefs |= IPV6_PREFER_SRC_COA; |
| 95 | 95 | ||
| 96 | if (ipv6_dev_get_saddr(ip6_dst_idev(&rt->u.dst)->dev, | 96 | if (ipv6_dev_get_saddr(net, |
| 97 | ip6_dst_idev(&rt->u.dst)->dev, | ||
| 97 | &flp->fl6_dst, srcprefs, | 98 | &flp->fl6_dst, srcprefs, |
| 98 | &saddr)) | 99 | &saddr)) |
| 99 | goto again; | 100 | goto again; |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index abedf95fdf2d..b3157a0cc15d 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
| @@ -91,19 +91,22 @@ static struct inet6_protocol icmpv6_protocol = { | |||
| 91 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 91 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, |
| 92 | }; | 92 | }; |
| 93 | 93 | ||
| 94 | static __inline__ int icmpv6_xmit_lock(struct sock *sk) | 94 | static __inline__ struct sock *icmpv6_xmit_lock(struct net *net) |
| 95 | { | 95 | { |
| 96 | struct sock *sk; | ||
| 97 | |||
| 96 | local_bh_disable(); | 98 | local_bh_disable(); |
| 97 | 99 | ||
| 100 | sk = icmpv6_sk(net); | ||
| 98 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { | 101 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { |
| 99 | /* This can happen if the output path (f.e. SIT or | 102 | /* This can happen if the output path (f.e. SIT or |
| 100 | * ip6ip6 tunnel) signals dst_link_failure() for an | 103 | * ip6ip6 tunnel) signals dst_link_failure() for an |
| 101 | * outgoing ICMP6 packet. | 104 | * outgoing ICMP6 packet. |
| 102 | */ | 105 | */ |
| 103 | local_bh_enable(); | 106 | local_bh_enable(); |
| 104 | return 1; | 107 | return NULL; |
| 105 | } | 108 | } |
| 106 | return 0; | 109 | return sk; |
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | static __inline__ void icmpv6_xmit_unlock(struct sock *sk) | 112 | static __inline__ void icmpv6_xmit_unlock(struct sock *sk) |
| @@ -392,11 +395,10 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
| 392 | fl.fl_icmp_code = code; | 395 | fl.fl_icmp_code = code; |
| 393 | security_skb_classify_flow(skb, &fl); | 396 | security_skb_classify_flow(skb, &fl); |
| 394 | 397 | ||
| 395 | sk = icmpv6_sk(net); | 398 | sk = icmpv6_xmit_lock(net); |
| 396 | np = inet6_sk(sk); | 399 | if (sk == NULL) |
| 397 | |||
| 398 | if (icmpv6_xmit_lock(sk)) | ||
| 399 | return; | 400 | return; |
| 401 | np = inet6_sk(sk); | ||
| 400 | 402 | ||
| 401 | if (!icmpv6_xrlim_allow(sk, type, &fl)) | 403 | if (!icmpv6_xrlim_allow(sk, type, &fl)) |
| 402 | goto out; | 404 | goto out; |
| @@ -539,11 +541,10 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
| 539 | fl.fl_icmp_type = ICMPV6_ECHO_REPLY; | 541 | fl.fl_icmp_type = ICMPV6_ECHO_REPLY; |
| 540 | security_skb_classify_flow(skb, &fl); | 542 | security_skb_classify_flow(skb, &fl); |
| 541 | 543 | ||
| 542 | sk = icmpv6_sk(net); | 544 | sk = icmpv6_xmit_lock(net); |
| 543 | np = inet6_sk(sk); | 545 | if (sk == NULL) |
| 544 | |||
| 545 | if (icmpv6_xmit_lock(sk)) | ||
| 546 | return; | 546 | return; |
| 547 | np = inet6_sk(sk); | ||
| 547 | 548 | ||
| 548 | if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) | 549 | if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) |
| 549 | fl.oif = np->mcast_oif; | 550 | fl.oif = np->mcast_oif; |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 52dddc25d3e6..29c7c99e69f7 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
| @@ -378,6 +378,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 378 | 378 | ||
| 379 | arg.skb = skb; | 379 | arg.skb = skb; |
| 380 | arg.cb = cb; | 380 | arg.cb = cb; |
| 381 | arg.net = net; | ||
| 381 | w->args = &arg; | 382 | w->args = &arg; |
| 382 | 383 | ||
| 383 | for (h = s_h; h < FIB_TABLE_HASHSZ; h++, s_e = 0) { | 384 | for (h = s_h; h < FIB_TABLE_HASHSZ; h++, s_e = 0) { |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index a4402de425d9..3df2c442d90b 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -934,7 +934,7 @@ static int ip6_dst_lookup_tail(struct sock *sk, | |||
| 934 | goto out_err_release; | 934 | goto out_err_release; |
| 935 | 935 | ||
| 936 | if (ipv6_addr_any(&fl->fl6_src)) { | 936 | if (ipv6_addr_any(&fl->fl6_src)) { |
| 937 | err = ipv6_dev_get_saddr(ip6_dst_idev(*dst)->dev, | 937 | err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev, |
| 938 | &fl->fl6_dst, | 938 | &fl->fl6_dst, |
| 939 | sk ? inet6_sk(sk)->srcprefs : 0, | 939 | sk ? inet6_sk(sk)->srcprefs : 0, |
| 940 | &fl->fl6_src); | 940 | &fl->fl6_src); |
| @@ -943,39 +943,39 @@ static int ip6_dst_lookup_tail(struct sock *sk, | |||
| 943 | } | 943 | } |
| 944 | 944 | ||
| 945 | #ifdef CONFIG_IPV6_OPTIMISTIC_DAD | 945 | #ifdef CONFIG_IPV6_OPTIMISTIC_DAD |
| 946 | /* | 946 | /* |
| 947 | * Here if the dst entry we've looked up | 947 | * Here if the dst entry we've looked up |
| 948 | * has a neighbour entry that is in the INCOMPLETE | 948 | * has a neighbour entry that is in the INCOMPLETE |
| 949 | * state and the src address from the flow is | 949 | * state and the src address from the flow is |
| 950 | * marked as OPTIMISTIC, we release the found | 950 | * marked as OPTIMISTIC, we release the found |
| 951 | * dst entry and replace it instead with the | 951 | * dst entry and replace it instead with the |
| 952 | * dst entry of the nexthop router | 952 | * dst entry of the nexthop router |
| 953 | */ | 953 | */ |
| 954 | if (!((*dst)->neighbour->nud_state & NUD_VALID)) { | 954 | if ((*dst)->neighbour && !((*dst)->neighbour->nud_state & NUD_VALID)) { |
| 955 | struct inet6_ifaddr *ifp; | 955 | struct inet6_ifaddr *ifp; |
| 956 | struct flowi fl_gw; | 956 | struct flowi fl_gw; |
| 957 | int redirect; | 957 | int redirect; |
| 958 | 958 | ||
| 959 | ifp = ipv6_get_ifaddr(net, &fl->fl6_src, | 959 | ifp = ipv6_get_ifaddr(net, &fl->fl6_src, |
| 960 | (*dst)->dev, 1); | 960 | (*dst)->dev, 1); |
| 961 | 961 | ||
| 962 | redirect = (ifp && ifp->flags & IFA_F_OPTIMISTIC); | 962 | redirect = (ifp && ifp->flags & IFA_F_OPTIMISTIC); |
| 963 | if (ifp) | 963 | if (ifp) |
| 964 | in6_ifa_put(ifp); | 964 | in6_ifa_put(ifp); |
| 965 | 965 | ||
| 966 | if (redirect) { | 966 | if (redirect) { |
| 967 | /* | 967 | /* |
| 968 | * We need to get the dst entry for the | 968 | * We need to get the dst entry for the |
| 969 | * default router instead | 969 | * default router instead |
| 970 | */ | 970 | */ |
| 971 | dst_release(*dst); | 971 | dst_release(*dst); |
| 972 | memcpy(&fl_gw, fl, sizeof(struct flowi)); | 972 | memcpy(&fl_gw, fl, sizeof(struct flowi)); |
| 973 | memset(&fl_gw.fl6_dst, 0, sizeof(struct in6_addr)); | 973 | memset(&fl_gw.fl6_dst, 0, sizeof(struct in6_addr)); |
| 974 | *dst = ip6_route_output(net, sk, &fl_gw); | 974 | *dst = ip6_route_output(net, sk, &fl_gw); |
| 975 | if ((err = (*dst)->error)) | 975 | if ((err = (*dst)->error)) |
| 976 | goto out_err_release; | 976 | goto out_err_release; |
| 977 | } | ||
| 978 | } | 977 | } |
| 978 | } | ||
| 979 | #endif | 979 | #endif |
| 980 | 980 | ||
| 981 | return 0; | 981 | return 0; |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 741cfcd96f88..4e5eac301f91 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
| @@ -911,7 +911,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 911 | } else { | 911 | } else { |
| 912 | if (np->rxopt.bits.rxinfo) { | 912 | if (np->rxopt.bits.rxinfo) { |
| 913 | struct in6_pktinfo src_info; | 913 | struct in6_pktinfo src_info; |
| 914 | src_info.ipi6_ifindex = np->mcast_oif; | 914 | src_info.ipi6_ifindex = np->mcast_oif ? np->mcast_oif : sk->sk_bound_dev_if; |
| 915 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); | 915 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); |
| 916 | put_cmsg(&msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info); | 916 | put_cmsg(&msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info); |
| 917 | } | 917 | } |
| @@ -921,7 +921,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
| 921 | } | 921 | } |
| 922 | if (np->rxopt.bits.rxoinfo) { | 922 | if (np->rxopt.bits.rxoinfo) { |
| 923 | struct in6_pktinfo src_info; | 923 | struct in6_pktinfo src_info; |
| 924 | src_info.ipi6_ifindex = np->mcast_oif; | 924 | src_info.ipi6_ifindex = np->mcast_oif ? np->mcast_oif : sk->sk_bound_dev_if; |
| 925 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); | 925 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); |
| 926 | put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); | 926 | put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); |
| 927 | } | 927 | } |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index beb48e3f038a..f1c62ba0f56b 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
| @@ -549,7 +549,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, | |||
| 549 | override = 0; | 549 | override = 0; |
| 550 | in6_ifa_put(ifp); | 550 | in6_ifa_put(ifp); |
| 551 | } else { | 551 | } else { |
| 552 | if (ipv6_dev_get_saddr(dev, daddr, | 552 | if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr, |
| 553 | inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs, | 553 | inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs, |
| 554 | &tmpaddr)) | 554 | &tmpaddr)) |
| 555 | return; | 555 | return; |
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c index 62e39ace0588..26654b26d7fa 100644 --- a/net/ipv6/netfilter/ip6t_hbh.c +++ b/net/ipv6/netfilter/ip6t_hbh.c | |||
| @@ -97,8 +97,6 @@ hbh_mt6(const struct sk_buff *skb, const struct net_device *in, | |||
| 97 | hdrlen -= 2; | 97 | hdrlen -= 2; |
| 98 | if (!(optinfo->flags & IP6T_OPTS_OPTS)) { | 98 | if (!(optinfo->flags & IP6T_OPTS_OPTS)) { |
| 99 | return ret; | 99 | return ret; |
| 100 | } else if (optinfo->flags & IP6T_OPTS_NSTRICT) { | ||
| 101 | pr_debug("Not strict - not implemented"); | ||
| 102 | } else { | 100 | } else { |
| 103 | pr_debug("Strict "); | 101 | pr_debug("Strict "); |
| 104 | pr_debug("#%d ", optinfo->optsnr); | 102 | pr_debug("#%d ", optinfo->optsnr); |
| @@ -177,6 +175,12 @@ hbh_mt6_check(const char *tablename, const void *entry, | |||
| 177 | pr_debug("ip6t_opts: unknown flags %X\n", optsinfo->invflags); | 175 | pr_debug("ip6t_opts: unknown flags %X\n", optsinfo->invflags); |
| 178 | return false; | 176 | return false; |
| 179 | } | 177 | } |
| 178 | |||
| 179 | if (optsinfo->flags & IP6T_OPTS_NSTRICT) { | ||
| 180 | pr_debug("ip6t_opts: Not strict - not implemented"); | ||
| 181 | return false; | ||
| 182 | } | ||
| 183 | |||
| 180 | return true; | 184 | return true; |
| 181 | } | 185 | } |
| 182 | 186 | ||
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 01d47674f7e5..e53e493606c5 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
| @@ -377,14 +377,14 @@ static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb) | |||
| 377 | skb_checksum_complete(skb)) { | 377 | skb_checksum_complete(skb)) { |
| 378 | atomic_inc(&sk->sk_drops); | 378 | atomic_inc(&sk->sk_drops); |
| 379 | kfree_skb(skb); | 379 | kfree_skb(skb); |
| 380 | return 0; | 380 | return NET_RX_DROP; |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | /* Charge it to the socket. */ | 383 | /* Charge it to the socket. */ |
| 384 | if (sock_queue_rcv_skb(sk,skb)<0) { | 384 | if (sock_queue_rcv_skb(sk,skb)<0) { |
| 385 | atomic_inc(&sk->sk_drops); | 385 | atomic_inc(&sk->sk_drops); |
| 386 | kfree_skb(skb); | 386 | kfree_skb(skb); |
| 387 | return 0; | 387 | return NET_RX_DROP; |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | return 0; | 390 | return 0; |
| @@ -429,7 +429,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 429 | if (skb_checksum_complete(skb)) { | 429 | if (skb_checksum_complete(skb)) { |
| 430 | atomic_inc(&sk->sk_drops); | 430 | atomic_inc(&sk->sk_drops); |
| 431 | kfree_skb(skb); | 431 | kfree_skb(skb); |
| 432 | return 0; | 432 | return NET_RX_DROP; |
| 433 | } | 433 | } |
| 434 | } | 434 | } |
| 435 | 435 | ||
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 41b165ffb369..63442a1e741c 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
| @@ -2106,7 +2106,8 @@ static inline size_t rt6_nlmsg_size(void) | |||
| 2106 | + nla_total_size(sizeof(struct rta_cacheinfo)); | 2106 | + nla_total_size(sizeof(struct rta_cacheinfo)); |
| 2107 | } | 2107 | } |
| 2108 | 2108 | ||
| 2109 | static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | 2109 | static int rt6_fill_node(struct net *net, |
| 2110 | struct sk_buff *skb, struct rt6_info *rt, | ||
| 2110 | struct in6_addr *dst, struct in6_addr *src, | 2111 | struct in6_addr *dst, struct in6_addr *src, |
| 2111 | int iif, int type, u32 pid, u32 seq, | 2112 | int iif, int type, u32 pid, u32 seq, |
| 2112 | int prefix, int nowait, unsigned int flags) | 2113 | int prefix, int nowait, unsigned int flags) |
| @@ -2189,7 +2190,7 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | |||
| 2189 | } else if (dst) { | 2190 | } else if (dst) { |
| 2190 | struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst); | 2191 | struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst); |
| 2191 | struct in6_addr saddr_buf; | 2192 | struct in6_addr saddr_buf; |
| 2192 | if (ipv6_dev_get_saddr(idev ? idev->dev : NULL, | 2193 | if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL, |
| 2193 | dst, 0, &saddr_buf) == 0) | 2194 | dst, 0, &saddr_buf) == 0) |
| 2194 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); | 2195 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); |
| 2195 | } | 2196 | } |
| @@ -2234,7 +2235,8 @@ int rt6_dump_route(struct rt6_info *rt, void *p_arg) | |||
| 2234 | } else | 2235 | } else |
| 2235 | prefix = 0; | 2236 | prefix = 0; |
| 2236 | 2237 | ||
| 2237 | return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE, | 2238 | return rt6_fill_node(arg->net, |
| 2239 | arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE, | ||
| 2238 | NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq, | 2240 | NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq, |
| 2239 | prefix, 0, NLM_F_MULTI); | 2241 | prefix, 0, NLM_F_MULTI); |
| 2240 | } | 2242 | } |
| @@ -2300,7 +2302,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
| 2300 | rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl); | 2302 | rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl); |
| 2301 | skb->dst = &rt->u.dst; | 2303 | skb->dst = &rt->u.dst; |
| 2302 | 2304 | ||
| 2303 | err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, | 2305 | err = rt6_fill_node(net, skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, |
| 2304 | RTM_NEWROUTE, NETLINK_CB(in_skb).pid, | 2306 | RTM_NEWROUTE, NETLINK_CB(in_skb).pid, |
| 2305 | nlh->nlmsg_seq, 0, 0, 0); | 2307 | nlh->nlmsg_seq, 0, 0, 0); |
| 2306 | if (err < 0) { | 2308 | if (err < 0) { |
| @@ -2327,7 +2329,7 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) | |||
| 2327 | if (skb == NULL) | 2329 | if (skb == NULL) |
| 2328 | goto errout; | 2330 | goto errout; |
| 2329 | 2331 | ||
| 2330 | err = rt6_fill_node(skb, rt, NULL, NULL, 0, | 2332 | err = rt6_fill_node(net, skb, rt, NULL, NULL, 0, |
| 2331 | event, info->pid, seq, 0, 0, 0); | 2333 | event, info->pid, seq, 0, 0, 0); |
| 2332 | if (err < 0) { | 2334 | if (err < 0) { |
| 2333 | /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ | 2335 | /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ |
| @@ -2686,6 +2688,8 @@ int __init ip6_route_init(void) | |||
| 2686 | if (ret) | 2688 | if (ret) |
| 2687 | goto out_kmem_cache; | 2689 | goto out_kmem_cache; |
| 2688 | 2690 | ||
| 2691 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops_template.kmem_cachep; | ||
| 2692 | |||
| 2689 | /* Registering of the loopback is done before this portion of code, | 2693 | /* Registering of the loopback is done before this portion of code, |
| 2690 | * the loopback reference in rt6_info will not be taken, do it | 2694 | * the loopback reference in rt6_info will not be taken, do it |
| 2691 | * manually for init_net */ | 2695 | * manually for init_net */ |
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index e6dfaeac6be3..587f8f60c489 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c | |||
| @@ -156,7 +156,7 @@ static struct ctl_table_header *ip6_base; | |||
| 156 | int ipv6_static_sysctl_register(void) | 156 | int ipv6_static_sysctl_register(void) |
| 157 | { | 157 | { |
| 158 | static struct ctl_table empty[1]; | 158 | static struct ctl_table empty[1]; |
| 159 | ip6_base = register_net_sysctl_rotable(net_ipv6_ctl_path, empty); | 159 | ip6_base = register_sysctl_paths(net_ipv6_ctl_path, empty); |
| 160 | if (ip6_base == NULL) | 160 | if (ip6_base == NULL) |
| 161 | return -ENOMEM; | 161 | return -ENOMEM; |
| 162 | return 0; | 162 | return 0; |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 5b90b369ccb2..10e22fd48222 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
| @@ -1050,7 +1050,7 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 | |||
| 1050 | struct tcphdr *th = tcp_hdr(skb), *t1; | 1050 | struct tcphdr *th = tcp_hdr(skb), *t1; |
| 1051 | struct sk_buff *buff; | 1051 | struct sk_buff *buff; |
| 1052 | struct flowi fl; | 1052 | struct flowi fl; |
| 1053 | struct net *net = dev_net(skb->dev); | 1053 | struct net *net = dev_net(skb->dst->dev); |
| 1054 | struct sock *ctl_sk = net->ipv6.tcp_sk; | 1054 | struct sock *ctl_sk = net->ipv6.tcp_sk; |
| 1055 | unsigned int tot_len = sizeof(struct tcphdr); | 1055 | unsigned int tot_len = sizeof(struct tcphdr); |
| 1056 | __be32 *topt; | 1056 | __be32 *topt; |
| @@ -2148,6 +2148,7 @@ static int tcpv6_net_init(struct net *net) | |||
| 2148 | static void tcpv6_net_exit(struct net *net) | 2148 | static void tcpv6_net_exit(struct net *net) |
| 2149 | { | 2149 | { |
| 2150 | inet_ctl_sock_destroy(net->ipv6.tcp_sk); | 2150 | inet_ctl_sock_destroy(net->ipv6.tcp_sk); |
| 2151 | inet_twsk_purge(net, &tcp_hashinfo, &tcp_death_row, AF_INET6); | ||
| 2151 | } | 2152 | } |
| 2152 | 2153 | ||
| 2153 | static struct pernet_operations tcpv6_net_ops = { | 2154 | static struct pernet_operations tcpv6_net_ops = { |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 8f1e0543b3c4..08e4cbbe3f04 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
| @@ -52,12 +52,14 @@ static struct dst_entry *xfrm6_dst_lookup(int tos, xfrm_address_t *saddr, | |||
| 52 | static int xfrm6_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr) | 52 | static int xfrm6_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr) |
| 53 | { | 53 | { |
| 54 | struct dst_entry *dst; | 54 | struct dst_entry *dst; |
| 55 | struct net_device *dev; | ||
| 55 | 56 | ||
| 56 | dst = xfrm6_dst_lookup(0, NULL, daddr); | 57 | dst = xfrm6_dst_lookup(0, NULL, daddr); |
| 57 | if (IS_ERR(dst)) | 58 | if (IS_ERR(dst)) |
| 58 | return -EHOSTUNREACH; | 59 | return -EHOSTUNREACH; |
| 59 | 60 | ||
| 60 | ipv6_dev_get_saddr(ip6_dst_idev(dst)->dev, | 61 | dev = ip6_dst_idev(dst)->dev; |
| 62 | ipv6_dev_get_saddr(dev_net(dev), dev, | ||
| 61 | (struct in6_addr *)&daddr->a6, 0, | 63 | (struct in6_addr *)&daddr->a6, 0, |
| 62 | (struct in6_addr *)&saddr->a6); | 64 | (struct in6_addr *)&saddr->a6); |
| 63 | dst_release(dst); | 65 | dst_release(dst); |
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index 705959b31e24..d7b54b5bfa69 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c | |||
| @@ -524,7 +524,6 @@ static int iucv_enable(void) | |||
| 524 | get_online_cpus(); | 524 | get_online_cpus(); |
| 525 | for_each_online_cpu(cpu) | 525 | for_each_online_cpu(cpu) |
| 526 | smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1); | 526 | smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1); |
| 527 | preempt_enable(); | ||
| 528 | if (cpus_empty(iucv_buffer_cpumask)) | 527 | if (cpus_empty(iucv_buffer_cpumask)) |
| 529 | /* No cpu could declare an iucv buffer. */ | 528 | /* No cpu could declare an iucv buffer. */ |
| 530 | goto out_path; | 529 | goto out_path; |
| @@ -547,7 +546,9 @@ out: | |||
| 547 | */ | 546 | */ |
| 548 | static void iucv_disable(void) | 547 | static void iucv_disable(void) |
| 549 | { | 548 | { |
| 549 | get_online_cpus(); | ||
| 550 | on_each_cpu(iucv_retrieve_cpu, NULL, 1); | 550 | on_each_cpu(iucv_retrieve_cpu, NULL, 1); |
| 551 | put_online_cpus(); | ||
| 551 | kfree(iucv_path_table); | 552 | kfree(iucv_path_table); |
| 552 | } | 553 | } |
| 553 | 554 | ||
diff --git a/net/key/af_key.c b/net/key/af_key.c index d628df97e02e..b7f5a1c353ee 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
| @@ -73,22 +73,18 @@ static int pfkey_can_dump(struct sock *sk) | |||
| 73 | return 0; | 73 | return 0; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | static int pfkey_do_dump(struct pfkey_sock *pfk) | 76 | static void pfkey_terminate_dump(struct pfkey_sock *pfk) |
| 77 | { | 77 | { |
| 78 | int rc; | 78 | if (pfk->dump.dump) { |
| 79 | 79 | pfk->dump.done(pfk); | |
| 80 | rc = pfk->dump.dump(pfk); | 80 | pfk->dump.dump = NULL; |
| 81 | if (rc == -ENOBUFS) | 81 | pfk->dump.done = NULL; |
| 82 | return 0; | 82 | } |
| 83 | |||
| 84 | pfk->dump.done(pfk); | ||
| 85 | pfk->dump.dump = NULL; | ||
| 86 | pfk->dump.done = NULL; | ||
| 87 | return rc; | ||
| 88 | } | 83 | } |
| 89 | 84 | ||
| 90 | static void pfkey_sock_destruct(struct sock *sk) | 85 | static void pfkey_sock_destruct(struct sock *sk) |
| 91 | { | 86 | { |
| 87 | pfkey_terminate_dump(pfkey_sk(sk)); | ||
| 92 | skb_queue_purge(&sk->sk_receive_queue); | 88 | skb_queue_purge(&sk->sk_receive_queue); |
| 93 | 89 | ||
| 94 | if (!sock_flag(sk, SOCK_DEAD)) { | 90 | if (!sock_flag(sk, SOCK_DEAD)) { |
| @@ -310,6 +306,18 @@ static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation, | |||
| 310 | return err; | 306 | return err; |
| 311 | } | 307 | } |
| 312 | 308 | ||
| 309 | static int pfkey_do_dump(struct pfkey_sock *pfk) | ||
| 310 | { | ||
| 311 | int rc; | ||
| 312 | |||
| 313 | rc = pfk->dump.dump(pfk); | ||
| 314 | if (rc == -ENOBUFS) | ||
| 315 | return 0; | ||
| 316 | |||
| 317 | pfkey_terminate_dump(pfk); | ||
| 318 | return rc; | ||
| 319 | } | ||
| 320 | |||
| 313 | static inline void pfkey_hdr_dup(struct sadb_msg *new, struct sadb_msg *orig) | 321 | static inline void pfkey_hdr_dup(struct sadb_msg *new, struct sadb_msg *orig) |
| 314 | { | 322 | { |
| 315 | *new = *orig; | 323 | *new = *orig; |
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c index 7439b63df5d0..cf82acec913a 100644 --- a/net/mac80211/debugfs_key.c +++ b/net/mac80211/debugfs_key.c | |||
| @@ -265,7 +265,7 @@ void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) | |||
| 265 | key = sdata->default_key; | 265 | key = sdata->default_key; |
| 266 | if (key) { | 266 | if (key) { |
| 267 | sprintf(buf, "../keys/%d", key->debugfs.cnt); | 267 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
| 268 | sdata->debugfs.default_key = | 268 | sdata->common_debugfs.default_key = |
| 269 | debugfs_create_symlink("default_key", | 269 | debugfs_create_symlink("default_key", |
| 270 | sdata->debugfsdir, buf); | 270 | sdata->debugfsdir, buf); |
| 271 | } else | 271 | } else |
| @@ -277,8 +277,8 @@ void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) | |||
| 277 | if (!sdata) | 277 | if (!sdata) |
| 278 | return; | 278 | return; |
| 279 | 279 | ||
| 280 | debugfs_remove(sdata->debugfs.default_key); | 280 | debugfs_remove(sdata->common_debugfs.default_key); |
| 281 | sdata->debugfs.default_key = NULL; | 281 | sdata->common_debugfs.default_key = NULL; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, | 284 | void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 475f89a8aee1..8165df578c92 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
| @@ -248,8 +248,8 @@ IEEE80211_IF_WFILE(min_discovery_timeout, | |||
| 248 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) | 248 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) |
| 249 | { | 249 | { |
| 250 | DEBUGFS_ADD(drop_unencrypted, sta); | 250 | DEBUGFS_ADD(drop_unencrypted, sta); |
| 251 | DEBUGFS_ADD(force_unicast_rateidx, ap); | 251 | DEBUGFS_ADD(force_unicast_rateidx, sta); |
| 252 | DEBUGFS_ADD(max_ratectrl_rateidx, ap); | 252 | DEBUGFS_ADD(max_ratectrl_rateidx, sta); |
| 253 | 253 | ||
| 254 | DEBUGFS_ADD(state, sta); | 254 | DEBUGFS_ADD(state, sta); |
| 255 | DEBUGFS_ADD(bssid, sta); | 255 | DEBUGFS_ADD(bssid, sta); |
| @@ -283,8 +283,8 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata) | |||
| 283 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) | 283 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) |
| 284 | { | 284 | { |
| 285 | DEBUGFS_ADD(drop_unencrypted, wds); | 285 | DEBUGFS_ADD(drop_unencrypted, wds); |
| 286 | DEBUGFS_ADD(force_unicast_rateidx, ap); | 286 | DEBUGFS_ADD(force_unicast_rateidx, wds); |
| 287 | DEBUGFS_ADD(max_ratectrl_rateidx, ap); | 287 | DEBUGFS_ADD(max_ratectrl_rateidx, wds); |
| 288 | 288 | ||
| 289 | DEBUGFS_ADD(peer, wds); | 289 | DEBUGFS_ADD(peer, wds); |
| 290 | } | 290 | } |
| @@ -292,8 +292,8 @@ static void add_wds_files(struct ieee80211_sub_if_data *sdata) | |||
| 292 | static void add_vlan_files(struct ieee80211_sub_if_data *sdata) | 292 | static void add_vlan_files(struct ieee80211_sub_if_data *sdata) |
| 293 | { | 293 | { |
| 294 | DEBUGFS_ADD(drop_unencrypted, vlan); | 294 | DEBUGFS_ADD(drop_unencrypted, vlan); |
| 295 | DEBUGFS_ADD(force_unicast_rateidx, ap); | 295 | DEBUGFS_ADD(force_unicast_rateidx, vlan); |
| 296 | DEBUGFS_ADD(max_ratectrl_rateidx, ap); | 296 | DEBUGFS_ADD(max_ratectrl_rateidx, vlan); |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) | 299 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) |
| @@ -381,8 +381,8 @@ static void add_files(struct ieee80211_sub_if_data *sdata) | |||
| 381 | static void del_sta_files(struct ieee80211_sub_if_data *sdata) | 381 | static void del_sta_files(struct ieee80211_sub_if_data *sdata) |
| 382 | { | 382 | { |
| 383 | DEBUGFS_DEL(drop_unencrypted, sta); | 383 | DEBUGFS_DEL(drop_unencrypted, sta); |
| 384 | DEBUGFS_DEL(force_unicast_rateidx, ap); | 384 | DEBUGFS_DEL(force_unicast_rateidx, sta); |
| 385 | DEBUGFS_DEL(max_ratectrl_rateidx, ap); | 385 | DEBUGFS_DEL(max_ratectrl_rateidx, sta); |
| 386 | 386 | ||
| 387 | DEBUGFS_DEL(state, sta); | 387 | DEBUGFS_DEL(state, sta); |
| 388 | DEBUGFS_DEL(bssid, sta); | 388 | DEBUGFS_DEL(bssid, sta); |
| @@ -416,8 +416,8 @@ static void del_ap_files(struct ieee80211_sub_if_data *sdata) | |||
| 416 | static void del_wds_files(struct ieee80211_sub_if_data *sdata) | 416 | static void del_wds_files(struct ieee80211_sub_if_data *sdata) |
| 417 | { | 417 | { |
| 418 | DEBUGFS_DEL(drop_unencrypted, wds); | 418 | DEBUGFS_DEL(drop_unencrypted, wds); |
| 419 | DEBUGFS_DEL(force_unicast_rateidx, ap); | 419 | DEBUGFS_DEL(force_unicast_rateidx, wds); |
| 420 | DEBUGFS_DEL(max_ratectrl_rateidx, ap); | 420 | DEBUGFS_DEL(max_ratectrl_rateidx, wds); |
| 421 | 421 | ||
| 422 | DEBUGFS_DEL(peer, wds); | 422 | DEBUGFS_DEL(peer, wds); |
| 423 | } | 423 | } |
| @@ -425,8 +425,8 @@ static void del_wds_files(struct ieee80211_sub_if_data *sdata) | |||
| 425 | static void del_vlan_files(struct ieee80211_sub_if_data *sdata) | 425 | static void del_vlan_files(struct ieee80211_sub_if_data *sdata) |
| 426 | { | 426 | { |
| 427 | DEBUGFS_DEL(drop_unencrypted, vlan); | 427 | DEBUGFS_DEL(drop_unencrypted, vlan); |
| 428 | DEBUGFS_DEL(force_unicast_rateidx, ap); | 428 | DEBUGFS_DEL(force_unicast_rateidx, vlan); |
| 429 | DEBUGFS_DEL(max_ratectrl_rateidx, ap); | 429 | DEBUGFS_DEL(max_ratectrl_rateidx, vlan); |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | static void del_monitor_files(struct ieee80211_sub_if_data *sdata) | 432 | static void del_monitor_files(struct ieee80211_sub_if_data *sdata) |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index ec59345af65b..4498d8713652 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
| @@ -470,6 +470,8 @@ struct ieee80211_sub_if_data { | |||
| 470 | struct dentry *auth_transaction; | 470 | struct dentry *auth_transaction; |
| 471 | struct dentry *flags; | 471 | struct dentry *flags; |
| 472 | struct dentry *num_beacons_sta; | 472 | struct dentry *num_beacons_sta; |
| 473 | struct dentry *force_unicast_rateidx; | ||
| 474 | struct dentry *max_ratectrl_rateidx; | ||
| 473 | } sta; | 475 | } sta; |
| 474 | struct { | 476 | struct { |
| 475 | struct dentry *drop_unencrypted; | 477 | struct dentry *drop_unencrypted; |
| @@ -483,15 +485,21 @@ struct ieee80211_sub_if_data { | |||
| 483 | struct { | 485 | struct { |
| 484 | struct dentry *drop_unencrypted; | 486 | struct dentry *drop_unencrypted; |
| 485 | struct dentry *peer; | 487 | struct dentry *peer; |
| 488 | struct dentry *force_unicast_rateidx; | ||
| 489 | struct dentry *max_ratectrl_rateidx; | ||
| 486 | } wds; | 490 | } wds; |
| 487 | struct { | 491 | struct { |
| 488 | struct dentry *drop_unencrypted; | 492 | struct dentry *drop_unencrypted; |
| 493 | struct dentry *force_unicast_rateidx; | ||
| 494 | struct dentry *max_ratectrl_rateidx; | ||
| 489 | } vlan; | 495 | } vlan; |
| 490 | struct { | 496 | struct { |
| 491 | struct dentry *mode; | 497 | struct dentry *mode; |
| 492 | } monitor; | 498 | } monitor; |
| 493 | struct dentry *default_key; | ||
| 494 | } debugfs; | 499 | } debugfs; |
| 500 | struct { | ||
| 501 | struct dentry *default_key; | ||
| 502 | } common_debugfs; | ||
| 495 | 503 | ||
| 496 | #ifdef CONFIG_MAC80211_MESH | 504 | #ifdef CONFIG_MAC80211_MESH |
| 497 | struct dentry *mesh_stats_dir; | 505 | struct dentry *mesh_stats_dir; |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index b5933b271491..35f2f95f2fa7 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
| @@ -383,7 +383,7 @@ errcopy: | |||
| 383 | hlist_for_each_safe(p, q, &newtbl->hash_buckets[i]) | 383 | hlist_for_each_safe(p, q, &newtbl->hash_buckets[i]) |
| 384 | tbl->free_node(p, 0); | 384 | tbl->free_node(p, 0); |
| 385 | } | 385 | } |
| 386 | __mesh_table_free(tbl); | 386 | __mesh_table_free(newtbl); |
| 387 | endgrow: | 387 | endgrow: |
| 388 | return NULL; | 388 | return NULL; |
| 389 | } | 389 | } |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index e1d11c9b6729..902cac1bd246 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
| @@ -813,7 +813,7 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
| 813 | } | 813 | } |
| 814 | } | 814 | } |
| 815 | 815 | ||
| 816 | if (count == 8) { | 816 | if (rates_len > count) { |
| 817 | pos = skb_put(skb, rates_len - count + 2); | 817 | pos = skb_put(skb, rates_len - count + 2); |
| 818 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 818 | *pos++ = WLAN_EID_EXT_SUPP_RATES; |
| 819 | *pos++ = rates_len - count; | 819 | *pos++ = rates_len - count; |
| @@ -2103,6 +2103,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
| 2103 | rcu_read_unlock(); | 2103 | rcu_read_unlock(); |
| 2104 | return; | 2104 | return; |
| 2105 | } | 2105 | } |
| 2106 | /* update new sta with its last rx activity */ | ||
| 2107 | sta->last_rx = jiffies; | ||
| 2106 | } | 2108 | } |
| 2107 | 2109 | ||
| 2108 | /* | 2110 | /* |
| @@ -2866,7 +2868,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
| 2866 | jiffies); | 2868 | jiffies); |
| 2867 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 2869 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
| 2868 | if (beacon_timestamp > rx_timestamp) { | 2870 | if (beacon_timestamp > rx_timestamp) { |
| 2869 | #ifndef CONFIG_MAC80211_IBSS_DEBUG | 2871 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 2870 | printk(KERN_DEBUG "%s: beacon TSF higher than " | 2872 | printk(KERN_DEBUG "%s: beacon TSF higher than " |
| 2871 | "local TSF - IBSS merge with BSSID %s\n", | 2873 | "local TSF - IBSS merge with BSSID %s\n", |
| 2872 | dev->name, print_mac(mac, mgmt->bssid)); | 2874 | dev->name, print_mac(mac, mgmt->bssid)); |
diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c index 1b1226d6653f..20633fdf7e6b 100644 --- a/net/netfilter/nf_conntrack_irc.c +++ b/net/netfilter/nf_conntrack_irc.c | |||
| @@ -68,11 +68,21 @@ static const char *const dccprotos[] = { | |||
| 68 | static int parse_dcc(char *data, const char *data_end, u_int32_t *ip, | 68 | static int parse_dcc(char *data, const char *data_end, u_int32_t *ip, |
| 69 | u_int16_t *port, char **ad_beg_p, char **ad_end_p) | 69 | u_int16_t *port, char **ad_beg_p, char **ad_end_p) |
| 70 | { | 70 | { |
| 71 | char *tmp; | ||
| 72 | |||
| 71 | /* at least 12: "AAAAAAAA P\1\n" */ | 73 | /* at least 12: "AAAAAAAA P\1\n" */ |
| 72 | while (*data++ != ' ') | 74 | while (*data++ != ' ') |
| 73 | if (data > data_end - 12) | 75 | if (data > data_end - 12) |
| 74 | return -1; | 76 | return -1; |
| 75 | 77 | ||
| 78 | /* Make sure we have a newline character within the packet boundaries | ||
| 79 | * because simple_strtoul parses until the first invalid character. */ | ||
| 80 | for (tmp = data; tmp <= data_end; tmp++) | ||
| 81 | if (*tmp == '\n') | ||
| 82 | break; | ||
| 83 | if (tmp > data_end || *tmp != '\n') | ||
| 84 | return -1; | ||
| 85 | |||
| 76 | *ad_beg_p = data; | 86 | *ad_beg_p = data; |
| 77 | *ip = simple_strtoul(data, &data, 10); | 87 | *ip = simple_strtoul(data, &data, 10); |
| 78 | 88 | ||
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 105a616c5c78..a8752031adcb 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
| @@ -968,7 +968,7 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[]) | |||
| 968 | /* need to zero data of old helper */ | 968 | /* need to zero data of old helper */ |
| 969 | memset(&help->help, 0, sizeof(help->help)); | 969 | memset(&help->help, 0, sizeof(help->help)); |
| 970 | } else { | 970 | } else { |
| 971 | help = nf_ct_helper_ext_add(ct, GFP_KERNEL); | 971 | help = nf_ct_helper_ext_add(ct, GFP_ATOMIC); |
| 972 | if (help == NULL) | 972 | if (help == NULL) |
| 973 | return -ENOMEM; | 973 | return -ENOMEM; |
| 974 | } | 974 | } |
| @@ -1136,16 +1136,33 @@ ctnetlink_create_conntrack(struct nlattr *cda[], | |||
| 1136 | ct->timeout.expires = jiffies + ct->timeout.expires * HZ; | 1136 | ct->timeout.expires = jiffies + ct->timeout.expires * HZ; |
| 1137 | ct->status |= IPS_CONFIRMED; | 1137 | ct->status |= IPS_CONFIRMED; |
| 1138 | 1138 | ||
| 1139 | rcu_read_lock(); | ||
| 1140 | helper = __nf_ct_helper_find(rtuple); | ||
| 1141 | if (helper) { | ||
| 1142 | help = nf_ct_helper_ext_add(ct, GFP_ATOMIC); | ||
| 1143 | if (help == NULL) { | ||
| 1144 | rcu_read_unlock(); | ||
| 1145 | err = -ENOMEM; | ||
| 1146 | goto err; | ||
| 1147 | } | ||
| 1148 | /* not in hash table yet so not strictly necessary */ | ||
| 1149 | rcu_assign_pointer(help->helper, helper); | ||
| 1150 | } | ||
| 1151 | |||
| 1139 | if (cda[CTA_STATUS]) { | 1152 | if (cda[CTA_STATUS]) { |
| 1140 | err = ctnetlink_change_status(ct, cda); | 1153 | err = ctnetlink_change_status(ct, cda); |
| 1141 | if (err < 0) | 1154 | if (err < 0) { |
| 1155 | rcu_read_unlock(); | ||
| 1142 | goto err; | 1156 | goto err; |
| 1157 | } | ||
| 1143 | } | 1158 | } |
| 1144 | 1159 | ||
| 1145 | if (cda[CTA_PROTOINFO]) { | 1160 | if (cda[CTA_PROTOINFO]) { |
| 1146 | err = ctnetlink_change_protoinfo(ct, cda); | 1161 | err = ctnetlink_change_protoinfo(ct, cda); |
| 1147 | if (err < 0) | 1162 | if (err < 0) { |
| 1163 | rcu_read_unlock(); | ||
| 1148 | goto err; | 1164 | goto err; |
| 1165 | } | ||
| 1149 | } | 1166 | } |
| 1150 | 1167 | ||
| 1151 | nf_ct_acct_ext_add(ct, GFP_KERNEL); | 1168 | nf_ct_acct_ext_add(ct, GFP_KERNEL); |
| @@ -1155,19 +1172,6 @@ ctnetlink_create_conntrack(struct nlattr *cda[], | |||
| 1155 | ct->mark = ntohl(nla_get_be32(cda[CTA_MARK])); | 1172 | ct->mark = ntohl(nla_get_be32(cda[CTA_MARK])); |
| 1156 | #endif | 1173 | #endif |
| 1157 | 1174 | ||
| 1158 | rcu_read_lock(); | ||
| 1159 | helper = __nf_ct_helper_find(rtuple); | ||
| 1160 | if (helper) { | ||
| 1161 | help = nf_ct_helper_ext_add(ct, GFP_KERNEL); | ||
| 1162 | if (help == NULL) { | ||
| 1163 | rcu_read_unlock(); | ||
| 1164 | err = -ENOMEM; | ||
| 1165 | goto err; | ||
| 1166 | } | ||
| 1167 | /* not in hash table yet so not strictly necessary */ | ||
| 1168 | rcu_assign_pointer(help->helper, helper); | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | /* setup master conntrack: this is a confirmed expectation */ | 1175 | /* setup master conntrack: this is a confirmed expectation */ |
| 1172 | if (master_ct) { | 1176 | if (master_ct) { |
| 1173 | __set_bit(IPS_EXPECTED_BIT, &ct->status); | 1177 | __set_bit(IPS_EXPECTED_BIT, &ct->status); |
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index 654a4f7f12c6..9bd03967fea4 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c | |||
| @@ -45,12 +45,12 @@ static LIST_HEAD(gre_keymap_list); | |||
| 45 | 45 | ||
| 46 | void nf_ct_gre_keymap_flush(void) | 46 | void nf_ct_gre_keymap_flush(void) |
| 47 | { | 47 | { |
| 48 | struct list_head *pos, *n; | 48 | struct nf_ct_gre_keymap *km, *tmp; |
| 49 | 49 | ||
| 50 | write_lock_bh(&nf_ct_gre_lock); | 50 | write_lock_bh(&nf_ct_gre_lock); |
| 51 | list_for_each_safe(pos, n, &gre_keymap_list) { | 51 | list_for_each_entry_safe(km, tmp, &gre_keymap_list, list) { |
| 52 | list_del(pos); | 52 | list_del(&km->list); |
| 53 | kfree(pos); | 53 | kfree(km); |
| 54 | } | 54 | } |
| 55 | write_unlock_bh(&nf_ct_gre_lock); | 55 | write_unlock_bh(&nf_ct_gre_lock); |
| 56 | } | 56 | } |
| @@ -97,10 +97,14 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir, | |||
| 97 | kmp = &help->help.ct_pptp_info.keymap[dir]; | 97 | kmp = &help->help.ct_pptp_info.keymap[dir]; |
| 98 | if (*kmp) { | 98 | if (*kmp) { |
| 99 | /* check whether it's a retransmission */ | 99 | /* check whether it's a retransmission */ |
| 100 | read_lock_bh(&nf_ct_gre_lock); | ||
| 100 | list_for_each_entry(km, &gre_keymap_list, list) { | 101 | list_for_each_entry(km, &gre_keymap_list, list) { |
| 101 | if (gre_key_cmpfn(km, t) && km == *kmp) | 102 | if (gre_key_cmpfn(km, t) && km == *kmp) { |
| 103 | read_unlock_bh(&nf_ct_gre_lock); | ||
| 102 | return 0; | 104 | return 0; |
| 105 | } | ||
| 103 | } | 106 | } |
| 107 | read_unlock_bh(&nf_ct_gre_lock); | ||
| 104 | pr_debug("trying to override keymap_%s for ct %p\n", | 108 | pr_debug("trying to override keymap_%s for ct %p\n", |
| 105 | dir == IP_CT_DIR_REPLY ? "reply" : "orig", ct); | 109 | dir == IP_CT_DIR_REPLY ? "reply" : "orig", ct); |
| 106 | return -EEXIST; | 110 | return -EEXIST; |
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 2f9bbc058b48..1fa306be60fb 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c | |||
| @@ -1193,7 +1193,6 @@ static const struct sip_handler sip_handlers[] = { | |||
| 1193 | static int process_sip_response(struct sk_buff *skb, | 1193 | static int process_sip_response(struct sk_buff *skb, |
| 1194 | const char **dptr, unsigned int *datalen) | 1194 | const char **dptr, unsigned int *datalen) |
| 1195 | { | 1195 | { |
| 1196 | static const struct sip_handler *handler; | ||
| 1197 | enum ip_conntrack_info ctinfo; | 1196 | enum ip_conntrack_info ctinfo; |
| 1198 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 1197 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
| 1199 | unsigned int matchoff, matchlen; | 1198 | unsigned int matchoff, matchlen; |
| @@ -1214,6 +1213,8 @@ static int process_sip_response(struct sk_buff *skb, | |||
| 1214 | dataoff = matchoff + matchlen + 1; | 1213 | dataoff = matchoff + matchlen + 1; |
| 1215 | 1214 | ||
| 1216 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { | 1215 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { |
| 1216 | const struct sip_handler *handler; | ||
| 1217 | |||
| 1217 | handler = &sip_handlers[i]; | 1218 | handler = &sip_handlers[i]; |
| 1218 | if (handler->response == NULL) | 1219 | if (handler->response == NULL) |
| 1219 | continue; | 1220 | continue; |
| @@ -1228,13 +1229,14 @@ static int process_sip_response(struct sk_buff *skb, | |||
| 1228 | static int process_sip_request(struct sk_buff *skb, | 1229 | static int process_sip_request(struct sk_buff *skb, |
| 1229 | const char **dptr, unsigned int *datalen) | 1230 | const char **dptr, unsigned int *datalen) |
| 1230 | { | 1231 | { |
| 1231 | static const struct sip_handler *handler; | ||
| 1232 | enum ip_conntrack_info ctinfo; | 1232 | enum ip_conntrack_info ctinfo; |
| 1233 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 1233 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
| 1234 | unsigned int matchoff, matchlen; | 1234 | unsigned int matchoff, matchlen; |
| 1235 | unsigned int cseq, i; | 1235 | unsigned int cseq, i; |
| 1236 | 1236 | ||
| 1237 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { | 1237 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { |
| 1238 | const struct sip_handler *handler; | ||
| 1239 | |||
| 1238 | handler = &sip_handlers[i]; | 1240 | handler = &sip_handlers[i]; |
| 1239 | if (handler->request == NULL) | 1241 | if (handler->request == NULL) |
| 1240 | continue; | 1242 | continue; |
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c index d2d45655cd1a..74aecc098bad 100644 --- a/net/rfkill/rfkill.c +++ b/net/rfkill/rfkill.c | |||
| @@ -150,6 +150,8 @@ static void update_rfkill_state(struct rfkill *rfkill) | |||
| 150 | * calls and handling all the red tape such as issuing notifications | 150 | * calls and handling all the red tape such as issuing notifications |
| 151 | * if the call is successful. | 151 | * if the call is successful. |
| 152 | * | 152 | * |
| 153 | * Suspended devices are not touched at all, and -EAGAIN is returned. | ||
| 154 | * | ||
| 153 | * Note that the @force parameter cannot override a (possibly cached) | 155 | * Note that the @force parameter cannot override a (possibly cached) |
| 154 | * state of RFKILL_STATE_HARD_BLOCKED. Any device making use of | 156 | * state of RFKILL_STATE_HARD_BLOCKED. Any device making use of |
| 155 | * RFKILL_STATE_HARD_BLOCKED implements either get_state() or | 157 | * RFKILL_STATE_HARD_BLOCKED implements either get_state() or |
| @@ -168,6 +170,9 @@ static int rfkill_toggle_radio(struct rfkill *rfkill, | |||
| 168 | int retval = 0; | 170 | int retval = 0; |
| 169 | enum rfkill_state oldstate, newstate; | 171 | enum rfkill_state oldstate, newstate; |
| 170 | 172 | ||
| 173 | if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP)) | ||
| 174 | return -EBUSY; | ||
| 175 | |||
| 171 | oldstate = rfkill->state; | 176 | oldstate = rfkill->state; |
| 172 | 177 | ||
| 173 | if (rfkill->get_state && !force && | 178 | if (rfkill->get_state && !force && |
| @@ -214,7 +219,7 @@ static int rfkill_toggle_radio(struct rfkill *rfkill, | |||
| 214 | * | 219 | * |
| 215 | * This function toggles the state of all switches of given type, | 220 | * This function toggles the state of all switches of given type, |
| 216 | * unless a specific switch is claimed by userspace (in which case, | 221 | * unless a specific switch is claimed by userspace (in which case, |
| 217 | * that switch is left alone). | 222 | * that switch is left alone) or suspended. |
| 218 | */ | 223 | */ |
| 219 | void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) | 224 | void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) |
| 220 | { | 225 | { |
| @@ -239,8 +244,8 @@ EXPORT_SYMBOL(rfkill_switch_all); | |||
| 239 | /** | 244 | /** |
| 240 | * rfkill_epo - emergency power off all transmitters | 245 | * rfkill_epo - emergency power off all transmitters |
| 241 | * | 246 | * |
| 242 | * This kicks all rfkill devices to RFKILL_STATE_SOFT_BLOCKED, ignoring | 247 | * This kicks all non-suspended rfkill devices to RFKILL_STATE_SOFT_BLOCKED, |
| 243 | * everything in its path but rfkill_mutex and rfkill->mutex. | 248 | * ignoring everything in its path but rfkill_mutex and rfkill->mutex. |
| 244 | */ | 249 | */ |
| 245 | void rfkill_epo(void) | 250 | void rfkill_epo(void) |
| 246 | { | 251 | { |
| @@ -372,7 +377,7 @@ static ssize_t rfkill_claim_show(struct device *dev, | |||
| 372 | { | 377 | { |
| 373 | struct rfkill *rfkill = to_rfkill(dev); | 378 | struct rfkill *rfkill = to_rfkill(dev); |
| 374 | 379 | ||
| 375 | return sprintf(buf, "%d", rfkill->user_claim); | 380 | return sprintf(buf, "%d\n", rfkill->user_claim); |
| 376 | } | 381 | } |
| 377 | 382 | ||
| 378 | static ssize_t rfkill_claim_store(struct device *dev, | 383 | static ssize_t rfkill_claim_store(struct device *dev, |
| @@ -458,13 +463,14 @@ static int rfkill_resume(struct device *dev) | |||
| 458 | if (dev->power.power_state.event != PM_EVENT_ON) { | 463 | if (dev->power.power_state.event != PM_EVENT_ON) { |
| 459 | mutex_lock(&rfkill->mutex); | 464 | mutex_lock(&rfkill->mutex); |
| 460 | 465 | ||
| 466 | dev->power.power_state.event = PM_EVENT_ON; | ||
| 467 | |||
| 461 | /* restore radio state AND notify everybody */ | 468 | /* restore radio state AND notify everybody */ |
| 462 | rfkill_toggle_radio(rfkill, rfkill->state, 1); | 469 | rfkill_toggle_radio(rfkill, rfkill->state, 1); |
| 463 | 470 | ||
| 464 | mutex_unlock(&rfkill->mutex); | 471 | mutex_unlock(&rfkill->mutex); |
| 465 | } | 472 | } |
| 466 | 473 | ||
| 467 | dev->power.power_state = PMSG_ON; | ||
| 468 | return 0; | 474 | return 0; |
| 469 | } | 475 | } |
| 470 | #else | 476 | #else |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index d2b6f54a6261..8eb79e92e94c 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
| @@ -205,7 +205,7 @@ replay: | |||
| 205 | } | 205 | } |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | root_lock = qdisc_root_lock(q); | 208 | root_lock = qdisc_root_sleeping_lock(q); |
| 209 | 209 | ||
| 210 | if (tp == NULL) { | 210 | if (tp == NULL) { |
| 211 | /* Proto-tcf does not exist, create new one */ | 211 | /* Proto-tcf does not exist, create new one */ |
| @@ -280,7 +280,7 @@ replay: | |||
| 280 | if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) { | 280 | if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) { |
| 281 | spin_lock_bh(root_lock); | 281 | spin_lock_bh(root_lock); |
| 282 | *back = tp->next; | 282 | *back = tp->next; |
| 283 | spin_lock_bh(root_lock); | 283 | spin_unlock_bh(root_lock); |
| 284 | 284 | ||
| 285 | tfilter_notify(skb, n, tp, fh, RTM_DELTFILTER); | 285 | tfilter_notify(skb, n, tp, fh, RTM_DELTFILTER); |
| 286 | tcf_destroy(tp); | 286 | tcf_destroy(tp); |
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index 481260a4f10f..e3d8455eebc2 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c | |||
| @@ -75,7 +75,7 @@ static __inline__ int route4_fastmap_hash(u32 id, int iif) | |||
| 75 | static inline | 75 | static inline |
| 76 | void route4_reset_fastmap(struct Qdisc *q, struct route4_head *head, u32 id) | 76 | void route4_reset_fastmap(struct Qdisc *q, struct route4_head *head, u32 id) |
| 77 | { | 77 | { |
| 78 | spinlock_t *root_lock = qdisc_root_lock(q); | 78 | spinlock_t *root_lock = qdisc_root_sleeping_lock(q); |
| 79 | 79 | ||
| 80 | spin_lock_bh(root_lock); | 80 | spin_lock_bh(root_lock); |
| 81 | memset(head->fastmap, 0, sizeof(head->fastmap)); | 81 | memset(head->fastmap, 0, sizeof(head->fastmap)); |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index c25465e5607a..1122c952aa99 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/kmod.h> | 27 | #include <linux/kmod.h> |
| 28 | #include <linux/list.h> | 28 | #include <linux/list.h> |
| 29 | #include <linux/hrtimer.h> | 29 | #include <linux/hrtimer.h> |
| 30 | #include <linux/lockdep.h> | ||
| 30 | 31 | ||
| 31 | #include <net/net_namespace.h> | 32 | #include <net/net_namespace.h> |
| 32 | #include <net/sock.h> | 33 | #include <net/sock.h> |
| @@ -198,19 +199,53 @@ struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle) | |||
| 198 | return NULL; | 199 | return NULL; |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 202 | /* | ||
| 203 | * This lock is needed until some qdiscs stop calling qdisc_tree_decrease_qlen() | ||
| 204 | * without rtnl_lock(); currently hfsc_dequeue(), netem_dequeue(), tbf_dequeue() | ||
| 205 | */ | ||
| 206 | static DEFINE_SPINLOCK(qdisc_list_lock); | ||
| 207 | |||
| 208 | static void qdisc_list_add(struct Qdisc *q) | ||
| 209 | { | ||
| 210 | if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { | ||
| 211 | spin_lock_bh(&qdisc_list_lock); | ||
| 212 | list_add_tail(&q->list, &qdisc_root_sleeping(q)->list); | ||
| 213 | spin_unlock_bh(&qdisc_list_lock); | ||
| 214 | } | ||
| 215 | } | ||
| 216 | |||
| 217 | void qdisc_list_del(struct Qdisc *q) | ||
| 218 | { | ||
| 219 | if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { | ||
| 220 | spin_lock_bh(&qdisc_list_lock); | ||
| 221 | list_del(&q->list); | ||
| 222 | spin_unlock_bh(&qdisc_list_lock); | ||
| 223 | } | ||
| 224 | } | ||
| 225 | EXPORT_SYMBOL(qdisc_list_del); | ||
| 226 | |||
| 201 | struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle) | 227 | struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle) |
| 202 | { | 228 | { |
| 203 | unsigned int i; | 229 | unsigned int i; |
| 230 | struct Qdisc *q; | ||
| 231 | |||
| 232 | spin_lock_bh(&qdisc_list_lock); | ||
| 204 | 233 | ||
| 205 | for (i = 0; i < dev->num_tx_queues; i++) { | 234 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 206 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); | 235 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 207 | struct Qdisc *q, *txq_root = txq->qdisc_sleeping; | 236 | struct Qdisc *txq_root = txq->qdisc_sleeping; |
| 208 | 237 | ||
| 209 | q = qdisc_match_from_root(txq_root, handle); | 238 | q = qdisc_match_from_root(txq_root, handle); |
| 210 | if (q) | 239 | if (q) |
| 211 | return q; | 240 | goto unlock; |
| 212 | } | 241 | } |
| 213 | return qdisc_match_from_root(dev->rx_queue.qdisc_sleeping, handle); | 242 | |
| 243 | q = qdisc_match_from_root(dev->rx_queue.qdisc_sleeping, handle); | ||
| 244 | |||
| 245 | unlock: | ||
| 246 | spin_unlock_bh(&qdisc_list_lock); | ||
| 247 | |||
| 248 | return q; | ||
| 214 | } | 249 | } |
| 215 | 250 | ||
| 216 | static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid) | 251 | static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid) |
| @@ -331,7 +366,7 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt) | |||
| 331 | if (!s || tsize != s->tsize || (!tab && tsize > 0)) | 366 | if (!s || tsize != s->tsize || (!tab && tsize > 0)) |
| 332 | return ERR_PTR(-EINVAL); | 367 | return ERR_PTR(-EINVAL); |
| 333 | 368 | ||
| 334 | spin_lock_bh(&qdisc_stab_lock); | 369 | spin_lock(&qdisc_stab_lock); |
| 335 | 370 | ||
| 336 | list_for_each_entry(stab, &qdisc_stab_list, list) { | 371 | list_for_each_entry(stab, &qdisc_stab_list, list) { |
| 337 | if (memcmp(&stab->szopts, s, sizeof(*s))) | 372 | if (memcmp(&stab->szopts, s, sizeof(*s))) |
| @@ -339,11 +374,11 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt) | |||
| 339 | if (tsize > 0 && memcmp(stab->data, tab, tsize * sizeof(u16))) | 374 | if (tsize > 0 && memcmp(stab->data, tab, tsize * sizeof(u16))) |
| 340 | continue; | 375 | continue; |
| 341 | stab->refcnt++; | 376 | stab->refcnt++; |
| 342 | spin_unlock_bh(&qdisc_stab_lock); | 377 | spin_unlock(&qdisc_stab_lock); |
| 343 | return stab; | 378 | return stab; |
| 344 | } | 379 | } |
| 345 | 380 | ||
| 346 | spin_unlock_bh(&qdisc_stab_lock); | 381 | spin_unlock(&qdisc_stab_lock); |
| 347 | 382 | ||
| 348 | stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL); | 383 | stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL); |
| 349 | if (!stab) | 384 | if (!stab) |
| @@ -354,9 +389,9 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt) | |||
| 354 | if (tsize > 0) | 389 | if (tsize > 0) |
| 355 | memcpy(stab->data, tab, tsize * sizeof(u16)); | 390 | memcpy(stab->data, tab, tsize * sizeof(u16)); |
| 356 | 391 | ||
| 357 | spin_lock_bh(&qdisc_stab_lock); | 392 | spin_lock(&qdisc_stab_lock); |
| 358 | list_add_tail(&stab->list, &qdisc_stab_list); | 393 | list_add_tail(&stab->list, &qdisc_stab_list); |
| 359 | spin_unlock_bh(&qdisc_stab_lock); | 394 | spin_unlock(&qdisc_stab_lock); |
| 360 | 395 | ||
| 361 | return stab; | 396 | return stab; |
| 362 | } | 397 | } |
| @@ -366,14 +401,14 @@ void qdisc_put_stab(struct qdisc_size_table *tab) | |||
| 366 | if (!tab) | 401 | if (!tab) |
| 367 | return; | 402 | return; |
| 368 | 403 | ||
| 369 | spin_lock_bh(&qdisc_stab_lock); | 404 | spin_lock(&qdisc_stab_lock); |
| 370 | 405 | ||
| 371 | if (--tab->refcnt == 0) { | 406 | if (--tab->refcnt == 0) { |
| 372 | list_del(&tab->list); | 407 | list_del(&tab->list); |
| 373 | kfree(tab); | 408 | kfree(tab); |
| 374 | } | 409 | } |
| 375 | 410 | ||
| 376 | spin_unlock_bh(&qdisc_stab_lock); | 411 | spin_unlock(&qdisc_stab_lock); |
| 377 | } | 412 | } |
| 378 | EXPORT_SYMBOL(qdisc_put_stab); | 413 | EXPORT_SYMBOL(qdisc_put_stab); |
| 379 | 414 | ||
| @@ -426,7 +461,7 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer) | |||
| 426 | 461 | ||
| 427 | wd->qdisc->flags &= ~TCQ_F_THROTTLED; | 462 | wd->qdisc->flags &= ~TCQ_F_THROTTLED; |
| 428 | smp_wmb(); | 463 | smp_wmb(); |
| 429 | __netif_schedule(wd->qdisc); | 464 | __netif_schedule(qdisc_root(wd->qdisc)); |
| 430 | 465 | ||
| 431 | return HRTIMER_NORESTART; | 466 | return HRTIMER_NORESTART; |
| 432 | } | 467 | } |
| @@ -443,6 +478,10 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) | |||
| 443 | { | 478 | { |
| 444 | ktime_t time; | 479 | ktime_t time; |
| 445 | 480 | ||
| 481 | if (test_bit(__QDISC_STATE_DEACTIVATED, | ||
| 482 | &qdisc_root_sleeping(wd->qdisc)->state)) | ||
| 483 | return; | ||
| 484 | |||
| 446 | wd->qdisc->flags |= TCQ_F_THROTTLED; | 485 | wd->qdisc->flags |= TCQ_F_THROTTLED; |
| 447 | time = ktime_set(0, 0); | 486 | time = ktime_set(0, 0); |
| 448 | time = ktime_add_ns(time, PSCHED_US2NS(expires)); | 487 | time = ktime_add_ns(time, PSCHED_US2NS(expires)); |
| @@ -585,7 +624,7 @@ static struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, | |||
| 585 | struct Qdisc *oqdisc = dev_queue->qdisc_sleeping; | 624 | struct Qdisc *oqdisc = dev_queue->qdisc_sleeping; |
| 586 | spinlock_t *root_lock; | 625 | spinlock_t *root_lock; |
| 587 | 626 | ||
| 588 | root_lock = qdisc_root_lock(oqdisc); | 627 | root_lock = qdisc_lock(oqdisc); |
| 589 | spin_lock_bh(root_lock); | 628 | spin_lock_bh(root_lock); |
| 590 | 629 | ||
| 591 | /* Prune old scheduler */ | 630 | /* Prune old scheduler */ |
| @@ -596,7 +635,7 @@ static struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, | |||
| 596 | if (qdisc == NULL) | 635 | if (qdisc == NULL) |
| 597 | qdisc = &noop_qdisc; | 636 | qdisc = &noop_qdisc; |
| 598 | dev_queue->qdisc_sleeping = qdisc; | 637 | dev_queue->qdisc_sleeping = qdisc; |
| 599 | dev_queue->qdisc = &noop_qdisc; | 638 | rcu_assign_pointer(dev_queue->qdisc, &noop_qdisc); |
| 600 | 639 | ||
| 601 | spin_unlock_bh(root_lock); | 640 | spin_unlock_bh(root_lock); |
| 602 | 641 | ||
| @@ -637,11 +676,8 @@ static void notify_and_destroy(struct sk_buff *skb, struct nlmsghdr *n, u32 clid | |||
| 637 | if (new || old) | 676 | if (new || old) |
| 638 | qdisc_notify(skb, n, clid, old, new); | 677 | qdisc_notify(skb, n, clid, old, new); |
| 639 | 678 | ||
| 640 | if (old) { | 679 | if (old) |
| 641 | spin_lock_bh(&old->q.lock); | ||
| 642 | qdisc_destroy(old); | 680 | qdisc_destroy(old); |
| 643 | spin_unlock_bh(&old->q.lock); | ||
| 644 | } | ||
| 645 | } | 681 | } |
| 646 | 682 | ||
| 647 | /* Graft qdisc "new" to class "classid" of qdisc "parent" or | 683 | /* Graft qdisc "new" to class "classid" of qdisc "parent" or |
| @@ -707,6 +743,10 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, | |||
| 707 | return err; | 743 | return err; |
| 708 | } | 744 | } |
| 709 | 745 | ||
| 746 | /* lockdep annotation is needed for ingress; egress gets it only for name */ | ||
| 747 | static struct lock_class_key qdisc_tx_lock; | ||
| 748 | static struct lock_class_key qdisc_rx_lock; | ||
| 749 | |||
| 710 | /* | 750 | /* |
| 711 | Allocate and initialize new qdisc. | 751 | Allocate and initialize new qdisc. |
| 712 | 752 | ||
| @@ -767,6 +807,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
| 767 | if (handle == TC_H_INGRESS) { | 807 | if (handle == TC_H_INGRESS) { |
| 768 | sch->flags |= TCQ_F_INGRESS; | 808 | sch->flags |= TCQ_F_INGRESS; |
| 769 | handle = TC_H_MAKE(TC_H_INGRESS, 0); | 809 | handle = TC_H_MAKE(TC_H_INGRESS, 0); |
| 810 | lockdep_set_class(qdisc_lock(sch), &qdisc_rx_lock); | ||
| 770 | } else { | 811 | } else { |
| 771 | if (handle == 0) { | 812 | if (handle == 0) { |
| 772 | handle = qdisc_alloc_handle(dev); | 813 | handle = qdisc_alloc_handle(dev); |
| @@ -774,6 +815,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
| 774 | if (handle == 0) | 815 | if (handle == 0) |
| 775 | goto err_out3; | 816 | goto err_out3; |
| 776 | } | 817 | } |
| 818 | lockdep_set_class(qdisc_lock(sch), &qdisc_tx_lock); | ||
| 777 | } | 819 | } |
| 778 | 820 | ||
| 779 | sch->handle = handle; | 821 | sch->handle = handle; |
| @@ -788,9 +830,16 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
| 788 | sch->stab = stab; | 830 | sch->stab = stab; |
| 789 | } | 831 | } |
| 790 | if (tca[TCA_RATE]) { | 832 | if (tca[TCA_RATE]) { |
| 833 | spinlock_t *root_lock; | ||
| 834 | |||
| 835 | if ((sch->parent != TC_H_ROOT) && | ||
| 836 | !(sch->flags & TCQ_F_INGRESS)) | ||
| 837 | root_lock = qdisc_root_sleeping_lock(sch); | ||
| 838 | else | ||
| 839 | root_lock = qdisc_lock(sch); | ||
| 840 | |||
| 791 | err = gen_new_estimator(&sch->bstats, &sch->rate_est, | 841 | err = gen_new_estimator(&sch->bstats, &sch->rate_est, |
| 792 | qdisc_root_lock(sch), | 842 | root_lock, tca[TCA_RATE]); |
| 793 | tca[TCA_RATE]); | ||
| 794 | if (err) { | 843 | if (err) { |
| 795 | /* | 844 | /* |
| 796 | * Any broken qdiscs that would require | 845 | * Any broken qdiscs that would require |
| @@ -802,8 +851,8 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
| 802 | goto err_out3; | 851 | goto err_out3; |
| 803 | } | 852 | } |
| 804 | } | 853 | } |
| 805 | if ((parent != TC_H_ROOT) && !(sch->flags & TCQ_F_INGRESS)) | 854 | |
| 806 | list_add_tail(&sch->list, &dev_queue->qdisc_sleeping->list); | 855 | qdisc_list_add(sch); |
| 807 | 856 | ||
| 808 | return sch; | 857 | return sch; |
| 809 | } | 858 | } |
| @@ -842,7 +891,8 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca) | |||
| 842 | 891 | ||
| 843 | if (tca[TCA_RATE]) | 892 | if (tca[TCA_RATE]) |
| 844 | gen_replace_estimator(&sch->bstats, &sch->rate_est, | 893 | gen_replace_estimator(&sch->bstats, &sch->rate_est, |
| 845 | qdisc_root_lock(sch), tca[TCA_RATE]); | 894 | qdisc_root_sleeping_lock(sch), |
| 895 | tca[TCA_RATE]); | ||
| 846 | return 0; | 896 | return 0; |
| 847 | } | 897 | } |
| 848 | 898 | ||
| @@ -1084,20 +1134,13 @@ create_n_graft: | |||
| 1084 | } | 1134 | } |
| 1085 | 1135 | ||
| 1086 | graft: | 1136 | graft: |
| 1087 | if (1) { | 1137 | err = qdisc_graft(dev, p, skb, n, clid, q, NULL); |
| 1088 | spinlock_t *root_lock; | 1138 | if (err) { |
| 1089 | 1139 | if (q) | |
| 1090 | err = qdisc_graft(dev, p, skb, n, clid, q, NULL); | 1140 | qdisc_destroy(q); |
| 1091 | if (err) { | 1141 | return err; |
| 1092 | if (q) { | ||
| 1093 | root_lock = qdisc_root_lock(q); | ||
| 1094 | spin_lock_bh(root_lock); | ||
| 1095 | qdisc_destroy(q); | ||
| 1096 | spin_unlock_bh(root_lock); | ||
| 1097 | } | ||
| 1098 | return err; | ||
| 1099 | } | ||
| 1100 | } | 1142 | } |
| 1143 | |||
| 1101 | return 0; | 1144 | return 0; |
| 1102 | } | 1145 | } |
| 1103 | 1146 | ||
| @@ -1126,8 +1169,8 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid, | |||
| 1126 | if (q->stab && qdisc_dump_stab(skb, q->stab) < 0) | 1169 | if (q->stab && qdisc_dump_stab(skb, q->stab) < 0) |
| 1127 | goto nla_put_failure; | 1170 | goto nla_put_failure; |
| 1128 | 1171 | ||
| 1129 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, | 1172 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, TCA_XSTATS, |
| 1130 | TCA_XSTATS, qdisc_root_lock(q), &d) < 0) | 1173 | qdisc_root_sleeping_lock(q), &d) < 0) |
| 1131 | goto nla_put_failure; | 1174 | goto nla_put_failure; |
| 1132 | 1175 | ||
| 1133 | if (q->ops->dump_stats && q->ops->dump_stats(q, &d) < 0) | 1176 | if (q->ops->dump_stats && q->ops->dump_stats(q, &d) < 0) |
| @@ -1418,8 +1461,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q, | |||
| 1418 | if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0) | 1461 | if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0) |
| 1419 | goto nla_put_failure; | 1462 | goto nla_put_failure; |
| 1420 | 1463 | ||
| 1421 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, | 1464 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, TCA_XSTATS, |
| 1422 | TCA_XSTATS, qdisc_root_lock(q), &d) < 0) | 1465 | qdisc_root_sleeping_lock(q), &d) < 0) |
| 1423 | goto nla_put_failure; | 1466 | goto nla_put_failure; |
| 1424 | 1467 | ||
| 1425 | if (cl_ops->dump_stats && cl_ops->dump_stats(q, cl, &d) < 0) | 1468 | if (cl_ops->dump_stats && cl_ops->dump_stats(q, cl, &d) < 0) |
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 4e261ce62f48..8b06fa900482 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c | |||
| @@ -521,6 +521,10 @@ static void cbq_ovl_delay(struct cbq_class *cl) | |||
| 521 | struct cbq_sched_data *q = qdisc_priv(cl->qdisc); | 521 | struct cbq_sched_data *q = qdisc_priv(cl->qdisc); |
| 522 | psched_tdiff_t delay = cl->undertime - q->now; | 522 | psched_tdiff_t delay = cl->undertime - q->now; |
| 523 | 523 | ||
| 524 | if (test_bit(__QDISC_STATE_DEACTIVATED, | ||
| 525 | &qdisc_root_sleeping(cl->qdisc)->state)) | ||
| 526 | return; | ||
| 527 | |||
| 524 | if (!cl->delayed) { | 528 | if (!cl->delayed) { |
| 525 | psched_time_t sched = q->now; | 529 | psched_time_t sched = q->now; |
| 526 | ktime_t expires; | 530 | ktime_t expires; |
| @@ -654,7 +658,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) | |||
| 654 | } | 658 | } |
| 655 | 659 | ||
| 656 | sch->flags &= ~TCQ_F_THROTTLED; | 660 | sch->flags &= ~TCQ_F_THROTTLED; |
| 657 | __netif_schedule(sch); | 661 | __netif_schedule(qdisc_root(sch)); |
| 658 | return HRTIMER_NORESTART; | 662 | return HRTIMER_NORESTART; |
| 659 | } | 663 | } |
| 660 | 664 | ||
| @@ -1750,7 +1754,7 @@ static void cbq_put(struct Qdisc *sch, unsigned long arg) | |||
| 1750 | 1754 | ||
| 1751 | if (--cl->refcnt == 0) { | 1755 | if (--cl->refcnt == 0) { |
| 1752 | #ifdef CONFIG_NET_CLS_ACT | 1756 | #ifdef CONFIG_NET_CLS_ACT |
| 1753 | spinlock_t *root_lock = qdisc_root_lock(sch); | 1757 | spinlock_t *root_lock = qdisc_root_sleeping_lock(sch); |
| 1754 | struct cbq_sched_data *q = qdisc_priv(sch); | 1758 | struct cbq_sched_data *q = qdisc_priv(sch); |
| 1755 | 1759 | ||
| 1756 | spin_lock_bh(root_lock); | 1760 | spin_lock_bh(root_lock); |
| @@ -1835,7 +1839,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t | |||
| 1835 | 1839 | ||
| 1836 | if (tca[TCA_RATE]) | 1840 | if (tca[TCA_RATE]) |
| 1837 | gen_replace_estimator(&cl->bstats, &cl->rate_est, | 1841 | gen_replace_estimator(&cl->bstats, &cl->rate_est, |
| 1838 | qdisc_root_lock(sch), | 1842 | qdisc_root_sleeping_lock(sch), |
| 1839 | tca[TCA_RATE]); | 1843 | tca[TCA_RATE]); |
| 1840 | return 0; | 1844 | return 0; |
| 1841 | } | 1845 | } |
| @@ -1926,7 +1930,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t | |||
| 1926 | 1930 | ||
| 1927 | if (tca[TCA_RATE]) | 1931 | if (tca[TCA_RATE]) |
| 1928 | gen_new_estimator(&cl->bstats, &cl->rate_est, | 1932 | gen_new_estimator(&cl->bstats, &cl->rate_est, |
| 1929 | qdisc_root_lock(sch), tca[TCA_RATE]); | 1933 | qdisc_root_sleeping_lock(sch), tca[TCA_RATE]); |
| 1930 | 1934 | ||
| 1931 | *arg = (unsigned long)cl; | 1935 | *arg = (unsigned long)cl; |
| 1932 | return 0; | 1936 | return 0; |
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 468574682caa..ec0a0839ce51 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c | |||
| @@ -215,10 +215,9 @@ static void dev_watchdog(unsigned long arg) | |||
| 215 | time_after(jiffies, (dev->trans_start + | 215 | time_after(jiffies, (dev->trans_start + |
| 216 | dev->watchdog_timeo))) { | 216 | dev->watchdog_timeo))) { |
| 217 | char drivername[64]; | 217 | char drivername[64]; |
| 218 | printk(KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit timed out\n", | 218 | WARN_ONCE(1, KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit timed out\n", |
| 219 | dev->name, netdev_drivername(dev, drivername, 64)); | 219 | dev->name, netdev_drivername(dev, drivername, 64)); |
| 220 | dev->tx_timeout(dev); | 220 | dev->tx_timeout(dev); |
| 221 | WARN_ON_ONCE(1); | ||
| 222 | } | 221 | } |
| 223 | if (!mod_timer(&dev->watchdog_timer, | 222 | if (!mod_timer(&dev->watchdog_timer, |
| 224 | round_jiffies(jiffies + | 223 | round_jiffies(jiffies + |
| @@ -518,15 +517,17 @@ void qdisc_reset(struct Qdisc *qdisc) | |||
| 518 | } | 517 | } |
| 519 | EXPORT_SYMBOL(qdisc_reset); | 518 | EXPORT_SYMBOL(qdisc_reset); |
| 520 | 519 | ||
| 521 | /* this is the rcu callback function to clean up a qdisc when there | 520 | void qdisc_destroy(struct Qdisc *qdisc) |
| 522 | * are no further references to it */ | ||
| 523 | |||
| 524 | static void __qdisc_destroy(struct rcu_head *head) | ||
| 525 | { | 521 | { |
| 526 | struct Qdisc *qdisc = container_of(head, struct Qdisc, q_rcu); | ||
| 527 | const struct Qdisc_ops *ops = qdisc->ops; | 522 | const struct Qdisc_ops *ops = qdisc->ops; |
| 528 | 523 | ||
| 524 | if (qdisc->flags & TCQ_F_BUILTIN || | ||
| 525 | !atomic_dec_and_test(&qdisc->refcnt)) | ||
| 526 | return; | ||
| 527 | |||
| 529 | #ifdef CONFIG_NET_SCHED | 528 | #ifdef CONFIG_NET_SCHED |
| 529 | qdisc_list_del(qdisc); | ||
| 530 | |||
| 530 | qdisc_put_stab(qdisc->stab); | 531 | qdisc_put_stab(qdisc->stab); |
| 531 | #endif | 532 | #endif |
| 532 | gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est); | 533 | gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est); |
| @@ -542,20 +543,6 @@ static void __qdisc_destroy(struct rcu_head *head) | |||
| 542 | 543 | ||
| 543 | kfree((char *) qdisc - qdisc->padded); | 544 | kfree((char *) qdisc - qdisc->padded); |
| 544 | } | 545 | } |
| 545 | |||
| 546 | /* Under qdisc_lock(qdisc) and BH! */ | ||
| 547 | |||
| 548 | void qdisc_destroy(struct Qdisc *qdisc) | ||
| 549 | { | ||
| 550 | if (qdisc->flags & TCQ_F_BUILTIN || | ||
| 551 | !atomic_dec_and_test(&qdisc->refcnt)) | ||
| 552 | return; | ||
| 553 | |||
| 554 | if (qdisc->parent) | ||
| 555 | list_del(&qdisc->list); | ||
| 556 | |||
| 557 | call_rcu(&qdisc->q_rcu, __qdisc_destroy); | ||
| 558 | } | ||
| 559 | EXPORT_SYMBOL(qdisc_destroy); | 546 | EXPORT_SYMBOL(qdisc_destroy); |
| 560 | 547 | ||
| 561 | static bool dev_all_qdisc_sleeping_noop(struct net_device *dev) | 548 | static bool dev_all_qdisc_sleeping_noop(struct net_device *dev) |
| @@ -597,6 +584,9 @@ static void transition_one_qdisc(struct net_device *dev, | |||
| 597 | struct Qdisc *new_qdisc = dev_queue->qdisc_sleeping; | 584 | struct Qdisc *new_qdisc = dev_queue->qdisc_sleeping; |
| 598 | int *need_watchdog_p = _need_watchdog; | 585 | int *need_watchdog_p = _need_watchdog; |
| 599 | 586 | ||
| 587 | if (!(new_qdisc->flags & TCQ_F_BUILTIN)) | ||
| 588 | clear_bit(__QDISC_STATE_DEACTIVATED, &new_qdisc->state); | ||
| 589 | |||
| 600 | rcu_assign_pointer(dev_queue->qdisc, new_qdisc); | 590 | rcu_assign_pointer(dev_queue->qdisc, new_qdisc); |
| 601 | if (need_watchdog_p && new_qdisc != &noqueue_qdisc) | 591 | if (need_watchdog_p && new_qdisc != &noqueue_qdisc) |
| 602 | *need_watchdog_p = 1; | 592 | *need_watchdog_p = 1; |
| @@ -640,14 +630,17 @@ static void dev_deactivate_queue(struct net_device *dev, | |||
| 640 | if (qdisc) { | 630 | if (qdisc) { |
| 641 | spin_lock_bh(qdisc_lock(qdisc)); | 631 | spin_lock_bh(qdisc_lock(qdisc)); |
| 642 | 632 | ||
| 643 | dev_queue->qdisc = qdisc_default; | 633 | if (!(qdisc->flags & TCQ_F_BUILTIN)) |
| 634 | set_bit(__QDISC_STATE_DEACTIVATED, &qdisc->state); | ||
| 635 | |||
| 636 | rcu_assign_pointer(dev_queue->qdisc, qdisc_default); | ||
| 644 | qdisc_reset(qdisc); | 637 | qdisc_reset(qdisc); |
| 645 | 638 | ||
| 646 | spin_unlock_bh(qdisc_lock(qdisc)); | 639 | spin_unlock_bh(qdisc_lock(qdisc)); |
| 647 | } | 640 | } |
| 648 | } | 641 | } |
| 649 | 642 | ||
| 650 | static bool some_qdisc_is_busy(struct net_device *dev, int lock) | 643 | static bool some_qdisc_is_busy(struct net_device *dev) |
| 651 | { | 644 | { |
| 652 | unsigned int i; | 645 | unsigned int i; |
| 653 | 646 | ||
| @@ -661,14 +654,12 @@ static bool some_qdisc_is_busy(struct net_device *dev, int lock) | |||
| 661 | q = dev_queue->qdisc_sleeping; | 654 | q = dev_queue->qdisc_sleeping; |
| 662 | root_lock = qdisc_lock(q); | 655 | root_lock = qdisc_lock(q); |
| 663 | 656 | ||
| 664 | if (lock) | 657 | spin_lock_bh(root_lock); |
| 665 | spin_lock_bh(root_lock); | ||
| 666 | 658 | ||
| 667 | val = (test_bit(__QDISC_STATE_RUNNING, &q->state) || | 659 | val = (test_bit(__QDISC_STATE_RUNNING, &q->state) || |
| 668 | test_bit(__QDISC_STATE_SCHED, &q->state)); | 660 | test_bit(__QDISC_STATE_SCHED, &q->state)); |
| 669 | 661 | ||
| 670 | if (lock) | 662 | spin_unlock_bh(root_lock); |
| 671 | spin_unlock_bh(root_lock); | ||
| 672 | 663 | ||
| 673 | if (val) | 664 | if (val) |
| 674 | return true; | 665 | return true; |
| @@ -678,8 +669,6 @@ static bool some_qdisc_is_busy(struct net_device *dev, int lock) | |||
| 678 | 669 | ||
| 679 | void dev_deactivate(struct net_device *dev) | 670 | void dev_deactivate(struct net_device *dev) |
| 680 | { | 671 | { |
| 681 | bool running; | ||
| 682 | |||
| 683 | netdev_for_each_tx_queue(dev, dev_deactivate_queue, &noop_qdisc); | 672 | netdev_for_each_tx_queue(dev, dev_deactivate_queue, &noop_qdisc); |
| 684 | dev_deactivate_queue(dev, &dev->rx_queue, &noop_qdisc); | 673 | dev_deactivate_queue(dev, &dev->rx_queue, &noop_qdisc); |
| 685 | 674 | ||
| @@ -689,25 +678,8 @@ void dev_deactivate(struct net_device *dev) | |||
| 689 | synchronize_rcu(); | 678 | synchronize_rcu(); |
| 690 | 679 | ||
| 691 | /* Wait for outstanding qdisc_run calls. */ | 680 | /* Wait for outstanding qdisc_run calls. */ |
| 692 | do { | 681 | while (some_qdisc_is_busy(dev)) |
| 693 | while (some_qdisc_is_busy(dev, 0)) | 682 | yield(); |
| 694 | yield(); | ||
| 695 | |||
| 696 | /* | ||
| 697 | * Double-check inside queue lock to ensure that all effects | ||
| 698 | * of the queue run are visible when we return. | ||
| 699 | */ | ||
| 700 | running = some_qdisc_is_busy(dev, 1); | ||
| 701 | |||
| 702 | /* | ||
| 703 | * The running flag should never be set at this point because | ||
| 704 | * we've already set dev->qdisc to noop_qdisc *inside* the same | ||
| 705 | * pair of spin locks. That is, if any qdisc_run starts after | ||
| 706 | * our initial test it should see the noop_qdisc and then | ||
| 707 | * clear the RUNNING bit before dropping the queue lock. So | ||
| 708 | * if it is set here then we've found a bug. | ||
| 709 | */ | ||
| 710 | } while (WARN_ON_ONCE(running)); | ||
| 711 | } | 683 | } |
| 712 | 684 | ||
| 713 | static void dev_init_scheduler_queue(struct net_device *dev, | 685 | static void dev_init_scheduler_queue(struct net_device *dev, |
| @@ -736,14 +708,10 @@ static void shutdown_scheduler_queue(struct net_device *dev, | |||
| 736 | struct Qdisc *qdisc_default = _qdisc_default; | 708 | struct Qdisc *qdisc_default = _qdisc_default; |
| 737 | 709 | ||
| 738 | if (qdisc) { | 710 | if (qdisc) { |
| 739 | spinlock_t *root_lock = qdisc_lock(qdisc); | 711 | rcu_assign_pointer(dev_queue->qdisc, qdisc_default); |
| 740 | |||
| 741 | dev_queue->qdisc = qdisc_default; | ||
| 742 | dev_queue->qdisc_sleeping = qdisc_default; | 712 | dev_queue->qdisc_sleeping = qdisc_default; |
| 743 | 713 | ||
| 744 | spin_lock_bh(root_lock); | ||
| 745 | qdisc_destroy(qdisc); | 714 | qdisc_destroy(qdisc); |
| 746 | spin_unlock_bh(root_lock); | ||
| 747 | } | 715 | } |
| 748 | } | 716 | } |
| 749 | 717 | ||
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index c2b8d9cce3d2..c1e77da8cd09 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c | |||
| @@ -1045,7 +1045,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, | |||
| 1045 | 1045 | ||
| 1046 | if (tca[TCA_RATE]) | 1046 | if (tca[TCA_RATE]) |
| 1047 | gen_replace_estimator(&cl->bstats, &cl->rate_est, | 1047 | gen_replace_estimator(&cl->bstats, &cl->rate_est, |
| 1048 | qdisc_root_lock(sch), | 1048 | qdisc_root_sleeping_lock(sch), |
| 1049 | tca[TCA_RATE]); | 1049 | tca[TCA_RATE]); |
| 1050 | return 0; | 1050 | return 0; |
| 1051 | } | 1051 | } |
| @@ -1104,7 +1104,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, | |||
| 1104 | 1104 | ||
| 1105 | if (tca[TCA_RATE]) | 1105 | if (tca[TCA_RATE]) |
| 1106 | gen_new_estimator(&cl->bstats, &cl->rate_est, | 1106 | gen_new_estimator(&cl->bstats, &cl->rate_est, |
| 1107 | qdisc_root_lock(sch), tca[TCA_RATE]); | 1107 | qdisc_root_sleeping_lock(sch), tca[TCA_RATE]); |
| 1108 | *arg = (unsigned long)cl; | 1108 | *arg = (unsigned long)cl; |
| 1109 | return 0; | 1109 | return 0; |
| 1110 | } | 1110 | } |
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 6febd245e62b..d14f02056ae6 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
| @@ -577,7 +577,7 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
| 577 | sch->qstats.drops++; | 577 | sch->qstats.drops++; |
| 578 | cl->qstats.drops++; | 578 | cl->qstats.drops++; |
| 579 | } | 579 | } |
| 580 | return NET_XMIT_DROP; | 580 | return ret; |
| 581 | } else { | 581 | } else { |
| 582 | cl->bstats.packets += | 582 | cl->bstats.packets += |
| 583 | skb_is_gso(skb)?skb_shinfo(skb)->gso_segs:1; | 583 | skb_is_gso(skb)?skb_shinfo(skb)->gso_segs:1; |
| @@ -623,7 +623,7 @@ static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch) | |||
| 623 | sch->qstats.drops++; | 623 | sch->qstats.drops++; |
| 624 | cl->qstats.drops++; | 624 | cl->qstats.drops++; |
| 625 | } | 625 | } |
| 626 | return NET_XMIT_DROP; | 626 | return ret; |
| 627 | } else | 627 | } else |
| 628 | htb_activate(q, cl); | 628 | htb_activate(q, cl); |
| 629 | 629 | ||
| @@ -1043,7 +1043,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt) | |||
| 1043 | 1043 | ||
| 1044 | static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) | 1044 | static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) |
| 1045 | { | 1045 | { |
| 1046 | spinlock_t *root_lock = qdisc_root_lock(sch); | 1046 | spinlock_t *root_lock = qdisc_root_sleeping_lock(sch); |
| 1047 | struct htb_sched *q = qdisc_priv(sch); | 1047 | struct htb_sched *q = qdisc_priv(sch); |
| 1048 | struct nlattr *nest; | 1048 | struct nlattr *nest; |
| 1049 | struct tc_htb_glob gopt; | 1049 | struct tc_htb_glob gopt; |
| @@ -1075,7 +1075,7 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, | |||
| 1075 | struct sk_buff *skb, struct tcmsg *tcm) | 1075 | struct sk_buff *skb, struct tcmsg *tcm) |
| 1076 | { | 1076 | { |
| 1077 | struct htb_class *cl = (struct htb_class *)arg; | 1077 | struct htb_class *cl = (struct htb_class *)arg; |
| 1078 | spinlock_t *root_lock = qdisc_root_lock(sch); | 1078 | spinlock_t *root_lock = qdisc_root_sleeping_lock(sch); |
| 1079 | struct nlattr *nest; | 1079 | struct nlattr *nest; |
| 1080 | struct tc_htb_opt opt; | 1080 | struct tc_htb_opt opt; |
| 1081 | 1081 | ||
| @@ -1372,7 +1372,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
| 1372 | goto failure; | 1372 | goto failure; |
| 1373 | 1373 | ||
| 1374 | gen_new_estimator(&cl->bstats, &cl->rate_est, | 1374 | gen_new_estimator(&cl->bstats, &cl->rate_est, |
| 1375 | qdisc_root_lock(sch), | 1375 | qdisc_root_sleeping_lock(sch), |
| 1376 | tca[TCA_RATE] ? : &est.nla); | 1376 | tca[TCA_RATE] ? : &est.nla); |
| 1377 | cl->refcnt = 1; | 1377 | cl->refcnt = 1; |
| 1378 | cl->children = 0; | 1378 | cl->children = 0; |
| @@ -1427,7 +1427,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
| 1427 | } else { | 1427 | } else { |
| 1428 | if (tca[TCA_RATE]) | 1428 | if (tca[TCA_RATE]) |
| 1429 | gen_replace_estimator(&cl->bstats, &cl->rate_est, | 1429 | gen_replace_estimator(&cl->bstats, &cl->rate_est, |
| 1430 | qdisc_root_lock(sch), | 1430 | qdisc_root_sleeping_lock(sch), |
| 1431 | tca[TCA_RATE]); | 1431 | tca[TCA_RATE]); |
| 1432 | sch_tree_lock(sch); | 1432 | sch_tree_lock(sch); |
| 1433 | } | 1433 | } |
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index fb0294d0b55e..3781e55046d0 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
| @@ -341,7 +341,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr) | |||
| 341 | for (i = 0; i < n; i++) | 341 | for (i = 0; i < n; i++) |
| 342 | d->table[i] = data[i]; | 342 | d->table[i] = data[i]; |
| 343 | 343 | ||
| 344 | root_lock = qdisc_root_lock(sch); | 344 | root_lock = qdisc_root_sleeping_lock(sch); |
| 345 | 345 | ||
| 346 | spin_lock_bh(root_lock); | 346 | spin_lock_bh(root_lock); |
| 347 | d = xchg(&q->delay_dist, d); | 347 | d = xchg(&q->delay_dist, d); |
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index eac197610edf..a6697c686c7f 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c | |||
| @@ -113,11 +113,11 @@ prio_requeue(struct sk_buff *skb, struct Qdisc* sch) | |||
| 113 | if ((ret = qdisc->ops->requeue(skb, qdisc)) == NET_XMIT_SUCCESS) { | 113 | if ((ret = qdisc->ops->requeue(skb, qdisc)) == NET_XMIT_SUCCESS) { |
| 114 | sch->q.qlen++; | 114 | sch->q.qlen++; |
| 115 | sch->qstats.requeues++; | 115 | sch->qstats.requeues++; |
| 116 | return 0; | 116 | return NET_XMIT_SUCCESS; |
| 117 | } | 117 | } |
| 118 | if (net_xmit_drop_count(ret)) | 118 | if (net_xmit_drop_count(ret)) |
| 119 | sch->qstats.drops++; | 119 | sch->qstats.drops++; |
| 120 | return NET_XMIT_DROP; | 120 | return ret; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | 123 | ||
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 7d3b7ff3bf07..94c61598b86a 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c | |||
| @@ -123,15 +123,8 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch) | |||
| 123 | struct tbf_sched_data *q = qdisc_priv(sch); | 123 | struct tbf_sched_data *q = qdisc_priv(sch); |
| 124 | int ret; | 124 | int ret; |
| 125 | 125 | ||
| 126 | if (qdisc_pkt_len(skb) > q->max_size) { | 126 | if (qdisc_pkt_len(skb) > q->max_size) |
| 127 | sch->qstats.drops++; | 127 | return qdisc_reshape_fail(skb, sch); |
| 128 | #ifdef CONFIG_NET_CLS_ACT | ||
| 129 | if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch)) | ||
| 130 | #endif | ||
| 131 | kfree_skb(skb); | ||
| 132 | |||
| 133 | return NET_XMIT_DROP; | ||
| 134 | } | ||
| 135 | 128 | ||
| 136 | ret = qdisc_enqueue(skb, q->qdisc); | 129 | ret = qdisc_enqueue(skb, q->qdisc); |
| 137 | if (ret != 0) { | 130 | if (ret != 0) { |
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c index 2c35c678563b..d35ef059abb1 100644 --- a/net/sched/sch_teql.c +++ b/net/sched/sch_teql.c | |||
| @@ -161,7 +161,7 @@ teql_destroy(struct Qdisc* sch) | |||
| 161 | txq = netdev_get_tx_queue(master->dev, 0); | 161 | txq = netdev_get_tx_queue(master->dev, 0); |
| 162 | master->slaves = NULL; | 162 | master->slaves = NULL; |
| 163 | 163 | ||
| 164 | root_lock = qdisc_root_lock(txq->qdisc); | 164 | root_lock = qdisc_root_sleeping_lock(txq->qdisc); |
| 165 | spin_lock_bh(root_lock); | 165 | spin_lock_bh(root_lock); |
| 166 | qdisc_reset(txq->qdisc); | 166 | qdisc_reset(txq->qdisc); |
| 167 | spin_unlock_bh(root_lock); | 167 | spin_unlock_bh(root_lock); |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 8472b8b349c4..abd51cef2413 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
| @@ -599,11 +599,12 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
| 599 | /* Check to see if this is a duplicate. */ | 599 | /* Check to see if this is a duplicate. */ |
| 600 | peer = sctp_assoc_lookup_paddr(asoc, addr); | 600 | peer = sctp_assoc_lookup_paddr(asoc, addr); |
| 601 | if (peer) { | 601 | if (peer) { |
| 602 | /* An UNKNOWN state is only set on transports added by | ||
| 603 | * user in sctp_connectx() call. Such transports should be | ||
| 604 | * considered CONFIRMED per RFC 4960, Section 5.4. | ||
| 605 | */ | ||
| 602 | if (peer->state == SCTP_UNKNOWN) { | 606 | if (peer->state == SCTP_UNKNOWN) { |
| 603 | if (peer_state == SCTP_ACTIVE) | 607 | peer->state = SCTP_ACTIVE; |
| 604 | peer->state = SCTP_ACTIVE; | ||
| 605 | if (peer_state == SCTP_UNCONFIRMED) | ||
| 606 | peer->state = SCTP_UNCONFIRMED; | ||
| 607 | } | 608 | } |
| 608 | return peer; | 609 | return peer; |
| 609 | } | 610 | } |
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 675a5c3e68a6..52db5f60daa0 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
| @@ -80,6 +80,10 @@ static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp) | |||
| 80 | { | 80 | { |
| 81 | struct sctp_auth_bytes *key; | 81 | struct sctp_auth_bytes *key; |
| 82 | 82 | ||
| 83 | /* Verify that we are not going to overflow INT_MAX */ | ||
| 84 | if ((INT_MAX - key_len) < sizeof(struct sctp_auth_bytes)) | ||
| 85 | return NULL; | ||
| 86 | |||
| 83 | /* Allocate the shared key */ | 87 | /* Allocate the shared key */ |
| 84 | key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp); | 88 | key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp); |
| 85 | if (!key) | 89 | if (!key) |
| @@ -782,6 +786,9 @@ int sctp_auth_ep_set_hmacs(struct sctp_endpoint *ep, | |||
| 782 | for (i = 0; i < hmacs->shmac_num_idents; i++) { | 786 | for (i = 0; i < hmacs->shmac_num_idents; i++) { |
| 783 | id = hmacs->shmac_idents[i]; | 787 | id = hmacs->shmac_idents[i]; |
| 784 | 788 | ||
| 789 | if (id > SCTP_AUTH_HMAC_ID_MAX) | ||
| 790 | return -EOPNOTSUPP; | ||
| 791 | |||
| 785 | if (SCTP_AUTH_HMAC_ID_SHA1 == id) | 792 | if (SCTP_AUTH_HMAC_ID_SHA1 == id) |
| 786 | has_sha1 = 1; | 793 | has_sha1 = 1; |
| 787 | 794 | ||
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index e39a0cdef184..4c8d9f45ce09 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
| @@ -103,6 +103,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
| 103 | 103 | ||
| 104 | /* Initialize the CHUNKS parameter */ | 104 | /* Initialize the CHUNKS parameter */ |
| 105 | auth_chunks->param_hdr.type = SCTP_PARAM_CHUNKS; | 105 | auth_chunks->param_hdr.type = SCTP_PARAM_CHUNKS; |
| 106 | auth_chunks->param_hdr.length = htons(sizeof(sctp_paramhdr_t)); | ||
| 106 | 107 | ||
| 107 | /* If the Add-IP functionality is enabled, we must | 108 | /* If the Add-IP functionality is enabled, we must |
| 108 | * authenticate, ASCONF and ASCONF-ACK chunks | 109 | * authenticate, ASCONF and ASCONF-ACK chunks |
| @@ -110,8 +111,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
| 110 | if (sctp_addip_enable) { | 111 | if (sctp_addip_enable) { |
| 111 | auth_chunks->chunks[0] = SCTP_CID_ASCONF; | 112 | auth_chunks->chunks[0] = SCTP_CID_ASCONF; |
| 112 | auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; | 113 | auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; |
| 113 | auth_chunks->param_hdr.length = | 114 | auth_chunks->param_hdr.length += htons(2); |
| 114 | htons(sizeof(sctp_paramhdr_t) + 2); | ||
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | 117 | ||
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 483a01d0740a..47f91afa0211 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
| @@ -319,7 +319,8 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk, | |||
| 319 | __func__, asoc, dst, NIP6(daddr->v6.sin6_addr)); | 319 | __func__, asoc, dst, NIP6(daddr->v6.sin6_addr)); |
| 320 | 320 | ||
| 321 | if (!asoc) { | 321 | if (!asoc) { |
| 322 | ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, | 322 | ipv6_dev_get_saddr(sock_net(sctp_opt2sk(sk)), |
| 323 | dst ? ip6_dst_idev(dst)->dev : NULL, | ||
| 323 | &daddr->v6.sin6_addr, | 324 | &daddr->v6.sin6_addr, |
| 324 | inet6_sk(&sk->inet.sk)->srcprefs, | 325 | inet6_sk(&sk->inet.sk)->srcprefs, |
| 325 | &saddr->v6.sin6_addr); | 326 | &saddr->v6.sin6_addr); |
diff --git a/net/sctp/output.c b/net/sctp/output.c index 0dc4a7dfb234..225c7123c41f 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
| @@ -533,7 +533,8 @@ int sctp_packet_transmit(struct sctp_packet *packet) | |||
| 533 | if (!(dst->dev->features & NETIF_F_NO_CSUM)) { | 533 | if (!(dst->dev->features & NETIF_F_NO_CSUM)) { |
| 534 | crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len); | 534 | crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len); |
| 535 | crc32 = sctp_end_cksum(crc32); | 535 | crc32 = sctp_end_cksum(crc32); |
| 536 | } | 536 | } else |
| 537 | nskb->ip_summed = CHECKSUM_UNNECESSARY; | ||
| 537 | 538 | ||
| 538 | /* 3) Put the resultant value into the checksum field in the | 539 | /* 3) Put the resultant value into the checksum field in the |
| 539 | * common header, and leave the rest of the bits unchanged. | 540 | * common header, and leave the rest of the bits unchanged. |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index e8ca4e54981f..d68869f966c3 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
| @@ -1012,6 +1012,29 @@ end: | |||
| 1012 | return retval; | 1012 | return retval; |
| 1013 | } | 1013 | } |
| 1014 | 1014 | ||
| 1015 | struct sctp_chunk *sctp_make_violation_paramlen( | ||
| 1016 | const struct sctp_association *asoc, | ||
| 1017 | const struct sctp_chunk *chunk, | ||
| 1018 | struct sctp_paramhdr *param) | ||
| 1019 | { | ||
| 1020 | struct sctp_chunk *retval; | ||
| 1021 | static const char error[] = "The following parameter had invalid length:"; | ||
| 1022 | size_t payload_len = sizeof(error) + sizeof(sctp_errhdr_t) + | ||
| 1023 | sizeof(sctp_paramhdr_t); | ||
| 1024 | |||
| 1025 | retval = sctp_make_abort(asoc, chunk, payload_len); | ||
| 1026 | if (!retval) | ||
| 1027 | goto nodata; | ||
| 1028 | |||
| 1029 | sctp_init_cause(retval, SCTP_ERROR_PROTO_VIOLATION, | ||
| 1030 | sizeof(error) + sizeof(sctp_paramhdr_t)); | ||
| 1031 | sctp_addto_chunk(retval, sizeof(error), error); | ||
| 1032 | sctp_addto_param(retval, sizeof(sctp_paramhdr_t), param); | ||
| 1033 | |||
| 1034 | nodata: | ||
| 1035 | return retval; | ||
| 1036 | } | ||
| 1037 | |||
| 1015 | /* Make a HEARTBEAT chunk. */ | 1038 | /* Make a HEARTBEAT chunk. */ |
| 1016 | struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc, | 1039 | struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc, |
| 1017 | const struct sctp_transport *transport, | 1040 | const struct sctp_transport *transport, |
| @@ -1782,11 +1805,6 @@ static int sctp_process_inv_paramlength(const struct sctp_association *asoc, | |||
| 1782 | const struct sctp_chunk *chunk, | 1805 | const struct sctp_chunk *chunk, |
| 1783 | struct sctp_chunk **errp) | 1806 | struct sctp_chunk **errp) |
| 1784 | { | 1807 | { |
| 1785 | static const char error[] = "The following parameter had invalid length:"; | ||
| 1786 | size_t payload_len = WORD_ROUND(sizeof(error)) + | ||
| 1787 | sizeof(sctp_paramhdr_t); | ||
| 1788 | |||
| 1789 | |||
| 1790 | /* This is a fatal error. Any accumulated non-fatal errors are | 1808 | /* This is a fatal error. Any accumulated non-fatal errors are |
| 1791 | * not reported. | 1809 | * not reported. |
| 1792 | */ | 1810 | */ |
| @@ -1794,14 +1812,7 @@ static int sctp_process_inv_paramlength(const struct sctp_association *asoc, | |||
| 1794 | sctp_chunk_free(*errp); | 1812 | sctp_chunk_free(*errp); |
| 1795 | 1813 | ||
| 1796 | /* Create an error chunk and fill it in with our payload. */ | 1814 | /* Create an error chunk and fill it in with our payload. */ |
| 1797 | *errp = sctp_make_op_error_space(asoc, chunk, payload_len); | 1815 | *errp = sctp_make_violation_paramlen(asoc, chunk, param); |
| 1798 | |||
| 1799 | if (*errp) { | ||
| 1800 | sctp_init_cause(*errp, SCTP_ERROR_PROTO_VIOLATION, | ||
| 1801 | sizeof(error) + sizeof(sctp_paramhdr_t)); | ||
| 1802 | sctp_addto_chunk(*errp, sizeof(error), error); | ||
| 1803 | sctp_addto_param(*errp, sizeof(sctp_paramhdr_t), param); | ||
| 1804 | } | ||
| 1805 | 1816 | ||
| 1806 | return 0; | 1817 | return 0; |
| 1807 | } | 1818 | } |
| @@ -1886,11 +1897,13 @@ static void sctp_process_ext_param(struct sctp_association *asoc, | |||
| 1886 | /* if the peer reports AUTH, assume that he | 1897 | /* if the peer reports AUTH, assume that he |
| 1887 | * supports AUTH. | 1898 | * supports AUTH. |
| 1888 | */ | 1899 | */ |
| 1889 | asoc->peer.auth_capable = 1; | 1900 | if (sctp_auth_enable) |
| 1901 | asoc->peer.auth_capable = 1; | ||
| 1890 | break; | 1902 | break; |
| 1891 | case SCTP_CID_ASCONF: | 1903 | case SCTP_CID_ASCONF: |
| 1892 | case SCTP_CID_ASCONF_ACK: | 1904 | case SCTP_CID_ASCONF_ACK: |
| 1893 | asoc->peer.asconf_capable = 1; | 1905 | if (sctp_addip_enable) |
| 1906 | asoc->peer.asconf_capable = 1; | ||
| 1894 | break; | 1907 | break; |
| 1895 | default: | 1908 | default: |
| 1896 | break; | 1909 | break; |
| @@ -2319,12 +2332,10 @@ clean_up: | |||
| 2319 | /* Release the transport structures. */ | 2332 | /* Release the transport structures. */ |
| 2320 | list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { | 2333 | list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { |
| 2321 | transport = list_entry(pos, struct sctp_transport, transports); | 2334 | transport = list_entry(pos, struct sctp_transport, transports); |
| 2322 | list_del_init(pos); | 2335 | if (transport->state != SCTP_ACTIVE) |
| 2323 | sctp_transport_free(transport); | 2336 | sctp_assoc_rm_peer(asoc, transport); |
| 2324 | } | 2337 | } |
| 2325 | 2338 | ||
| 2326 | asoc->peer.transport_count = 0; | ||
| 2327 | |||
| 2328 | nomem: | 2339 | nomem: |
| 2329 | return 0; | 2340 | return 0; |
| 2330 | } | 2341 | } |
| @@ -2460,6 +2471,9 @@ do_addr_param: | |||
| 2460 | break; | 2471 | break; |
| 2461 | 2472 | ||
| 2462 | case SCTP_PARAM_SET_PRIMARY: | 2473 | case SCTP_PARAM_SET_PRIMARY: |
| 2474 | if (!sctp_addip_enable) | ||
| 2475 | goto fall_through; | ||
| 2476 | |||
| 2463 | addr_param = param.v + sizeof(sctp_addip_param_t); | 2477 | addr_param = param.v + sizeof(sctp_addip_param_t); |
| 2464 | 2478 | ||
| 2465 | af = sctp_get_af_specific(param_type2af(param.p->type)); | 2479 | af = sctp_get_af_specific(param_type2af(param.p->type)); |
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 8848d329aa2c..7c622af2ce55 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
| @@ -119,7 +119,7 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
| 119 | const struct sctp_endpoint *ep, | 119 | const struct sctp_endpoint *ep, |
| 120 | const struct sctp_association *asoc, | 120 | const struct sctp_association *asoc, |
| 121 | const sctp_subtype_t type, | 121 | const sctp_subtype_t type, |
| 122 | void *arg, | 122 | void *arg, void *ext, |
| 123 | sctp_cmd_seq_t *commands); | 123 | sctp_cmd_seq_t *commands); |
| 124 | 124 | ||
| 125 | static sctp_disposition_t sctp_sf_violation_ctsn( | 125 | static sctp_disposition_t sctp_sf_violation_ctsn( |
| @@ -3425,7 +3425,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
| 3425 | addr_param = (union sctp_addr_param *)hdr->params; | 3425 | addr_param = (union sctp_addr_param *)hdr->params; |
| 3426 | length = ntohs(addr_param->p.length); | 3426 | length = ntohs(addr_param->p.length); |
| 3427 | if (length < sizeof(sctp_paramhdr_t)) | 3427 | if (length < sizeof(sctp_paramhdr_t)) |
| 3428 | return sctp_sf_violation_paramlen(ep, asoc, type, | 3428 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, |
| 3429 | (void *)addr_param, commands); | 3429 | (void *)addr_param, commands); |
| 3430 | 3430 | ||
| 3431 | /* Verify the ASCONF chunk before processing it. */ | 3431 | /* Verify the ASCONF chunk before processing it. */ |
| @@ -3433,8 +3433,8 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
| 3433 | (sctp_paramhdr_t *)((void *)addr_param + length), | 3433 | (sctp_paramhdr_t *)((void *)addr_param + length), |
| 3434 | (void *)chunk->chunk_end, | 3434 | (void *)chunk->chunk_end, |
| 3435 | &err_param)) | 3435 | &err_param)) |
| 3436 | return sctp_sf_violation_paramlen(ep, asoc, type, | 3436 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, |
| 3437 | (void *)&err_param, commands); | 3437 | (void *)err_param, commands); |
| 3438 | 3438 | ||
| 3439 | /* ADDIP 5.2 E1) Compare the value of the serial number to the value | 3439 | /* ADDIP 5.2 E1) Compare the value of the serial number to the value |
| 3440 | * the endpoint stored in a new association variable | 3440 | * the endpoint stored in a new association variable |
| @@ -3542,8 +3542,8 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
| 3542 | (sctp_paramhdr_t *)addip_hdr->params, | 3542 | (sctp_paramhdr_t *)addip_hdr->params, |
| 3543 | (void *)asconf_ack->chunk_end, | 3543 | (void *)asconf_ack->chunk_end, |
| 3544 | &err_param)) | 3544 | &err_param)) |
| 3545 | return sctp_sf_violation_paramlen(ep, asoc, type, | 3545 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, |
| 3546 | (void *)&err_param, commands); | 3546 | (void *)err_param, commands); |
| 3547 | 3547 | ||
| 3548 | if (last_asconf) { | 3548 | if (last_asconf) { |
| 3549 | addip_hdr = (sctp_addiphdr_t *)last_asconf->subh.addip_hdr; | 3549 | addip_hdr = (sctp_addiphdr_t *)last_asconf->subh.addip_hdr; |
| @@ -4240,12 +4240,38 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
| 4240 | const struct sctp_endpoint *ep, | 4240 | const struct sctp_endpoint *ep, |
| 4241 | const struct sctp_association *asoc, | 4241 | const struct sctp_association *asoc, |
| 4242 | const sctp_subtype_t type, | 4242 | const sctp_subtype_t type, |
| 4243 | void *arg, | 4243 | void *arg, void *ext, |
| 4244 | sctp_cmd_seq_t *commands) { | 4244 | sctp_cmd_seq_t *commands) |
| 4245 | static const char err_str[] = "The following parameter had invalid length:"; | 4245 | { |
| 4246 | struct sctp_chunk *chunk = arg; | ||
| 4247 | struct sctp_paramhdr *param = ext; | ||
| 4248 | struct sctp_chunk *abort = NULL; | ||
| 4246 | 4249 | ||
| 4247 | return sctp_sf_abort_violation(ep, asoc, arg, commands, err_str, | 4250 | if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) |
| 4248 | sizeof(err_str)); | 4251 | goto discard; |
| 4252 | |||
| 4253 | /* Make the abort chunk. */ | ||
| 4254 | abort = sctp_make_violation_paramlen(asoc, chunk, param); | ||
| 4255 | if (!abort) | ||
| 4256 | goto nomem; | ||
| 4257 | |||
| 4258 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | ||
| 4259 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | ||
| 4260 | |||
| 4261 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, | ||
| 4262 | SCTP_ERROR(ECONNABORTED)); | ||
| 4263 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | ||
| 4264 | SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION)); | ||
| 4265 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | ||
| 4266 | |||
| 4267 | discard: | ||
| 4268 | sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands); | ||
| 4269 | |||
| 4270 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | ||
| 4271 | |||
| 4272 | return SCTP_DISPOSITION_ABORT; | ||
| 4273 | nomem: | ||
| 4274 | return SCTP_DISPOSITION_NOMEM; | ||
| 4249 | } | 4275 | } |
| 4250 | 4276 | ||
| 4251 | /* Handle a protocol violation when the peer trying to advance the | 4277 | /* Handle a protocol violation when the peer trying to advance the |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index dbb79adf8f3c..5ffb9dec1c3f 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
| @@ -3055,6 +3055,9 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, | |||
| 3055 | { | 3055 | { |
| 3056 | struct sctp_authchunk val; | 3056 | struct sctp_authchunk val; |
| 3057 | 3057 | ||
| 3058 | if (!sctp_auth_enable) | ||
| 3059 | return -EACCES; | ||
| 3060 | |||
| 3058 | if (optlen != sizeof(struct sctp_authchunk)) | 3061 | if (optlen != sizeof(struct sctp_authchunk)) |
| 3059 | return -EINVAL; | 3062 | return -EINVAL; |
| 3060 | if (copy_from_user(&val, optval, optlen)) | 3063 | if (copy_from_user(&val, optval, optlen)) |
| @@ -3083,8 +3086,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, | |||
| 3083 | int optlen) | 3086 | int optlen) |
| 3084 | { | 3087 | { |
| 3085 | struct sctp_hmacalgo *hmacs; | 3088 | struct sctp_hmacalgo *hmacs; |
| 3089 | u32 idents; | ||
| 3086 | int err; | 3090 | int err; |
| 3087 | 3091 | ||
| 3092 | if (!sctp_auth_enable) | ||
| 3093 | return -EACCES; | ||
| 3094 | |||
| 3088 | if (optlen < sizeof(struct sctp_hmacalgo)) | 3095 | if (optlen < sizeof(struct sctp_hmacalgo)) |
| 3089 | return -EINVAL; | 3096 | return -EINVAL; |
| 3090 | 3097 | ||
| @@ -3097,8 +3104,9 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, | |||
| 3097 | goto out; | 3104 | goto out; |
| 3098 | } | 3105 | } |
| 3099 | 3106 | ||
| 3100 | if (hmacs->shmac_num_idents == 0 || | 3107 | idents = hmacs->shmac_num_idents; |
| 3101 | hmacs->shmac_num_idents > SCTP_AUTH_NUM_HMACS) { | 3108 | if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || |
| 3109 | (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) { | ||
| 3102 | err = -EINVAL; | 3110 | err = -EINVAL; |
| 3103 | goto out; | 3111 | goto out; |
| 3104 | } | 3112 | } |
| @@ -3123,6 +3131,9 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
| 3123 | struct sctp_association *asoc; | 3131 | struct sctp_association *asoc; |
| 3124 | int ret; | 3132 | int ret; |
| 3125 | 3133 | ||
| 3134 | if (!sctp_auth_enable) | ||
| 3135 | return -EACCES; | ||
| 3136 | |||
| 3126 | if (optlen <= sizeof(struct sctp_authkey)) | 3137 | if (optlen <= sizeof(struct sctp_authkey)) |
| 3127 | return -EINVAL; | 3138 | return -EINVAL; |
| 3128 | 3139 | ||
| @@ -3135,6 +3146,11 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
| 3135 | goto out; | 3146 | goto out; |
| 3136 | } | 3147 | } |
| 3137 | 3148 | ||
| 3149 | if (authkey->sca_keylength > optlen - sizeof(struct sctp_authkey)) { | ||
| 3150 | ret = -EINVAL; | ||
| 3151 | goto out; | ||
| 3152 | } | ||
| 3153 | |||
| 3138 | asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); | 3154 | asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); |
| 3139 | if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { | 3155 | if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { |
| 3140 | ret = -EINVAL; | 3156 | ret = -EINVAL; |
| @@ -3160,6 +3176,9 @@ static int sctp_setsockopt_active_key(struct sock *sk, | |||
| 3160 | struct sctp_authkeyid val; | 3176 | struct sctp_authkeyid val; |
| 3161 | struct sctp_association *asoc; | 3177 | struct sctp_association *asoc; |
| 3162 | 3178 | ||
| 3179 | if (!sctp_auth_enable) | ||
| 3180 | return -EACCES; | ||
| 3181 | |||
| 3163 | if (optlen != sizeof(struct sctp_authkeyid)) | 3182 | if (optlen != sizeof(struct sctp_authkeyid)) |
| 3164 | return -EINVAL; | 3183 | return -EINVAL; |
| 3165 | if (copy_from_user(&val, optval, optlen)) | 3184 | if (copy_from_user(&val, optval, optlen)) |
| @@ -3185,6 +3204,9 @@ static int sctp_setsockopt_del_key(struct sock *sk, | |||
| 3185 | struct sctp_authkeyid val; | 3204 | struct sctp_authkeyid val; |
| 3186 | struct sctp_association *asoc; | 3205 | struct sctp_association *asoc; |
| 3187 | 3206 | ||
| 3207 | if (!sctp_auth_enable) | ||
| 3208 | return -EACCES; | ||
| 3209 | |||
| 3188 | if (optlen != sizeof(struct sctp_authkeyid)) | 3210 | if (optlen != sizeof(struct sctp_authkeyid)) |
| 3189 | return -EINVAL; | 3211 | return -EINVAL; |
| 3190 | if (copy_from_user(&val, optval, optlen)) | 3212 | if (copy_from_user(&val, optval, optlen)) |
| @@ -5197,19 +5219,29 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len, | |||
| 5197 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, | 5219 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, |
| 5198 | char __user *optval, int __user *optlen) | 5220 | char __user *optval, int __user *optlen) |
| 5199 | { | 5221 | { |
| 5222 | struct sctp_hmacalgo __user *p = (void __user *)optval; | ||
| 5200 | struct sctp_hmac_algo_param *hmacs; | 5223 | struct sctp_hmac_algo_param *hmacs; |
| 5201 | __u16 param_len; | 5224 | __u16 data_len = 0; |
| 5225 | u32 num_idents; | ||
| 5226 | |||
| 5227 | if (!sctp_auth_enable) | ||
| 5228 | return -EACCES; | ||
| 5202 | 5229 | ||
| 5203 | hmacs = sctp_sk(sk)->ep->auth_hmacs_list; | 5230 | hmacs = sctp_sk(sk)->ep->auth_hmacs_list; |
| 5204 | param_len = ntohs(hmacs->param_hdr.length); | 5231 | data_len = ntohs(hmacs->param_hdr.length) - sizeof(sctp_paramhdr_t); |
| 5205 | 5232 | ||
| 5206 | if (len < param_len) | 5233 | if (len < sizeof(struct sctp_hmacalgo) + data_len) |
| 5207 | return -EINVAL; | 5234 | return -EINVAL; |
| 5235 | |||
| 5236 | len = sizeof(struct sctp_hmacalgo) + data_len; | ||
| 5237 | num_idents = data_len / sizeof(u16); | ||
| 5238 | |||
| 5208 | if (put_user(len, optlen)) | 5239 | if (put_user(len, optlen)) |
| 5209 | return -EFAULT; | 5240 | return -EFAULT; |
| 5210 | if (copy_to_user(optval, hmacs->hmac_ids, len)) | 5241 | if (put_user(num_idents, &p->shmac_num_idents)) |
| 5242 | return -EFAULT; | ||
| 5243 | if (copy_to_user(p->shmac_idents, hmacs->hmac_ids, data_len)) | ||
| 5211 | return -EFAULT; | 5244 | return -EFAULT; |
| 5212 | |||
| 5213 | return 0; | 5245 | return 0; |
| 5214 | } | 5246 | } |
| 5215 | 5247 | ||
| @@ -5219,6 +5251,9 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len, | |||
| 5219 | struct sctp_authkeyid val; | 5251 | struct sctp_authkeyid val; |
| 5220 | struct sctp_association *asoc; | 5252 | struct sctp_association *asoc; |
| 5221 | 5253 | ||
| 5254 | if (!sctp_auth_enable) | ||
| 5255 | return -EACCES; | ||
| 5256 | |||
| 5222 | if (len < sizeof(struct sctp_authkeyid)) | 5257 | if (len < sizeof(struct sctp_authkeyid)) |
| 5223 | return -EINVAL; | 5258 | return -EINVAL; |
| 5224 | if (copy_from_user(&val, optval, sizeof(struct sctp_authkeyid))) | 5259 | if (copy_from_user(&val, optval, sizeof(struct sctp_authkeyid))) |
| @@ -5233,6 +5268,12 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len, | |||
| 5233 | else | 5268 | else |
| 5234 | val.scact_keynumber = sctp_sk(sk)->ep->active_key_id; | 5269 | val.scact_keynumber = sctp_sk(sk)->ep->active_key_id; |
| 5235 | 5270 | ||
| 5271 | len = sizeof(struct sctp_authkeyid); | ||
| 5272 | if (put_user(len, optlen)) | ||
| 5273 | return -EFAULT; | ||
| 5274 | if (copy_to_user(optval, &val, len)) | ||
| 5275 | return -EFAULT; | ||
| 5276 | |||
| 5236 | return 0; | 5277 | return 0; |
| 5237 | } | 5278 | } |
| 5238 | 5279 | ||
| @@ -5243,13 +5284,16 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | |||
| 5243 | struct sctp_authchunks val; | 5284 | struct sctp_authchunks val; |
| 5244 | struct sctp_association *asoc; | 5285 | struct sctp_association *asoc; |
| 5245 | struct sctp_chunks_param *ch; | 5286 | struct sctp_chunks_param *ch; |
| 5246 | u32 num_chunks; | 5287 | u32 num_chunks = 0; |
| 5247 | char __user *to; | 5288 | char __user *to; |
| 5248 | 5289 | ||
| 5249 | if (len <= sizeof(struct sctp_authchunks)) | 5290 | if (!sctp_auth_enable) |
| 5291 | return -EACCES; | ||
| 5292 | |||
| 5293 | if (len < sizeof(struct sctp_authchunks)) | ||
| 5250 | return -EINVAL; | 5294 | return -EINVAL; |
| 5251 | 5295 | ||
| 5252 | if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) | 5296 | if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) |
| 5253 | return -EFAULT; | 5297 | return -EFAULT; |
| 5254 | 5298 | ||
| 5255 | to = p->gauth_chunks; | 5299 | to = p->gauth_chunks; |
| @@ -5258,20 +5302,21 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | |||
| 5258 | return -EINVAL; | 5302 | return -EINVAL; |
| 5259 | 5303 | ||
| 5260 | ch = asoc->peer.peer_chunks; | 5304 | ch = asoc->peer.peer_chunks; |
| 5305 | if (!ch) | ||
| 5306 | goto num; | ||
| 5261 | 5307 | ||
| 5262 | /* See if the user provided enough room for all the data */ | 5308 | /* See if the user provided enough room for all the data */ |
| 5263 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); | 5309 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); |
| 5264 | if (len < num_chunks) | 5310 | if (len < num_chunks) |
| 5265 | return -EINVAL; | 5311 | return -EINVAL; |
| 5266 | 5312 | ||
| 5267 | len = num_chunks; | 5313 | if (copy_to_user(to, ch->chunks, num_chunks)) |
| 5268 | if (put_user(len, optlen)) | ||
| 5269 | return -EFAULT; | 5314 | return -EFAULT; |
| 5315 | num: | ||
| 5316 | len = sizeof(struct sctp_authchunks) + num_chunks; | ||
| 5317 | if (put_user(len, optlen)) return -EFAULT; | ||
| 5270 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) | 5318 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) |
| 5271 | return -EFAULT; | 5319 | return -EFAULT; |
| 5272 | if (copy_to_user(to, ch->chunks, len)) | ||
| 5273 | return -EFAULT; | ||
| 5274 | |||
| 5275 | return 0; | 5320 | return 0; |
| 5276 | } | 5321 | } |
| 5277 | 5322 | ||
| @@ -5282,13 +5327,16 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | |||
| 5282 | struct sctp_authchunks val; | 5327 | struct sctp_authchunks val; |
| 5283 | struct sctp_association *asoc; | 5328 | struct sctp_association *asoc; |
| 5284 | struct sctp_chunks_param *ch; | 5329 | struct sctp_chunks_param *ch; |
| 5285 | u32 num_chunks; | 5330 | u32 num_chunks = 0; |
| 5286 | char __user *to; | 5331 | char __user *to; |
| 5287 | 5332 | ||
| 5288 | if (len <= sizeof(struct sctp_authchunks)) | 5333 | if (!sctp_auth_enable) |
| 5334 | return -EACCES; | ||
| 5335 | |||
| 5336 | if (len < sizeof(struct sctp_authchunks)) | ||
| 5289 | return -EINVAL; | 5337 | return -EINVAL; |
| 5290 | 5338 | ||
| 5291 | if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) | 5339 | if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) |
| 5292 | return -EFAULT; | 5340 | return -EFAULT; |
| 5293 | 5341 | ||
| 5294 | to = p->gauth_chunks; | 5342 | to = p->gauth_chunks; |
| @@ -5301,17 +5349,21 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | |||
| 5301 | else | 5349 | else |
| 5302 | ch = sctp_sk(sk)->ep->auth_chunk_list; | 5350 | ch = sctp_sk(sk)->ep->auth_chunk_list; |
| 5303 | 5351 | ||
| 5352 | if (!ch) | ||
| 5353 | goto num; | ||
| 5354 | |||
| 5304 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); | 5355 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); |
| 5305 | if (len < num_chunks) | 5356 | if (len < sizeof(struct sctp_authchunks) + num_chunks) |
| 5306 | return -EINVAL; | 5357 | return -EINVAL; |
| 5307 | 5358 | ||
| 5308 | len = num_chunks; | 5359 | if (copy_to_user(to, ch->chunks, num_chunks)) |
| 5360 | return -EFAULT; | ||
| 5361 | num: | ||
| 5362 | len = sizeof(struct sctp_authchunks) + num_chunks; | ||
| 5309 | if (put_user(len, optlen)) | 5363 | if (put_user(len, optlen)) |
| 5310 | return -EFAULT; | 5364 | return -EFAULT; |
| 5311 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) | 5365 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) |
| 5312 | return -EFAULT; | 5366 | return -EFAULT; |
| 5313 | if (copy_to_user(to, ch->chunks, len)) | ||
| 5314 | return -EFAULT; | ||
| 5315 | 5367 | ||
| 5316 | return 0; | 5368 | return 0; |
| 5317 | } | 5369 | } |
diff --git a/net/socket.c b/net/socket.c index 8ef8ba81b9e2..3e8d4e35c08f 100644 --- a/net/socket.c +++ b/net/socket.c | |||
| @@ -1511,6 +1511,7 @@ out_fd: | |||
| 1511 | goto out_put; | 1511 | goto out_put; |
| 1512 | } | 1512 | } |
| 1513 | 1513 | ||
| 1514 | #if 0 | ||
| 1514 | #ifdef HAVE_SET_RESTORE_SIGMASK | 1515 | #ifdef HAVE_SET_RESTORE_SIGMASK |
| 1515 | asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, | 1516 | asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, |
| 1516 | int __user *upeer_addrlen, | 1517 | int __user *upeer_addrlen, |
| @@ -1564,6 +1565,7 @@ asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, | |||
| 1564 | return do_accept(fd, upeer_sockaddr, upeer_addrlen, flags); | 1565 | return do_accept(fd, upeer_sockaddr, upeer_addrlen, flags); |
| 1565 | } | 1566 | } |
| 1566 | #endif | 1567 | #endif |
| 1568 | #endif | ||
| 1567 | 1569 | ||
| 1568 | asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, | 1570 | asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, |
| 1569 | int __user *upeer_addrlen) | 1571 | int __user *upeer_addrlen) |
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 0f8c439b848a..5231f7aaac0e 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c | |||
| @@ -60,24 +60,14 @@ static int proc_do_xprt(ctl_table *table, int write, struct file *file, | |||
| 60 | void __user *buffer, size_t *lenp, loff_t *ppos) | 60 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 61 | { | 61 | { |
| 62 | char tmpbuf[256]; | 62 | char tmpbuf[256]; |
| 63 | int len; | 63 | size_t len; |
| 64 | |||
| 64 | if ((*ppos && !write) || !*lenp) { | 65 | if ((*ppos && !write) || !*lenp) { |
| 65 | *lenp = 0; | 66 | *lenp = 0; |
| 66 | return 0; | 67 | return 0; |
| 67 | } | 68 | } |
| 68 | if (write) | 69 | len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); |
| 69 | return -EINVAL; | 70 | return simple_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); |
| 70 | else { | ||
| 71 | len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); | ||
| 72 | if (!access_ok(VERIFY_WRITE, buffer, len)) | ||
| 73 | return -EFAULT; | ||
| 74 | |||
| 75 | if (__copy_to_user(buffer, tmpbuf, len)) | ||
| 76 | return -EFAULT; | ||
| 77 | } | ||
| 78 | *lenp -= len; | ||
| 79 | *ppos += len; | ||
| 80 | return 0; | ||
| 81 | } | 71 | } |
| 82 | 72 | ||
| 83 | static int | 73 | static int |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c index b4b17f44cb29..74de31a06616 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | |||
| @@ -443,18 +443,18 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp) | |||
| 443 | 443 | ||
| 444 | dprintk("svcrdma: rqstp=%p\n", rqstp); | 444 | dprintk("svcrdma: rqstp=%p\n", rqstp); |
| 445 | 445 | ||
| 446 | spin_lock_bh(&rdma_xprt->sc_read_complete_lock); | 446 | spin_lock_bh(&rdma_xprt->sc_rq_dto_lock); |
| 447 | if (!list_empty(&rdma_xprt->sc_read_complete_q)) { | 447 | if (!list_empty(&rdma_xprt->sc_read_complete_q)) { |
| 448 | ctxt = list_entry(rdma_xprt->sc_read_complete_q.next, | 448 | ctxt = list_entry(rdma_xprt->sc_read_complete_q.next, |
| 449 | struct svc_rdma_op_ctxt, | 449 | struct svc_rdma_op_ctxt, |
| 450 | dto_q); | 450 | dto_q); |
| 451 | list_del_init(&ctxt->dto_q); | 451 | list_del_init(&ctxt->dto_q); |
| 452 | } | 452 | } |
| 453 | spin_unlock_bh(&rdma_xprt->sc_read_complete_lock); | 453 | if (ctxt) { |
| 454 | if (ctxt) | 454 | spin_unlock_bh(&rdma_xprt->sc_rq_dto_lock); |
| 455 | return rdma_read_complete(rqstp, ctxt); | 455 | return rdma_read_complete(rqstp, ctxt); |
| 456 | } | ||
| 456 | 457 | ||
| 457 | spin_lock_bh(&rdma_xprt->sc_rq_dto_lock); | ||
| 458 | if (!list_empty(&rdma_xprt->sc_rq_dto_q)) { | 458 | if (!list_empty(&rdma_xprt->sc_rq_dto_q)) { |
| 459 | ctxt = list_entry(rdma_xprt->sc_rq_dto_q.next, | 459 | ctxt = list_entry(rdma_xprt->sc_rq_dto_q.next, |
| 460 | struct svc_rdma_op_ctxt, | 460 | struct svc_rdma_op_ctxt, |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c index 19ddc382b777..900cb69728c6 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c | |||
| @@ -359,11 +359,11 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt) | |||
| 359 | if (test_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags)) { | 359 | if (test_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags)) { |
| 360 | struct svc_rdma_op_ctxt *read_hdr = ctxt->read_hdr; | 360 | struct svc_rdma_op_ctxt *read_hdr = ctxt->read_hdr; |
| 361 | BUG_ON(!read_hdr); | 361 | BUG_ON(!read_hdr); |
| 362 | spin_lock_bh(&xprt->sc_rq_dto_lock); | ||
| 362 | set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags); | 363 | set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags); |
| 363 | spin_lock_bh(&xprt->sc_read_complete_lock); | ||
| 364 | list_add_tail(&read_hdr->dto_q, | 364 | list_add_tail(&read_hdr->dto_q, |
| 365 | &xprt->sc_read_complete_q); | 365 | &xprt->sc_read_complete_q); |
| 366 | spin_unlock_bh(&xprt->sc_read_complete_lock); | 366 | spin_unlock_bh(&xprt->sc_rq_dto_lock); |
| 367 | svc_xprt_enqueue(&xprt->sc_xprt); | 367 | svc_xprt_enqueue(&xprt->sc_xprt); |
| 368 | } | 368 | } |
| 369 | svc_rdma_put_context(ctxt, 0); | 369 | svc_rdma_put_context(ctxt, 0); |
| @@ -428,7 +428,6 @@ static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv, | |||
| 428 | init_waitqueue_head(&cma_xprt->sc_send_wait); | 428 | init_waitqueue_head(&cma_xprt->sc_send_wait); |
| 429 | 429 | ||
| 430 | spin_lock_init(&cma_xprt->sc_lock); | 430 | spin_lock_init(&cma_xprt->sc_lock); |
| 431 | spin_lock_init(&cma_xprt->sc_read_complete_lock); | ||
| 432 | spin_lock_init(&cma_xprt->sc_rq_dto_lock); | 431 | spin_lock_init(&cma_xprt->sc_rq_dto_lock); |
| 433 | 432 | ||
| 434 | cma_xprt->sc_ord = svcrdma_ord; | 433 | cma_xprt->sc_ord = svcrdma_ord; |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index b1ff16aa4bdb..3ddaff42d1bb 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
| @@ -96,8 +96,8 @@ struct bcbearer { | |||
| 96 | struct media media; | 96 | struct media media; |
| 97 | struct bcbearer_pair bpairs[MAX_BEARERS]; | 97 | struct bcbearer_pair bpairs[MAX_BEARERS]; |
| 98 | struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1]; | 98 | struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1]; |
| 99 | struct node_map remains; | 99 | struct tipc_node_map remains; |
| 100 | struct node_map remains_new; | 100 | struct tipc_node_map remains_new; |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | /** | 103 | /** |
| @@ -110,7 +110,7 @@ struct bcbearer { | |||
| 110 | 110 | ||
| 111 | struct bclink { | 111 | struct bclink { |
| 112 | struct link link; | 112 | struct link link; |
| 113 | struct node node; | 113 | struct tipc_node node; |
| 114 | }; | 114 | }; |
| 115 | 115 | ||
| 116 | 116 | ||
| @@ -149,7 +149,7 @@ static void bcbuf_decr_acks(struct sk_buff *buf) | |||
| 149 | * Called with 'node' locked, bc_lock unlocked | 149 | * Called with 'node' locked, bc_lock unlocked |
| 150 | */ | 150 | */ |
| 151 | 151 | ||
| 152 | static void bclink_set_gap(struct node *n_ptr) | 152 | static void bclink_set_gap(struct tipc_node *n_ptr) |
| 153 | { | 153 | { |
| 154 | struct sk_buff *buf = n_ptr->bclink.deferred_head; | 154 | struct sk_buff *buf = n_ptr->bclink.deferred_head; |
| 155 | 155 | ||
| @@ -202,7 +202,7 @@ static void bclink_retransmit_pkt(u32 after, u32 to) | |||
| 202 | * Node is locked, bc_lock unlocked. | 202 | * Node is locked, bc_lock unlocked. |
| 203 | */ | 203 | */ |
| 204 | 204 | ||
| 205 | void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked) | 205 | void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked) |
| 206 | { | 206 | { |
| 207 | struct sk_buff *crs; | 207 | struct sk_buff *crs; |
| 208 | struct sk_buff *next; | 208 | struct sk_buff *next; |
| @@ -250,7 +250,7 @@ void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked) | |||
| 250 | * tipc_net_lock and node lock set | 250 | * tipc_net_lock and node lock set |
| 251 | */ | 251 | */ |
| 252 | 252 | ||
| 253 | static void bclink_send_ack(struct node *n_ptr) | 253 | static void bclink_send_ack(struct tipc_node *n_ptr) |
| 254 | { | 254 | { |
| 255 | struct link *l_ptr = n_ptr->active_links[n_ptr->addr & 1]; | 255 | struct link *l_ptr = n_ptr->active_links[n_ptr->addr & 1]; |
| 256 | 256 | ||
| @@ -264,7 +264,7 @@ static void bclink_send_ack(struct node *n_ptr) | |||
| 264 | * tipc_net_lock and node lock set | 264 | * tipc_net_lock and node lock set |
| 265 | */ | 265 | */ |
| 266 | 266 | ||
| 267 | static void bclink_send_nack(struct node *n_ptr) | 267 | static void bclink_send_nack(struct tipc_node *n_ptr) |
| 268 | { | 268 | { |
| 269 | struct sk_buff *buf; | 269 | struct sk_buff *buf; |
| 270 | struct tipc_msg *msg; | 270 | struct tipc_msg *msg; |
| @@ -308,7 +308,7 @@ static void bclink_send_nack(struct node *n_ptr) | |||
| 308 | * tipc_net_lock and node lock set | 308 | * tipc_net_lock and node lock set |
| 309 | */ | 309 | */ |
| 310 | 310 | ||
| 311 | void tipc_bclink_check_gap(struct node *n_ptr, u32 last_sent) | 311 | void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 last_sent) |
| 312 | { | 312 | { |
| 313 | if (!n_ptr->bclink.supported || | 313 | if (!n_ptr->bclink.supported || |
| 314 | less_eq(last_sent, mod(n_ptr->bclink.last_in))) | 314 | less_eq(last_sent, mod(n_ptr->bclink.last_in))) |
| @@ -328,7 +328,7 @@ void tipc_bclink_check_gap(struct node *n_ptr, u32 last_sent) | |||
| 328 | 328 | ||
| 329 | static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 gap_to) | 329 | static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 gap_to) |
| 330 | { | 330 | { |
| 331 | struct node *n_ptr = tipc_node_find(dest); | 331 | struct tipc_node *n_ptr = tipc_node_find(dest); |
| 332 | u32 my_after, my_to; | 332 | u32 my_after, my_to; |
| 333 | 333 | ||
| 334 | if (unlikely(!n_ptr || !tipc_node_is_up(n_ptr))) | 334 | if (unlikely(!n_ptr || !tipc_node_is_up(n_ptr))) |
| @@ -418,7 +418,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) | |||
| 418 | static int rx_count = 0; | 418 | static int rx_count = 0; |
| 419 | #endif | 419 | #endif |
| 420 | struct tipc_msg *msg = buf_msg(buf); | 420 | struct tipc_msg *msg = buf_msg(buf); |
| 421 | struct node* node = tipc_node_find(msg_prevnode(msg)); | 421 | struct tipc_node* node = tipc_node_find(msg_prevnode(msg)); |
| 422 | u32 next_in; | 422 | u32 next_in; |
| 423 | u32 seqno; | 423 | u32 seqno; |
| 424 | struct sk_buff *deferred; | 424 | struct sk_buff *deferred; |
| @@ -538,7 +538,7 @@ u32 tipc_bclink_get_last_sent(void) | |||
| 538 | return last_sent; | 538 | return last_sent; |
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | u32 tipc_bclink_acks_missing(struct node *n_ptr) | 541 | u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr) |
| 542 | { | 542 | { |
| 543 | return (n_ptr->bclink.supported && | 543 | return (n_ptr->bclink.supported && |
| 544 | (tipc_bclink_get_last_sent() != n_ptr->bclink.acked)); | 544 | (tipc_bclink_get_last_sent() != n_ptr->bclink.acked)); |
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index a2416fa6b906..5aa024b99c55 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
| @@ -41,12 +41,12 @@ | |||
| 41 | #define WSIZE 32 | 41 | #define WSIZE 32 |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | * struct node_map - set of node identifiers | 44 | * struct tipc_node_map - set of node identifiers |
| 45 | * @count: # of nodes in set | 45 | * @count: # of nodes in set |
| 46 | * @map: bitmap of node identifiers that are in the set | 46 | * @map: bitmap of node identifiers that are in the set |
| 47 | */ | 47 | */ |
| 48 | 48 | ||
| 49 | struct node_map { | 49 | struct tipc_node_map { |
| 50 | u32 count; | 50 | u32 count; |
| 51 | u32 map[MAX_NODES / WSIZE]; | 51 | u32 map[MAX_NODES / WSIZE]; |
| 52 | }; | 52 | }; |
| @@ -68,7 +68,7 @@ struct port_list { | |||
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | struct node; | 71 | struct tipc_node; |
| 72 | 72 | ||
| 73 | extern char tipc_bclink_name[]; | 73 | extern char tipc_bclink_name[]; |
| 74 | 74 | ||
| @@ -77,7 +77,7 @@ extern char tipc_bclink_name[]; | |||
| 77 | * nmap_add - add a node to a node map | 77 | * nmap_add - add a node to a node map |
| 78 | */ | 78 | */ |
| 79 | 79 | ||
| 80 | static inline void tipc_nmap_add(struct node_map *nm_ptr, u32 node) | 80 | static inline void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node) |
| 81 | { | 81 | { |
| 82 | int n = tipc_node(node); | 82 | int n = tipc_node(node); |
| 83 | int w = n / WSIZE; | 83 | int w = n / WSIZE; |
| @@ -93,7 +93,7 @@ static inline void tipc_nmap_add(struct node_map *nm_ptr, u32 node) | |||
| 93 | * nmap_remove - remove a node from a node map | 93 | * nmap_remove - remove a node from a node map |
| 94 | */ | 94 | */ |
| 95 | 95 | ||
| 96 | static inline void tipc_nmap_remove(struct node_map *nm_ptr, u32 node) | 96 | static inline void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) |
| 97 | { | 97 | { |
| 98 | int n = tipc_node(node); | 98 | int n = tipc_node(node); |
| 99 | int w = n / WSIZE; | 99 | int w = n / WSIZE; |
| @@ -109,7 +109,7 @@ static inline void tipc_nmap_remove(struct node_map *nm_ptr, u32 node) | |||
| 109 | * nmap_equal - test for equality of node maps | 109 | * nmap_equal - test for equality of node maps |
| 110 | */ | 110 | */ |
| 111 | 111 | ||
| 112 | static inline int tipc_nmap_equal(struct node_map *nm_a, struct node_map *nm_b) | 112 | static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) |
| 113 | { | 113 | { |
| 114 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); | 114 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); |
| 115 | } | 115 | } |
| @@ -121,8 +121,8 @@ static inline int tipc_nmap_equal(struct node_map *nm_a, struct node_map *nm_b) | |||
| 121 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) | 121 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) |
| 122 | */ | 122 | */ |
| 123 | 123 | ||
| 124 | static inline void tipc_nmap_diff(struct node_map *nm_a, struct node_map *nm_b, | 124 | static inline void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, |
| 125 | struct node_map *nm_diff) | 125 | struct tipc_node_map *nm_diff) |
| 126 | { | 126 | { |
| 127 | int stop = sizeof(nm_a->map) / sizeof(u32); | 127 | int stop = sizeof(nm_a->map) / sizeof(u32); |
| 128 | int w; | 128 | int w; |
| @@ -195,12 +195,12 @@ static inline void tipc_port_list_free(struct port_list *pl_ptr) | |||
| 195 | 195 | ||
| 196 | int tipc_bclink_init(void); | 196 | int tipc_bclink_init(void); |
| 197 | void tipc_bclink_stop(void); | 197 | void tipc_bclink_stop(void); |
| 198 | void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked); | 198 | void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked); |
| 199 | int tipc_bclink_send_msg(struct sk_buff *buf); | 199 | int tipc_bclink_send_msg(struct sk_buff *buf); |
| 200 | void tipc_bclink_recv_pkt(struct sk_buff *buf); | 200 | void tipc_bclink_recv_pkt(struct sk_buff *buf); |
| 201 | u32 tipc_bclink_get_last_sent(void); | 201 | u32 tipc_bclink_get_last_sent(void); |
| 202 | u32 tipc_bclink_acks_missing(struct node *n_ptr); | 202 | u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr); |
| 203 | void tipc_bclink_check_gap(struct node *n_ptr, u32 seqno); | 203 | void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 seqno); |
| 204 | int tipc_bclink_stats(char *stats_buf, const u32 buf_size); | 204 | int tipc_bclink_stats(char *stats_buf, const u32 buf_size); |
| 205 | int tipc_bclink_reset_stats(void); | 205 | int tipc_bclink_reset_stats(void); |
| 206 | int tipc_bclink_set_queue_limits(u32 limit); | 206 | int tipc_bclink_set_queue_limits(u32 limit); |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 6a9aba3edd08..a7a36779b9b3 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
| @@ -599,7 +599,7 @@ int tipc_block_bearer(const char *name) | |||
| 599 | spin_lock_bh(&b_ptr->publ.lock); | 599 | spin_lock_bh(&b_ptr->publ.lock); |
| 600 | b_ptr->publ.blocked = 1; | 600 | b_ptr->publ.blocked = 1; |
| 601 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 601 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
| 602 | struct node *n_ptr = l_ptr->owner; | 602 | struct tipc_node *n_ptr = l_ptr->owner; |
| 603 | 603 | ||
| 604 | spin_lock_bh(&n_ptr->lock); | 604 | spin_lock_bh(&n_ptr->lock); |
| 605 | tipc_link_reset(l_ptr); | 605 | tipc_link_reset(l_ptr); |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 6a36b6600e6c..ca5734892713 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
| @@ -104,7 +104,7 @@ struct bearer { | |||
| 104 | u32 continue_count; | 104 | u32 continue_count; |
| 105 | int active; | 105 | int active; |
| 106 | char net_plane; | 106 | char net_plane; |
| 107 | struct node_map nodes; | 107 | struct tipc_node_map nodes; |
| 108 | }; | 108 | }; |
| 109 | 109 | ||
| 110 | struct bearer_name { | 110 | struct bearer_name { |
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index 46ee6c58532d..689fdefe9d04 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
| @@ -48,8 +48,8 @@ static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf, | |||
| 48 | u32 lower, u32 upper); | 48 | u32 lower, u32 upper); |
| 49 | static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest); | 49 | static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest); |
| 50 | 50 | ||
| 51 | struct node **tipc_local_nodes = NULL; | 51 | struct tipc_node **tipc_local_nodes = NULL; |
| 52 | struct node_map tipc_cltr_bcast_nodes = {0,{0,}}; | 52 | struct tipc_node_map tipc_cltr_bcast_nodes = {0,{0,}}; |
| 53 | u32 tipc_highest_allowed_slave = 0; | 53 | u32 tipc_highest_allowed_slave = 0; |
| 54 | 54 | ||
| 55 | struct cluster *tipc_cltr_create(u32 addr) | 55 | struct cluster *tipc_cltr_create(u32 addr) |
| @@ -115,7 +115,7 @@ void tipc_cltr_delete(struct cluster *c_ptr) | |||
| 115 | 115 | ||
| 116 | u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr) | 116 | u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr) |
| 117 | { | 117 | { |
| 118 | struct node *n_ptr; | 118 | struct tipc_node *n_ptr; |
| 119 | u32 n_num = tipc_node(addr) + 1; | 119 | u32 n_num = tipc_node(addr) + 1; |
| 120 | 120 | ||
| 121 | if (!c_ptr) | 121 | if (!c_ptr) |
| @@ -133,7 +133,7 @@ u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr) | |||
| 133 | return 0; | 133 | return 0; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr) | 136 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr) |
| 137 | { | 137 | { |
| 138 | u32 n_num = tipc_node(n_ptr->addr); | 138 | u32 n_num = tipc_node(n_ptr->addr); |
| 139 | u32 max_n_num = tipc_max_nodes; | 139 | u32 max_n_num = tipc_max_nodes; |
| @@ -196,7 +196,7 @@ u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref) | |||
| 196 | * Uses deterministic and fair algorithm. | 196 | * Uses deterministic and fair algorithm. |
| 197 | */ | 197 | */ |
| 198 | 198 | ||
| 199 | struct node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector) | 199 | struct tipc_node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector) |
| 200 | { | 200 | { |
| 201 | u32 n_num; | 201 | u32 n_num; |
| 202 | u32 mask = tipc_max_nodes; | 202 | u32 mask = tipc_max_nodes; |
| @@ -379,7 +379,7 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
| 379 | { | 379 | { |
| 380 | struct tipc_msg *msg = buf_msg(buf); | 380 | struct tipc_msg *msg = buf_msg(buf); |
| 381 | struct cluster *c_ptr; | 381 | struct cluster *c_ptr; |
| 382 | struct node *n_ptr; | 382 | struct tipc_node *n_ptr; |
| 383 | unchar *node_table; | 383 | unchar *node_table; |
| 384 | u32 table_size; | 384 | u32 table_size; |
| 385 | u32 router; | 385 | u32 router; |
| @@ -499,7 +499,7 @@ static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf, | |||
| 499 | u32 lower, u32 upper) | 499 | u32 lower, u32 upper) |
| 500 | { | 500 | { |
| 501 | struct sk_buff *buf_copy; | 501 | struct sk_buff *buf_copy; |
| 502 | struct node *n_ptr; | 502 | struct tipc_node *n_ptr; |
| 503 | u32 n_num; | 503 | u32 n_num; |
| 504 | u32 tstop; | 504 | u32 tstop; |
| 505 | 505 | ||
| @@ -534,7 +534,7 @@ void tipc_cltr_broadcast(struct sk_buff *buf) | |||
| 534 | { | 534 | { |
| 535 | struct sk_buff *buf_copy; | 535 | struct sk_buff *buf_copy; |
| 536 | struct cluster *c_ptr; | 536 | struct cluster *c_ptr; |
| 537 | struct node *n_ptr; | 537 | struct tipc_node *n_ptr; |
| 538 | u32 n_num; | 538 | u32 n_num; |
| 539 | u32 tstart; | 539 | u32 tstart; |
| 540 | u32 tstop; | 540 | u32 tstop; |
diff --git a/net/tipc/cluster.h b/net/tipc/cluster.h index 62df074afaec..333efb0b9c44 100644 --- a/net/tipc/cluster.h +++ b/net/tipc/cluster.h | |||
| @@ -54,24 +54,24 @@ | |||
| 54 | struct cluster { | 54 | struct cluster { |
| 55 | u32 addr; | 55 | u32 addr; |
| 56 | struct _zone *owner; | 56 | struct _zone *owner; |
| 57 | struct node **nodes; | 57 | struct tipc_node **nodes; |
| 58 | u32 highest_node; | 58 | u32 highest_node; |
| 59 | u32 highest_slave; | 59 | u32 highest_slave; |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | 62 | ||
| 63 | extern struct node **tipc_local_nodes; | 63 | extern struct tipc_node **tipc_local_nodes; |
| 64 | extern u32 tipc_highest_allowed_slave; | 64 | extern u32 tipc_highest_allowed_slave; |
| 65 | extern struct node_map tipc_cltr_bcast_nodes; | 65 | extern struct tipc_node_map tipc_cltr_bcast_nodes; |
| 66 | 66 | ||
| 67 | void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router); | 67 | void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router); |
| 68 | void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest); | 68 | void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest); |
| 69 | struct node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector); | 69 | struct tipc_node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector); |
| 70 | u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref); | 70 | u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref); |
| 71 | void tipc_cltr_recv_routing_table(struct sk_buff *buf); | 71 | void tipc_cltr_recv_routing_table(struct sk_buff *buf); |
| 72 | struct cluster *tipc_cltr_create(u32 addr); | 72 | struct cluster *tipc_cltr_create(u32 addr); |
| 73 | void tipc_cltr_delete(struct cluster *c_ptr); | 73 | void tipc_cltr_delete(struct cluster *c_ptr); |
| 74 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr); | 74 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr); |
| 75 | void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest); | 75 | void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest); |
| 76 | void tipc_cltr_broadcast(struct sk_buff *buf); | 76 | void tipc_cltr_broadcast(struct sk_buff *buf); |
| 77 | int tipc_cltr_init(void); | 77 | int tipc_cltr_init(void); |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 1657f0e795ff..74b7d1e28aec 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
| @@ -193,7 +193,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr) | |||
| 193 | /* Always accept link here */ | 193 | /* Always accept link here */ |
| 194 | struct sk_buff *rbuf; | 194 | struct sk_buff *rbuf; |
| 195 | struct tipc_media_addr *addr; | 195 | struct tipc_media_addr *addr; |
| 196 | struct node *n_ptr = tipc_node_find(orig); | 196 | struct tipc_node *n_ptr = tipc_node_find(orig); |
| 197 | int link_fully_up; | 197 | int link_fully_up; |
| 198 | 198 | ||
| 199 | dbg(" in own cluster\n"); | 199 | dbg(" in own cluster\n"); |
diff --git a/net/tipc/link.c b/net/tipc/link.c index d60113ba4b1b..dd4c18b9a35b 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -1155,7 +1155,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | |||
| 1155 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | 1155 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) |
| 1156 | { | 1156 | { |
| 1157 | struct link *l_ptr; | 1157 | struct link *l_ptr; |
| 1158 | struct node *n_ptr; | 1158 | struct tipc_node *n_ptr; |
| 1159 | int res = -ELINKCONG; | 1159 | int res = -ELINKCONG; |
| 1160 | 1160 | ||
| 1161 | read_lock_bh(&tipc_net_lock); | 1161 | read_lock_bh(&tipc_net_lock); |
| @@ -1226,7 +1226,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, | |||
| 1226 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) | 1226 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) |
| 1227 | { | 1227 | { |
| 1228 | struct link *l_ptr; | 1228 | struct link *l_ptr; |
| 1229 | struct node *n_ptr; | 1229 | struct tipc_node *n_ptr; |
| 1230 | int res; | 1230 | int res; |
| 1231 | u32 selector = msg_origport(buf_msg(buf)) & 1; | 1231 | u32 selector = msg_origport(buf_msg(buf)) & 1; |
| 1232 | u32 dummy; | 1232 | u32 dummy; |
| @@ -1270,7 +1270,7 @@ int tipc_link_send_sections_fast(struct port *sender, | |||
| 1270 | struct tipc_msg *hdr = &sender->publ.phdr; | 1270 | struct tipc_msg *hdr = &sender->publ.phdr; |
| 1271 | struct link *l_ptr; | 1271 | struct link *l_ptr; |
| 1272 | struct sk_buff *buf; | 1272 | struct sk_buff *buf; |
| 1273 | struct node *node; | 1273 | struct tipc_node *node; |
| 1274 | int res; | 1274 | int res; |
| 1275 | u32 selector = msg_origport(hdr) & 1; | 1275 | u32 selector = msg_origport(hdr) & 1; |
| 1276 | 1276 | ||
| @@ -1364,7 +1364,7 @@ static int link_send_sections_long(struct port *sender, | |||
| 1364 | u32 destaddr) | 1364 | u32 destaddr) |
| 1365 | { | 1365 | { |
| 1366 | struct link *l_ptr; | 1366 | struct link *l_ptr; |
| 1367 | struct node *node; | 1367 | struct tipc_node *node; |
| 1368 | struct tipc_msg *hdr = &sender->publ.phdr; | 1368 | struct tipc_msg *hdr = &sender->publ.phdr; |
| 1369 | u32 dsz = msg_data_sz(hdr); | 1369 | u32 dsz = msg_data_sz(hdr); |
| 1370 | u32 max_pkt,fragm_sz,rest; | 1370 | u32 max_pkt,fragm_sz,rest; |
| @@ -1636,7 +1636,7 @@ void tipc_link_push_queue(struct link *l_ptr) | |||
| 1636 | 1636 | ||
| 1637 | static void link_reset_all(unsigned long addr) | 1637 | static void link_reset_all(unsigned long addr) |
| 1638 | { | 1638 | { |
| 1639 | struct node *n_ptr; | 1639 | struct tipc_node *n_ptr; |
| 1640 | char addr_string[16]; | 1640 | char addr_string[16]; |
| 1641 | u32 i; | 1641 | u32 i; |
| 1642 | 1642 | ||
| @@ -1682,7 +1682,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf) | |||
| 1682 | 1682 | ||
| 1683 | /* Handle failure on broadcast link */ | 1683 | /* Handle failure on broadcast link */ |
| 1684 | 1684 | ||
| 1685 | struct node *n_ptr; | 1685 | struct tipc_node *n_ptr; |
| 1686 | char addr_string[16]; | 1686 | char addr_string[16]; |
| 1687 | 1687 | ||
| 1688 | tipc_printf(TIPC_OUTPUT, "Msg seq number: %u, ", msg_seqno(msg)); | 1688 | tipc_printf(TIPC_OUTPUT, "Msg seq number: %u, ", msg_seqno(msg)); |
| @@ -1843,7 +1843,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) | |||
| 1843 | read_lock_bh(&tipc_net_lock); | 1843 | read_lock_bh(&tipc_net_lock); |
| 1844 | while (head) { | 1844 | while (head) { |
| 1845 | struct bearer *b_ptr = (struct bearer *)tb_ptr; | 1845 | struct bearer *b_ptr = (struct bearer *)tb_ptr; |
| 1846 | struct node *n_ptr; | 1846 | struct tipc_node *n_ptr; |
| 1847 | struct link *l_ptr; | 1847 | struct link *l_ptr; |
| 1848 | struct sk_buff *crs; | 1848 | struct sk_buff *crs; |
| 1849 | struct sk_buff *buf = head; | 1849 | struct sk_buff *buf = head; |
| @@ -2935,7 +2935,7 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window) | |||
| 2935 | * Returns pointer to link (or 0 if invalid link name). | 2935 | * Returns pointer to link (or 0 if invalid link name). |
| 2936 | */ | 2936 | */ |
| 2937 | 2937 | ||
| 2938 | static struct link *link_find_link(const char *name, struct node **node) | 2938 | static struct link *link_find_link(const char *name, struct tipc_node **node) |
| 2939 | { | 2939 | { |
| 2940 | struct link_name link_name_parts; | 2940 | struct link_name link_name_parts; |
| 2941 | struct bearer *b_ptr; | 2941 | struct bearer *b_ptr; |
| @@ -2965,7 +2965,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
| 2965 | struct tipc_link_config *args; | 2965 | struct tipc_link_config *args; |
| 2966 | u32 new_value; | 2966 | u32 new_value; |
| 2967 | struct link *l_ptr; | 2967 | struct link *l_ptr; |
| 2968 | struct node *node; | 2968 | struct tipc_node *node; |
| 2969 | int res; | 2969 | int res; |
| 2970 | 2970 | ||
| 2971 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) | 2971 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) |
| @@ -3043,7 +3043,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_ | |||
| 3043 | { | 3043 | { |
| 3044 | char *link_name; | 3044 | char *link_name; |
| 3045 | struct link *l_ptr; | 3045 | struct link *l_ptr; |
| 3046 | struct node *node; | 3046 | struct tipc_node *node; |
| 3047 | 3047 | ||
| 3048 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | 3048 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) |
| 3049 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 3049 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
| @@ -3091,7 +3091,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | |||
| 3091 | { | 3091 | { |
| 3092 | struct print_buf pb; | 3092 | struct print_buf pb; |
| 3093 | struct link *l_ptr; | 3093 | struct link *l_ptr; |
| 3094 | struct node *node; | 3094 | struct tipc_node *node; |
| 3095 | char *status; | 3095 | char *status; |
| 3096 | u32 profile_total = 0; | 3096 | u32 profile_total = 0; |
| 3097 | 3097 | ||
| @@ -3207,7 +3207,7 @@ int link_control(const char *name, u32 op, u32 val) | |||
| 3207 | int res = -EINVAL; | 3207 | int res = -EINVAL; |
| 3208 | struct link *l_ptr; | 3208 | struct link *l_ptr; |
| 3209 | u32 bearer_id; | 3209 | u32 bearer_id; |
| 3210 | struct node * node; | 3210 | struct tipc_node * node; |
| 3211 | u32 a; | 3211 | u32 a; |
| 3212 | 3212 | ||
| 3213 | a = link_name2addr(name, &bearer_id); | 3213 | a = link_name2addr(name, &bearer_id); |
| @@ -3249,7 +3249,7 @@ int link_control(const char *name, u32 op, u32 val) | |||
| 3249 | 3249 | ||
| 3250 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | 3250 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) |
| 3251 | { | 3251 | { |
| 3252 | struct node *n_ptr; | 3252 | struct tipc_node *n_ptr; |
| 3253 | struct link *l_ptr; | 3253 | struct link *l_ptr; |
| 3254 | u32 res = MAX_PKT_DEFAULT; | 3254 | u32 res = MAX_PKT_DEFAULT; |
| 3255 | 3255 | ||
diff --git a/net/tipc/link.h b/net/tipc/link.h index 52f3e7c1871f..6a51e38ad25c 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
| @@ -116,7 +116,7 @@ struct link { | |||
| 116 | char name[TIPC_MAX_LINK_NAME]; | 116 | char name[TIPC_MAX_LINK_NAME]; |
| 117 | struct tipc_media_addr media_addr; | 117 | struct tipc_media_addr media_addr; |
| 118 | struct timer_list timer; | 118 | struct timer_list timer; |
| 119 | struct node *owner; | 119 | struct tipc_node *owner; |
| 120 | struct list_head link_list; | 120 | struct list_head link_list; |
| 121 | 121 | ||
| 122 | /* Management and link supervision data */ | 122 | /* Management and link supervision data */ |
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index b9e7cd336d76..139882d4ed00 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h | |||
| @@ -76,7 +76,7 @@ struct publication { | |||
| 76 | u32 node; | 76 | u32 node; |
| 77 | u32 ref; | 77 | u32 ref; |
| 78 | u32 key; | 78 | u32 key; |
| 79 | struct node_subscr subscr; | 79 | struct tipc_node_subscr subscr; |
| 80 | struct list_head local_list; | 80 | struct list_head local_list; |
| 81 | struct list_head pport_list; | 81 | struct list_head pport_list; |
| 82 | struct publication *node_list_next; | 82 | struct publication *node_list_next; |
diff --git a/net/tipc/net.c b/net/tipc/net.c index ec7b04fbdc43..7906608bf510 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
| @@ -118,7 +118,7 @@ | |||
| 118 | DEFINE_RWLOCK(tipc_net_lock); | 118 | DEFINE_RWLOCK(tipc_net_lock); |
| 119 | struct network tipc_net = { NULL }; | 119 | struct network tipc_net = { NULL }; |
| 120 | 120 | ||
| 121 | struct node *tipc_net_select_remote_node(u32 addr, u32 ref) | 121 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) |
| 122 | { | 122 | { |
| 123 | return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); | 123 | return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); |
| 124 | } | 124 | } |
diff --git a/net/tipc/net.h b/net/tipc/net.h index d154ac2bda9a..de2b9ad8f646 100644 --- a/net/tipc/net.h +++ b/net/tipc/net.h | |||
| @@ -55,7 +55,7 @@ extern rwlock_t tipc_net_lock; | |||
| 55 | void tipc_net_remove_as_router(u32 router); | 55 | void tipc_net_remove_as_router(u32 router); |
| 56 | void tipc_net_send_external_routes(u32 dest); | 56 | void tipc_net_send_external_routes(u32 dest); |
| 57 | void tipc_net_route_msg(struct sk_buff *buf); | 57 | void tipc_net_route_msg(struct sk_buff *buf); |
| 58 | struct node *tipc_net_select_remote_node(u32 addr, u32 ref); | 58 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref); |
| 59 | u32 tipc_net_select_router(u32 addr, u32 ref); | 59 | u32 tipc_net_select_router(u32 addr, u32 ref); |
| 60 | 60 | ||
| 61 | int tipc_net_start(u32 addr); | 61 | int tipc_net_start(u32 addr); |
diff --git a/net/tipc/node.c b/net/tipc/node.c index ee952ad60218..20d98c56e152 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
| @@ -46,11 +46,11 @@ | |||
| 46 | #include "bearer.h" | 46 | #include "bearer.h" |
| 47 | #include "name_distr.h" | 47 | #include "name_distr.h" |
| 48 | 48 | ||
| 49 | void node_print(struct print_buf *buf, struct node *n_ptr, char *str); | 49 | void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str); |
| 50 | static void node_lost_contact(struct node *n_ptr); | 50 | static void node_lost_contact(struct tipc_node *n_ptr); |
| 51 | static void node_established_contact(struct node *n_ptr); | 51 | static void node_established_contact(struct tipc_node *n_ptr); |
| 52 | 52 | ||
| 53 | struct node *tipc_nodes = NULL; /* sorted list of nodes within cluster */ | 53 | struct tipc_node *tipc_nodes = NULL; /* sorted list of nodes within cluster */ |
| 54 | 54 | ||
| 55 | static DEFINE_SPINLOCK(node_create_lock); | 55 | static DEFINE_SPINLOCK(node_create_lock); |
| 56 | 56 | ||
| @@ -66,11 +66,11 @@ u32 tipc_own_tag = 0; | |||
| 66 | * but this is a non-trivial change.) | 66 | * but this is a non-trivial change.) |
| 67 | */ | 67 | */ |
| 68 | 68 | ||
| 69 | struct node *tipc_node_create(u32 addr) | 69 | struct tipc_node *tipc_node_create(u32 addr) |
| 70 | { | 70 | { |
| 71 | struct cluster *c_ptr; | 71 | struct cluster *c_ptr; |
| 72 | struct node *n_ptr; | 72 | struct tipc_node *n_ptr; |
| 73 | struct node **curr_node; | 73 | struct tipc_node **curr_node; |
| 74 | 74 | ||
| 75 | spin_lock_bh(&node_create_lock); | 75 | spin_lock_bh(&node_create_lock); |
| 76 | 76 | ||
| @@ -120,7 +120,7 @@ struct node *tipc_node_create(u32 addr) | |||
| 120 | return n_ptr; | 120 | return n_ptr; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | void tipc_node_delete(struct node *n_ptr) | 123 | void tipc_node_delete(struct tipc_node *n_ptr) |
| 124 | { | 124 | { |
| 125 | if (!n_ptr) | 125 | if (!n_ptr) |
| 126 | return; | 126 | return; |
| @@ -146,7 +146,7 @@ void tipc_node_delete(struct node *n_ptr) | |||
| 146 | * Link becomes active (alone or shared) or standby, depending on its priority. | 146 | * Link becomes active (alone or shared) or standby, depending on its priority. |
| 147 | */ | 147 | */ |
| 148 | 148 | ||
| 149 | void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr) | 149 | void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr) |
| 150 | { | 150 | { |
| 151 | struct link **active = &n_ptr->active_links[0]; | 151 | struct link **active = &n_ptr->active_links[0]; |
| 152 | 152 | ||
| @@ -180,7 +180,7 @@ void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr) | |||
| 180 | * node_select_active_links - select active link | 180 | * node_select_active_links - select active link |
| 181 | */ | 181 | */ |
| 182 | 182 | ||
| 183 | static void node_select_active_links(struct node *n_ptr) | 183 | static void node_select_active_links(struct tipc_node *n_ptr) |
| 184 | { | 184 | { |
| 185 | struct link **active = &n_ptr->active_links[0]; | 185 | struct link **active = &n_ptr->active_links[0]; |
| 186 | u32 i; | 186 | u32 i; |
| @@ -208,7 +208,7 @@ static void node_select_active_links(struct node *n_ptr) | |||
| 208 | * tipc_node_link_down - handle loss of link | 208 | * tipc_node_link_down - handle loss of link |
| 209 | */ | 209 | */ |
| 210 | 210 | ||
| 211 | void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr) | 211 | void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr) |
| 212 | { | 212 | { |
| 213 | struct link **active; | 213 | struct link **active; |
| 214 | 214 | ||
| @@ -235,30 +235,30 @@ void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr) | |||
| 235 | node_lost_contact(n_ptr); | 235 | node_lost_contact(n_ptr); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | int tipc_node_has_active_links(struct node *n_ptr) | 238 | int tipc_node_has_active_links(struct tipc_node *n_ptr) |
| 239 | { | 239 | { |
| 240 | return (n_ptr && | 240 | return (n_ptr && |
| 241 | ((n_ptr->active_links[0]) || (n_ptr->active_links[1]))); | 241 | ((n_ptr->active_links[0]) || (n_ptr->active_links[1]))); |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | int tipc_node_has_redundant_links(struct node *n_ptr) | 244 | int tipc_node_has_redundant_links(struct tipc_node *n_ptr) |
| 245 | { | 245 | { |
| 246 | return (n_ptr->working_links > 1); | 246 | return (n_ptr->working_links > 1); |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | static int tipc_node_has_active_routes(struct node *n_ptr) | 249 | static int tipc_node_has_active_routes(struct tipc_node *n_ptr) |
| 250 | { | 250 | { |
| 251 | return (n_ptr && (n_ptr->last_router >= 0)); | 251 | return (n_ptr && (n_ptr->last_router >= 0)); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | int tipc_node_is_up(struct node *n_ptr) | 254 | int tipc_node_is_up(struct tipc_node *n_ptr) |
| 255 | { | 255 | { |
| 256 | return (tipc_node_has_active_links(n_ptr) || tipc_node_has_active_routes(n_ptr)); | 256 | return (tipc_node_has_active_links(n_ptr) || tipc_node_has_active_routes(n_ptr)); |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | struct node *tipc_node_attach_link(struct link *l_ptr) | 259 | struct tipc_node *tipc_node_attach_link(struct link *l_ptr) |
| 260 | { | 260 | { |
| 261 | struct node *n_ptr = tipc_node_find(l_ptr->addr); | 261 | struct tipc_node *n_ptr = tipc_node_find(l_ptr->addr); |
| 262 | 262 | ||
| 263 | if (!n_ptr) | 263 | if (!n_ptr) |
| 264 | n_ptr = tipc_node_create(l_ptr->addr); | 264 | n_ptr = tipc_node_create(l_ptr->addr); |
| @@ -285,7 +285,7 @@ struct node *tipc_node_attach_link(struct link *l_ptr) | |||
| 285 | return NULL; | 285 | return NULL; |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr) | 288 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) |
| 289 | { | 289 | { |
| 290 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; | 290 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; |
| 291 | tipc_net.zones[tipc_zone(l_ptr->addr)]->links--; | 291 | tipc_net.zones[tipc_zone(l_ptr->addr)]->links--; |
| @@ -338,7 +338,7 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr) | |||
| 338 | * | 338 | * |
| 339 | */ | 339 | */ |
| 340 | 340 | ||
| 341 | static void node_established_contact(struct node *n_ptr) | 341 | static void node_established_contact(struct tipc_node *n_ptr) |
| 342 | { | 342 | { |
| 343 | struct cluster *c_ptr; | 343 | struct cluster *c_ptr; |
| 344 | 344 | ||
| @@ -384,10 +384,10 @@ static void node_established_contact(struct node *n_ptr) | |||
| 384 | tipc_highest_allowed_slave); | 384 | tipc_highest_allowed_slave); |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | static void node_lost_contact(struct node *n_ptr) | 387 | static void node_lost_contact(struct tipc_node *n_ptr) |
| 388 | { | 388 | { |
| 389 | struct cluster *c_ptr; | 389 | struct cluster *c_ptr; |
| 390 | struct node_subscr *ns, *tns; | 390 | struct tipc_node_subscr *ns, *tns; |
| 391 | char addr_string[16]; | 391 | char addr_string[16]; |
| 392 | u32 i; | 392 | u32 i; |
| 393 | 393 | ||
| @@ -466,9 +466,9 @@ static void node_lost_contact(struct node *n_ptr) | |||
| 466 | * Called by when cluster local lookup has failed. | 466 | * Called by when cluster local lookup has failed. |
| 467 | */ | 467 | */ |
| 468 | 468 | ||
| 469 | struct node *tipc_node_select_next_hop(u32 addr, u32 selector) | 469 | struct tipc_node *tipc_node_select_next_hop(u32 addr, u32 selector) |
| 470 | { | 470 | { |
| 471 | struct node *n_ptr; | 471 | struct tipc_node *n_ptr; |
| 472 | u32 router_addr; | 472 | u32 router_addr; |
| 473 | 473 | ||
| 474 | if (!tipc_addr_domain_valid(addr)) | 474 | if (!tipc_addr_domain_valid(addr)) |
| @@ -513,7 +513,7 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector) | |||
| 513 | * Uses a deterministic and fair algorithm for selecting router node. | 513 | * Uses a deterministic and fair algorithm for selecting router node. |
| 514 | */ | 514 | */ |
| 515 | 515 | ||
| 516 | u32 tipc_node_select_router(struct node *n_ptr, u32 ref) | 516 | u32 tipc_node_select_router(struct tipc_node *n_ptr, u32 ref) |
| 517 | { | 517 | { |
| 518 | u32 ulim; | 518 | u32 ulim; |
| 519 | u32 mask; | 519 | u32 mask; |
| @@ -551,7 +551,7 @@ u32 tipc_node_select_router(struct node *n_ptr, u32 ref) | |||
| 551 | return tipc_addr(own_zone(), own_cluster(), r); | 551 | return tipc_addr(own_zone(), own_cluster(), r); |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | void tipc_node_add_router(struct node *n_ptr, u32 router) | 554 | void tipc_node_add_router(struct tipc_node *n_ptr, u32 router) |
| 555 | { | 555 | { |
| 556 | u32 r_num = tipc_node(router); | 556 | u32 r_num = tipc_node(router); |
| 557 | 557 | ||
| @@ -562,7 +562,7 @@ void tipc_node_add_router(struct node *n_ptr, u32 router) | |||
| 562 | !n_ptr->routers[n_ptr->last_router]); | 562 | !n_ptr->routers[n_ptr->last_router]); |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | void tipc_node_remove_router(struct node *n_ptr, u32 router) | 565 | void tipc_node_remove_router(struct tipc_node *n_ptr, u32 router) |
| 566 | { | 566 | { |
| 567 | u32 r_num = tipc_node(router); | 567 | u32 r_num = tipc_node(router); |
| 568 | 568 | ||
| @@ -580,7 +580,7 @@ void tipc_node_remove_router(struct node *n_ptr, u32 router) | |||
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | #if 0 | 582 | #if 0 |
| 583 | void node_print(struct print_buf *buf, struct node *n_ptr, char *str) | 583 | void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str) |
| 584 | { | 584 | { |
| 585 | u32 i; | 585 | u32 i; |
| 586 | 586 | ||
| @@ -597,7 +597,7 @@ void node_print(struct print_buf *buf, struct node *n_ptr, char *str) | |||
| 597 | 597 | ||
| 598 | u32 tipc_available_nodes(const u32 domain) | 598 | u32 tipc_available_nodes(const u32 domain) |
| 599 | { | 599 | { |
| 600 | struct node *n_ptr; | 600 | struct tipc_node *n_ptr; |
| 601 | u32 cnt = 0; | 601 | u32 cnt = 0; |
| 602 | 602 | ||
| 603 | read_lock_bh(&tipc_net_lock); | 603 | read_lock_bh(&tipc_net_lock); |
| @@ -615,7 +615,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 615 | { | 615 | { |
| 616 | u32 domain; | 616 | u32 domain; |
| 617 | struct sk_buff *buf; | 617 | struct sk_buff *buf; |
| 618 | struct node *n_ptr; | 618 | struct tipc_node *n_ptr; |
| 619 | struct tipc_node_info node_info; | 619 | struct tipc_node_info node_info; |
| 620 | u32 payload_size; | 620 | u32 payload_size; |
| 621 | 621 | ||
| @@ -667,7 +667,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 667 | { | 667 | { |
| 668 | u32 domain; | 668 | u32 domain; |
| 669 | struct sk_buff *buf; | 669 | struct sk_buff *buf; |
| 670 | struct node *n_ptr; | 670 | struct tipc_node *n_ptr; |
| 671 | struct tipc_link_info link_info; | 671 | struct tipc_link_info link_info; |
| 672 | u32 payload_size; | 672 | u32 payload_size; |
| 673 | 673 | ||
diff --git a/net/tipc/node.h b/net/tipc/node.h index cd1882654bbb..6f990da5d143 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | #include "bearer.h" | 43 | #include "bearer.h" |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * struct node - TIPC node structure | 46 | * struct tipc_node - TIPC node structure |
| 47 | * @addr: network address of node | 47 | * @addr: network address of node |
| 48 | * @lock: spinlock governing access to structure | 48 | * @lock: spinlock governing access to structure |
| 49 | * @owner: pointer to cluster that node belongs to | 49 | * @owner: pointer to cluster that node belongs to |
| @@ -68,11 +68,11 @@ | |||
| 68 | * @defragm: list of partially reassembled b'cast message fragments from node | 68 | * @defragm: list of partially reassembled b'cast message fragments from node |
| 69 | */ | 69 | */ |
| 70 | 70 | ||
| 71 | struct node { | 71 | struct tipc_node { |
| 72 | u32 addr; | 72 | u32 addr; |
| 73 | spinlock_t lock; | 73 | spinlock_t lock; |
| 74 | struct cluster *owner; | 74 | struct cluster *owner; |
| 75 | struct node *next; | 75 | struct tipc_node *next; |
| 76 | struct list_head nsub; | 76 | struct list_head nsub; |
| 77 | struct link *active_links[2]; | 77 | struct link *active_links[2]; |
| 78 | struct link *links[MAX_BEARERS]; | 78 | struct link *links[MAX_BEARERS]; |
| @@ -94,26 +94,26 @@ struct node { | |||
| 94 | } bclink; | 94 | } bclink; |
| 95 | }; | 95 | }; |
| 96 | 96 | ||
| 97 | extern struct node *tipc_nodes; | 97 | extern struct tipc_node *tipc_nodes; |
| 98 | extern u32 tipc_own_tag; | 98 | extern u32 tipc_own_tag; |
| 99 | 99 | ||
| 100 | struct node *tipc_node_create(u32 addr); | 100 | struct tipc_node *tipc_node_create(u32 addr); |
| 101 | void tipc_node_delete(struct node *n_ptr); | 101 | void tipc_node_delete(struct tipc_node *n_ptr); |
| 102 | struct node *tipc_node_attach_link(struct link *l_ptr); | 102 | struct tipc_node *tipc_node_attach_link(struct link *l_ptr); |
| 103 | void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr); | 103 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr); |
| 104 | void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr); | 104 | void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr); |
| 105 | void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr); | 105 | void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr); |
| 106 | int tipc_node_has_active_links(struct node *n_ptr); | 106 | int tipc_node_has_active_links(struct tipc_node *n_ptr); |
| 107 | int tipc_node_has_redundant_links(struct node *n_ptr); | 107 | int tipc_node_has_redundant_links(struct tipc_node *n_ptr); |
| 108 | u32 tipc_node_select_router(struct node *n_ptr, u32 ref); | 108 | u32 tipc_node_select_router(struct tipc_node *n_ptr, u32 ref); |
| 109 | struct node *tipc_node_select_next_hop(u32 addr, u32 selector); | 109 | struct tipc_node *tipc_node_select_next_hop(u32 addr, u32 selector); |
| 110 | int tipc_node_is_up(struct node *n_ptr); | 110 | int tipc_node_is_up(struct tipc_node *n_ptr); |
| 111 | void tipc_node_add_router(struct node *n_ptr, u32 router); | 111 | void tipc_node_add_router(struct tipc_node *n_ptr, u32 router); |
| 112 | void tipc_node_remove_router(struct node *n_ptr, u32 router); | 112 | void tipc_node_remove_router(struct tipc_node *n_ptr, u32 router); |
| 113 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); | 113 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); |
| 114 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); | 114 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); |
| 115 | 115 | ||
| 116 | static inline struct node *tipc_node_find(u32 addr) | 116 | static inline struct tipc_node *tipc_node_find(u32 addr) |
| 117 | { | 117 | { |
| 118 | if (likely(in_own_cluster(addr))) | 118 | if (likely(in_own_cluster(addr))) |
| 119 | return tipc_local_nodes[tipc_node(addr)]; | 119 | return tipc_local_nodes[tipc_node(addr)]; |
| @@ -126,19 +126,19 @@ static inline struct node *tipc_node_find(u32 addr) | |||
| 126 | return NULL; | 126 | return NULL; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | static inline struct node *tipc_node_select(u32 addr, u32 selector) | 129 | static inline struct tipc_node *tipc_node_select(u32 addr, u32 selector) |
| 130 | { | 130 | { |
| 131 | if (likely(in_own_cluster(addr))) | 131 | if (likely(in_own_cluster(addr))) |
| 132 | return tipc_local_nodes[tipc_node(addr)]; | 132 | return tipc_local_nodes[tipc_node(addr)]; |
| 133 | return tipc_node_select_next_hop(addr, selector); | 133 | return tipc_node_select_next_hop(addr, selector); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | static inline void tipc_node_lock(struct node *n_ptr) | 136 | static inline void tipc_node_lock(struct tipc_node *n_ptr) |
| 137 | { | 137 | { |
| 138 | spin_lock_bh(&n_ptr->lock); | 138 | spin_lock_bh(&n_ptr->lock); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | static inline void tipc_node_unlock(struct node *n_ptr) | 141 | static inline void tipc_node_unlock(struct tipc_node *n_ptr) |
| 142 | { | 142 | { |
| 143 | spin_unlock_bh(&n_ptr->lock); | 143 | spin_unlock_bh(&n_ptr->lock); |
| 144 | } | 144 | } |
diff --git a/net/tipc/node_subscr.c b/net/tipc/node_subscr.c index 8ecbd0fb6103..19194d476a9e 100644 --- a/net/tipc/node_subscr.c +++ b/net/tipc/node_subscr.c | |||
| @@ -44,7 +44,7 @@ | |||
| 44 | * tipc_nodesub_subscribe - create "node down" subscription for specified node | 44 | * tipc_nodesub_subscribe - create "node down" subscription for specified node |
| 45 | */ | 45 | */ |
| 46 | 46 | ||
| 47 | void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, | 47 | void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, |
| 48 | void *usr_handle, net_ev_handler handle_down) | 48 | void *usr_handle, net_ev_handler handle_down) |
| 49 | { | 49 | { |
| 50 | if (addr == tipc_own_addr) { | 50 | if (addr == tipc_own_addr) { |
| @@ -69,7 +69,7 @@ void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, | |||
| 69 | * tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) | 69 | * tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) |
| 70 | */ | 70 | */ |
| 71 | 71 | ||
| 72 | void tipc_nodesub_unsubscribe(struct node_subscr *node_sub) | 72 | void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub) |
| 73 | { | 73 | { |
| 74 | if (!node_sub->node) | 74 | if (!node_sub->node) |
| 75 | return; | 75 | return; |
diff --git a/net/tipc/node_subscr.h b/net/tipc/node_subscr.h index 5f3f5859b84c..006ed739f515 100644 --- a/net/tipc/node_subscr.h +++ b/net/tipc/node_subscr.h | |||
| @@ -42,22 +42,22 @@ | |||
| 42 | typedef void (*net_ev_handler) (void *usr_handle); | 42 | typedef void (*net_ev_handler) (void *usr_handle); |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | * struct node_subscr - "node down" subscription entry | 45 | * struct tipc_node_subscr - "node down" subscription entry |
| 46 | * @node: ptr to node structure of interest (or NULL, if none) | 46 | * @node: ptr to node structure of interest (or NULL, if none) |
| 47 | * @handle_node_down: routine to invoke when node fails | 47 | * @handle_node_down: routine to invoke when node fails |
| 48 | * @usr_handle: argument to pass to routine when node fails | 48 | * @usr_handle: argument to pass to routine when node fails |
| 49 | * @nodesub_list: adjacent entries in list of subscriptions for the node | 49 | * @nodesub_list: adjacent entries in list of subscriptions for the node |
| 50 | */ | 50 | */ |
| 51 | 51 | ||
| 52 | struct node_subscr { | 52 | struct tipc_node_subscr { |
| 53 | struct node *node; | 53 | struct tipc_node *node; |
| 54 | net_ev_handler handle_node_down; | 54 | net_ev_handler handle_node_down; |
| 55 | void *usr_handle; | 55 | void *usr_handle; |
| 56 | struct list_head nodesub_list; | 56 | struct list_head nodesub_list; |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, | 59 | void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, |
| 60 | void *usr_handle, net_ev_handler handle_down); | 60 | void *usr_handle, net_ev_handler handle_down); |
| 61 | void tipc_nodesub_unsubscribe(struct node_subscr *node_sub); | 61 | void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub); |
| 62 | 62 | ||
| 63 | #endif | 63 | #endif |
diff --git a/net/tipc/port.h b/net/tipc/port.h index e5f8c16429bd..ff31ee4a1dc3 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
| @@ -105,7 +105,7 @@ struct port { | |||
| 105 | u32 probing_interval; | 105 | u32 probing_interval; |
| 106 | u32 last_in_seqno; | 106 | u32 last_in_seqno; |
| 107 | struct timer_list timer; | 107 | struct timer_list timer; |
| 108 | struct node_subscr subscription; | 108 | struct tipc_node_subscr subscription; |
| 109 | }; | 109 | }; |
| 110 | 110 | ||
| 111 | extern spinlock_t tipc_port_list_lock; | 111 | extern spinlock_t tipc_port_list_lock; |
diff --git a/net/tipc/zone.c b/net/tipc/zone.c index 3506f8563441..2c01ba2d86bf 100644 --- a/net/tipc/zone.c +++ b/net/tipc/zone.c | |||
| @@ -111,10 +111,10 @@ void tipc_zone_send_external_routes(struct _zone *z_ptr, u32 dest) | |||
| 111 | } | 111 | } |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | struct node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref) | 114 | struct tipc_node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref) |
| 115 | { | 115 | { |
| 116 | struct cluster *c_ptr; | 116 | struct cluster *c_ptr; |
| 117 | struct node *n_ptr; | 117 | struct tipc_node *n_ptr; |
| 118 | u32 c_num; | 118 | u32 c_num; |
| 119 | 119 | ||
| 120 | if (!z_ptr) | 120 | if (!z_ptr) |
diff --git a/net/tipc/zone.h b/net/tipc/zone.h index 6e7a08df8af5..7bdc3406ba9b 100644 --- a/net/tipc/zone.h +++ b/net/tipc/zone.h | |||
| @@ -54,7 +54,7 @@ struct _zone { | |||
| 54 | u32 links; | 54 | u32 links; |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | struct node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref); | 57 | struct tipc_node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref); |
| 58 | u32 tipc_zone_select_router(struct _zone *z_ptr, u32 addr, u32 ref); | 58 | u32 tipc_zone_select_router(struct _zone *z_ptr, u32 addr, u32 ref); |
| 59 | void tipc_zone_remove_as_router(struct _zone *z_ptr, u32 router); | 59 | void tipc_zone_remove_as_router(struct _zone *z_ptr, u32 router); |
| 60 | void tipc_zone_send_external_routes(struct _zone *z_ptr, u32 dest); | 60 | void tipc_zone_send_external_routes(struct _zone *z_ptr, u32 dest); |
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index ab015c62d561..833b024f8f66 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig | |||
| @@ -39,4 +39,5 @@ config WIRELESS_EXT_SYSFS | |||
| 39 | files in /sys/class/net/*/wireless/. The same information | 39 | files in /sys/class/net/*/wireless/. The same information |
| 40 | is available via the ioctls as well. | 40 | is available via the ioctls as well. |
| 41 | 41 | ||
| 42 | Say Y if you have programs using it (we don't know of any). | 42 | Say Y if you have programs using it, like old versions of |
| 43 | hal. | ||
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index ac25b4c0e982..dc50f1e71f76 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c | |||
| @@ -27,10 +27,14 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb) | |||
| 27 | - skb_headroom(skb); | 27 | - skb_headroom(skb); |
| 28 | int ntail = dst->dev->needed_tailroom - skb_tailroom(skb); | 28 | int ntail = dst->dev->needed_tailroom - skb_tailroom(skb); |
| 29 | 29 | ||
| 30 | if (nhead > 0 || ntail > 0) | 30 | if (nhead <= 0) { |
| 31 | return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC); | 31 | if (ntail <= 0) |
| 32 | 32 | return 0; | |
| 33 | return 0; | 33 | nhead = 0; |
| 34 | } else if (ntail < 0) | ||
| 35 | ntail = 0; | ||
| 36 | |||
| 37 | return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC); | ||
| 34 | } | 38 | } |
| 35 | 39 | ||
| 36 | static int xfrm_output_one(struct sk_buff *skb, int err) | 40 | static int xfrm_output_one(struct sk_buff *skb, int err) |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 841b32a2e680..b7754b1b73a4 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
| @@ -1077,6 +1077,7 @@ static void __xfrm_policy_link(struct xfrm_policy *pol, int dir) | |||
| 1077 | struct hlist_head *chain = policy_hash_bysel(&pol->selector, | 1077 | struct hlist_head *chain = policy_hash_bysel(&pol->selector, |
| 1078 | pol->family, dir); | 1078 | pol->family, dir); |
| 1079 | 1079 | ||
| 1080 | list_add_tail(&pol->bytype, &xfrm_policy_bytype[pol->type]); | ||
| 1080 | hlist_add_head(&pol->bydst, chain); | 1081 | hlist_add_head(&pol->bydst, chain); |
| 1081 | hlist_add_head(&pol->byidx, xfrm_policy_byidx+idx_hash(pol->index)); | 1082 | hlist_add_head(&pol->byidx, xfrm_policy_byidx+idx_hash(pol->index)); |
| 1082 | xfrm_policy_count[dir]++; | 1083 | xfrm_policy_count[dir]++; |
| @@ -1731,8 +1732,7 @@ restart: | |||
| 1731 | * We can't enlist stable bundles either. | 1732 | * We can't enlist stable bundles either. |
| 1732 | */ | 1733 | */ |
| 1733 | write_unlock_bh(&policy->lock); | 1734 | write_unlock_bh(&policy->lock); |
| 1734 | if (dst) | 1735 | dst_free(dst); |
| 1735 | dst_free(dst); | ||
| 1736 | 1736 | ||
| 1737 | if (pol_dead) | 1737 | if (pol_dead) |
| 1738 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTPOLDEAD); | 1738 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTPOLDEAD); |
| @@ -1748,8 +1748,7 @@ restart: | |||
| 1748 | err = xfrm_dst_update_origin(dst, fl); | 1748 | err = xfrm_dst_update_origin(dst, fl); |
| 1749 | if (unlikely(err)) { | 1749 | if (unlikely(err)) { |
| 1750 | write_unlock_bh(&policy->lock); | 1750 | write_unlock_bh(&policy->lock); |
| 1751 | if (dst) | 1751 | dst_free(dst); |
| 1752 | dst_free(dst); | ||
| 1753 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTBUNDLECHECKERROR); | 1752 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTBUNDLECHECKERROR); |
| 1754 | goto error; | 1753 | goto error; |
| 1755 | } | 1754 | } |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 4c6914ef7d92..0a8f09c3144c 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
| @@ -780,11 +780,13 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
| 780 | { | 780 | { |
| 781 | unsigned int h; | 781 | unsigned int h; |
| 782 | struct hlist_node *entry; | 782 | struct hlist_node *entry; |
| 783 | struct xfrm_state *x, *x0; | 783 | struct xfrm_state *x, *x0, *to_put; |
| 784 | int acquire_in_progress = 0; | 784 | int acquire_in_progress = 0; |
| 785 | int error = 0; | 785 | int error = 0; |
| 786 | struct xfrm_state *best = NULL; | 786 | struct xfrm_state *best = NULL; |
| 787 | 787 | ||
| 788 | to_put = NULL; | ||
| 789 | |||
| 788 | spin_lock_bh(&xfrm_state_lock); | 790 | spin_lock_bh(&xfrm_state_lock); |
| 789 | h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family); | 791 | h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family); |
| 790 | hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) { | 792 | hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) { |
| @@ -833,7 +835,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
| 833 | if (tmpl->id.spi && | 835 | if (tmpl->id.spi && |
| 834 | (x0 = __xfrm_state_lookup(daddr, tmpl->id.spi, | 836 | (x0 = __xfrm_state_lookup(daddr, tmpl->id.spi, |
| 835 | tmpl->id.proto, family)) != NULL) { | 837 | tmpl->id.proto, family)) != NULL) { |
| 836 | xfrm_state_put(x0); | 838 | to_put = x0; |
| 837 | error = -EEXIST; | 839 | error = -EEXIST; |
| 838 | goto out; | 840 | goto out; |
| 839 | } | 841 | } |
| @@ -849,13 +851,14 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
| 849 | error = security_xfrm_state_alloc_acquire(x, pol->security, fl->secid); | 851 | error = security_xfrm_state_alloc_acquire(x, pol->security, fl->secid); |
| 850 | if (error) { | 852 | if (error) { |
| 851 | x->km.state = XFRM_STATE_DEAD; | 853 | x->km.state = XFRM_STATE_DEAD; |
| 852 | xfrm_state_put(x); | 854 | to_put = x; |
| 853 | x = NULL; | 855 | x = NULL; |
| 854 | goto out; | 856 | goto out; |
| 855 | } | 857 | } |
| 856 | 858 | ||
| 857 | if (km_query(x, tmpl, pol) == 0) { | 859 | if (km_query(x, tmpl, pol) == 0) { |
| 858 | x->km.state = XFRM_STATE_ACQ; | 860 | x->km.state = XFRM_STATE_ACQ; |
| 861 | list_add_tail(&x->all, &xfrm_state_all); | ||
| 859 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); | 862 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); |
| 860 | h = xfrm_src_hash(daddr, saddr, family); | 863 | h = xfrm_src_hash(daddr, saddr, family); |
| 861 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); | 864 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); |
| @@ -870,7 +873,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
| 870 | xfrm_hash_grow_check(x->bydst.next != NULL); | 873 | xfrm_hash_grow_check(x->bydst.next != NULL); |
| 871 | } else { | 874 | } else { |
| 872 | x->km.state = XFRM_STATE_DEAD; | 875 | x->km.state = XFRM_STATE_DEAD; |
| 873 | xfrm_state_put(x); | 876 | to_put = x; |
| 874 | x = NULL; | 877 | x = NULL; |
| 875 | error = -ESRCH; | 878 | error = -ESRCH; |
| 876 | } | 879 | } |
| @@ -881,6 +884,8 @@ out: | |||
| 881 | else | 884 | else |
| 882 | *err = acquire_in_progress ? -EAGAIN : error; | 885 | *err = acquire_in_progress ? -EAGAIN : error; |
| 883 | spin_unlock_bh(&xfrm_state_lock); | 886 | spin_unlock_bh(&xfrm_state_lock); |
| 887 | if (to_put) | ||
| 888 | xfrm_state_put(to_put); | ||
| 884 | return x; | 889 | return x; |
| 885 | } | 890 | } |
| 886 | 891 | ||
| @@ -1051,6 +1056,7 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re | |||
| 1051 | xfrm_state_hold(x); | 1056 | xfrm_state_hold(x); |
| 1052 | x->timer.expires = jiffies + sysctl_xfrm_acq_expires*HZ; | 1057 | x->timer.expires = jiffies + sysctl_xfrm_acq_expires*HZ; |
| 1053 | add_timer(&x->timer); | 1058 | add_timer(&x->timer); |
| 1059 | list_add_tail(&x->all, &xfrm_state_all); | ||
| 1054 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); | 1060 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); |
| 1055 | h = xfrm_src_hash(daddr, saddr, family); | 1061 | h = xfrm_src_hash(daddr, saddr, family); |
| 1056 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); | 1062 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); |
| @@ -1067,18 +1073,20 @@ static struct xfrm_state *__xfrm_find_acq_byseq(u32 seq); | |||
| 1067 | 1073 | ||
| 1068 | int xfrm_state_add(struct xfrm_state *x) | 1074 | int xfrm_state_add(struct xfrm_state *x) |
| 1069 | { | 1075 | { |
| 1070 | struct xfrm_state *x1; | 1076 | struct xfrm_state *x1, *to_put; |
| 1071 | int family; | 1077 | int family; |
| 1072 | int err; | 1078 | int err; |
| 1073 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); | 1079 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); |
| 1074 | 1080 | ||
| 1075 | family = x->props.family; | 1081 | family = x->props.family; |
| 1076 | 1082 | ||
| 1083 | to_put = NULL; | ||
| 1084 | |||
| 1077 | spin_lock_bh(&xfrm_state_lock); | 1085 | spin_lock_bh(&xfrm_state_lock); |
| 1078 | 1086 | ||
| 1079 | x1 = __xfrm_state_locate(x, use_spi, family); | 1087 | x1 = __xfrm_state_locate(x, use_spi, family); |
| 1080 | if (x1) { | 1088 | if (x1) { |
| 1081 | xfrm_state_put(x1); | 1089 | to_put = x1; |
| 1082 | x1 = NULL; | 1090 | x1 = NULL; |
| 1083 | err = -EEXIST; | 1091 | err = -EEXIST; |
| 1084 | goto out; | 1092 | goto out; |
| @@ -1088,7 +1096,7 @@ int xfrm_state_add(struct xfrm_state *x) | |||
| 1088 | x1 = __xfrm_find_acq_byseq(x->km.seq); | 1096 | x1 = __xfrm_find_acq_byseq(x->km.seq); |
| 1089 | if (x1 && ((x1->id.proto != x->id.proto) || | 1097 | if (x1 && ((x1->id.proto != x->id.proto) || |
| 1090 | xfrm_addr_cmp(&x1->id.daddr, &x->id.daddr, family))) { | 1098 | xfrm_addr_cmp(&x1->id.daddr, &x->id.daddr, family))) { |
| 1091 | xfrm_state_put(x1); | 1099 | to_put = x1; |
| 1092 | x1 = NULL; | 1100 | x1 = NULL; |
| 1093 | } | 1101 | } |
| 1094 | } | 1102 | } |
| @@ -1110,6 +1118,9 @@ out: | |||
| 1110 | xfrm_state_put(x1); | 1118 | xfrm_state_put(x1); |
| 1111 | } | 1119 | } |
| 1112 | 1120 | ||
| 1121 | if (to_put) | ||
| 1122 | xfrm_state_put(to_put); | ||
| 1123 | |||
| 1113 | return err; | 1124 | return err; |
| 1114 | } | 1125 | } |
| 1115 | EXPORT_SYMBOL(xfrm_state_add); | 1126 | EXPORT_SYMBOL(xfrm_state_add); |
| @@ -1269,10 +1280,12 @@ EXPORT_SYMBOL(xfrm_state_migrate); | |||
| 1269 | 1280 | ||
| 1270 | int xfrm_state_update(struct xfrm_state *x) | 1281 | int xfrm_state_update(struct xfrm_state *x) |
| 1271 | { | 1282 | { |
| 1272 | struct xfrm_state *x1; | 1283 | struct xfrm_state *x1, *to_put; |
| 1273 | int err; | 1284 | int err; |
| 1274 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); | 1285 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); |
| 1275 | 1286 | ||
| 1287 | to_put = NULL; | ||
| 1288 | |||
| 1276 | spin_lock_bh(&xfrm_state_lock); | 1289 | spin_lock_bh(&xfrm_state_lock); |
| 1277 | x1 = __xfrm_state_locate(x, use_spi, x->props.family); | 1290 | x1 = __xfrm_state_locate(x, use_spi, x->props.family); |
| 1278 | 1291 | ||
| @@ -1281,7 +1294,7 @@ int xfrm_state_update(struct xfrm_state *x) | |||
| 1281 | goto out; | 1294 | goto out; |
| 1282 | 1295 | ||
| 1283 | if (xfrm_state_kern(x1)) { | 1296 | if (xfrm_state_kern(x1)) { |
| 1284 | xfrm_state_put(x1); | 1297 | to_put = x1; |
| 1285 | err = -EEXIST; | 1298 | err = -EEXIST; |
| 1286 | goto out; | 1299 | goto out; |
| 1287 | } | 1300 | } |
| @@ -1295,6 +1308,9 @@ int xfrm_state_update(struct xfrm_state *x) | |||
| 1295 | out: | 1308 | out: |
| 1296 | spin_unlock_bh(&xfrm_state_lock); | 1309 | spin_unlock_bh(&xfrm_state_lock); |
| 1297 | 1310 | ||
| 1311 | if (to_put) | ||
| 1312 | xfrm_state_put(to_put); | ||
| 1313 | |||
| 1298 | if (err) | 1314 | if (err) |
| 1299 | return err; | 1315 | return err; |
| 1300 | 1316 | ||
