diff options
Diffstat (limited to 'net/tipc/link.c')
| -rw-r--r-- | net/tipc/link.c | 882 |
1 files changed, 284 insertions, 598 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index 23bcc1132365..14f09b3cb87c 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | #include "socket.h" | 40 | #include "socket.h" |
| 41 | #include "name_distr.h" | 41 | #include "name_distr.h" |
| 42 | #include "discover.h" | 42 | #include "discover.h" |
| 43 | #include "config.h" | ||
| 44 | #include "netlink.h" | 43 | #include "netlink.h" |
| 45 | 44 | ||
| 46 | #include <linux/pkt_sched.h> | 45 | #include <linux/pkt_sched.h> |
| @@ -101,19 +100,20 @@ static const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = { | |||
| 101 | */ | 100 | */ |
| 102 | #define START_CHANGEOVER 100000u | 101 | #define START_CHANGEOVER 100000u |
| 103 | 102 | ||
| 104 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | 103 | static void link_handle_out_of_seq_msg(struct tipc_link *link, |
| 105 | struct sk_buff *buf); | 104 | struct sk_buff *skb); |
| 106 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf); | 105 | static void tipc_link_proto_rcv(struct tipc_link *link, |
| 107 | static int tipc_link_tunnel_rcv(struct tipc_node *n_ptr, | 106 | struct sk_buff *skb); |
| 108 | struct sk_buff **buf); | 107 | static int tipc_link_tunnel_rcv(struct tipc_node *node, |
| 109 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance); | 108 | struct sk_buff **skb); |
| 109 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol); | ||
| 110 | static void link_state_event(struct tipc_link *l_ptr, u32 event); | 110 | static void link_state_event(struct tipc_link *l_ptr, u32 event); |
| 111 | static void link_reset_statistics(struct tipc_link *l_ptr); | 111 | static void link_reset_statistics(struct tipc_link *l_ptr); |
| 112 | static void link_print(struct tipc_link *l_ptr, const char *str); | 112 | static void link_print(struct tipc_link *l_ptr, const char *str); |
| 113 | static void tipc_link_sync_xmit(struct tipc_link *l); | 113 | static void tipc_link_sync_xmit(struct tipc_link *l); |
| 114 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); | 114 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); |
| 115 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf); | 115 | static void tipc_link_input(struct tipc_link *l, struct sk_buff *skb); |
| 116 | static int tipc_link_prepare_input(struct tipc_link *l, struct sk_buff **buf); | 116 | static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb); |
| 117 | 117 | ||
| 118 | /* | 118 | /* |
| 119 | * Simple link routines | 119 | * Simple link routines |
| @@ -123,13 +123,30 @@ static unsigned int align(unsigned int i) | |||
| 123 | return (i + 3) & ~3u; | 123 | return (i + 3) & ~3u; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | static void tipc_link_release(struct kref *kref) | ||
| 127 | { | ||
| 128 | kfree(container_of(kref, struct tipc_link, ref)); | ||
| 129 | } | ||
| 130 | |||
| 131 | static void tipc_link_get(struct tipc_link *l_ptr) | ||
| 132 | { | ||
| 133 | kref_get(&l_ptr->ref); | ||
| 134 | } | ||
| 135 | |||
| 136 | static void tipc_link_put(struct tipc_link *l_ptr) | ||
| 137 | { | ||
| 138 | kref_put(&l_ptr->ref, tipc_link_release); | ||
| 139 | } | ||
| 140 | |||
| 126 | static void link_init_max_pkt(struct tipc_link *l_ptr) | 141 | static void link_init_max_pkt(struct tipc_link *l_ptr) |
| 127 | { | 142 | { |
| 143 | struct tipc_node *node = l_ptr->owner; | ||
| 144 | struct tipc_net *tn = net_generic(node->net, tipc_net_id); | ||
| 128 | struct tipc_bearer *b_ptr; | 145 | struct tipc_bearer *b_ptr; |
| 129 | u32 max_pkt; | 146 | u32 max_pkt; |
| 130 | 147 | ||
| 131 | rcu_read_lock(); | 148 | rcu_read_lock(); |
| 132 | b_ptr = rcu_dereference_rtnl(bearer_list[l_ptr->bearer_id]); | 149 | b_ptr = rcu_dereference_rtnl(tn->bearer_list[l_ptr->bearer_id]); |
| 133 | if (!b_ptr) { | 150 | if (!b_ptr) { |
| 134 | rcu_read_unlock(); | 151 | rcu_read_unlock(); |
| 135 | return; | 152 | return; |
| @@ -169,8 +186,9 @@ int tipc_link_is_active(struct tipc_link *l_ptr) | |||
| 169 | * link_timeout - handle expiration of link timer | 186 | * link_timeout - handle expiration of link timer |
| 170 | * @l_ptr: pointer to link | 187 | * @l_ptr: pointer to link |
| 171 | */ | 188 | */ |
| 172 | static void link_timeout(struct tipc_link *l_ptr) | 189 | static void link_timeout(unsigned long data) |
| 173 | { | 190 | { |
| 191 | struct tipc_link *l_ptr = (struct tipc_link *)data; | ||
| 174 | struct sk_buff *skb; | 192 | struct sk_buff *skb; |
| 175 | 193 | ||
| 176 | tipc_node_lock(l_ptr->owner); | 194 | tipc_node_lock(l_ptr->owner); |
| @@ -215,11 +233,13 @@ static void link_timeout(struct tipc_link *l_ptr) | |||
| 215 | tipc_link_push_packets(l_ptr); | 233 | tipc_link_push_packets(l_ptr); |
| 216 | 234 | ||
| 217 | tipc_node_unlock(l_ptr->owner); | 235 | tipc_node_unlock(l_ptr->owner); |
| 236 | tipc_link_put(l_ptr); | ||
| 218 | } | 237 | } |
| 219 | 238 | ||
| 220 | static void link_set_timer(struct tipc_link *l_ptr, u32 time) | 239 | static void link_set_timer(struct tipc_link *link, unsigned long time) |
| 221 | { | 240 | { |
| 222 | k_start_timer(&l_ptr->timer, time); | 241 | if (!mod_timer(&link->timer, jiffies + time)) |
| 242 | tipc_link_get(link); | ||
| 223 | } | 243 | } |
| 224 | 244 | ||
| 225 | /** | 245 | /** |
| @@ -234,6 +254,7 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
| 234 | struct tipc_bearer *b_ptr, | 254 | struct tipc_bearer *b_ptr, |
| 235 | const struct tipc_media_addr *media_addr) | 255 | const struct tipc_media_addr *media_addr) |
| 236 | { | 256 | { |
| 257 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
| 237 | struct tipc_link *l_ptr; | 258 | struct tipc_link *l_ptr; |
| 238 | struct tipc_msg *msg; | 259 | struct tipc_msg *msg; |
| 239 | char *if_name; | 260 | char *if_name; |
| @@ -259,12 +280,12 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
| 259 | pr_warn("Link creation failed, no memory\n"); | 280 | pr_warn("Link creation failed, no memory\n"); |
| 260 | return NULL; | 281 | return NULL; |
| 261 | } | 282 | } |
| 262 | 283 | kref_init(&l_ptr->ref); | |
| 263 | l_ptr->addr = peer; | 284 | l_ptr->addr = peer; |
| 264 | if_name = strchr(b_ptr->name, ':') + 1; | 285 | if_name = strchr(b_ptr->name, ':') + 1; |
| 265 | sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:unknown", | 286 | sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:unknown", |
| 266 | tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), | 287 | tipc_zone(tn->own_addr), tipc_cluster(tn->own_addr), |
| 267 | tipc_node(tipc_own_addr), | 288 | tipc_node(tn->own_addr), |
| 268 | if_name, | 289 | if_name, |
| 269 | tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); | 290 | tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); |
| 270 | /* note: peer i/f name is updated by reset/activate message */ | 291 | /* note: peer i/f name is updated by reset/activate message */ |
| @@ -278,9 +299,10 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
| 278 | 299 | ||
| 279 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; | 300 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; |
| 280 | msg = l_ptr->pmsg; | 301 | msg = l_ptr->pmsg; |
| 281 | tipc_msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr); | 302 | tipc_msg_init(tn->own_addr, msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, |
| 303 | l_ptr->addr); | ||
| 282 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); | 304 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); |
| 283 | msg_set_session(msg, (tipc_random & 0xffff)); | 305 | msg_set_session(msg, (tn->random & 0xffff)); |
| 284 | msg_set_bearer_id(msg, b_ptr->identity); | 306 | msg_set_bearer_id(msg, b_ptr->identity); |
| 285 | strcpy((char *)msg_data(msg), if_name); | 307 | strcpy((char *)msg_data(msg), if_name); |
| 286 | 308 | ||
| @@ -293,48 +315,52 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
| 293 | l_ptr->next_out_no = 1; | 315 | l_ptr->next_out_no = 1; |
| 294 | __skb_queue_head_init(&l_ptr->outqueue); | 316 | __skb_queue_head_init(&l_ptr->outqueue); |
| 295 | __skb_queue_head_init(&l_ptr->deferred_queue); | 317 | __skb_queue_head_init(&l_ptr->deferred_queue); |
| 296 | skb_queue_head_init(&l_ptr->waiting_sks); | 318 | skb_queue_head_init(&l_ptr->wakeupq); |
| 297 | 319 | skb_queue_head_init(&l_ptr->inputq); | |
| 320 | skb_queue_head_init(&l_ptr->namedq); | ||
| 298 | link_reset_statistics(l_ptr); | 321 | link_reset_statistics(l_ptr); |
| 299 | |||
| 300 | tipc_node_attach_link(n_ptr, l_ptr); | 322 | tipc_node_attach_link(n_ptr, l_ptr); |
| 301 | 323 | setup_timer(&l_ptr->timer, link_timeout, (unsigned long)l_ptr); | |
| 302 | k_init_timer(&l_ptr->timer, (Handler)link_timeout, | ||
| 303 | (unsigned long)l_ptr); | ||
| 304 | |||
| 305 | link_state_event(l_ptr, STARTING_EVT); | 324 | link_state_event(l_ptr, STARTING_EVT); |
| 306 | 325 | ||
| 307 | return l_ptr; | 326 | return l_ptr; |
| 308 | } | 327 | } |
| 309 | 328 | ||
| 310 | void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down) | 329 | /** |
| 330 | * link_delete - Conditional deletion of link. | ||
| 331 | * If timer still running, real delete is done when it expires | ||
| 332 | * @link: link to be deleted | ||
| 333 | */ | ||
| 334 | void tipc_link_delete(struct tipc_link *link) | ||
| 335 | { | ||
| 336 | tipc_link_reset_fragments(link); | ||
| 337 | tipc_node_detach_link(link->owner, link); | ||
| 338 | tipc_link_put(link); | ||
| 339 | } | ||
| 340 | |||
| 341 | void tipc_link_delete_list(struct net *net, unsigned int bearer_id, | ||
| 342 | bool shutting_down) | ||
| 311 | { | 343 | { |
| 312 | struct tipc_link *l_ptr; | 344 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
| 313 | struct tipc_node *n_ptr; | 345 | struct tipc_link *link; |
| 346 | struct tipc_node *node; | ||
| 314 | 347 | ||
| 315 | rcu_read_lock(); | 348 | rcu_read_lock(); |
| 316 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 349 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
| 317 | tipc_node_lock(n_ptr); | 350 | tipc_node_lock(node); |
| 318 | l_ptr = n_ptr->links[bearer_id]; | 351 | link = node->links[bearer_id]; |
| 319 | if (l_ptr) { | 352 | if (!link) { |
| 320 | tipc_link_reset(l_ptr); | 353 | tipc_node_unlock(node); |
| 321 | if (shutting_down || !tipc_node_is_up(n_ptr)) { | ||
| 322 | tipc_node_detach_link(l_ptr->owner, l_ptr); | ||
| 323 | tipc_link_reset_fragments(l_ptr); | ||
| 324 | tipc_node_unlock(n_ptr); | ||
| 325 | |||
| 326 | /* Nobody else can access this link now: */ | ||
| 327 | del_timer_sync(&l_ptr->timer); | ||
| 328 | kfree(l_ptr); | ||
| 329 | } else { | ||
| 330 | /* Detach/delete when failover is finished: */ | ||
| 331 | l_ptr->flags |= LINK_STOPPED; | ||
| 332 | tipc_node_unlock(n_ptr); | ||
| 333 | del_timer_sync(&l_ptr->timer); | ||
| 334 | } | ||
| 335 | continue; | 354 | continue; |
| 336 | } | 355 | } |
| 337 | tipc_node_unlock(n_ptr); | 356 | tipc_link_reset(link); |
| 357 | if (del_timer(&link->timer)) | ||
| 358 | tipc_link_put(link); | ||
| 359 | link->flags |= LINK_STOPPED; | ||
| 360 | /* Delete link now, or when failover is finished: */ | ||
| 361 | if (shutting_down || !tipc_node_is_up(node)) | ||
| 362 | tipc_link_delete(link); | ||
| 363 | tipc_node_unlock(node); | ||
| 338 | } | 364 | } |
| 339 | rcu_read_unlock(); | 365 | rcu_read_unlock(); |
| 340 | } | 366 | } |
| @@ -352,13 +378,14 @@ static bool link_schedule_user(struct tipc_link *link, u32 oport, | |||
| 352 | { | 378 | { |
| 353 | struct sk_buff *buf; | 379 | struct sk_buff *buf; |
| 354 | 380 | ||
| 355 | buf = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0, tipc_own_addr, | 381 | buf = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0, |
| 356 | tipc_own_addr, oport, 0, 0); | 382 | link_own_addr(link), link_own_addr(link), |
| 383 | oport, 0, 0); | ||
| 357 | if (!buf) | 384 | if (!buf) |
| 358 | return false; | 385 | return false; |
| 359 | TIPC_SKB_CB(buf)->chain_sz = chain_sz; | 386 | TIPC_SKB_CB(buf)->chain_sz = chain_sz; |
| 360 | TIPC_SKB_CB(buf)->chain_imp = imp; | 387 | TIPC_SKB_CB(buf)->chain_imp = imp; |
| 361 | skb_queue_tail(&link->waiting_sks, buf); | 388 | skb_queue_tail(&link->wakeupq, buf); |
| 362 | link->stats.link_congs++; | 389 | link->stats.link_congs++; |
| 363 | return true; | 390 | return true; |
| 364 | } | 391 | } |
| @@ -369,17 +396,19 @@ static bool link_schedule_user(struct tipc_link *link, u32 oport, | |||
| 369 | * Move a number of waiting users, as permitted by available space in | 396 | * Move a number of waiting users, as permitted by available space in |
| 370 | * the send queue, from link wait queue to node wait queue for wakeup | 397 | * the send queue, from link wait queue to node wait queue for wakeup |
| 371 | */ | 398 | */ |
| 372 | static void link_prepare_wakeup(struct tipc_link *link) | 399 | void link_prepare_wakeup(struct tipc_link *link) |
| 373 | { | 400 | { |
| 374 | uint pend_qsz = skb_queue_len(&link->outqueue); | 401 | uint pend_qsz = skb_queue_len(&link->outqueue); |
| 375 | struct sk_buff *skb, *tmp; | 402 | struct sk_buff *skb, *tmp; |
| 376 | 403 | ||
| 377 | skb_queue_walk_safe(&link->waiting_sks, skb, tmp) { | 404 | skb_queue_walk_safe(&link->wakeupq, skb, tmp) { |
| 378 | if (pend_qsz >= link->queue_limit[TIPC_SKB_CB(skb)->chain_imp]) | 405 | if (pend_qsz >= link->queue_limit[TIPC_SKB_CB(skb)->chain_imp]) |
| 379 | break; | 406 | break; |
| 380 | pend_qsz += TIPC_SKB_CB(skb)->chain_sz; | 407 | pend_qsz += TIPC_SKB_CB(skb)->chain_sz; |
| 381 | skb_unlink(skb, &link->waiting_sks); | 408 | skb_unlink(skb, &link->wakeupq); |
| 382 | skb_queue_tail(&link->owner->waiting_sks, skb); | 409 | skb_queue_tail(&link->inputq, skb); |
| 410 | link->owner->inputq = &link->inputq; | ||
| 411 | link->owner->action_flags |= TIPC_MSG_EVT; | ||
| 383 | } | 412 | } |
| 384 | } | 413 | } |
| 385 | 414 | ||
| @@ -425,20 +454,21 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
| 425 | return; | 454 | return; |
| 426 | 455 | ||
| 427 | tipc_node_link_down(l_ptr->owner, l_ptr); | 456 | tipc_node_link_down(l_ptr->owner, l_ptr); |
| 428 | tipc_bearer_remove_dest(l_ptr->bearer_id, l_ptr->addr); | 457 | tipc_bearer_remove_dest(owner->net, l_ptr->bearer_id, l_ptr->addr); |
| 429 | 458 | ||
| 430 | if (was_active_link && tipc_node_active_links(l_ptr->owner)) { | 459 | if (was_active_link && tipc_node_active_links(l_ptr->owner)) { |
| 431 | l_ptr->reset_checkpoint = checkpoint; | 460 | l_ptr->reset_checkpoint = checkpoint; |
| 432 | l_ptr->exp_msg_count = START_CHANGEOVER; | 461 | l_ptr->exp_msg_count = START_CHANGEOVER; |
| 433 | } | 462 | } |
| 434 | 463 | ||
| 435 | /* Clean up all queues: */ | 464 | /* Clean up all queues, except inputq: */ |
| 436 | __skb_queue_purge(&l_ptr->outqueue); | 465 | __skb_queue_purge(&l_ptr->outqueue); |
| 437 | __skb_queue_purge(&l_ptr->deferred_queue); | 466 | __skb_queue_purge(&l_ptr->deferred_queue); |
| 438 | if (!skb_queue_empty(&l_ptr->waiting_sks)) { | 467 | if (!owner->inputq) |
| 439 | skb_queue_splice_init(&l_ptr->waiting_sks, &owner->waiting_sks); | 468 | owner->inputq = &l_ptr->inputq; |
| 440 | owner->action_flags |= TIPC_WAKEUP_USERS; | 469 | skb_queue_splice_init(&l_ptr->wakeupq, owner->inputq); |
| 441 | } | 470 | if (!skb_queue_empty(owner->inputq)) |
| 471 | owner->action_flags |= TIPC_MSG_EVT; | ||
| 442 | l_ptr->next_out = NULL; | 472 | l_ptr->next_out = NULL; |
| 443 | l_ptr->unacked_window = 0; | 473 | l_ptr->unacked_window = 0; |
| 444 | l_ptr->checkpoint = 1; | 474 | l_ptr->checkpoint = 1; |
| @@ -448,13 +478,14 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
| 448 | link_reset_statistics(l_ptr); | 478 | link_reset_statistics(l_ptr); |
| 449 | } | 479 | } |
| 450 | 480 | ||
| 451 | void tipc_link_reset_list(unsigned int bearer_id) | 481 | void tipc_link_reset_list(struct net *net, unsigned int bearer_id) |
| 452 | { | 482 | { |
| 483 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 453 | struct tipc_link *l_ptr; | 484 | struct tipc_link *l_ptr; |
| 454 | struct tipc_node *n_ptr; | 485 | struct tipc_node *n_ptr; |
| 455 | 486 | ||
| 456 | rcu_read_lock(); | 487 | rcu_read_lock(); |
| 457 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 488 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 458 | tipc_node_lock(n_ptr); | 489 | tipc_node_lock(n_ptr); |
| 459 | l_ptr = n_ptr->links[bearer_id]; | 490 | l_ptr = n_ptr->links[bearer_id]; |
| 460 | if (l_ptr) | 491 | if (l_ptr) |
| @@ -464,11 +495,14 @@ void tipc_link_reset_list(unsigned int bearer_id) | |||
| 464 | rcu_read_unlock(); | 495 | rcu_read_unlock(); |
| 465 | } | 496 | } |
| 466 | 497 | ||
| 467 | static void link_activate(struct tipc_link *l_ptr) | 498 | static void link_activate(struct tipc_link *link) |
| 468 | { | 499 | { |
| 469 | l_ptr->next_in_no = l_ptr->stats.recv_info = 1; | 500 | struct tipc_node *node = link->owner; |
| 470 | tipc_node_link_up(l_ptr->owner, l_ptr); | 501 | |
| 471 | tipc_bearer_add_dest(l_ptr->bearer_id, l_ptr->addr); | 502 | link->next_in_no = 1; |
| 503 | link->stats.recv_info = 1; | ||
| 504 | tipc_node_link_up(node, link); | ||
| 505 | tipc_bearer_add_dest(node->net, link->bearer_id, link->addr); | ||
| 472 | } | 506 | } |
| 473 | 507 | ||
| 474 | /** | 508 | /** |
| @@ -479,7 +513,7 @@ static void link_activate(struct tipc_link *l_ptr) | |||
| 479 | static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | 513 | static void link_state_event(struct tipc_link *l_ptr, unsigned int event) |
| 480 | { | 514 | { |
| 481 | struct tipc_link *other; | 515 | struct tipc_link *other; |
| 482 | u32 cont_intv = l_ptr->continuity_interval; | 516 | unsigned long cont_intv = l_ptr->cont_intv; |
| 483 | 517 | ||
| 484 | if (l_ptr->flags & LINK_STOPPED) | 518 | if (l_ptr->flags & LINK_STOPPED) |
| 485 | return; | 519 | return; |
| @@ -522,8 +556,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 522 | link_set_timer(l_ptr, cont_intv / 4); | 556 | link_set_timer(l_ptr, cont_intv / 4); |
| 523 | break; | 557 | break; |
| 524 | case RESET_MSG: | 558 | case RESET_MSG: |
| 525 | pr_info("%s<%s>, requested by peer\n", link_rst_msg, | 559 | pr_debug("%s<%s>, requested by peer\n", |
| 526 | l_ptr->name); | 560 | link_rst_msg, l_ptr->name); |
| 527 | tipc_link_reset(l_ptr); | 561 | tipc_link_reset(l_ptr); |
| 528 | l_ptr->state = RESET_RESET; | 562 | l_ptr->state = RESET_RESET; |
| 529 | l_ptr->fsm_msg_cnt = 0; | 563 | l_ptr->fsm_msg_cnt = 0; |
| @@ -533,7 +567,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 533 | link_set_timer(l_ptr, cont_intv); | 567 | link_set_timer(l_ptr, cont_intv); |
| 534 | break; | 568 | break; |
| 535 | default: | 569 | default: |
| 536 | pr_err("%s%u in WW state\n", link_unk_evt, event); | 570 | pr_debug("%s%u in WW state\n", link_unk_evt, event); |
| 537 | } | 571 | } |
| 538 | break; | 572 | break; |
| 539 | case WORKING_UNKNOWN: | 573 | case WORKING_UNKNOWN: |
| @@ -545,8 +579,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 545 | link_set_timer(l_ptr, cont_intv); | 579 | link_set_timer(l_ptr, cont_intv); |
| 546 | break; | 580 | break; |
| 547 | case RESET_MSG: | 581 | case RESET_MSG: |
| 548 | pr_info("%s<%s>, requested by peer while probing\n", | 582 | pr_debug("%s<%s>, requested by peer while probing\n", |
| 549 | link_rst_msg, l_ptr->name); | 583 | link_rst_msg, l_ptr->name); |
| 550 | tipc_link_reset(l_ptr); | 584 | tipc_link_reset(l_ptr); |
| 551 | l_ptr->state = RESET_RESET; | 585 | l_ptr->state = RESET_RESET; |
| 552 | l_ptr->fsm_msg_cnt = 0; | 586 | l_ptr->fsm_msg_cnt = 0; |
| @@ -572,8 +606,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 572 | l_ptr->fsm_msg_cnt++; | 606 | l_ptr->fsm_msg_cnt++; |
| 573 | link_set_timer(l_ptr, cont_intv / 4); | 607 | link_set_timer(l_ptr, cont_intv / 4); |
| 574 | } else { /* Link has failed */ | 608 | } else { /* Link has failed */ |
| 575 | pr_warn("%s<%s>, peer not responding\n", | 609 | pr_debug("%s<%s>, peer not responding\n", |
| 576 | link_rst_msg, l_ptr->name); | 610 | link_rst_msg, l_ptr->name); |
| 577 | tipc_link_reset(l_ptr); | 611 | tipc_link_reset(l_ptr); |
| 578 | l_ptr->state = RESET_UNKNOWN; | 612 | l_ptr->state = RESET_UNKNOWN; |
| 579 | l_ptr->fsm_msg_cnt = 0; | 613 | l_ptr->fsm_msg_cnt = 0; |
| @@ -614,7 +648,9 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 614 | break; | 648 | break; |
| 615 | case STARTING_EVT: | 649 | case STARTING_EVT: |
| 616 | l_ptr->flags |= LINK_STARTED; | 650 | l_ptr->flags |= LINK_STARTED; |
| 617 | /* fall through */ | 651 | l_ptr->fsm_msg_cnt++; |
| 652 | link_set_timer(l_ptr, cont_intv); | ||
| 653 | break; | ||
| 618 | case TIMEOUT_EVT: | 654 | case TIMEOUT_EVT: |
| 619 | tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); | 655 | tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); |
| 620 | l_ptr->fsm_msg_cnt++; | 656 | l_ptr->fsm_msg_cnt++; |
| @@ -700,7 +736,8 @@ drop: | |||
| 700 | * Only the socket functions tipc_send_stream() and tipc_send_packet() need | 736 | * Only the socket functions tipc_send_stream() and tipc_send_packet() need |
| 701 | * to act on the return value, since they may need to do more send attempts. | 737 | * to act on the return value, since they may need to do more send attempts. |
| 702 | */ | 738 | */ |
| 703 | int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list) | 739 | int __tipc_link_xmit(struct net *net, struct tipc_link *link, |
| 740 | struct sk_buff_head *list) | ||
| 704 | { | 741 | { |
| 705 | struct tipc_msg *msg = buf_msg(skb_peek(list)); | 742 | struct tipc_msg *msg = buf_msg(skb_peek(list)); |
| 706 | uint psz = msg_size(msg); | 743 | uint psz = msg_size(msg); |
| @@ -733,7 +770,8 @@ int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list) | |||
| 733 | 770 | ||
| 734 | if (skb_queue_len(outqueue) < sndlim) { | 771 | if (skb_queue_len(outqueue) < sndlim) { |
| 735 | __skb_queue_tail(outqueue, skb); | 772 | __skb_queue_tail(outqueue, skb); |
| 736 | tipc_bearer_send(link->bearer_id, skb, addr); | 773 | tipc_bearer_send(net, link->bearer_id, |
| 774 | skb, addr); | ||
| 737 | link->next_out = NULL; | 775 | link->next_out = NULL; |
| 738 | link->unacked_window = 0; | 776 | link->unacked_window = 0; |
| 739 | } else if (tipc_msg_bundle(outqueue, skb, mtu)) { | 777 | } else if (tipc_msg_bundle(outqueue, skb, mtu)) { |
| @@ -758,7 +796,7 @@ int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list) | |||
| 758 | 796 | ||
| 759 | static void skb2list(struct sk_buff *skb, struct sk_buff_head *list) | 797 | static void skb2list(struct sk_buff *skb, struct sk_buff_head *list) |
| 760 | { | 798 | { |
| 761 | __skb_queue_head_init(list); | 799 | skb_queue_head_init(list); |
| 762 | __skb_queue_tail(list, skb); | 800 | __skb_queue_tail(list, skb); |
| 763 | } | 801 | } |
| 764 | 802 | ||
| @@ -767,19 +805,21 @@ static int __tipc_link_xmit_skb(struct tipc_link *link, struct sk_buff *skb) | |||
| 767 | struct sk_buff_head head; | 805 | struct sk_buff_head head; |
| 768 | 806 | ||
| 769 | skb2list(skb, &head); | 807 | skb2list(skb, &head); |
| 770 | return __tipc_link_xmit(link, &head); | 808 | return __tipc_link_xmit(link->owner->net, link, &head); |
| 771 | } | 809 | } |
| 772 | 810 | ||
| 773 | int tipc_link_xmit_skb(struct sk_buff *skb, u32 dnode, u32 selector) | 811 | int tipc_link_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode, |
| 812 | u32 selector) | ||
| 774 | { | 813 | { |
| 775 | struct sk_buff_head head; | 814 | struct sk_buff_head head; |
| 776 | 815 | ||
| 777 | skb2list(skb, &head); | 816 | skb2list(skb, &head); |
| 778 | return tipc_link_xmit(&head, dnode, selector); | 817 | return tipc_link_xmit(net, &head, dnode, selector); |
| 779 | } | 818 | } |
| 780 | 819 | ||
| 781 | /** | 820 | /** |
| 782 | * tipc_link_xmit() is the general link level function for message sending | 821 | * tipc_link_xmit() is the general link level function for message sending |
| 822 | * @net: the applicable net namespace | ||
| 783 | * @list: chain of buffers containing message | 823 | * @list: chain of buffers containing message |
| 784 | * @dsz: amount of user data to be sent | 824 | * @dsz: amount of user data to be sent |
| 785 | * @dnode: address of destination node | 825 | * @dnode: address of destination node |
| @@ -787,33 +827,28 @@ int tipc_link_xmit_skb(struct sk_buff *skb, u32 dnode, u32 selector) | |||
| 787 | * Consumes the buffer chain, except when returning -ELINKCONG | 827 | * Consumes the buffer chain, except when returning -ELINKCONG |
| 788 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE | 828 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE |
| 789 | */ | 829 | */ |
| 790 | int tipc_link_xmit(struct sk_buff_head *list, u32 dnode, u32 selector) | 830 | int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dnode, |
| 831 | u32 selector) | ||
| 791 | { | 832 | { |
| 792 | struct tipc_link *link = NULL; | 833 | struct tipc_link *link = NULL; |
| 793 | struct tipc_node *node; | 834 | struct tipc_node *node; |
| 794 | int rc = -EHOSTUNREACH; | 835 | int rc = -EHOSTUNREACH; |
| 795 | 836 | ||
| 796 | node = tipc_node_find(dnode); | 837 | node = tipc_node_find(net, dnode); |
| 797 | if (node) { | 838 | if (node) { |
| 798 | tipc_node_lock(node); | 839 | tipc_node_lock(node); |
| 799 | link = node->active_links[selector & 1]; | 840 | link = node->active_links[selector & 1]; |
| 800 | if (link) | 841 | if (link) |
| 801 | rc = __tipc_link_xmit(link, list); | 842 | rc = __tipc_link_xmit(net, link, list); |
| 802 | tipc_node_unlock(node); | 843 | tipc_node_unlock(node); |
| 803 | } | 844 | } |
| 804 | |||
| 805 | if (link) | 845 | if (link) |
| 806 | return rc; | 846 | return rc; |
| 807 | 847 | ||
| 808 | if (likely(in_own_node(dnode))) { | 848 | if (likely(in_own_node(net, dnode))) |
| 809 | /* As a node local message chain never contains more than one | 849 | return tipc_sk_rcv(net, list); |
| 810 | * buffer, we just need to dequeue one SKB buffer from the | ||
| 811 | * head list. | ||
| 812 | */ | ||
| 813 | return tipc_sk_rcv(__skb_dequeue(list)); | ||
| 814 | } | ||
| 815 | __skb_queue_purge(list); | ||
| 816 | 850 | ||
| 851 | __skb_queue_purge(list); | ||
| 817 | return rc; | 852 | return rc; |
| 818 | } | 853 | } |
| 819 | 854 | ||
| @@ -835,7 +870,8 @@ static void tipc_link_sync_xmit(struct tipc_link *link) | |||
| 835 | return; | 870 | return; |
| 836 | 871 | ||
| 837 | msg = buf_msg(skb); | 872 | msg = buf_msg(skb); |
| 838 | tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, INT_H_SIZE, link->addr); | 873 | tipc_msg_init(link_own_addr(link), msg, BCAST_PROTOCOL, STATE_MSG, |
| 874 | INT_H_SIZE, link->addr); | ||
| 839 | msg_set_last_bcast(msg, link->owner->bclink.acked); | 875 | msg_set_last_bcast(msg, link->owner->bclink.acked); |
| 840 | __tipc_link_xmit_skb(link, skb); | 876 | __tipc_link_xmit_skb(link, skb); |
| 841 | } | 877 | } |
| @@ -890,7 +926,8 @@ void tipc_link_push_packets(struct tipc_link *l_ptr) | |||
| 890 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 926 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
| 891 | if (msg_user(msg) == MSG_BUNDLER) | 927 | if (msg_user(msg) == MSG_BUNDLER) |
| 892 | TIPC_SKB_CB(skb)->bundling = false; | 928 | TIPC_SKB_CB(skb)->bundling = false; |
| 893 | tipc_bearer_send(l_ptr->bearer_id, skb, | 929 | tipc_bearer_send(l_ptr->owner->net, |
| 930 | l_ptr->bearer_id, skb, | ||
| 894 | &l_ptr->media_addr); | 931 | &l_ptr->media_addr); |
| 895 | l_ptr->next_out = tipc_skb_queue_next(outqueue, skb); | 932 | l_ptr->next_out = tipc_skb_queue_next(outqueue, skb); |
| 896 | } else { | 933 | } else { |
| @@ -923,6 +960,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, | |||
| 923 | struct sk_buff *buf) | 960 | struct sk_buff *buf) |
| 924 | { | 961 | { |
| 925 | struct tipc_msg *msg = buf_msg(buf); | 962 | struct tipc_msg *msg = buf_msg(buf); |
| 963 | struct net *net = l_ptr->owner->net; | ||
| 926 | 964 | ||
| 927 | pr_warn("Retransmission failure on link <%s>\n", l_ptr->name); | 965 | pr_warn("Retransmission failure on link <%s>\n", l_ptr->name); |
| 928 | 966 | ||
| @@ -940,7 +978,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, | |||
| 940 | pr_cont("Outstanding acks: %lu\n", | 978 | pr_cont("Outstanding acks: %lu\n", |
| 941 | (unsigned long) TIPC_SKB_CB(buf)->handle); | 979 | (unsigned long) TIPC_SKB_CB(buf)->handle); |
| 942 | 980 | ||
| 943 | n_ptr = tipc_bclink_retransmit_to(); | 981 | n_ptr = tipc_bclink_retransmit_to(net); |
| 944 | tipc_node_lock(n_ptr); | 982 | tipc_node_lock(n_ptr); |
| 945 | 983 | ||
| 946 | tipc_addr_string_fill(addr_string, n_ptr->addr); | 984 | tipc_addr_string_fill(addr_string, n_ptr->addr); |
| @@ -955,7 +993,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, | |||
| 955 | 993 | ||
| 956 | tipc_node_unlock(n_ptr); | 994 | tipc_node_unlock(n_ptr); |
| 957 | 995 | ||
| 958 | tipc_bclink_set_flags(TIPC_BCLINK_RESET); | 996 | tipc_bclink_set_flags(net, TIPC_BCLINK_RESET); |
| 959 | l_ptr->stale_count = 0; | 997 | l_ptr->stale_count = 0; |
| 960 | } | 998 | } |
| 961 | } | 999 | } |
| @@ -987,7 +1025,8 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *skb, | |||
| 987 | msg = buf_msg(skb); | 1025 | msg = buf_msg(skb); |
| 988 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); | 1026 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); |
| 989 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 1027 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
| 990 | tipc_bearer_send(l_ptr->bearer_id, skb, &l_ptr->media_addr); | 1028 | tipc_bearer_send(l_ptr->owner->net, l_ptr->bearer_id, skb, |
| 1029 | &l_ptr->media_addr); | ||
| 991 | retransmits--; | 1030 | retransmits--; |
| 992 | l_ptr->stats.retransmitted++; | 1031 | l_ptr->stats.retransmitted++; |
| 993 | } | 1032 | } |
| @@ -1063,14 +1102,16 @@ static int link_recv_buf_validate(struct sk_buff *buf) | |||
| 1063 | 1102 | ||
| 1064 | /** | 1103 | /** |
| 1065 | * tipc_rcv - process TIPC packets/messages arriving from off-node | 1104 | * tipc_rcv - process TIPC packets/messages arriving from off-node |
| 1105 | * @net: the applicable net namespace | ||
| 1066 | * @skb: TIPC packet | 1106 | * @skb: TIPC packet |
| 1067 | * @b_ptr: pointer to bearer message arrived on | 1107 | * @b_ptr: pointer to bearer message arrived on |
| 1068 | * | 1108 | * |
| 1069 | * Invoked with no locks held. Bearer pointer must point to a valid bearer | 1109 | * Invoked with no locks held. Bearer pointer must point to a valid bearer |
| 1070 | * structure (i.e. cannot be NULL), but bearer can be inactive. | 1110 | * structure (i.e. cannot be NULL), but bearer can be inactive. |
| 1071 | */ | 1111 | */ |
| 1072 | void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | 1112 | void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr) |
| 1073 | { | 1113 | { |
| 1114 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 1074 | struct sk_buff_head head; | 1115 | struct sk_buff_head head; |
| 1075 | struct tipc_node *n_ptr; | 1116 | struct tipc_node *n_ptr; |
| 1076 | struct tipc_link *l_ptr; | 1117 | struct tipc_link *l_ptr; |
| @@ -1096,19 +1137,19 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1096 | 1137 | ||
| 1097 | if (unlikely(msg_non_seq(msg))) { | 1138 | if (unlikely(msg_non_seq(msg))) { |
| 1098 | if (msg_user(msg) == LINK_CONFIG) | 1139 | if (msg_user(msg) == LINK_CONFIG) |
| 1099 | tipc_disc_rcv(skb, b_ptr); | 1140 | tipc_disc_rcv(net, skb, b_ptr); |
| 1100 | else | 1141 | else |
| 1101 | tipc_bclink_rcv(skb); | 1142 | tipc_bclink_rcv(net, skb); |
| 1102 | continue; | 1143 | continue; |
| 1103 | } | 1144 | } |
| 1104 | 1145 | ||
| 1105 | /* Discard unicast link messages destined for another node */ | 1146 | /* Discard unicast link messages destined for another node */ |
| 1106 | if (unlikely(!msg_short(msg) && | 1147 | if (unlikely(!msg_short(msg) && |
| 1107 | (msg_destnode(msg) != tipc_own_addr))) | 1148 | (msg_destnode(msg) != tn->own_addr))) |
| 1108 | goto discard; | 1149 | goto discard; |
| 1109 | 1150 | ||
| 1110 | /* Locate neighboring node that sent message */ | 1151 | /* Locate neighboring node that sent message */ |
| 1111 | n_ptr = tipc_node_find(msg_prevnode(msg)); | 1152 | n_ptr = tipc_node_find(net, msg_prevnode(msg)); |
| 1112 | if (unlikely(!n_ptr)) | 1153 | if (unlikely(!n_ptr)) |
| 1113 | goto discard; | 1154 | goto discard; |
| 1114 | tipc_node_lock(n_ptr); | 1155 | tipc_node_lock(n_ptr); |
| @@ -1116,7 +1157,7 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1116 | /* Locate unicast link endpoint that should handle message */ | 1157 | /* Locate unicast link endpoint that should handle message */ |
| 1117 | l_ptr = n_ptr->links[b_ptr->identity]; | 1158 | l_ptr = n_ptr->links[b_ptr->identity]; |
| 1118 | if (unlikely(!l_ptr)) | 1159 | if (unlikely(!l_ptr)) |
| 1119 | goto unlock_discard; | 1160 | goto unlock; |
| 1120 | 1161 | ||
| 1121 | /* Verify that communication with node is currently allowed */ | 1162 | /* Verify that communication with node is currently allowed */ |
| 1122 | if ((n_ptr->action_flags & TIPC_WAIT_PEER_LINKS_DOWN) && | 1163 | if ((n_ptr->action_flags & TIPC_WAIT_PEER_LINKS_DOWN) && |
| @@ -1127,7 +1168,7 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1127 | n_ptr->action_flags &= ~TIPC_WAIT_PEER_LINKS_DOWN; | 1168 | n_ptr->action_flags &= ~TIPC_WAIT_PEER_LINKS_DOWN; |
| 1128 | 1169 | ||
| 1129 | if (tipc_node_blocked(n_ptr)) | 1170 | if (tipc_node_blocked(n_ptr)) |
| 1130 | goto unlock_discard; | 1171 | goto unlock; |
| 1131 | 1172 | ||
| 1132 | /* Validate message sequence number info */ | 1173 | /* Validate message sequence number info */ |
| 1133 | seq_no = msg_seqno(msg); | 1174 | seq_no = msg_seqno(msg); |
| @@ -1151,18 +1192,16 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1151 | if (unlikely(l_ptr->next_out)) | 1192 | if (unlikely(l_ptr->next_out)) |
| 1152 | tipc_link_push_packets(l_ptr); | 1193 | tipc_link_push_packets(l_ptr); |
| 1153 | 1194 | ||
| 1154 | if (released && !skb_queue_empty(&l_ptr->waiting_sks)) { | 1195 | if (released && !skb_queue_empty(&l_ptr->wakeupq)) |
| 1155 | link_prepare_wakeup(l_ptr); | 1196 | link_prepare_wakeup(l_ptr); |
| 1156 | l_ptr->owner->action_flags |= TIPC_WAKEUP_USERS; | ||
| 1157 | } | ||
| 1158 | 1197 | ||
| 1159 | /* Process the incoming packet */ | 1198 | /* Process the incoming packet */ |
| 1160 | if (unlikely(!link_working_working(l_ptr))) { | 1199 | if (unlikely(!link_working_working(l_ptr))) { |
| 1161 | if (msg_user(msg) == LINK_PROTOCOL) { | 1200 | if (msg_user(msg) == LINK_PROTOCOL) { |
| 1162 | tipc_link_proto_rcv(l_ptr, skb); | 1201 | tipc_link_proto_rcv(l_ptr, skb); |
| 1163 | link_retrieve_defq(l_ptr, &head); | 1202 | link_retrieve_defq(l_ptr, &head); |
| 1164 | tipc_node_unlock(n_ptr); | 1203 | skb = NULL; |
| 1165 | continue; | 1204 | goto unlock; |
| 1166 | } | 1205 | } |
| 1167 | 1206 | ||
| 1168 | /* Traffic message. Conditionally activate link */ | 1207 | /* Traffic message. Conditionally activate link */ |
| @@ -1171,18 +1210,18 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1171 | if (link_working_working(l_ptr)) { | 1210 | if (link_working_working(l_ptr)) { |
| 1172 | /* Re-insert buffer in front of queue */ | 1211 | /* Re-insert buffer in front of queue */ |
| 1173 | __skb_queue_head(&head, skb); | 1212 | __skb_queue_head(&head, skb); |
| 1174 | tipc_node_unlock(n_ptr); | 1213 | skb = NULL; |
| 1175 | continue; | 1214 | goto unlock; |
| 1176 | } | 1215 | } |
| 1177 | goto unlock_discard; | 1216 | goto unlock; |
| 1178 | } | 1217 | } |
| 1179 | 1218 | ||
| 1180 | /* Link is now in state WORKING_WORKING */ | 1219 | /* Link is now in state WORKING_WORKING */ |
| 1181 | if (unlikely(seq_no != mod(l_ptr->next_in_no))) { | 1220 | if (unlikely(seq_no != mod(l_ptr->next_in_no))) { |
| 1182 | link_handle_out_of_seq_msg(l_ptr, skb); | 1221 | link_handle_out_of_seq_msg(l_ptr, skb); |
| 1183 | link_retrieve_defq(l_ptr, &head); | 1222 | link_retrieve_defq(l_ptr, &head); |
| 1184 | tipc_node_unlock(n_ptr); | 1223 | skb = NULL; |
| 1185 | continue; | 1224 | goto unlock; |
| 1186 | } | 1225 | } |
| 1187 | l_ptr->next_in_no++; | 1226 | l_ptr->next_in_no++; |
| 1188 | if (unlikely(!skb_queue_empty(&l_ptr->deferred_queue))) | 1227 | if (unlikely(!skb_queue_empty(&l_ptr->deferred_queue))) |
| @@ -1192,95 +1231,102 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1192 | l_ptr->stats.sent_acks++; | 1231 | l_ptr->stats.sent_acks++; |
| 1193 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); | 1232 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); |
| 1194 | } | 1233 | } |
| 1195 | 1234 | tipc_link_input(l_ptr, skb); | |
| 1196 | if (tipc_link_prepare_input(l_ptr, &skb)) { | 1235 | skb = NULL; |
| 1197 | tipc_node_unlock(n_ptr); | 1236 | unlock: |
| 1198 | continue; | ||
| 1199 | } | ||
| 1200 | tipc_node_unlock(n_ptr); | ||
| 1201 | |||
| 1202 | if (tipc_link_input(l_ptr, skb) != 0) | ||
| 1203 | goto discard; | ||
| 1204 | continue; | ||
| 1205 | unlock_discard: | ||
| 1206 | tipc_node_unlock(n_ptr); | 1237 | tipc_node_unlock(n_ptr); |
| 1207 | discard: | 1238 | discard: |
| 1208 | kfree_skb(skb); | 1239 | if (unlikely(skb)) |
| 1240 | kfree_skb(skb); | ||
| 1209 | } | 1241 | } |
| 1210 | } | 1242 | } |
| 1211 | 1243 | ||
| 1212 | /** | 1244 | /* tipc_data_input - deliver data and name distr msgs to upper layer |
| 1213 | * tipc_link_prepare_input - process TIPC link messages | ||
| 1214 | * | ||
| 1215 | * returns nonzero if the message was consumed | ||
| 1216 | * | 1245 | * |
| 1246 | * Consumes buffer if message is of right type | ||
| 1217 | * Node lock must be held | 1247 | * Node lock must be held |
| 1218 | */ | 1248 | */ |
| 1219 | static int tipc_link_prepare_input(struct tipc_link *l, struct sk_buff **buf) | 1249 | static bool tipc_data_input(struct tipc_link *link, struct sk_buff *skb) |
| 1220 | { | 1250 | { |
| 1221 | struct tipc_node *n; | 1251 | struct tipc_node *node = link->owner; |
| 1222 | struct tipc_msg *msg; | 1252 | struct tipc_msg *msg = buf_msg(skb); |
| 1223 | int res = -EINVAL; | 1253 | u32 dport = msg_destport(msg); |
| 1224 | 1254 | ||
| 1225 | n = l->owner; | ||
| 1226 | msg = buf_msg(*buf); | ||
| 1227 | switch (msg_user(msg)) { | 1255 | switch (msg_user(msg)) { |
| 1228 | case CHANGEOVER_PROTOCOL: | 1256 | case TIPC_LOW_IMPORTANCE: |
| 1229 | if (tipc_link_tunnel_rcv(n, buf)) | 1257 | case TIPC_MEDIUM_IMPORTANCE: |
| 1230 | res = 0; | 1258 | case TIPC_HIGH_IMPORTANCE: |
| 1231 | break; | 1259 | case TIPC_CRITICAL_IMPORTANCE: |
| 1232 | case MSG_FRAGMENTER: | 1260 | case CONN_MANAGER: |
| 1233 | l->stats.recv_fragments++; | 1261 | if (tipc_skb_queue_tail(&link->inputq, skb, dport)) { |
| 1234 | if (tipc_buf_append(&l->reasm_buf, buf)) { | 1262 | node->inputq = &link->inputq; |
| 1235 | l->stats.recv_fragmented++; | 1263 | node->action_flags |= TIPC_MSG_EVT; |
| 1236 | res = 0; | ||
| 1237 | } else if (!l->reasm_buf) { | ||
| 1238 | tipc_link_reset(l); | ||
| 1239 | } | 1264 | } |
| 1240 | break; | 1265 | return true; |
| 1241 | case MSG_BUNDLER: | ||
| 1242 | l->stats.recv_bundles++; | ||
| 1243 | l->stats.recv_bundled += msg_msgcnt(msg); | ||
| 1244 | res = 0; | ||
| 1245 | break; | ||
| 1246 | case NAME_DISTRIBUTOR: | 1266 | case NAME_DISTRIBUTOR: |
| 1247 | n->bclink.recv_permitted = true; | 1267 | node->bclink.recv_permitted = true; |
| 1248 | res = 0; | 1268 | node->namedq = &link->namedq; |
| 1249 | break; | 1269 | skb_queue_tail(&link->namedq, skb); |
| 1270 | if (skb_queue_len(&link->namedq) == 1) | ||
| 1271 | node->action_flags |= TIPC_NAMED_MSG_EVT; | ||
| 1272 | return true; | ||
| 1273 | case MSG_BUNDLER: | ||
| 1274 | case CHANGEOVER_PROTOCOL: | ||
| 1275 | case MSG_FRAGMENTER: | ||
| 1250 | case BCAST_PROTOCOL: | 1276 | case BCAST_PROTOCOL: |
| 1251 | tipc_link_sync_rcv(n, *buf); | 1277 | return false; |
| 1252 | break; | ||
| 1253 | default: | 1278 | default: |
| 1254 | res = 0; | 1279 | pr_warn("Dropping received illegal msg type\n"); |
| 1255 | } | 1280 | kfree_skb(skb); |
| 1256 | return res; | 1281 | return false; |
| 1282 | }; | ||
| 1257 | } | 1283 | } |
| 1258 | /** | 1284 | |
| 1259 | * tipc_link_input - Deliver message too higher layers | 1285 | /* tipc_link_input - process packet that has passed link protocol check |
| 1286 | * | ||
| 1287 | * Consumes buffer | ||
| 1288 | * Node lock must be held | ||
| 1260 | */ | 1289 | */ |
| 1261 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf) | 1290 | static void tipc_link_input(struct tipc_link *link, struct sk_buff *skb) |
| 1262 | { | 1291 | { |
| 1263 | struct tipc_msg *msg = buf_msg(buf); | 1292 | struct tipc_node *node = link->owner; |
| 1264 | int res = 0; | 1293 | struct tipc_msg *msg = buf_msg(skb); |
| 1294 | struct sk_buff *iskb; | ||
| 1295 | int pos = 0; | ||
| 1296 | |||
| 1297 | if (likely(tipc_data_input(link, skb))) | ||
| 1298 | return; | ||
| 1265 | 1299 | ||
| 1266 | switch (msg_user(msg)) { | 1300 | switch (msg_user(msg)) { |
| 1267 | case TIPC_LOW_IMPORTANCE: | 1301 | case CHANGEOVER_PROTOCOL: |
| 1268 | case TIPC_MEDIUM_IMPORTANCE: | 1302 | if (!tipc_link_tunnel_rcv(node, &skb)) |
| 1269 | case TIPC_HIGH_IMPORTANCE: | 1303 | break; |
| 1270 | case TIPC_CRITICAL_IMPORTANCE: | 1304 | if (msg_user(buf_msg(skb)) != MSG_BUNDLER) { |
| 1271 | case CONN_MANAGER: | 1305 | tipc_data_input(link, skb); |
| 1272 | tipc_sk_rcv(buf); | 1306 | break; |
| 1307 | } | ||
| 1308 | case MSG_BUNDLER: | ||
| 1309 | link->stats.recv_bundles++; | ||
| 1310 | link->stats.recv_bundled += msg_msgcnt(msg); | ||
| 1311 | |||
| 1312 | while (tipc_msg_extract(skb, &iskb, &pos)) | ||
| 1313 | tipc_data_input(link, iskb); | ||
| 1273 | break; | 1314 | break; |
| 1274 | case NAME_DISTRIBUTOR: | 1315 | case MSG_FRAGMENTER: |
| 1275 | tipc_named_rcv(buf); | 1316 | link->stats.recv_fragments++; |
| 1317 | if (tipc_buf_append(&link->reasm_buf, &skb)) { | ||
| 1318 | link->stats.recv_fragmented++; | ||
| 1319 | tipc_data_input(link, skb); | ||
| 1320 | } else if (!link->reasm_buf) { | ||
| 1321 | tipc_link_reset(link); | ||
| 1322 | } | ||
| 1276 | break; | 1323 | break; |
| 1277 | case MSG_BUNDLER: | 1324 | case BCAST_PROTOCOL: |
| 1278 | tipc_link_bundle_rcv(buf); | 1325 | tipc_link_sync_rcv(node, skb); |
| 1279 | break; | 1326 | break; |
| 1280 | default: | 1327 | default: |
| 1281 | res = -EINVAL; | 1328 | break; |
| 1282 | } | 1329 | }; |
| 1283 | return res; | ||
| 1284 | } | 1330 | } |
| 1285 | 1331 | ||
| 1286 | /** | 1332 | /** |
| @@ -1381,7 +1427,7 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, | |||
| 1381 | msg_set_type(msg, msg_typ); | 1427 | msg_set_type(msg, msg_typ); |
| 1382 | msg_set_net_plane(msg, l_ptr->net_plane); | 1428 | msg_set_net_plane(msg, l_ptr->net_plane); |
| 1383 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 1429 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
| 1384 | msg_set_last_bcast(msg, tipc_bclink_get_last_sent()); | 1430 | msg_set_last_bcast(msg, tipc_bclink_get_last_sent(l_ptr->owner->net)); |
| 1385 | 1431 | ||
| 1386 | if (msg_typ == STATE_MSG) { | 1432 | if (msg_typ == STATE_MSG) { |
| 1387 | u32 next_sent = mod(l_ptr->next_out_no); | 1433 | u32 next_sent = mod(l_ptr->next_out_no); |
| @@ -1445,7 +1491,8 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, | |||
| 1445 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); | 1491 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); |
| 1446 | buf->priority = TC_PRIO_CONTROL; | 1492 | buf->priority = TC_PRIO_CONTROL; |
| 1447 | 1493 | ||
| 1448 | tipc_bearer_send(l_ptr->bearer_id, buf, &l_ptr->media_addr); | 1494 | tipc_bearer_send(l_ptr->owner->net, l_ptr->bearer_id, buf, |
| 1495 | &l_ptr->media_addr); | ||
| 1449 | l_ptr->unacked_window = 0; | 1496 | l_ptr->unacked_window = 0; |
| 1450 | kfree_skb(buf); | 1497 | kfree_skb(buf); |
| 1451 | } | 1498 | } |
| @@ -1455,7 +1502,8 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, | |||
| 1455 | * Note that network plane id propagates through the network, and may | 1502 | * Note that network plane id propagates through the network, and may |
| 1456 | * change at any time. The node with lowest address rules | 1503 | * change at any time. The node with lowest address rules |
| 1457 | */ | 1504 | */ |
| 1458 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf) | 1505 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, |
| 1506 | struct sk_buff *buf) | ||
| 1459 | { | 1507 | { |
| 1460 | u32 rec_gap = 0; | 1508 | u32 rec_gap = 0; |
| 1461 | u32 max_pkt_info; | 1509 | u32 max_pkt_info; |
| @@ -1468,7 +1516,7 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 1468 | goto exit; | 1516 | goto exit; |
| 1469 | 1517 | ||
| 1470 | if (l_ptr->net_plane != msg_net_plane(msg)) | 1518 | if (l_ptr->net_plane != msg_net_plane(msg)) |
| 1471 | if (tipc_own_addr > msg_prevnode(msg)) | 1519 | if (link_own_addr(l_ptr) > msg_prevnode(msg)) |
| 1472 | l_ptr->net_plane = msg_net_plane(msg); | 1520 | l_ptr->net_plane = msg_net_plane(msg); |
| 1473 | 1521 | ||
| 1474 | switch (msg_type(msg)) { | 1522 | switch (msg_type(msg)) { |
| @@ -1535,9 +1583,9 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 1535 | 1583 | ||
| 1536 | if (msg_linkprio(msg) && | 1584 | if (msg_linkprio(msg) && |
| 1537 | (msg_linkprio(msg) != l_ptr->priority)) { | 1585 | (msg_linkprio(msg) != l_ptr->priority)) { |
| 1538 | pr_warn("%s<%s>, priority change %u->%u\n", | 1586 | pr_debug("%s<%s>, priority change %u->%u\n", |
| 1539 | link_rst_msg, l_ptr->name, l_ptr->priority, | 1587 | link_rst_msg, l_ptr->name, |
| 1540 | msg_linkprio(msg)); | 1588 | l_ptr->priority, msg_linkprio(msg)); |
| 1541 | l_ptr->priority = msg_linkprio(msg); | 1589 | l_ptr->priority = msg_linkprio(msg); |
| 1542 | tipc_link_reset(l_ptr); /* Enforce change to take effect */ | 1590 | tipc_link_reset(l_ptr); /* Enforce change to take effect */ |
| 1543 | break; | 1591 | break; |
| @@ -1636,8 +1684,8 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr) | |||
| 1636 | if (!tunnel) | 1684 | if (!tunnel) |
| 1637 | return; | 1685 | return; |
| 1638 | 1686 | ||
| 1639 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 1687 | tipc_msg_init(link_own_addr(l_ptr), &tunnel_hdr, CHANGEOVER_PROTOCOL, |
| 1640 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); | 1688 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); |
| 1641 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 1689 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
| 1642 | msg_set_msgcnt(&tunnel_hdr, msgcount); | 1690 | msg_set_msgcnt(&tunnel_hdr, msgcount); |
| 1643 | 1691 | ||
| @@ -1694,8 +1742,8 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, | |||
| 1694 | struct sk_buff *skb; | 1742 | struct sk_buff *skb; |
| 1695 | struct tipc_msg tunnel_hdr; | 1743 | struct tipc_msg tunnel_hdr; |
| 1696 | 1744 | ||
| 1697 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 1745 | tipc_msg_init(link_own_addr(l_ptr), &tunnel_hdr, CHANGEOVER_PROTOCOL, |
| 1698 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); | 1746 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); |
| 1699 | msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue)); | 1747 | msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue)); |
| 1700 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 1748 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
| 1701 | skb_queue_walk(&l_ptr->outqueue, skb) { | 1749 | skb_queue_walk(&l_ptr->outqueue, skb) { |
| @@ -1729,7 +1777,7 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, | |||
| 1729 | * @from_pos: offset to extract from | 1777 | * @from_pos: offset to extract from |
| 1730 | * | 1778 | * |
| 1731 | * Returns a new message buffer containing an embedded message. The | 1779 | * Returns a new message buffer containing an embedded message. The |
| 1732 | * encapsulating message itself is left unchanged. | 1780 | * encapsulating buffer is left unchanged. |
| 1733 | */ | 1781 | */ |
| 1734 | static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | 1782 | static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) |
| 1735 | { | 1783 | { |
| @@ -1743,8 +1791,6 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | |||
| 1743 | return eb; | 1791 | return eb; |
| 1744 | } | 1792 | } |
| 1745 | 1793 | ||
| 1746 | |||
| 1747 | |||
| 1748 | /* tipc_link_dup_rcv(): Receive a tunnelled DUPLICATE_MSG packet. | 1794 | /* tipc_link_dup_rcv(): Receive a tunnelled DUPLICATE_MSG packet. |
| 1749 | * Owner node is locked. | 1795 | * Owner node is locked. |
| 1750 | */ | 1796 | */ |
| @@ -1804,10 +1850,8 @@ static struct sk_buff *tipc_link_failover_rcv(struct tipc_link *l_ptr, | |||
| 1804 | } | 1850 | } |
| 1805 | } | 1851 | } |
| 1806 | exit: | 1852 | exit: |
| 1807 | if ((l_ptr->exp_msg_count == 0) && (l_ptr->flags & LINK_STOPPED)) { | 1853 | if ((!l_ptr->exp_msg_count) && (l_ptr->flags & LINK_STOPPED)) |
| 1808 | tipc_node_detach_link(l_ptr->owner, l_ptr); | 1854 | tipc_link_delete(l_ptr); |
| 1809 | kfree(l_ptr); | ||
| 1810 | } | ||
| 1811 | return buf; | 1855 | return buf; |
| 1812 | } | 1856 | } |
| 1813 | 1857 | ||
| @@ -1845,50 +1889,16 @@ exit: | |||
| 1845 | return *buf != NULL; | 1889 | return *buf != NULL; |
| 1846 | } | 1890 | } |
| 1847 | 1891 | ||
| 1848 | /* | 1892 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol) |
| 1849 | * Bundler functionality: | ||
| 1850 | */ | ||
| 1851 | void tipc_link_bundle_rcv(struct sk_buff *buf) | ||
| 1852 | { | 1893 | { |
| 1853 | u32 msgcount = msg_msgcnt(buf_msg(buf)); | 1894 | unsigned long intv = ((tol / 4) > 500) ? 500 : tol / 4; |
| 1854 | u32 pos = INT_H_SIZE; | ||
| 1855 | struct sk_buff *obuf; | ||
| 1856 | struct tipc_msg *omsg; | ||
| 1857 | |||
| 1858 | while (msgcount--) { | ||
| 1859 | obuf = buf_extract(buf, pos); | ||
| 1860 | if (obuf == NULL) { | ||
| 1861 | pr_warn("Link unable to unbundle message(s)\n"); | ||
| 1862 | break; | ||
| 1863 | } | ||
| 1864 | omsg = buf_msg(obuf); | ||
| 1865 | pos += align(msg_size(omsg)); | ||
| 1866 | if (msg_isdata(omsg)) { | ||
| 1867 | if (unlikely(msg_type(omsg) == TIPC_MCAST_MSG)) | ||
| 1868 | tipc_sk_mcast_rcv(obuf); | ||
| 1869 | else | ||
| 1870 | tipc_sk_rcv(obuf); | ||
| 1871 | } else if (msg_user(omsg) == CONN_MANAGER) { | ||
| 1872 | tipc_sk_rcv(obuf); | ||
| 1873 | } else if (msg_user(omsg) == NAME_DISTRIBUTOR) { | ||
| 1874 | tipc_named_rcv(obuf); | ||
| 1875 | } else { | ||
| 1876 | pr_warn("Illegal bundled msg: %u\n", msg_user(omsg)); | ||
| 1877 | kfree_skb(obuf); | ||
| 1878 | } | ||
| 1879 | } | ||
| 1880 | kfree_skb(buf); | ||
| 1881 | } | ||
| 1882 | 1895 | ||
| 1883 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance) | 1896 | if ((tol < TIPC_MIN_LINK_TOL) || (tol > TIPC_MAX_LINK_TOL)) |
| 1884 | { | ||
| 1885 | if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) | ||
| 1886 | return; | 1897 | return; |
| 1887 | 1898 | ||
| 1888 | l_ptr->tolerance = tolerance; | 1899 | l_ptr->tolerance = tol; |
| 1889 | l_ptr->continuity_interval = | 1900 | l_ptr->cont_intv = msecs_to_jiffies(intv); |
| 1890 | ((tolerance / 4) > 500) ? 500 : tolerance / 4; | 1901 | l_ptr->abort_limit = tol / (jiffies_to_msecs(l_ptr->cont_intv) / 4); |
| 1891 | l_ptr->abort_limit = tolerance / (l_ptr->continuity_interval / 4); | ||
| 1892 | } | 1902 | } |
| 1893 | 1903 | ||
| 1894 | void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | 1904 | void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) |
| @@ -1911,22 +1921,25 @@ void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | |||
| 1911 | } | 1921 | } |
| 1912 | 1922 | ||
| 1913 | /* tipc_link_find_owner - locate owner node of link by link's name | 1923 | /* tipc_link_find_owner - locate owner node of link by link's name |
| 1924 | * @net: the applicable net namespace | ||
| 1914 | * @name: pointer to link name string | 1925 | * @name: pointer to link name string |
| 1915 | * @bearer_id: pointer to index in 'node->links' array where the link was found. | 1926 | * @bearer_id: pointer to index in 'node->links' array where the link was found. |
| 1916 | * | 1927 | * |
| 1917 | * Returns pointer to node owning the link, or 0 if no matching link is found. | 1928 | * Returns pointer to node owning the link, or 0 if no matching link is found. |
| 1918 | */ | 1929 | */ |
| 1919 | static struct tipc_node *tipc_link_find_owner(const char *link_name, | 1930 | static struct tipc_node *tipc_link_find_owner(struct net *net, |
| 1931 | const char *link_name, | ||
| 1920 | unsigned int *bearer_id) | 1932 | unsigned int *bearer_id) |
| 1921 | { | 1933 | { |
| 1934 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 1922 | struct tipc_link *l_ptr; | 1935 | struct tipc_link *l_ptr; |
| 1923 | struct tipc_node *n_ptr; | 1936 | struct tipc_node *n_ptr; |
| 1924 | struct tipc_node *found_node = 0; | 1937 | struct tipc_node *found_node = NULL; |
| 1925 | int i; | 1938 | int i; |
| 1926 | 1939 | ||
| 1927 | *bearer_id = 0; | 1940 | *bearer_id = 0; |
| 1928 | rcu_read_lock(); | 1941 | rcu_read_lock(); |
| 1929 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 1942 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 1930 | tipc_node_lock(n_ptr); | 1943 | tipc_node_lock(n_ptr); |
| 1931 | for (i = 0; i < MAX_BEARERS; i++) { | 1944 | for (i = 0; i < MAX_BEARERS; i++) { |
| 1932 | l_ptr = n_ptr->links[i]; | 1945 | l_ptr = n_ptr->links[i]; |
| @@ -1946,148 +1959,6 @@ static struct tipc_node *tipc_link_find_owner(const char *link_name, | |||
| 1946 | } | 1959 | } |
| 1947 | 1960 | ||
| 1948 | /** | 1961 | /** |
| 1949 | * link_value_is_valid -- validate proposed link tolerance/priority/window | ||
| 1950 | * | ||
| 1951 | * @cmd: value type (TIPC_CMD_SET_LINK_*) | ||
| 1952 | * @new_value: the new value | ||
| 1953 | * | ||
| 1954 | * Returns 1 if value is within range, 0 if not. | ||
| 1955 | */ | ||
| 1956 | static int link_value_is_valid(u16 cmd, u32 new_value) | ||
| 1957 | { | ||
| 1958 | switch (cmd) { | ||
| 1959 | case TIPC_CMD_SET_LINK_TOL: | ||
| 1960 | return (new_value >= TIPC_MIN_LINK_TOL) && | ||
| 1961 | (new_value <= TIPC_MAX_LINK_TOL); | ||
| 1962 | case TIPC_CMD_SET_LINK_PRI: | ||
| 1963 | return (new_value <= TIPC_MAX_LINK_PRI); | ||
| 1964 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 1965 | return (new_value >= TIPC_MIN_LINK_WIN) && | ||
| 1966 | (new_value <= TIPC_MAX_LINK_WIN); | ||
| 1967 | } | ||
| 1968 | return 0; | ||
| 1969 | } | ||
| 1970 | |||
| 1971 | /** | ||
| 1972 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media | ||
| 1973 | * @name: ptr to link, bearer, or media name | ||
| 1974 | * @new_value: new value of link, bearer, or media setting | ||
| 1975 | * @cmd: which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) | ||
| 1976 | * | ||
| 1977 | * Caller must hold RTNL lock to ensure link/bearer/media is not deleted. | ||
| 1978 | * | ||
| 1979 | * Returns 0 if value updated and negative value on error. | ||
| 1980 | */ | ||
| 1981 | static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | ||
| 1982 | { | ||
| 1983 | struct tipc_node *node; | ||
| 1984 | struct tipc_link *l_ptr; | ||
| 1985 | struct tipc_bearer *b_ptr; | ||
| 1986 | struct tipc_media *m_ptr; | ||
| 1987 | int bearer_id; | ||
| 1988 | int res = 0; | ||
| 1989 | |||
| 1990 | node = tipc_link_find_owner(name, &bearer_id); | ||
| 1991 | if (node) { | ||
| 1992 | tipc_node_lock(node); | ||
| 1993 | l_ptr = node->links[bearer_id]; | ||
| 1994 | |||
| 1995 | if (l_ptr) { | ||
| 1996 | switch (cmd) { | ||
| 1997 | case TIPC_CMD_SET_LINK_TOL: | ||
| 1998 | link_set_supervision_props(l_ptr, new_value); | ||
| 1999 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, | ||
| 2000 | new_value, 0, 0); | ||
| 2001 | break; | ||
| 2002 | case TIPC_CMD_SET_LINK_PRI: | ||
| 2003 | l_ptr->priority = new_value; | ||
| 2004 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, | ||
| 2005 | 0, new_value, 0); | ||
| 2006 | break; | ||
| 2007 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 2008 | tipc_link_set_queue_limits(l_ptr, new_value); | ||
| 2009 | break; | ||
| 2010 | default: | ||
| 2011 | res = -EINVAL; | ||
| 2012 | break; | ||
| 2013 | } | ||
| 2014 | } | ||
| 2015 | tipc_node_unlock(node); | ||
| 2016 | return res; | ||
| 2017 | } | ||
| 2018 | |||
| 2019 | b_ptr = tipc_bearer_find(name); | ||
| 2020 | if (b_ptr) { | ||
| 2021 | switch (cmd) { | ||
| 2022 | case TIPC_CMD_SET_LINK_TOL: | ||
| 2023 | b_ptr->tolerance = new_value; | ||
| 2024 | break; | ||
| 2025 | case TIPC_CMD_SET_LINK_PRI: | ||
| 2026 | b_ptr->priority = new_value; | ||
| 2027 | break; | ||
| 2028 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 2029 | b_ptr->window = new_value; | ||
| 2030 | break; | ||
| 2031 | default: | ||
| 2032 | res = -EINVAL; | ||
| 2033 | break; | ||
| 2034 | } | ||
| 2035 | return res; | ||
| 2036 | } | ||
| 2037 | |||
| 2038 | m_ptr = tipc_media_find(name); | ||
| 2039 | if (!m_ptr) | ||
| 2040 | return -ENODEV; | ||
| 2041 | switch (cmd) { | ||
| 2042 | case TIPC_CMD_SET_LINK_TOL: | ||
| 2043 | m_ptr->tolerance = new_value; | ||
| 2044 | break; | ||
| 2045 | case TIPC_CMD_SET_LINK_PRI: | ||
| 2046 | m_ptr->priority = new_value; | ||
| 2047 | break; | ||
| 2048 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 2049 | m_ptr->window = new_value; | ||
| 2050 | break; | ||
| 2051 | default: | ||
| 2052 | res = -EINVAL; | ||
| 2053 | break; | ||
| 2054 | } | ||
| 2055 | return res; | ||
| 2056 | } | ||
| 2057 | |||
| 2058 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, | ||
| 2059 | u16 cmd) | ||
| 2060 | { | ||
| 2061 | struct tipc_link_config *args; | ||
| 2062 | u32 new_value; | ||
| 2063 | int res; | ||
| 2064 | |||
| 2065 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) | ||
| 2066 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 2067 | |||
| 2068 | args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); | ||
| 2069 | new_value = ntohl(args->value); | ||
| 2070 | |||
| 2071 | if (!link_value_is_valid(cmd, new_value)) | ||
| 2072 | return tipc_cfg_reply_error_string( | ||
| 2073 | "cannot change, value invalid"); | ||
| 2074 | |||
| 2075 | if (!strcmp(args->name, tipc_bclink_name)) { | ||
| 2076 | if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && | ||
| 2077 | (tipc_bclink_set_queue_limits(new_value) == 0)) | ||
| 2078 | return tipc_cfg_reply_none(); | ||
| 2079 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
| 2080 | " (cannot change setting on broadcast link)"); | ||
| 2081 | } | ||
| 2082 | |||
| 2083 | res = link_cmd_set_value(args->name, new_value, cmd); | ||
| 2084 | if (res) | ||
| 2085 | return tipc_cfg_reply_error_string("cannot change link setting"); | ||
| 2086 | |||
| 2087 | return tipc_cfg_reply_none(); | ||
| 2088 | } | ||
| 2089 | |||
| 2090 | /** | ||
| 2091 | * link_reset_statistics - reset link statistics | 1962 | * link_reset_statistics - reset link statistics |
| 2092 | * @l_ptr: pointer to link | 1963 | * @l_ptr: pointer to link |
| 2093 | */ | 1964 | */ |
| @@ -2098,207 +1969,13 @@ static void link_reset_statistics(struct tipc_link *l_ptr) | |||
| 2098 | l_ptr->stats.recv_info = l_ptr->next_in_no; | 1969 | l_ptr->stats.recv_info = l_ptr->next_in_no; |
| 2099 | } | 1970 | } |
| 2100 | 1971 | ||
| 2101 | struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) | ||
| 2102 | { | ||
| 2103 | char *link_name; | ||
| 2104 | struct tipc_link *l_ptr; | ||
| 2105 | struct tipc_node *node; | ||
| 2106 | unsigned int bearer_id; | ||
| 2107 | |||
| 2108 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | ||
| 2109 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 2110 | |||
| 2111 | link_name = (char *)TLV_DATA(req_tlv_area); | ||
| 2112 | if (!strcmp(link_name, tipc_bclink_name)) { | ||
| 2113 | if (tipc_bclink_reset_stats()) | ||
| 2114 | return tipc_cfg_reply_error_string("link not found"); | ||
| 2115 | return tipc_cfg_reply_none(); | ||
| 2116 | } | ||
| 2117 | node = tipc_link_find_owner(link_name, &bearer_id); | ||
| 2118 | if (!node) | ||
| 2119 | return tipc_cfg_reply_error_string("link not found"); | ||
| 2120 | |||
| 2121 | tipc_node_lock(node); | ||
| 2122 | l_ptr = node->links[bearer_id]; | ||
| 2123 | if (!l_ptr) { | ||
| 2124 | tipc_node_unlock(node); | ||
| 2125 | return tipc_cfg_reply_error_string("link not found"); | ||
| 2126 | } | ||
| 2127 | link_reset_statistics(l_ptr); | ||
| 2128 | tipc_node_unlock(node); | ||
| 2129 | return tipc_cfg_reply_none(); | ||
| 2130 | } | ||
| 2131 | |||
| 2132 | /** | ||
| 2133 | * percent - convert count to a percentage of total (rounding up or down) | ||
| 2134 | */ | ||
| 2135 | static u32 percent(u32 count, u32 total) | ||
| 2136 | { | ||
| 2137 | return (count * 100 + (total / 2)) / total; | ||
| 2138 | } | ||
| 2139 | |||
| 2140 | /** | ||
| 2141 | * tipc_link_stats - print link statistics | ||
| 2142 | * @name: link name | ||
| 2143 | * @buf: print buffer area | ||
| 2144 | * @buf_size: size of print buffer area | ||
| 2145 | * | ||
| 2146 | * Returns length of print buffer data string (or 0 if error) | ||
| 2147 | */ | ||
| 2148 | static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | ||
| 2149 | { | ||
| 2150 | struct tipc_link *l; | ||
| 2151 | struct tipc_stats *s; | ||
| 2152 | struct tipc_node *node; | ||
| 2153 | char *status; | ||
| 2154 | u32 profile_total = 0; | ||
| 2155 | unsigned int bearer_id; | ||
| 2156 | int ret; | ||
| 2157 | |||
| 2158 | if (!strcmp(name, tipc_bclink_name)) | ||
| 2159 | return tipc_bclink_stats(buf, buf_size); | ||
| 2160 | |||
| 2161 | node = tipc_link_find_owner(name, &bearer_id); | ||
| 2162 | if (!node) | ||
| 2163 | return 0; | ||
| 2164 | |||
| 2165 | tipc_node_lock(node); | ||
| 2166 | |||
| 2167 | l = node->links[bearer_id]; | ||
| 2168 | if (!l) { | ||
| 2169 | tipc_node_unlock(node); | ||
| 2170 | return 0; | ||
| 2171 | } | ||
| 2172 | |||
| 2173 | s = &l->stats; | ||
| 2174 | |||
| 2175 | if (tipc_link_is_active(l)) | ||
| 2176 | status = "ACTIVE"; | ||
| 2177 | else if (tipc_link_is_up(l)) | ||
| 2178 | status = "STANDBY"; | ||
| 2179 | else | ||
| 2180 | status = "DEFUNCT"; | ||
| 2181 | |||
| 2182 | ret = tipc_snprintf(buf, buf_size, "Link <%s>\n" | ||
| 2183 | " %s MTU:%u Priority:%u Tolerance:%u ms" | ||
| 2184 | " Window:%u packets\n", | ||
| 2185 | l->name, status, l->max_pkt, l->priority, | ||
| 2186 | l->tolerance, l->queue_limit[0]); | ||
| 2187 | |||
| 2188 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
| 2189 | " RX packets:%u fragments:%u/%u bundles:%u/%u\n", | ||
| 2190 | l->next_in_no - s->recv_info, s->recv_fragments, | ||
| 2191 | s->recv_fragmented, s->recv_bundles, | ||
| 2192 | s->recv_bundled); | ||
| 2193 | |||
| 2194 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
| 2195 | " TX packets:%u fragments:%u/%u bundles:%u/%u\n", | ||
| 2196 | l->next_out_no - s->sent_info, s->sent_fragments, | ||
| 2197 | s->sent_fragmented, s->sent_bundles, | ||
| 2198 | s->sent_bundled); | ||
| 2199 | |||
| 2200 | profile_total = s->msg_length_counts; | ||
| 2201 | if (!profile_total) | ||
| 2202 | profile_total = 1; | ||
| 2203 | |||
| 2204 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
| 2205 | " TX profile sample:%u packets average:%u octets\n" | ||
| 2206 | " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% " | ||
| 2207 | "-16384:%u%% -32768:%u%% -66000:%u%%\n", | ||
| 2208 | s->msg_length_counts, | ||
| 2209 | s->msg_lengths_total / profile_total, | ||
| 2210 | percent(s->msg_length_profile[0], profile_total), | ||
| 2211 | percent(s->msg_length_profile[1], profile_total), | ||
| 2212 | percent(s->msg_length_profile[2], profile_total), | ||
| 2213 | percent(s->msg_length_profile[3], profile_total), | ||
| 2214 | percent(s->msg_length_profile[4], profile_total), | ||
| 2215 | percent(s->msg_length_profile[5], profile_total), | ||
| 2216 | percent(s->msg_length_profile[6], profile_total)); | ||
| 2217 | |||
| 2218 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
| 2219 | " RX states:%u probes:%u naks:%u defs:%u" | ||
| 2220 | " dups:%u\n", s->recv_states, s->recv_probes, | ||
| 2221 | s->recv_nacks, s->deferred_recv, s->duplicates); | ||
| 2222 | |||
| 2223 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
| 2224 | " TX states:%u probes:%u naks:%u acks:%u" | ||
| 2225 | " dups:%u\n", s->sent_states, s->sent_probes, | ||
| 2226 | s->sent_nacks, s->sent_acks, s->retransmitted); | ||
| 2227 | |||
| 2228 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
| 2229 | " Congestion link:%u Send queue" | ||
| 2230 | " max:%u avg:%u\n", s->link_congs, | ||
| 2231 | s->max_queue_sz, s->queue_sz_counts ? | ||
| 2232 | (s->accu_queue_sz / s->queue_sz_counts) : 0); | ||
| 2233 | |||
| 2234 | tipc_node_unlock(node); | ||
| 2235 | return ret; | ||
| 2236 | } | ||
| 2237 | |||
| 2238 | struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space) | ||
| 2239 | { | ||
| 2240 | struct sk_buff *buf; | ||
| 2241 | struct tlv_desc *rep_tlv; | ||
| 2242 | int str_len; | ||
| 2243 | int pb_len; | ||
| 2244 | char *pb; | ||
| 2245 | |||
| 2246 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | ||
| 2247 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 2248 | |||
| 2249 | buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN)); | ||
| 2250 | if (!buf) | ||
| 2251 | return NULL; | ||
| 2252 | |||
| 2253 | rep_tlv = (struct tlv_desc *)buf->data; | ||
| 2254 | pb = TLV_DATA(rep_tlv); | ||
| 2255 | pb_len = ULTRA_STRING_MAX_LEN; | ||
| 2256 | str_len = tipc_link_stats((char *)TLV_DATA(req_tlv_area), | ||
| 2257 | pb, pb_len); | ||
| 2258 | if (!str_len) { | ||
| 2259 | kfree_skb(buf); | ||
| 2260 | return tipc_cfg_reply_error_string("link not found"); | ||
| 2261 | } | ||
| 2262 | str_len += 1; /* for "\0" */ | ||
| 2263 | skb_put(buf, TLV_SPACE(str_len)); | ||
| 2264 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | ||
| 2265 | |||
| 2266 | return buf; | ||
| 2267 | } | ||
| 2268 | |||
| 2269 | /** | ||
| 2270 | * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination | ||
| 2271 | * @dest: network address of destination node | ||
| 2272 | * @selector: used to select from set of active links | ||
| 2273 | * | ||
| 2274 | * If no active link can be found, uses default maximum packet size. | ||
| 2275 | */ | ||
| 2276 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | ||
| 2277 | { | ||
| 2278 | struct tipc_node *n_ptr; | ||
| 2279 | struct tipc_link *l_ptr; | ||
| 2280 | u32 res = MAX_PKT_DEFAULT; | ||
| 2281 | |||
| 2282 | if (dest == tipc_own_addr) | ||
| 2283 | return MAX_MSG_SIZE; | ||
| 2284 | |||
| 2285 | n_ptr = tipc_node_find(dest); | ||
| 2286 | if (n_ptr) { | ||
| 2287 | tipc_node_lock(n_ptr); | ||
| 2288 | l_ptr = n_ptr->active_links[selector & 1]; | ||
| 2289 | if (l_ptr) | ||
| 2290 | res = l_ptr->max_pkt; | ||
| 2291 | tipc_node_unlock(n_ptr); | ||
| 2292 | } | ||
| 2293 | return res; | ||
| 2294 | } | ||
| 2295 | |||
| 2296 | static void link_print(struct tipc_link *l_ptr, const char *str) | 1972 | static void link_print(struct tipc_link *l_ptr, const char *str) |
| 2297 | { | 1973 | { |
| 1974 | struct tipc_net *tn = net_generic(l_ptr->owner->net, tipc_net_id); | ||
| 2298 | struct tipc_bearer *b_ptr; | 1975 | struct tipc_bearer *b_ptr; |
| 2299 | 1976 | ||
| 2300 | rcu_read_lock(); | 1977 | rcu_read_lock(); |
| 2301 | b_ptr = rcu_dereference_rtnl(bearer_list[l_ptr->bearer_id]); | 1978 | b_ptr = rcu_dereference_rtnl(tn->bearer_list[l_ptr->bearer_id]); |
| 2302 | if (b_ptr) | 1979 | if (b_ptr) |
| 2303 | pr_info("%s Link %x<%s>:", str, l_ptr->addr, b_ptr->name); | 1980 | pr_info("%s Link %x<%s>:", str, l_ptr->addr, b_ptr->name); |
| 2304 | rcu_read_unlock(); | 1981 | rcu_read_unlock(); |
| @@ -2362,6 +2039,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | |||
| 2362 | struct tipc_link *link; | 2039 | struct tipc_link *link; |
| 2363 | struct tipc_node *node; | 2040 | struct tipc_node *node; |
| 2364 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2041 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
| 2042 | struct net *net = sock_net(skb->sk); | ||
| 2365 | 2043 | ||
| 2366 | if (!info->attrs[TIPC_NLA_LINK]) | 2044 | if (!info->attrs[TIPC_NLA_LINK]) |
| 2367 | return -EINVAL; | 2045 | return -EINVAL; |
| @@ -2377,7 +2055,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | |||
| 2377 | 2055 | ||
| 2378 | name = nla_data(attrs[TIPC_NLA_LINK_NAME]); | 2056 | name = nla_data(attrs[TIPC_NLA_LINK_NAME]); |
| 2379 | 2057 | ||
| 2380 | node = tipc_link_find_owner(name, &bearer_id); | 2058 | node = tipc_link_find_owner(net, name, &bearer_id); |
| 2381 | if (!node) | 2059 | if (!node) |
| 2382 | return -EINVAL; | 2060 | return -EINVAL; |
| 2383 | 2061 | ||
| @@ -2493,14 +2171,16 @@ msg_full: | |||
| 2493 | } | 2171 | } |
| 2494 | 2172 | ||
| 2495 | /* Caller should hold appropriate locks to protect the link */ | 2173 | /* Caller should hold appropriate locks to protect the link */ |
| 2496 | static int __tipc_nl_add_link(struct tipc_nl_msg *msg, struct tipc_link *link) | 2174 | static int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, |
| 2175 | struct tipc_link *link) | ||
| 2497 | { | 2176 | { |
| 2498 | int err; | 2177 | int err; |
| 2499 | void *hdr; | 2178 | void *hdr; |
| 2500 | struct nlattr *attrs; | 2179 | struct nlattr *attrs; |
| 2501 | struct nlattr *prop; | 2180 | struct nlattr *prop; |
| 2181 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 2502 | 2182 | ||
| 2503 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, | 2183 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, |
| 2504 | NLM_F_MULTI, TIPC_NL_LINK_GET); | 2184 | NLM_F_MULTI, TIPC_NL_LINK_GET); |
| 2505 | if (!hdr) | 2185 | if (!hdr) |
| 2506 | return -EMSGSIZE; | 2186 | return -EMSGSIZE; |
| @@ -2512,7 +2192,7 @@ static int __tipc_nl_add_link(struct tipc_nl_msg *msg, struct tipc_link *link) | |||
| 2512 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name)) | 2192 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name)) |
| 2513 | goto attr_msg_full; | 2193 | goto attr_msg_full; |
| 2514 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, | 2194 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, |
| 2515 | tipc_cluster_mask(tipc_own_addr))) | 2195 | tipc_cluster_mask(tn->own_addr))) |
| 2516 | goto attr_msg_full; | 2196 | goto attr_msg_full; |
| 2517 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->max_pkt)) | 2197 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->max_pkt)) |
| 2518 | goto attr_msg_full; | 2198 | goto attr_msg_full; |
| @@ -2562,9 +2242,8 @@ msg_full: | |||
| 2562 | } | 2242 | } |
| 2563 | 2243 | ||
| 2564 | /* Caller should hold node lock */ | 2244 | /* Caller should hold node lock */ |
| 2565 | static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | 2245 | static int __tipc_nl_add_node_links(struct net *net, struct tipc_nl_msg *msg, |
| 2566 | struct tipc_node *node, | 2246 | struct tipc_node *node, u32 *prev_link) |
| 2567 | u32 *prev_link) | ||
| 2568 | { | 2247 | { |
| 2569 | u32 i; | 2248 | u32 i; |
| 2570 | int err; | 2249 | int err; |
| @@ -2575,7 +2254,7 @@ static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | |||
| 2575 | if (!node->links[i]) | 2254 | if (!node->links[i]) |
| 2576 | continue; | 2255 | continue; |
| 2577 | 2256 | ||
| 2578 | err = __tipc_nl_add_link(msg, node->links[i]); | 2257 | err = __tipc_nl_add_link(net, msg, node->links[i]); |
| 2579 | if (err) | 2258 | if (err) |
| 2580 | return err; | 2259 | return err; |
| 2581 | } | 2260 | } |
| @@ -2586,6 +2265,8 @@ static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | |||
| 2586 | 2265 | ||
| 2587 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | 2266 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) |
| 2588 | { | 2267 | { |
| 2268 | struct net *net = sock_net(skb->sk); | ||
| 2269 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 2589 | struct tipc_node *node; | 2270 | struct tipc_node *node; |
| 2590 | struct tipc_nl_msg msg; | 2271 | struct tipc_nl_msg msg; |
| 2591 | u32 prev_node = cb->args[0]; | 2272 | u32 prev_node = cb->args[0]; |
| @@ -2603,7 +2284,7 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 2603 | rcu_read_lock(); | 2284 | rcu_read_lock(); |
| 2604 | 2285 | ||
| 2605 | if (prev_node) { | 2286 | if (prev_node) { |
| 2606 | node = tipc_node_find(prev_node); | 2287 | node = tipc_node_find(net, prev_node); |
| 2607 | if (!node) { | 2288 | if (!node) { |
| 2608 | /* We never set seq or call nl_dump_check_consistent() | 2289 | /* We never set seq or call nl_dump_check_consistent() |
| 2609 | * this means that setting prev_seq here will cause the | 2290 | * this means that setting prev_seq here will cause the |
| @@ -2615,9 +2296,11 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 2615 | goto out; | 2296 | goto out; |
| 2616 | } | 2297 | } |
| 2617 | 2298 | ||
| 2618 | list_for_each_entry_continue_rcu(node, &tipc_node_list, list) { | 2299 | list_for_each_entry_continue_rcu(node, &tn->node_list, |
| 2300 | list) { | ||
| 2619 | tipc_node_lock(node); | 2301 | tipc_node_lock(node); |
| 2620 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2302 | err = __tipc_nl_add_node_links(net, &msg, node, |
| 2303 | &prev_link); | ||
| 2621 | tipc_node_unlock(node); | 2304 | tipc_node_unlock(node); |
| 2622 | if (err) | 2305 | if (err) |
| 2623 | goto out; | 2306 | goto out; |
| @@ -2625,13 +2308,14 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 2625 | prev_node = node->addr; | 2308 | prev_node = node->addr; |
| 2626 | } | 2309 | } |
| 2627 | } else { | 2310 | } else { |
| 2628 | err = tipc_nl_add_bc_link(&msg); | 2311 | err = tipc_nl_add_bc_link(net, &msg); |
| 2629 | if (err) | 2312 | if (err) |
| 2630 | goto out; | 2313 | goto out; |
| 2631 | 2314 | ||
| 2632 | list_for_each_entry_rcu(node, &tipc_node_list, list) { | 2315 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
| 2633 | tipc_node_lock(node); | 2316 | tipc_node_lock(node); |
| 2634 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2317 | err = __tipc_nl_add_node_links(net, &msg, node, |
| 2318 | &prev_link); | ||
| 2635 | tipc_node_unlock(node); | 2319 | tipc_node_unlock(node); |
| 2636 | if (err) | 2320 | if (err) |
| 2637 | goto out; | 2321 | goto out; |
| @@ -2652,6 +2336,7 @@ out: | |||
| 2652 | 2336 | ||
| 2653 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | 2337 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) |
| 2654 | { | 2338 | { |
| 2339 | struct net *net = genl_info_net(info); | ||
| 2655 | struct sk_buff *ans_skb; | 2340 | struct sk_buff *ans_skb; |
| 2656 | struct tipc_nl_msg msg; | 2341 | struct tipc_nl_msg msg; |
| 2657 | struct tipc_link *link; | 2342 | struct tipc_link *link; |
| @@ -2664,7 +2349,7 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | |||
| 2664 | return -EINVAL; | 2349 | return -EINVAL; |
| 2665 | 2350 | ||
| 2666 | name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]); | 2351 | name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]); |
| 2667 | node = tipc_link_find_owner(name, &bearer_id); | 2352 | node = tipc_link_find_owner(net, name, &bearer_id); |
| 2668 | if (!node) | 2353 | if (!node) |
| 2669 | return -EINVAL; | 2354 | return -EINVAL; |
| 2670 | 2355 | ||
| @@ -2683,7 +2368,7 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | |||
| 2683 | goto err_out; | 2368 | goto err_out; |
| 2684 | } | 2369 | } |
| 2685 | 2370 | ||
| 2686 | err = __tipc_nl_add_link(&msg, link); | 2371 | err = __tipc_nl_add_link(net, &msg, link); |
| 2687 | if (err) | 2372 | if (err) |
| 2688 | goto err_out; | 2373 | goto err_out; |
| 2689 | 2374 | ||
| @@ -2706,6 +2391,7 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | |||
| 2706 | struct tipc_link *link; | 2391 | struct tipc_link *link; |
| 2707 | struct tipc_node *node; | 2392 | struct tipc_node *node; |
| 2708 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2393 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
| 2394 | struct net *net = sock_net(skb->sk); | ||
| 2709 | 2395 | ||
| 2710 | if (!info->attrs[TIPC_NLA_LINK]) | 2396 | if (!info->attrs[TIPC_NLA_LINK]) |
| 2711 | return -EINVAL; | 2397 | return -EINVAL; |
| @@ -2722,13 +2408,13 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | |||
| 2722 | link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); | 2408 | link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); |
| 2723 | 2409 | ||
| 2724 | if (strcmp(link_name, tipc_bclink_name) == 0) { | 2410 | if (strcmp(link_name, tipc_bclink_name) == 0) { |
| 2725 | err = tipc_bclink_reset_stats(); | 2411 | err = tipc_bclink_reset_stats(net); |
| 2726 | if (err) | 2412 | if (err) |
| 2727 | return err; | 2413 | return err; |
| 2728 | return 0; | 2414 | return 0; |
| 2729 | } | 2415 | } |
| 2730 | 2416 | ||
| 2731 | node = tipc_link_find_owner(link_name, &bearer_id); | 2417 | node = tipc_link_find_owner(net, link_name, &bearer_id); |
| 2732 | if (!node) | 2418 | if (!node) |
| 2733 | return -EINVAL; | 2419 | return -EINVAL; |
| 2734 | 2420 | ||
