diff options
Diffstat (limited to 'net/tipc')
| -rw-r--r-- | net/tipc/bcast.c | 6 | ||||
| -rw-r--r-- | net/tipc/bearer.c | 323 | ||||
| -rw-r--r-- | net/tipc/bearer.h | 52 | ||||
| -rw-r--r-- | net/tipc/core.c | 8 | ||||
| -rw-r--r-- | net/tipc/discover.c | 17 | ||||
| -rw-r--r-- | net/tipc/eth_media.c | 326 | ||||
| -rw-r--r-- | net/tipc/ib_media.c | 319 | ||||
| -rw-r--r-- | net/tipc/link.c | 124 | ||||
| -rw-r--r-- | net/tipc/link.h | 7 | ||||
| -rw-r--r-- | net/tipc/node.c | 6 |
10 files changed, 330 insertions, 858 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 0d4402587fdf..4c2a80b3c01e 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
| @@ -621,12 +621,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf, struct tipc_bearer *unused1, | |||
| 621 | if (!p) | 621 | if (!p) |
| 622 | break; /* No more bearers to try */ | 622 | break; /* No more bearers to try */ |
| 623 | 623 | ||
| 624 | if (tipc_bearer_blocked(p)) { | ||
| 625 | if (!s || tipc_bearer_blocked(s)) | ||
| 626 | continue; /* Can't use either bearer */ | ||
| 627 | b = s; | ||
| 628 | } | ||
| 629 | |||
| 630 | tipc_nmap_diff(&bcbearer->remains, &b->nodes, | 624 | tipc_nmap_diff(&bcbearer->remains, &b->nodes, |
| 631 | &bcbearer->remains_new); | 625 | &bcbearer->remains_new); |
| 632 | if (bcbearer->remains_new.count == bcbearer->remains.count) | 626 | if (bcbearer->remains_new.count == bcbearer->remains.count) |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 3f9707a16d06..3bb5f266b0eb 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * net/tipc/bearer.c: TIPC bearer code | 2 | * net/tipc/bearer.c: TIPC bearer code |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 1996-2006, Ericsson AB | 4 | * Copyright (c) 1996-2006, 2013, Ericsson AB |
| 5 | * Copyright (c) 2004-2006, 2010-2011, Wind River Systems | 5 | * Copyright (c) 2004-2006, 2010-2013, Wind River Systems |
| 6 | * All rights reserved. | 6 | * All rights reserved. |
| 7 | * | 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
| @@ -41,8 +41,13 @@ | |||
| 41 | 41 | ||
| 42 | #define MAX_ADDR_STR 60 | 42 | #define MAX_ADDR_STR 60 |
| 43 | 43 | ||
| 44 | static struct tipc_media *media_list[MAX_MEDIA]; | 44 | static struct tipc_media * const media_info_array[] = { |
| 45 | static u32 media_count; | 45 | ð_media_info, |
| 46 | #ifdef CONFIG_TIPC_MEDIA_IB | ||
| 47 | &ib_media_info, | ||
| 48 | #endif | ||
| 49 | NULL | ||
| 50 | }; | ||
| 46 | 51 | ||
| 47 | struct tipc_bearer tipc_bearers[MAX_BEARERS]; | 52 | struct tipc_bearer tipc_bearers[MAX_BEARERS]; |
| 48 | 53 | ||
| @@ -55,11 +60,11 @@ struct tipc_media *tipc_media_find(const char *name) | |||
| 55 | { | 60 | { |
| 56 | u32 i; | 61 | u32 i; |
| 57 | 62 | ||
| 58 | for (i = 0; i < media_count; i++) { | 63 | for (i = 0; media_info_array[i] != NULL; i++) { |
| 59 | if (!strcmp(media_list[i]->name, name)) | 64 | if (!strcmp(media_info_array[i]->name, name)) |
| 60 | return media_list[i]; | 65 | break; |
| 61 | } | 66 | } |
| 62 | return NULL; | 67 | return media_info_array[i]; |
| 63 | } | 68 | } |
| 64 | 69 | ||
| 65 | /** | 70 | /** |
| @@ -69,44 +74,11 @@ static struct tipc_media *media_find_id(u8 type) | |||
| 69 | { | 74 | { |
| 70 | u32 i; | 75 | u32 i; |
| 71 | 76 | ||
| 72 | for (i = 0; i < media_count; i++) { | 77 | for (i = 0; media_info_array[i] != NULL; i++) { |
| 73 | if (media_list[i]->type_id == type) | 78 | if (media_info_array[i]->type_id == type) |
| 74 | return media_list[i]; | 79 | break; |
| 75 | } | 80 | } |
| 76 | return NULL; | 81 | return media_info_array[i]; |
| 77 | } | ||
| 78 | |||
| 79 | /** | ||
| 80 | * tipc_register_media - register a media type | ||
| 81 | * | ||
| 82 | * Bearers for this media type must be activated separately at a later stage. | ||
| 83 | */ | ||
| 84 | int tipc_register_media(struct tipc_media *m_ptr) | ||
| 85 | { | ||
| 86 | int res = -EINVAL; | ||
| 87 | |||
| 88 | write_lock_bh(&tipc_net_lock); | ||
| 89 | |||
| 90 | if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME) | ||
| 91 | goto exit; | ||
| 92 | if (m_ptr->priority > TIPC_MAX_LINK_PRI) | ||
| 93 | goto exit; | ||
| 94 | if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) || | ||
| 95 | (m_ptr->tolerance > TIPC_MAX_LINK_TOL)) | ||
| 96 | goto exit; | ||
| 97 | if (media_count >= MAX_MEDIA) | ||
| 98 | goto exit; | ||
| 99 | if (tipc_media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) | ||
| 100 | goto exit; | ||
| 101 | |||
| 102 | media_list[media_count] = m_ptr; | ||
| 103 | media_count++; | ||
| 104 | res = 0; | ||
| 105 | exit: | ||
| 106 | write_unlock_bh(&tipc_net_lock); | ||
| 107 | if (res) | ||
| 108 | pr_warn("Media <%s> registration error\n", m_ptr->name); | ||
| 109 | return res; | ||
| 110 | } | 82 | } |
| 111 | 83 | ||
| 112 | /** | 84 | /** |
| @@ -144,13 +116,11 @@ struct sk_buff *tipc_media_get_names(void) | |||
| 144 | if (!buf) | 116 | if (!buf) |
| 145 | return NULL; | 117 | return NULL; |
| 146 | 118 | ||
| 147 | read_lock_bh(&tipc_net_lock); | 119 | for (i = 0; media_info_array[i] != NULL; i++) { |
| 148 | for (i = 0; i < media_count; i++) { | ||
| 149 | tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, | 120 | tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, |
| 150 | media_list[i]->name, | 121 | media_info_array[i]->name, |
| 151 | strlen(media_list[i]->name) + 1); | 122 | strlen(media_info_array[i]->name) + 1); |
| 152 | } | 123 | } |
| 153 | read_unlock_bh(&tipc_net_lock); | ||
| 154 | return buf; | 124 | return buf; |
| 155 | } | 125 | } |
| 156 | 126 | ||
| @@ -239,7 +209,7 @@ struct tipc_bearer *tipc_bearer_find_interface(const char *if_name) | |||
| 239 | struct sk_buff *tipc_bearer_get_names(void) | 209 | struct sk_buff *tipc_bearer_get_names(void) |
| 240 | { | 210 | { |
| 241 | struct sk_buff *buf; | 211 | struct sk_buff *buf; |
| 242 | struct tipc_bearer *b_ptr; | 212 | struct tipc_bearer *b; |
| 243 | int i, j; | 213 | int i, j; |
| 244 | 214 | ||
| 245 | buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME)); | 215 | buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME)); |
| @@ -247,13 +217,13 @@ struct sk_buff *tipc_bearer_get_names(void) | |||
| 247 | return NULL; | 217 | return NULL; |
| 248 | 218 | ||
| 249 | read_lock_bh(&tipc_net_lock); | 219 | read_lock_bh(&tipc_net_lock); |
| 250 | for (i = 0; i < media_count; i++) { | 220 | for (i = 0; media_info_array[i] != NULL; i++) { |
| 251 | for (j = 0; j < MAX_BEARERS; j++) { | 221 | for (j = 0; j < MAX_BEARERS; j++) { |
| 252 | b_ptr = &tipc_bearers[j]; | 222 | b = &tipc_bearers[j]; |
| 253 | if (b_ptr->active && (b_ptr->media == media_list[i])) { | 223 | if (b->active && (b->media == media_info_array[i])) { |
| 254 | tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, | 224 | tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, |
| 255 | b_ptr->name, | 225 | b->name, |
| 256 | strlen(b_ptr->name) + 1); | 226 | strlen(b->name) + 1); |
| 257 | } | 227 | } |
| 258 | } | 228 | } |
| 259 | } | 229 | } |
| @@ -275,31 +245,6 @@ void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest) | |||
| 275 | tipc_disc_remove_dest(b_ptr->link_req); | 245 | tipc_disc_remove_dest(b_ptr->link_req); |
| 276 | } | 246 | } |
| 277 | 247 | ||
| 278 | /* | ||
| 279 | * Interrupt enabling new requests after bearer blocking: | ||
| 280 | * See bearer_send(). | ||
| 281 | */ | ||
| 282 | void tipc_continue(struct tipc_bearer *b) | ||
| 283 | { | ||
| 284 | spin_lock_bh(&b->lock); | ||
| 285 | b->blocked = 0; | ||
| 286 | spin_unlock_bh(&b->lock); | ||
| 287 | } | ||
| 288 | |||
| 289 | /* | ||
| 290 | * tipc_bearer_blocked - determines if bearer is currently blocked | ||
| 291 | */ | ||
| 292 | int tipc_bearer_blocked(struct tipc_bearer *b) | ||
| 293 | { | ||
| 294 | int res; | ||
| 295 | |||
| 296 | spin_lock_bh(&b->lock); | ||
| 297 | res = b->blocked; | ||
| 298 | spin_unlock_bh(&b->lock); | ||
| 299 | |||
| 300 | return res; | ||
| 301 | } | ||
| 302 | |||
| 303 | /** | 248 | /** |
| 304 | * tipc_enable_bearer - enable bearer with the given name | 249 | * tipc_enable_bearer - enable bearer with the given name |
| 305 | */ | 250 | */ |
| @@ -387,6 +332,7 @@ restart: | |||
| 387 | 332 | ||
| 388 | b_ptr = &tipc_bearers[bearer_id]; | 333 | b_ptr = &tipc_bearers[bearer_id]; |
| 389 | strcpy(b_ptr->name, name); | 334 | strcpy(b_ptr->name, name); |
| 335 | b_ptr->media = m_ptr; | ||
| 390 | res = m_ptr->enable_media(b_ptr); | 336 | res = m_ptr->enable_media(b_ptr); |
| 391 | if (res) { | 337 | if (res) { |
| 392 | pr_warn("Bearer <%s> rejected, enable failure (%d)\n", | 338 | pr_warn("Bearer <%s> rejected, enable failure (%d)\n", |
| @@ -395,7 +341,6 @@ restart: | |||
| 395 | } | 341 | } |
| 396 | 342 | ||
| 397 | b_ptr->identity = bearer_id; | 343 | b_ptr->identity = bearer_id; |
| 398 | b_ptr->media = m_ptr; | ||
| 399 | b_ptr->tolerance = m_ptr->tolerance; | 344 | b_ptr->tolerance = m_ptr->tolerance; |
| 400 | b_ptr->window = m_ptr->window; | 345 | b_ptr->window = m_ptr->window; |
| 401 | b_ptr->net_plane = bearer_id + 'A'; | 346 | b_ptr->net_plane = bearer_id + 'A'; |
| @@ -420,17 +365,16 @@ exit: | |||
| 420 | } | 365 | } |
| 421 | 366 | ||
| 422 | /** | 367 | /** |
| 423 | * tipc_block_bearer - Block the bearer, and reset all its links | 368 | * tipc_reset_bearer - Reset all links established over this bearer |
| 424 | */ | 369 | */ |
| 425 | int tipc_block_bearer(struct tipc_bearer *b_ptr) | 370 | static int tipc_reset_bearer(struct tipc_bearer *b_ptr) |
| 426 | { | 371 | { |
| 427 | struct tipc_link *l_ptr; | 372 | struct tipc_link *l_ptr; |
| 428 | struct tipc_link *temp_l_ptr; | 373 | struct tipc_link *temp_l_ptr; |
| 429 | 374 | ||
| 430 | read_lock_bh(&tipc_net_lock); | 375 | read_lock_bh(&tipc_net_lock); |
| 431 | pr_info("Blocking bearer <%s>\n", b_ptr->name); | 376 | pr_info("Resetting bearer <%s>\n", b_ptr->name); |
| 432 | spin_lock_bh(&b_ptr->lock); | 377 | spin_lock_bh(&b_ptr->lock); |
| 433 | b_ptr->blocked = 1; | ||
| 434 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 378 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
| 435 | struct tipc_node *n_ptr = l_ptr->owner; | 379 | struct tipc_node *n_ptr = l_ptr->owner; |
| 436 | 380 | ||
| @@ -456,7 +400,6 @@ static void bearer_disable(struct tipc_bearer *b_ptr) | |||
| 456 | 400 | ||
| 457 | pr_info("Disabling bearer <%s>\n", b_ptr->name); | 401 | pr_info("Disabling bearer <%s>\n", b_ptr->name); |
| 458 | spin_lock_bh(&b_ptr->lock); | 402 | spin_lock_bh(&b_ptr->lock); |
| 459 | b_ptr->blocked = 1; | ||
| 460 | b_ptr->media->disable_media(b_ptr); | 403 | b_ptr->media->disable_media(b_ptr); |
| 461 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 404 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
| 462 | tipc_link_delete(l_ptr); | 405 | tipc_link_delete(l_ptr); |
| @@ -490,6 +433,211 @@ int tipc_disable_bearer(const char *name) | |||
| 490 | } | 433 | } |
| 491 | 434 | ||
| 492 | 435 | ||
| 436 | /* tipc_l2_media_addr_set - initialize Ethernet media address structure | ||
| 437 | * | ||
| 438 | * Media-dependent "value" field stores MAC address in first 6 bytes | ||
| 439 | * and zeroes out the remaining bytes. | ||
| 440 | */ | ||
| 441 | void tipc_l2_media_addr_set(const struct tipc_bearer *b, | ||
| 442 | struct tipc_media_addr *a, char *mac) | ||
| 443 | { | ||
| 444 | int len = b->media->hwaddr_len; | ||
| 445 | |||
| 446 | if (unlikely(sizeof(a->value) < len)) { | ||
| 447 | WARN_ONCE(1, "Media length invalid\n"); | ||
| 448 | return; | ||
| 449 | } | ||
| 450 | |||
| 451 | memcpy(a->value, mac, len); | ||
| 452 | memset(a->value + len, 0, sizeof(a->value) - len); | ||
| 453 | a->media_id = b->media->type_id; | ||
| 454 | a->broadcast = !memcmp(mac, b->bcast_addr.value, len); | ||
| 455 | } | ||
| 456 | |||
| 457 | int tipc_enable_l2_media(struct tipc_bearer *b) | ||
| 458 | { | ||
| 459 | struct net_device *dev; | ||
| 460 | char *driver_name = strchr((const char *)b->name, ':') + 1; | ||
| 461 | |||
| 462 | /* Find device with specified name */ | ||
| 463 | dev = dev_get_by_name(&init_net, driver_name); | ||
| 464 | if (!dev) | ||
| 465 | return -ENODEV; | ||
| 466 | |||
| 467 | /* Associate TIPC bearer with Ethernet bearer */ | ||
| 468 | b->media_ptr = dev; | ||
| 469 | memset(b->bcast_addr.value, 0, sizeof(b->bcast_addr.value)); | ||
| 470 | memcpy(b->bcast_addr.value, dev->broadcast, b->media->hwaddr_len); | ||
| 471 | b->bcast_addr.media_id = b->media->type_id; | ||
| 472 | b->bcast_addr.broadcast = 1; | ||
| 473 | b->mtu = dev->mtu; | ||
| 474 | tipc_l2_media_addr_set(b, &b->addr, (char *)dev->dev_addr); | ||
| 475 | rcu_assign_pointer(dev->tipc_ptr, b); | ||
| 476 | return 0; | ||
| 477 | } | ||
| 478 | |||
| 479 | /* tipc_disable_l2_media - detach TIPC bearer from an Ethernet interface | ||
| 480 | * | ||
| 481 | * Mark Ethernet bearer as inactive so that incoming buffers are thrown away, | ||
| 482 | * then get worker thread to complete bearer cleanup. (Can't do cleanup | ||
| 483 | * here because cleanup code needs to sleep and caller holds spinlocks.) | ||
| 484 | */ | ||
| 485 | void tipc_disable_l2_media(struct tipc_bearer *b) | ||
| 486 | { | ||
| 487 | struct net_device *dev = (struct net_device *)b->media_ptr; | ||
| 488 | RCU_INIT_POINTER(dev->tipc_ptr, NULL); | ||
| 489 | dev_put(dev); | ||
| 490 | } | ||
| 491 | |||
| 492 | /** | ||
| 493 | * tipc_l2_send_msg - send a TIPC packet out over an Ethernet interface | ||
| 494 | * @buf: the packet to be sent | ||
| 495 | * @b_ptr: the bearer throught which the packet is to be sent | ||
| 496 | * @dest: peer destination address | ||
| 497 | */ | ||
| 498 | int tipc_l2_send_msg(struct sk_buff *buf, struct tipc_bearer *b, | ||
| 499 | struct tipc_media_addr *dest) | ||
| 500 | { | ||
| 501 | struct sk_buff *clone; | ||
| 502 | int delta; | ||
| 503 | struct net_device *dev = (struct net_device *)b->media_ptr; | ||
| 504 | |||
| 505 | clone = skb_clone(buf, GFP_ATOMIC); | ||
| 506 | if (!clone) | ||
| 507 | return 0; | ||
| 508 | |||
| 509 | delta = dev->hard_header_len - skb_headroom(buf); | ||
| 510 | if ((delta > 0) && | ||
| 511 | pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) { | ||
| 512 | kfree_skb(clone); | ||
| 513 | return 0; | ||
| 514 | } | ||
| 515 | |||
| 516 | skb_reset_network_header(clone); | ||
| 517 | clone->dev = dev; | ||
| 518 | clone->protocol = htons(ETH_P_TIPC); | ||
| 519 | dev_hard_header(clone, dev, ETH_P_TIPC, dest->value, | ||
| 520 | dev->dev_addr, clone->len); | ||
| 521 | dev_queue_xmit(clone); | ||
| 522 | return 0; | ||
| 523 | } | ||
| 524 | |||
| 525 | /* tipc_bearer_send- sends buffer to destination over bearer | ||
| 526 | * | ||
| 527 | * IMPORTANT: | ||
| 528 | * The media send routine must not alter the buffer being passed in | ||
| 529 | * as it may be needed for later retransmission! | ||
| 530 | */ | ||
| 531 | void tipc_bearer_send(struct tipc_bearer *b, struct sk_buff *buf, | ||
| 532 | struct tipc_media_addr *dest) | ||
| 533 | { | ||
| 534 | b->media->send_msg(buf, b, dest); | ||
| 535 | } | ||
| 536 | |||
| 537 | /** | ||
| 538 | * tipc_l2_rcv_msg - handle incoming TIPC message from an interface | ||
| 539 | * @buf: the received packet | ||
| 540 | * @dev: the net device that the packet was received on | ||
| 541 | * @pt: the packet_type structure which was used to register this handler | ||
| 542 | * @orig_dev: the original receive net device in case the device is a bond | ||
| 543 | * | ||
| 544 | * Accept only packets explicitly sent to this node, or broadcast packets; | ||
| 545 | * ignores packets sent using interface multicast, and traffic sent to other | ||
| 546 | * nodes (which can happen if interface is running in promiscuous mode). | ||
| 547 | */ | ||
| 548 | static int tipc_l2_rcv_msg(struct sk_buff *buf, struct net_device *dev, | ||
| 549 | struct packet_type *pt, struct net_device *orig_dev) | ||
| 550 | { | ||
| 551 | struct tipc_bearer *b_ptr; | ||
| 552 | |||
| 553 | if (!net_eq(dev_net(dev), &init_net)) { | ||
| 554 | kfree_skb(buf); | ||
| 555 | return NET_RX_DROP; | ||
| 556 | } | ||
| 557 | |||
| 558 | rcu_read_lock(); | ||
| 559 | b_ptr = rcu_dereference(dev->tipc_ptr); | ||
| 560 | if (likely(b_ptr)) { | ||
| 561 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { | ||
| 562 | buf->next = NULL; | ||
| 563 | tipc_recv_msg(buf, b_ptr); | ||
| 564 | rcu_read_unlock(); | ||
| 565 | return NET_RX_SUCCESS; | ||
| 566 | } | ||
| 567 | } | ||
| 568 | rcu_read_unlock(); | ||
| 569 | |||
| 570 | kfree_skb(buf); | ||
| 571 | return NET_RX_DROP; | ||
| 572 | } | ||
| 573 | |||
| 574 | /** | ||
| 575 | * tipc_l2_device_event - handle device events from network device | ||
| 576 | * @nb: the context of the notification | ||
| 577 | * @evt: the type of event | ||
| 578 | * @ptr: the net device that the event was on | ||
| 579 | * | ||
| 580 | * This function is called by the Ethernet driver in case of link | ||
| 581 | * change event. | ||
| 582 | */ | ||
| 583 | static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, | ||
| 584 | void *ptr) | ||
| 585 | { | ||
| 586 | struct tipc_bearer *b_ptr; | ||
| 587 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); | ||
| 588 | |||
| 589 | if (!net_eq(dev_net(dev), &init_net)) | ||
| 590 | return NOTIFY_DONE; | ||
| 591 | |||
| 592 | rcu_read_lock(); | ||
| 593 | b_ptr = rcu_dereference(dev->tipc_ptr); | ||
| 594 | if (!b_ptr) { | ||
| 595 | rcu_read_unlock(); | ||
| 596 | return NOTIFY_DONE; | ||
| 597 | } | ||
| 598 | |||
| 599 | b_ptr->mtu = dev->mtu; | ||
| 600 | |||
| 601 | switch (evt) { | ||
| 602 | case NETDEV_CHANGE: | ||
| 603 | if (netif_carrier_ok(dev)) | ||
| 604 | break; | ||
| 605 | case NETDEV_DOWN: | ||
| 606 | case NETDEV_CHANGEMTU: | ||
| 607 | case NETDEV_CHANGEADDR: | ||
| 608 | tipc_reset_bearer(b_ptr); | ||
| 609 | break; | ||
| 610 | case NETDEV_UNREGISTER: | ||
| 611 | case NETDEV_CHANGENAME: | ||
| 612 | tipc_disable_bearer(b_ptr->name); | ||
| 613 | break; | ||
| 614 | } | ||
| 615 | rcu_read_unlock(); | ||
| 616 | |||
| 617 | return NOTIFY_OK; | ||
| 618 | } | ||
| 619 | |||
| 620 | static struct packet_type tipc_packet_type __read_mostly = { | ||
| 621 | .type = __constant_htons(ETH_P_TIPC), | ||
| 622 | .func = tipc_l2_rcv_msg, | ||
| 623 | }; | ||
| 624 | |||
| 625 | static struct notifier_block notifier = { | ||
| 626 | .notifier_call = tipc_l2_device_event, | ||
| 627 | .priority = 0, | ||
| 628 | }; | ||
| 629 | |||
| 630 | int tipc_bearer_setup(void) | ||
| 631 | { | ||
| 632 | dev_add_pack(&tipc_packet_type); | ||
| 633 | return register_netdevice_notifier(¬ifier); | ||
| 634 | } | ||
| 635 | |||
| 636 | void tipc_bearer_cleanup(void) | ||
| 637 | { | ||
| 638 | unregister_netdevice_notifier(¬ifier); | ||
| 639 | dev_remove_pack(&tipc_packet_type); | ||
| 640 | } | ||
| 493 | 641 | ||
| 494 | void tipc_bearer_stop(void) | 642 | void tipc_bearer_stop(void) |
| 495 | { | 643 | { |
| @@ -499,5 +647,4 @@ void tipc_bearer_stop(void) | |||
| 499 | if (tipc_bearers[i].active) | 647 | if (tipc_bearers[i].active) |
| 500 | bearer_disable(&tipc_bearers[i]); | 648 | bearer_disable(&tipc_bearers[i]); |
| 501 | } | 649 | } |
| 502 | media_count = 0; | ||
| 503 | } | 650 | } |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index e5e04be6fffa..fa95c34ca926 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * net/tipc/bearer.h: Include file for TIPC bearer code | 2 | * net/tipc/bearer.h: Include file for TIPC bearer code |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 1996-2006, Ericsson AB | 4 | * Copyright (c) 1996-2006, 2013, Ericsson AB |
| 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems | 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
| 6 | * All rights reserved. | 6 | * All rights reserved. |
| 7 | * | 7 | * |
| @@ -73,18 +73,18 @@ struct tipc_media_addr { | |||
| 73 | struct tipc_bearer; | 73 | struct tipc_bearer; |
| 74 | 74 | ||
| 75 | /** | 75 | /** |
| 76 | * struct tipc_media - TIPC media information available to internal users | 76 | * struct tipc_media - Media specific info exposed to generic bearer layer |
| 77 | * @send_msg: routine which handles buffer transmission | 77 | * @send_msg: routine which handles buffer transmission |
| 78 | * @enable_media: routine which enables a media | 78 | * @enable_media: routine which enables a media |
| 79 | * @disable_media: routine which disables a media | 79 | * @disable_media: routine which disables a media |
| 80 | * @addr2str: routine which converts media address to string | 80 | * @addr2str: routine which converts media address to string |
| 81 | * @addr2msg: routine which converts media address to protocol message area | 81 | * @addr2msg: routine which converts media address to protocol message area |
| 82 | * @msg2addr: routine which converts media address from protocol message area | 82 | * @msg2addr: routine which converts media address from protocol message area |
| 83 | * @bcast_addr: media address used in broadcasting | ||
| 84 | * @priority: default link (and bearer) priority | 83 | * @priority: default link (and bearer) priority |
| 85 | * @tolerance: default time (in ms) before declaring link failure | 84 | * @tolerance: default time (in ms) before declaring link failure |
| 86 | * @window: default window (in packets) before declaring link congestion | 85 | * @window: default window (in packets) before declaring link congestion |
| 87 | * @type_id: TIPC media identifier | 86 | * @type_id: TIPC media identifier |
| 87 | * @hwaddr_len: TIPC media address len | ||
| 88 | * @name: media name | 88 | * @name: media name |
| 89 | */ | 89 | */ |
| 90 | struct tipc_media { | 90 | struct tipc_media { |
| @@ -101,18 +101,20 @@ struct tipc_media { | |||
| 101 | u32 tolerance; | 101 | u32 tolerance; |
| 102 | u32 window; | 102 | u32 window; |
| 103 | u32 type_id; | 103 | u32 type_id; |
| 104 | u32 hwaddr_len; | ||
| 104 | char name[TIPC_MAX_MEDIA_NAME]; | 105 | char name[TIPC_MAX_MEDIA_NAME]; |
| 105 | }; | 106 | }; |
| 106 | 107 | ||
| 107 | /** | 108 | /** |
| 108 | * struct tipc_bearer - TIPC bearer structure | 109 | * struct tipc_bearer - Generic TIPC bearer structure |
| 110 | * @dev: ptr to associated network device | ||
| 109 | * @usr_handle: pointer to additional media-specific information about bearer | 111 | * @usr_handle: pointer to additional media-specific information about bearer |
| 110 | * @mtu: max packet size bearer can support | 112 | * @mtu: max packet size bearer can support |
| 111 | * @blocked: non-zero if bearer is blocked | ||
| 112 | * @lock: spinlock for controlling access to bearer | 113 | * @lock: spinlock for controlling access to bearer |
| 113 | * @addr: media-specific address associated with bearer | 114 | * @addr: media-specific address associated with bearer |
| 114 | * @name: bearer name (format = media:interface) | 115 | * @name: bearer name (format = media:interface) |
| 115 | * @media: ptr to media structure associated with bearer | 116 | * @media: ptr to media structure associated with bearer |
| 117 | * @bcast_addr: media address used in broadcasting | ||
| 116 | * @priority: default link priority for bearer | 118 | * @priority: default link priority for bearer |
| 117 | * @window: default window size for bearer | 119 | * @window: default window size for bearer |
| 118 | * @tolerance: default link tolerance for bearer | 120 | * @tolerance: default link tolerance for bearer |
| @@ -128,9 +130,8 @@ struct tipc_media { | |||
| 128 | * care of initializing all other fields. | 130 | * care of initializing all other fields. |
| 129 | */ | 131 | */ |
| 130 | struct tipc_bearer { | 132 | struct tipc_bearer { |
| 131 | void *usr_handle; /* initalized by media */ | 133 | void *media_ptr; /* initalized by media */ |
| 132 | u32 mtu; /* initalized by media */ | 134 | u32 mtu; /* initalized by media */ |
| 133 | int blocked; /* initalized by media */ | ||
| 134 | struct tipc_media_addr addr; /* initalized by media */ | 135 | struct tipc_media_addr addr; /* initalized by media */ |
| 135 | char name[TIPC_MAX_BEARER_NAME]; | 136 | char name[TIPC_MAX_BEARER_NAME]; |
| 136 | spinlock_t lock; | 137 | spinlock_t lock; |
| @@ -159,34 +160,31 @@ extern struct tipc_bearer tipc_bearers[]; | |||
| 159 | /* | 160 | /* |
| 160 | * TIPC routines available to supported media types | 161 | * TIPC routines available to supported media types |
| 161 | */ | 162 | */ |
| 162 | int tipc_register_media(struct tipc_media *m_ptr); | ||
| 163 | 163 | ||
| 164 | void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); | 164 | void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); |
| 165 | 165 | ||
| 166 | int tipc_block_bearer(struct tipc_bearer *b_ptr); | ||
| 167 | void tipc_continue(struct tipc_bearer *tb_ptr); | ||
| 168 | |||
| 169 | int tipc_enable_bearer(const char *bearer_name, u32 disc_domain, u32 priority); | 166 | int tipc_enable_bearer(const char *bearer_name, u32 disc_domain, u32 priority); |
| 170 | int tipc_disable_bearer(const char *name); | 167 | int tipc_disable_bearer(const char *name); |
| 171 | 168 | ||
| 172 | /* | 169 | /* |
| 173 | * Routines made available to TIPC by supported media types | 170 | * Routines made available to TIPC by supported media types |
| 174 | */ | 171 | */ |
| 175 | int tipc_eth_media_start(void); | 172 | extern struct tipc_media eth_media_info; |
| 176 | void tipc_eth_media_stop(void); | ||
| 177 | 173 | ||
| 178 | #ifdef CONFIG_TIPC_MEDIA_IB | 174 | #ifdef CONFIG_TIPC_MEDIA_IB |
| 179 | int tipc_ib_media_start(void); | 175 | extern struct tipc_media ib_media_info; |
| 180 | void tipc_ib_media_stop(void); | ||
| 181 | #else | ||
| 182 | static inline int tipc_ib_media_start(void) { return 0; } | ||
| 183 | static inline void tipc_ib_media_stop(void) { return; } | ||
| 184 | #endif | 176 | #endif |
| 185 | 177 | ||
| 186 | int tipc_media_set_priority(const char *name, u32 new_value); | 178 | int tipc_media_set_priority(const char *name, u32 new_value); |
| 187 | int tipc_media_set_window(const char *name, u32 new_value); | 179 | int tipc_media_set_window(const char *name, u32 new_value); |
| 188 | void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); | 180 | void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); |
| 189 | struct sk_buff *tipc_media_get_names(void); | 181 | struct sk_buff *tipc_media_get_names(void); |
| 182 | void tipc_l2_media_addr_set(const struct tipc_bearer *b, | ||
| 183 | struct tipc_media_addr *a, char *mac); | ||
| 184 | int tipc_enable_l2_media(struct tipc_bearer *b); | ||
| 185 | void tipc_disable_l2_media(struct tipc_bearer *b); | ||
| 186 | int tipc_l2_send_msg(struct sk_buff *buf, struct tipc_bearer *b, | ||
| 187 | struct tipc_media_addr *dest); | ||
| 190 | 188 | ||
| 191 | struct sk_buff *tipc_bearer_get_names(void); | 189 | struct sk_buff *tipc_bearer_get_names(void); |
| 192 | void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest); | 190 | void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest); |
| @@ -194,20 +192,10 @@ void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest); | |||
| 194 | struct tipc_bearer *tipc_bearer_find(const char *name); | 192 | struct tipc_bearer *tipc_bearer_find(const char *name); |
| 195 | struct tipc_bearer *tipc_bearer_find_interface(const char *if_name); | 193 | struct tipc_bearer *tipc_bearer_find_interface(const char *if_name); |
| 196 | struct tipc_media *tipc_media_find(const char *name); | 194 | struct tipc_media *tipc_media_find(const char *name); |
| 197 | int tipc_bearer_blocked(struct tipc_bearer *b_ptr); | 195 | int tipc_bearer_setup(void); |
| 196 | void tipc_bearer_cleanup(void); | ||
| 198 | void tipc_bearer_stop(void); | 197 | void tipc_bearer_stop(void); |
| 199 | 198 | void tipc_bearer_send(struct tipc_bearer *b, struct sk_buff *buf, | |
| 200 | /** | 199 | struct tipc_media_addr *dest); |
| 201 | * tipc_bearer_send- sends buffer to destination over bearer | ||
| 202 | * | ||
| 203 | * IMPORTANT: | ||
| 204 | * The media send routine must not alter the buffer being passed in | ||
| 205 | * as it may be needed for later retransmission! | ||
| 206 | */ | ||
| 207 | static inline void tipc_bearer_send(struct tipc_bearer *b, struct sk_buff *buf, | ||
| 208 | struct tipc_media_addr *dest) | ||
| 209 | { | ||
| 210 | b->media->send_msg(buf, b, dest); | ||
| 211 | } | ||
| 212 | 200 | ||
| 213 | #endif /* _TIPC_BEARER_H */ | 201 | #endif /* _TIPC_BEARER_H */ |
diff --git a/net/tipc/core.c b/net/tipc/core.c index fd4eeeaa972a..68977c423022 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
| @@ -82,8 +82,7 @@ struct sk_buff *tipc_buf_acquire(u32 size) | |||
| 82 | static void tipc_core_stop_net(void) | 82 | static void tipc_core_stop_net(void) |
| 83 | { | 83 | { |
| 84 | tipc_net_stop(); | 84 | tipc_net_stop(); |
| 85 | tipc_eth_media_stop(); | 85 | tipc_bearer_cleanup(); |
| 86 | tipc_ib_media_stop(); | ||
| 87 | } | 86 | } |
| 88 | 87 | ||
| 89 | /** | 88 | /** |
| @@ -94,10 +93,7 @@ int tipc_core_start_net(unsigned long addr) | |||
| 94 | int res; | 93 | int res; |
| 95 | 94 | ||
| 96 | tipc_net_start(addr); | 95 | tipc_net_start(addr); |
| 97 | res = tipc_eth_media_start(); | 96 | res = tipc_bearer_setup(); |
| 98 | if (res < 0) | ||
| 99 | goto err; | ||
| 100 | res = tipc_ib_media_start(); | ||
| 101 | if (res < 0) | 97 | if (res < 0) |
| 102 | goto err; | 98 | goto err; |
| 103 | return res; | 99 | return res; |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index ecc758c6eacf..bc849f1efa16 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
| @@ -239,7 +239,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) | |||
| 239 | /* Accept discovery message & send response, if necessary */ | 239 | /* Accept discovery message & send response, if necessary */ |
| 240 | link_fully_up = link_working_working(link); | 240 | link_fully_up = link_working_working(link); |
| 241 | 241 | ||
| 242 | if ((type == DSC_REQ_MSG) && !link_fully_up && !b_ptr->blocked) { | 242 | if ((type == DSC_REQ_MSG) && !link_fully_up) { |
| 243 | rbuf = tipc_disc_init_msg(DSC_RESP_MSG, orig, b_ptr); | 243 | rbuf = tipc_disc_init_msg(DSC_RESP_MSG, orig, b_ptr); |
| 244 | if (rbuf) { | 244 | if (rbuf) { |
| 245 | tipc_bearer_send(b_ptr, rbuf, &media_addr); | 245 | tipc_bearer_send(b_ptr, rbuf, &media_addr); |
| @@ -288,16 +288,6 @@ void tipc_disc_remove_dest(struct tipc_link_req *req) | |||
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | /** | 290 | /** |
| 291 | * disc_send_msg - send link setup request message | ||
| 292 | * @req: ptr to link request structure | ||
| 293 | */ | ||
| 294 | static void disc_send_msg(struct tipc_link_req *req) | ||
| 295 | { | ||
| 296 | if (!req->bearer->blocked) | ||
| 297 | tipc_bearer_send(req->bearer, req->buf, &req->dest); | ||
| 298 | } | ||
| 299 | |||
| 300 | /** | ||
| 301 | * disc_timeout - send a periodic link setup request | 291 | * disc_timeout - send a periodic link setup request |
| 302 | * @req: ptr to link request structure | 292 | * @req: ptr to link request structure |
| 303 | * | 293 | * |
| @@ -322,7 +312,8 @@ static void disc_timeout(struct tipc_link_req *req) | |||
| 322 | * hold at fast polling rate if don't have any associated nodes, | 312 | * hold at fast polling rate if don't have any associated nodes, |
| 323 | * otherwise hold at slow polling rate | 313 | * otherwise hold at slow polling rate |
| 324 | */ | 314 | */ |
| 325 | disc_send_msg(req); | 315 | tipc_bearer_send(req->bearer, req->buf, &req->dest); |
| 316 | |||
| 326 | 317 | ||
| 327 | req->timer_intv *= 2; | 318 | req->timer_intv *= 2; |
| 328 | if (req->num_nodes) | 319 | if (req->num_nodes) |
| @@ -368,7 +359,7 @@ int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest, | |||
| 368 | k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req); | 359 | k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req); |
| 369 | k_start_timer(&req->timer, req->timer_intv); | 360 | k_start_timer(&req->timer, req->timer_intv); |
| 370 | b_ptr->link_req = req; | 361 | b_ptr->link_req = req; |
| 371 | disc_send_msg(req); | 362 | tipc_bearer_send(req->bearer, req->buf, &req->dest); |
| 372 | return 0; | 363 | return 0; |
| 373 | } | 364 | } |
| 374 | 365 | ||
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index f80d59f5a161..67cf3f935dba 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC | 2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2001-2007, Ericsson AB | 4 | * Copyright (c) 2001-2007, 2013, Ericsson AB |
| 5 | * Copyright (c) 2005-2008, 2011-2013, Wind River Systems | 5 | * Copyright (c) 2005-2008, 2011-2013, Wind River Systems |
| 6 | * All rights reserved. | 6 | * All rights reserved. |
| 7 | * | 7 | * |
| @@ -37,259 +37,11 @@ | |||
| 37 | #include "core.h" | 37 | #include "core.h" |
| 38 | #include "bearer.h" | 38 | #include "bearer.h" |
| 39 | 39 | ||
| 40 | #define MAX_ETH_MEDIA MAX_BEARERS | ||
| 41 | |||
| 42 | #define ETH_ADDR_OFFSET 4 /* message header offset of MAC address */ | 40 | #define ETH_ADDR_OFFSET 4 /* message header offset of MAC address */ |
| 43 | 41 | ||
| 44 | /** | 42 | /* convert Ethernet address to string */ |
| 45 | * struct eth_media - Ethernet bearer data structure | 43 | static int tipc_eth_addr2str(struct tipc_media_addr *a, char *str_buf, |
| 46 | * @bearer: ptr to associated "generic" bearer structure | 44 | int str_size) |
| 47 | * @dev: ptr to associated Ethernet network device | ||
| 48 | * @tipc_packet_type: used in binding TIPC to Ethernet driver | ||
| 49 | * @setup: work item used when enabling bearer | ||
| 50 | * @cleanup: work item used when disabling bearer | ||
| 51 | */ | ||
| 52 | struct eth_media { | ||
| 53 | struct tipc_bearer *bearer; | ||
| 54 | struct net_device *dev; | ||
| 55 | struct packet_type tipc_packet_type; | ||
| 56 | struct work_struct setup; | ||
| 57 | struct work_struct cleanup; | ||
| 58 | }; | ||
| 59 | |||
| 60 | static struct tipc_media eth_media_info; | ||
| 61 | static struct eth_media eth_media_array[MAX_ETH_MEDIA]; | ||
| 62 | static int eth_started; | ||
| 63 | |||
| 64 | static int recv_notification(struct notifier_block *nb, unsigned long evt, | ||
| 65 | void *dv); | ||
| 66 | /* | ||
| 67 | * Network device notifier info | ||
| 68 | */ | ||
| 69 | static struct notifier_block notifier = { | ||
| 70 | .notifier_call = recv_notification, | ||
| 71 | .priority = 0 | ||
| 72 | }; | ||
| 73 | |||
| 74 | /** | ||
| 75 | * eth_media_addr_set - initialize Ethernet media address structure | ||
| 76 | * | ||
| 77 | * Media-dependent "value" field stores MAC address in first 6 bytes | ||
| 78 | * and zeroes out the remaining bytes. | ||
| 79 | */ | ||
| 80 | static void eth_media_addr_set(const struct tipc_bearer *tb_ptr, | ||
| 81 | struct tipc_media_addr *a, char *mac) | ||
| 82 | { | ||
| 83 | memcpy(a->value, mac, ETH_ALEN); | ||
| 84 | memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN); | ||
| 85 | a->media_id = TIPC_MEDIA_TYPE_ETH; | ||
| 86 | a->broadcast = !memcmp(mac, tb_ptr->bcast_addr.value, ETH_ALEN); | ||
| 87 | } | ||
| 88 | |||
| 89 | /** | ||
| 90 | * send_msg - send a TIPC message out over an Ethernet interface | ||
| 91 | */ | ||
| 92 | static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | ||
| 93 | struct tipc_media_addr *dest) | ||
| 94 | { | ||
| 95 | struct sk_buff *clone; | ||
| 96 | struct net_device *dev; | ||
| 97 | int delta; | ||
| 98 | |||
| 99 | clone = skb_clone(buf, GFP_ATOMIC); | ||
| 100 | if (!clone) | ||
| 101 | return 0; | ||
| 102 | |||
| 103 | dev = ((struct eth_media *)(tb_ptr->usr_handle))->dev; | ||
| 104 | delta = dev->hard_header_len - skb_headroom(buf); | ||
| 105 | |||
| 106 | if ((delta > 0) && | ||
| 107 | pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) { | ||
| 108 | kfree_skb(clone); | ||
| 109 | return 0; | ||
| 110 | } | ||
| 111 | |||
| 112 | skb_reset_network_header(clone); | ||
| 113 | clone->dev = dev; | ||
| 114 | clone->protocol = htons(ETH_P_TIPC); | ||
| 115 | dev_hard_header(clone, dev, ETH_P_TIPC, dest->value, | ||
| 116 | dev->dev_addr, clone->len); | ||
| 117 | dev_queue_xmit(clone); | ||
| 118 | return 0; | ||
| 119 | } | ||
| 120 | |||
| 121 | /** | ||
| 122 | * recv_msg - handle incoming TIPC message from an Ethernet interface | ||
| 123 | * | ||
| 124 | * Accept only packets explicitly sent to this node, or broadcast packets; | ||
| 125 | * ignores packets sent using Ethernet multicast, and traffic sent to other | ||
| 126 | * nodes (which can happen if interface is running in promiscuous mode). | ||
| 127 | */ | ||
| 128 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, | ||
| 129 | struct packet_type *pt, struct net_device *orig_dev) | ||
| 130 | { | ||
| 131 | struct eth_media *eb_ptr = (struct eth_media *)pt->af_packet_priv; | ||
| 132 | |||
| 133 | if (!net_eq(dev_net(dev), &init_net)) { | ||
| 134 | kfree_skb(buf); | ||
| 135 | return NET_RX_DROP; | ||
| 136 | } | ||
| 137 | |||
| 138 | if (likely(eb_ptr->bearer)) { | ||
| 139 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { | ||
| 140 | buf->next = NULL; | ||
| 141 | tipc_recv_msg(buf, eb_ptr->bearer); | ||
| 142 | return NET_RX_SUCCESS; | ||
| 143 | } | ||
| 144 | } | ||
| 145 | kfree_skb(buf); | ||
| 146 | return NET_RX_DROP; | ||
| 147 | } | ||
| 148 | |||
| 149 | /** | ||
| 150 | * setup_media - setup association between Ethernet bearer and interface | ||
| 151 | */ | ||
| 152 | static void setup_media(struct work_struct *work) | ||
| 153 | { | ||
| 154 | struct eth_media *eb_ptr = | ||
| 155 | container_of(work, struct eth_media, setup); | ||
| 156 | |||
| 157 | dev_add_pack(&eb_ptr->tipc_packet_type); | ||
| 158 | } | ||
| 159 | |||
| 160 | /** | ||
| 161 | * enable_media - attach TIPC bearer to an Ethernet interface | ||
| 162 | */ | ||
| 163 | static int enable_media(struct tipc_bearer *tb_ptr) | ||
| 164 | { | ||
| 165 | struct net_device *dev; | ||
| 166 | struct eth_media *eb_ptr = ð_media_array[0]; | ||
| 167 | struct eth_media *stop = ð_media_array[MAX_ETH_MEDIA]; | ||
| 168 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; | ||
| 169 | int pending_dev = 0; | ||
| 170 | |||
| 171 | /* Find unused Ethernet bearer structure */ | ||
| 172 | while (eb_ptr->dev) { | ||
| 173 | if (!eb_ptr->bearer) | ||
| 174 | pending_dev++; | ||
| 175 | if (++eb_ptr == stop) | ||
| 176 | return pending_dev ? -EAGAIN : -EDQUOT; | ||
| 177 | } | ||
| 178 | |||
| 179 | /* Find device with specified name */ | ||
| 180 | dev = dev_get_by_name(&init_net, driver_name); | ||
| 181 | if (!dev) | ||
| 182 | return -ENODEV; | ||
| 183 | |||
| 184 | /* Create Ethernet bearer for device */ | ||
| 185 | eb_ptr->dev = dev; | ||
| 186 | eb_ptr->tipc_packet_type.type = htons(ETH_P_TIPC); | ||
| 187 | eb_ptr->tipc_packet_type.dev = dev; | ||
| 188 | eb_ptr->tipc_packet_type.func = recv_msg; | ||
| 189 | eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr; | ||
| 190 | INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list)); | ||
| 191 | INIT_WORK(&eb_ptr->setup, setup_media); | ||
| 192 | schedule_work(&eb_ptr->setup); | ||
| 193 | |||
| 194 | /* Associate TIPC bearer with Ethernet bearer */ | ||
| 195 | eb_ptr->bearer = tb_ptr; | ||
| 196 | tb_ptr->usr_handle = (void *)eb_ptr; | ||
| 197 | memset(tb_ptr->bcast_addr.value, 0, sizeof(tb_ptr->bcast_addr.value)); | ||
| 198 | memcpy(tb_ptr->bcast_addr.value, dev->broadcast, ETH_ALEN); | ||
| 199 | tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_ETH; | ||
| 200 | tb_ptr->bcast_addr.broadcast = 1; | ||
| 201 | tb_ptr->mtu = dev->mtu; | ||
| 202 | tb_ptr->blocked = 0; | ||
| 203 | eth_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr); | ||
| 204 | return 0; | ||
| 205 | } | ||
| 206 | |||
| 207 | /** | ||
| 208 | * cleanup_media - break association between Ethernet bearer and interface | ||
| 209 | * | ||
| 210 | * This routine must be invoked from a work queue because it can sleep. | ||
| 211 | */ | ||
| 212 | static void cleanup_media(struct work_struct *work) | ||
| 213 | { | ||
| 214 | struct eth_media *eb_ptr = | ||
| 215 | container_of(work, struct eth_media, cleanup); | ||
| 216 | |||
| 217 | dev_remove_pack(&eb_ptr->tipc_packet_type); | ||
| 218 | dev_put(eb_ptr->dev); | ||
| 219 | eb_ptr->dev = NULL; | ||
| 220 | } | ||
| 221 | |||
| 222 | /** | ||
| 223 | * disable_media - detach TIPC bearer from an Ethernet interface | ||
| 224 | * | ||
| 225 | * Mark Ethernet bearer as inactive so that incoming buffers are thrown away, | ||
| 226 | * then get worker thread to complete bearer cleanup. (Can't do cleanup | ||
| 227 | * here because cleanup code needs to sleep and caller holds spinlocks.) | ||
| 228 | */ | ||
| 229 | static void disable_media(struct tipc_bearer *tb_ptr) | ||
| 230 | { | ||
| 231 | struct eth_media *eb_ptr = (struct eth_media *)tb_ptr->usr_handle; | ||
| 232 | |||
| 233 | eb_ptr->bearer = NULL; | ||
| 234 | INIT_WORK(&eb_ptr->cleanup, cleanup_media); | ||
| 235 | schedule_work(&eb_ptr->cleanup); | ||
| 236 | } | ||
| 237 | |||
| 238 | /** | ||
| 239 | * recv_notification - handle device updates from OS | ||
| 240 | * | ||
| 241 | * Change the state of the Ethernet bearer (if any) associated with the | ||
| 242 | * specified device. | ||
| 243 | */ | ||
| 244 | static int recv_notification(struct notifier_block *nb, unsigned long evt, | ||
| 245 | void *ptr) | ||
| 246 | { | ||
| 247 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); | ||
| 248 | struct eth_media *eb_ptr = ð_media_array[0]; | ||
| 249 | struct eth_media *stop = ð_media_array[MAX_ETH_MEDIA]; | ||
| 250 | |||
| 251 | if (!net_eq(dev_net(dev), &init_net)) | ||
| 252 | return NOTIFY_DONE; | ||
| 253 | |||
| 254 | while ((eb_ptr->dev != dev)) { | ||
| 255 | if (++eb_ptr == stop) | ||
| 256 | return NOTIFY_DONE; /* couldn't find device */ | ||
| 257 | } | ||
| 258 | if (!eb_ptr->bearer) | ||
| 259 | return NOTIFY_DONE; /* bearer had been disabled */ | ||
| 260 | |||
| 261 | eb_ptr->bearer->mtu = dev->mtu; | ||
| 262 | |||
| 263 | switch (evt) { | ||
| 264 | case NETDEV_CHANGE: | ||
| 265 | if (netif_carrier_ok(dev)) | ||
| 266 | tipc_continue(eb_ptr->bearer); | ||
| 267 | else | ||
| 268 | tipc_block_bearer(eb_ptr->bearer); | ||
| 269 | break; | ||
| 270 | case NETDEV_UP: | ||
| 271 | tipc_continue(eb_ptr->bearer); | ||
| 272 | break; | ||
| 273 | case NETDEV_DOWN: | ||
| 274 | tipc_block_bearer(eb_ptr->bearer); | ||
| 275 | break; | ||
| 276 | case NETDEV_CHANGEMTU: | ||
| 277 | case NETDEV_CHANGEADDR: | ||
| 278 | tipc_block_bearer(eb_ptr->bearer); | ||
| 279 | tipc_continue(eb_ptr->bearer); | ||
| 280 | break; | ||
| 281 | case NETDEV_UNREGISTER: | ||
| 282 | case NETDEV_CHANGENAME: | ||
| 283 | tipc_disable_bearer(eb_ptr->bearer->name); | ||
| 284 | break; | ||
| 285 | } | ||
| 286 | return NOTIFY_OK; | ||
| 287 | } | ||
| 288 | |||
| 289 | /** | ||
| 290 | * eth_addr2str - convert Ethernet address to string | ||
| 291 | */ | ||
| 292 | static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | ||
| 293 | { | 45 | { |
| 294 | if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ | 46 | if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ |
| 295 | return 1; | 47 | return 1; |
| @@ -298,10 +50,8 @@ static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | |||
| 298 | return 0; | 50 | return 0; |
| 299 | } | 51 | } |
| 300 | 52 | ||
| 301 | /** | 53 | /* convert Ethernet address format to message header format */ |
| 302 | * eth_str2addr - convert Ethernet address format to message header format | 54 | static int tipc_eth_addr2msg(struct tipc_media_addr *a, char *msg_area) |
| 303 | */ | ||
| 304 | static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) | ||
| 305 | { | 55 | { |
| 306 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); | 56 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); |
| 307 | msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH; | 57 | msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH; |
| @@ -309,68 +59,30 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) | |||
| 309 | return 0; | 59 | return 0; |
| 310 | } | 60 | } |
| 311 | 61 | ||
| 312 | /** | 62 | /* convert message header address format to Ethernet format */ |
| 313 | * eth_str2addr - convert message header address format to Ethernet format | 63 | static int tipc_eth_msg2addr(const struct tipc_bearer *tb_ptr, |
| 314 | */ | 64 | struct tipc_media_addr *a, char *msg_area) |
| 315 | static int eth_msg2addr(const struct tipc_bearer *tb_ptr, | ||
| 316 | struct tipc_media_addr *a, char *msg_area) | ||
| 317 | { | 65 | { |
| 318 | if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) | 66 | if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) |
| 319 | return 1; | 67 | return 1; |
| 320 | 68 | ||
| 321 | eth_media_addr_set(tb_ptr, a, msg_area + ETH_ADDR_OFFSET); | 69 | tipc_l2_media_addr_set(tb_ptr, a, msg_area + ETH_ADDR_OFFSET); |
| 322 | return 0; | 70 | return 0; |
| 323 | } | 71 | } |
| 324 | 72 | ||
| 325 | /* | 73 | /* Ethernet media registration info */ |
| 326 | * Ethernet media registration info | 74 | struct tipc_media eth_media_info = { |
| 327 | */ | 75 | .send_msg = tipc_l2_send_msg, |
| 328 | static struct tipc_media eth_media_info = { | 76 | .enable_media = tipc_enable_l2_media, |
| 329 | .send_msg = send_msg, | 77 | .disable_media = tipc_disable_l2_media, |
| 330 | .enable_media = enable_media, | 78 | .addr2str = tipc_eth_addr2str, |
| 331 | .disable_media = disable_media, | 79 | .addr2msg = tipc_eth_addr2msg, |
| 332 | .addr2str = eth_addr2str, | 80 | .msg2addr = tipc_eth_msg2addr, |
| 333 | .addr2msg = eth_addr2msg, | ||
| 334 | .msg2addr = eth_msg2addr, | ||
| 335 | .priority = TIPC_DEF_LINK_PRI, | 81 | .priority = TIPC_DEF_LINK_PRI, |
| 336 | .tolerance = TIPC_DEF_LINK_TOL, | 82 | .tolerance = TIPC_DEF_LINK_TOL, |
| 337 | .window = TIPC_DEF_LINK_WIN, | 83 | .window = TIPC_DEF_LINK_WIN, |
| 338 | .type_id = TIPC_MEDIA_TYPE_ETH, | 84 | .type_id = TIPC_MEDIA_TYPE_ETH, |
| 85 | .hwaddr_len = ETH_ALEN, | ||
| 339 | .name = "eth" | 86 | .name = "eth" |
| 340 | }; | 87 | }; |
| 341 | 88 | ||
| 342 | /** | ||
| 343 | * tipc_eth_media_start - activate Ethernet bearer support | ||
| 344 | * | ||
| 345 | * Register Ethernet media type with TIPC bearer code. Also register | ||
| 346 | * with OS for notifications about device state changes. | ||
| 347 | */ | ||
| 348 | int tipc_eth_media_start(void) | ||
| 349 | { | ||
| 350 | int res; | ||
| 351 | |||
| 352 | if (eth_started) | ||
| 353 | return -EINVAL; | ||
| 354 | |||
| 355 | res = tipc_register_media(ð_media_info); | ||
| 356 | if (res) | ||
| 357 | return res; | ||
| 358 | |||
| 359 | res = register_netdevice_notifier(¬ifier); | ||
| 360 | if (!res) | ||
| 361 | eth_started = 1; | ||
| 362 | return res; | ||
| 363 | } | ||
| 364 | |||
| 365 | /** | ||
| 366 | * tipc_eth_media_stop - deactivate Ethernet bearer support | ||
| 367 | */ | ||
| 368 | void tipc_eth_media_stop(void) | ||
| 369 | { | ||
| 370 | if (!eth_started) | ||
| 371 | return; | ||
| 372 | |||
| 373 | flush_scheduled_work(); | ||
| 374 | unregister_netdevice_notifier(¬ifier); | ||
| 375 | eth_started = 0; | ||
| 376 | } | ||
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c index c13989297464..844a77e25828 100644 --- a/net/tipc/ib_media.c +++ b/net/tipc/ib_media.c | |||
| @@ -42,252 +42,9 @@ | |||
| 42 | #include "core.h" | 42 | #include "core.h" |
| 43 | #include "bearer.h" | 43 | #include "bearer.h" |
| 44 | 44 | ||
| 45 | #define MAX_IB_MEDIA MAX_BEARERS | 45 | /* convert InfiniBand address to string */ |
| 46 | 46 | static int tipc_ib_addr2str(struct tipc_media_addr *a, char *str_buf, | |
| 47 | /** | 47 | int str_size) |
| 48 | * struct ib_media - Infiniband media data structure | ||
| 49 | * @bearer: ptr to associated "generic" bearer structure | ||
| 50 | * @dev: ptr to associated Infiniband network device | ||
| 51 | * @tipc_packet_type: used in binding TIPC to Infiniband driver | ||
| 52 | * @cleanup: work item used when disabling bearer | ||
| 53 | */ | ||
| 54 | |||
| 55 | struct ib_media { | ||
| 56 | struct tipc_bearer *bearer; | ||
| 57 | struct net_device *dev; | ||
| 58 | struct packet_type tipc_packet_type; | ||
| 59 | struct work_struct setup; | ||
| 60 | struct work_struct cleanup; | ||
| 61 | }; | ||
| 62 | |||
| 63 | static struct tipc_media ib_media_info; | ||
| 64 | static struct ib_media ib_media_array[MAX_IB_MEDIA]; | ||
| 65 | static int ib_started; | ||
| 66 | |||
| 67 | /** | ||
| 68 | * ib_media_addr_set - initialize Infiniband media address structure | ||
| 69 | * | ||
| 70 | * Media-dependent "value" field stores MAC address in first 6 bytes | ||
| 71 | * and zeroes out the remaining bytes. | ||
| 72 | */ | ||
| 73 | static void ib_media_addr_set(const struct tipc_bearer *tb_ptr, | ||
| 74 | struct tipc_media_addr *a, char *mac) | ||
| 75 | { | ||
| 76 | BUILD_BUG_ON(sizeof(a->value) < INFINIBAND_ALEN); | ||
| 77 | memcpy(a->value, mac, INFINIBAND_ALEN); | ||
| 78 | a->media_id = TIPC_MEDIA_TYPE_IB; | ||
| 79 | a->broadcast = !memcmp(mac, tb_ptr->bcast_addr.value, INFINIBAND_ALEN); | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * send_msg - send a TIPC message out over an InfiniBand interface | ||
| 84 | */ | ||
| 85 | static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | ||
| 86 | struct tipc_media_addr *dest) | ||
| 87 | { | ||
| 88 | struct sk_buff *clone; | ||
| 89 | struct net_device *dev; | ||
| 90 | int delta; | ||
| 91 | |||
| 92 | clone = skb_clone(buf, GFP_ATOMIC); | ||
| 93 | if (!clone) | ||
| 94 | return 0; | ||
| 95 | |||
| 96 | dev = ((struct ib_media *)(tb_ptr->usr_handle))->dev; | ||
| 97 | delta = dev->hard_header_len - skb_headroom(buf); | ||
| 98 | |||
| 99 | if ((delta > 0) && | ||
| 100 | pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) { | ||
| 101 | kfree_skb(clone); | ||
| 102 | return 0; | ||
| 103 | } | ||
| 104 | |||
| 105 | skb_reset_network_header(clone); | ||
| 106 | clone->dev = dev; | ||
| 107 | clone->protocol = htons(ETH_P_TIPC); | ||
| 108 | dev_hard_header(clone, dev, ETH_P_TIPC, dest->value, | ||
| 109 | dev->dev_addr, clone->len); | ||
| 110 | dev_queue_xmit(clone); | ||
| 111 | return 0; | ||
| 112 | } | ||
| 113 | |||
| 114 | /** | ||
| 115 | * recv_msg - handle incoming TIPC message from an InfiniBand interface | ||
| 116 | * | ||
| 117 | * Accept only packets explicitly sent to this node, or broadcast packets; | ||
| 118 | * ignores packets sent using InfiniBand multicast, and traffic sent to other | ||
| 119 | * nodes (which can happen if interface is running in promiscuous mode). | ||
| 120 | */ | ||
| 121 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, | ||
| 122 | struct packet_type *pt, struct net_device *orig_dev) | ||
| 123 | { | ||
| 124 | struct ib_media *ib_ptr = (struct ib_media *)pt->af_packet_priv; | ||
| 125 | |||
| 126 | if (!net_eq(dev_net(dev), &init_net)) { | ||
| 127 | kfree_skb(buf); | ||
| 128 | return NET_RX_DROP; | ||
| 129 | } | ||
| 130 | |||
| 131 | if (likely(ib_ptr->bearer)) { | ||
| 132 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { | ||
| 133 | buf->next = NULL; | ||
| 134 | tipc_recv_msg(buf, ib_ptr->bearer); | ||
| 135 | return NET_RX_SUCCESS; | ||
| 136 | } | ||
| 137 | } | ||
| 138 | kfree_skb(buf); | ||
| 139 | return NET_RX_DROP; | ||
| 140 | } | ||
| 141 | |||
| 142 | /** | ||
| 143 | * setup_bearer - setup association between InfiniBand bearer and interface | ||
| 144 | */ | ||
| 145 | static void setup_media(struct work_struct *work) | ||
| 146 | { | ||
| 147 | struct ib_media *ib_ptr = | ||
| 148 | container_of(work, struct ib_media, setup); | ||
| 149 | |||
| 150 | dev_add_pack(&ib_ptr->tipc_packet_type); | ||
| 151 | } | ||
| 152 | |||
| 153 | /** | ||
| 154 | * enable_media - attach TIPC bearer to an InfiniBand interface | ||
| 155 | */ | ||
| 156 | static int enable_media(struct tipc_bearer *tb_ptr) | ||
| 157 | { | ||
| 158 | struct net_device *dev; | ||
| 159 | struct ib_media *ib_ptr = &ib_media_array[0]; | ||
| 160 | struct ib_media *stop = &ib_media_array[MAX_IB_MEDIA]; | ||
| 161 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; | ||
| 162 | int pending_dev = 0; | ||
| 163 | |||
| 164 | /* Find unused InfiniBand bearer structure */ | ||
| 165 | while (ib_ptr->dev) { | ||
| 166 | if (!ib_ptr->bearer) | ||
| 167 | pending_dev++; | ||
| 168 | if (++ib_ptr == stop) | ||
| 169 | return pending_dev ? -EAGAIN : -EDQUOT; | ||
| 170 | } | ||
| 171 | |||
| 172 | /* Find device with specified name */ | ||
| 173 | dev = dev_get_by_name(&init_net, driver_name); | ||
| 174 | if (!dev) | ||
| 175 | return -ENODEV; | ||
| 176 | |||
| 177 | /* Create InfiniBand bearer for device */ | ||
| 178 | ib_ptr->dev = dev; | ||
| 179 | ib_ptr->tipc_packet_type.type = htons(ETH_P_TIPC); | ||
| 180 | ib_ptr->tipc_packet_type.dev = dev; | ||
| 181 | ib_ptr->tipc_packet_type.func = recv_msg; | ||
| 182 | ib_ptr->tipc_packet_type.af_packet_priv = ib_ptr; | ||
| 183 | INIT_LIST_HEAD(&(ib_ptr->tipc_packet_type.list)); | ||
| 184 | INIT_WORK(&ib_ptr->setup, setup_media); | ||
| 185 | schedule_work(&ib_ptr->setup); | ||
| 186 | |||
| 187 | /* Associate TIPC bearer with InfiniBand bearer */ | ||
| 188 | ib_ptr->bearer = tb_ptr; | ||
| 189 | tb_ptr->usr_handle = (void *)ib_ptr; | ||
| 190 | memset(tb_ptr->bcast_addr.value, 0, sizeof(tb_ptr->bcast_addr.value)); | ||
| 191 | memcpy(tb_ptr->bcast_addr.value, dev->broadcast, INFINIBAND_ALEN); | ||
| 192 | tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_IB; | ||
| 193 | tb_ptr->bcast_addr.broadcast = 1; | ||
| 194 | tb_ptr->mtu = dev->mtu; | ||
| 195 | tb_ptr->blocked = 0; | ||
| 196 | ib_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr); | ||
| 197 | return 0; | ||
| 198 | } | ||
| 199 | |||
| 200 | /** | ||
| 201 | * cleanup_bearer - break association between InfiniBand bearer and interface | ||
| 202 | * | ||
| 203 | * This routine must be invoked from a work queue because it can sleep. | ||
| 204 | */ | ||
| 205 | static void cleanup_bearer(struct work_struct *work) | ||
| 206 | { | ||
| 207 | struct ib_media *ib_ptr = | ||
| 208 | container_of(work, struct ib_media, cleanup); | ||
| 209 | |||
| 210 | dev_remove_pack(&ib_ptr->tipc_packet_type); | ||
| 211 | dev_put(ib_ptr->dev); | ||
| 212 | ib_ptr->dev = NULL; | ||
| 213 | } | ||
| 214 | |||
| 215 | /** | ||
| 216 | * disable_media - detach TIPC bearer from an InfiniBand interface | ||
| 217 | * | ||
| 218 | * Mark InfiniBand bearer as inactive so that incoming buffers are thrown away, | ||
| 219 | * then get worker thread to complete bearer cleanup. (Can't do cleanup | ||
| 220 | * here because cleanup code needs to sleep and caller holds spinlocks.) | ||
| 221 | */ | ||
| 222 | static void disable_media(struct tipc_bearer *tb_ptr) | ||
| 223 | { | ||
| 224 | struct ib_media *ib_ptr = (struct ib_media *)tb_ptr->usr_handle; | ||
| 225 | |||
| 226 | ib_ptr->bearer = NULL; | ||
| 227 | INIT_WORK(&ib_ptr->cleanup, cleanup_bearer); | ||
| 228 | schedule_work(&ib_ptr->cleanup); | ||
| 229 | } | ||
| 230 | |||
| 231 | /** | ||
| 232 | * recv_notification - handle device updates from OS | ||
| 233 | * | ||
| 234 | * Change the state of the InfiniBand bearer (if any) associated with the | ||
| 235 | * specified device. | ||
| 236 | */ | ||
| 237 | static int recv_notification(struct notifier_block *nb, unsigned long evt, | ||
| 238 | void *ptr) | ||
| 239 | { | ||
| 240 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); | ||
| 241 | struct ib_media *ib_ptr = &ib_media_array[0]; | ||
| 242 | struct ib_media *stop = &ib_media_array[MAX_IB_MEDIA]; | ||
| 243 | |||
| 244 | if (!net_eq(dev_net(dev), &init_net)) | ||
| 245 | return NOTIFY_DONE; | ||
| 246 | |||
| 247 | while ((ib_ptr->dev != dev)) { | ||
| 248 | if (++ib_ptr == stop) | ||
| 249 | return NOTIFY_DONE; /* couldn't find device */ | ||
| 250 | } | ||
| 251 | if (!ib_ptr->bearer) | ||
| 252 | return NOTIFY_DONE; /* bearer had been disabled */ | ||
| 253 | |||
| 254 | ib_ptr->bearer->mtu = dev->mtu; | ||
| 255 | |||
| 256 | switch (evt) { | ||
| 257 | case NETDEV_CHANGE: | ||
| 258 | if (netif_carrier_ok(dev)) | ||
| 259 | tipc_continue(ib_ptr->bearer); | ||
| 260 | else | ||
| 261 | tipc_block_bearer(ib_ptr->bearer); | ||
| 262 | break; | ||
| 263 | case NETDEV_UP: | ||
| 264 | tipc_continue(ib_ptr->bearer); | ||
| 265 | break; | ||
| 266 | case NETDEV_DOWN: | ||
| 267 | tipc_block_bearer(ib_ptr->bearer); | ||
| 268 | break; | ||
| 269 | case NETDEV_CHANGEMTU: | ||
| 270 | case NETDEV_CHANGEADDR: | ||
| 271 | tipc_block_bearer(ib_ptr->bearer); | ||
| 272 | tipc_continue(ib_ptr->bearer); | ||
| 273 | break; | ||
| 274 | case NETDEV_UNREGISTER: | ||
| 275 | case NETDEV_CHANGENAME: | ||
| 276 | tipc_disable_bearer(ib_ptr->bearer->name); | ||
| 277 | break; | ||
| 278 | } | ||
| 279 | return NOTIFY_OK; | ||
| 280 | } | ||
| 281 | |||
| 282 | static struct notifier_block notifier = { | ||
| 283 | .notifier_call = recv_notification, | ||
| 284 | .priority = 0, | ||
| 285 | }; | ||
| 286 | |||
| 287 | /** | ||
| 288 | * ib_addr2str - convert InfiniBand address to string | ||
| 289 | */ | ||
| 290 | static int ib_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | ||
| 291 | { | 48 | { |
| 292 | if (str_size < 60) /* 60 = 19 * strlen("xx:") + strlen("xx\0") */ | 49 | if (str_size < 60) /* 60 = 19 * strlen("xx:") + strlen("xx\0") */ |
| 293 | return 1; | 50 | return 1; |
| @@ -297,10 +54,8 @@ static int ib_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | |||
| 297 | return 0; | 54 | return 0; |
| 298 | } | 55 | } |
| 299 | 56 | ||
| 300 | /** | 57 | /* convert InfiniBand address format to message header format */ |
| 301 | * ib_addr2msg - convert InfiniBand address format to message header format | 58 | static int tipc_ib_addr2msg(struct tipc_media_addr *a, char *msg_area) |
| 302 | */ | ||
| 303 | static int ib_addr2msg(struct tipc_media_addr *a, char *msg_area) | ||
| 304 | { | 59 | { |
| 305 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); | 60 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); |
| 306 | msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_IB; | 61 | msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_IB; |
| @@ -308,65 +63,27 @@ static int ib_addr2msg(struct tipc_media_addr *a, char *msg_area) | |||
| 308 | return 0; | 63 | return 0; |
| 309 | } | 64 | } |
| 310 | 65 | ||
| 311 | /** | 66 | /* convert message header address format to InfiniBand format */ |
| 312 | * ib_msg2addr - convert message header address format to InfiniBand format | 67 | static int tipc_ib_msg2addr(const struct tipc_bearer *tb_ptr, |
| 313 | */ | 68 | struct tipc_media_addr *a, char *msg_area) |
| 314 | static int ib_msg2addr(const struct tipc_bearer *tb_ptr, | ||
| 315 | struct tipc_media_addr *a, char *msg_area) | ||
| 316 | { | 69 | { |
| 317 | ib_media_addr_set(tb_ptr, a, msg_area); | 70 | tipc_l2_media_addr_set(tb_ptr, a, msg_area); |
| 318 | return 0; | 71 | return 0; |
| 319 | } | 72 | } |
| 320 | 73 | ||
| 321 | /* | 74 | /* InfiniBand media registration info */ |
| 322 | * InfiniBand media registration info | 75 | struct tipc_media ib_media_info = { |
| 323 | */ | 76 | .send_msg = tipc_l2_send_msg, |
| 324 | static struct tipc_media ib_media_info = { | 77 | .enable_media = tipc_enable_l2_media, |
| 325 | .send_msg = send_msg, | 78 | .disable_media = tipc_disable_l2_media, |
| 326 | .enable_media = enable_media, | 79 | .addr2str = tipc_ib_addr2str, |
| 327 | .disable_media = disable_media, | 80 | .addr2msg = tipc_ib_addr2msg, |
| 328 | .addr2str = ib_addr2str, | 81 | .msg2addr = tipc_ib_msg2addr, |
| 329 | .addr2msg = ib_addr2msg, | ||
| 330 | .msg2addr = ib_msg2addr, | ||
| 331 | .priority = TIPC_DEF_LINK_PRI, | 82 | .priority = TIPC_DEF_LINK_PRI, |
| 332 | .tolerance = TIPC_DEF_LINK_TOL, | 83 | .tolerance = TIPC_DEF_LINK_TOL, |
| 333 | .window = TIPC_DEF_LINK_WIN, | 84 | .window = TIPC_DEF_LINK_WIN, |
| 334 | .type_id = TIPC_MEDIA_TYPE_IB, | 85 | .type_id = TIPC_MEDIA_TYPE_IB, |
| 86 | .hwaddr_len = INFINIBAND_ALEN, | ||
| 335 | .name = "ib" | 87 | .name = "ib" |
| 336 | }; | 88 | }; |
| 337 | 89 | ||
| 338 | /** | ||
| 339 | * tipc_ib_media_start - activate InfiniBand bearer support | ||
| 340 | * | ||
| 341 | * Register InfiniBand media type with TIPC bearer code. Also register | ||
| 342 | * with OS for notifications about device state changes. | ||
| 343 | */ | ||
| 344 | int tipc_ib_media_start(void) | ||
| 345 | { | ||
| 346 | int res; | ||
| 347 | |||
| 348 | if (ib_started) | ||
| 349 | return -EINVAL; | ||
| 350 | |||
| 351 | res = tipc_register_media(&ib_media_info); | ||
| 352 | if (res) | ||
| 353 | return res; | ||
| 354 | |||
| 355 | res = register_netdevice_notifier(¬ifier); | ||
| 356 | if (!res) | ||
| 357 | ib_started = 1; | ||
| 358 | return res; | ||
| 359 | } | ||
| 360 | |||
| 361 | /** | ||
| 362 | * tipc_ib_media_stop - deactivate InfiniBand bearer support | ||
| 363 | */ | ||
| 364 | void tipc_ib_media_stop(void) | ||
| 365 | { | ||
| 366 | if (!ib_started) | ||
| 367 | return; | ||
| 368 | |||
| 369 | flush_scheduled_work(); | ||
| 370 | unregister_netdevice_notifier(¬ifier); | ||
| 371 | ib_started = 0; | ||
| 372 | } | ||
diff --git a/net/tipc/link.c b/net/tipc/link.c index 69cd9bf3f561..3d73144a1ccc 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -386,14 +386,7 @@ exit: | |||
| 386 | */ | 386 | */ |
| 387 | static void link_release_outqueue(struct tipc_link *l_ptr) | 387 | static void link_release_outqueue(struct tipc_link *l_ptr) |
| 388 | { | 388 | { |
| 389 | struct sk_buff *buf = l_ptr->first_out; | 389 | kfree_skb_list(l_ptr->first_out); |
| 390 | struct sk_buff *next; | ||
| 391 | |||
| 392 | while (buf) { | ||
| 393 | next = buf->next; | ||
| 394 | kfree_skb(buf); | ||
| 395 | buf = next; | ||
| 396 | } | ||
| 397 | l_ptr->first_out = NULL; | 390 | l_ptr->first_out = NULL; |
| 398 | l_ptr->out_queue_size = 0; | 391 | l_ptr->out_queue_size = 0; |
| 399 | } | 392 | } |
| @@ -415,32 +408,15 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr) | |||
| 415 | */ | 408 | */ |
| 416 | void tipc_link_stop(struct tipc_link *l_ptr) | 409 | void tipc_link_stop(struct tipc_link *l_ptr) |
| 417 | { | 410 | { |
| 418 | struct sk_buff *buf; | 411 | kfree_skb_list(l_ptr->oldest_deferred_in); |
| 419 | struct sk_buff *next; | 412 | kfree_skb_list(l_ptr->first_out); |
| 420 | |||
| 421 | buf = l_ptr->oldest_deferred_in; | ||
| 422 | while (buf) { | ||
| 423 | next = buf->next; | ||
| 424 | kfree_skb(buf); | ||
| 425 | buf = next; | ||
| 426 | } | ||
| 427 | |||
| 428 | buf = l_ptr->first_out; | ||
| 429 | while (buf) { | ||
| 430 | next = buf->next; | ||
| 431 | kfree_skb(buf); | ||
| 432 | buf = next; | ||
| 433 | } | ||
| 434 | |||
| 435 | tipc_link_reset_fragments(l_ptr); | 413 | tipc_link_reset_fragments(l_ptr); |
| 436 | |||
| 437 | kfree_skb(l_ptr->proto_msg_queue); | 414 | kfree_skb(l_ptr->proto_msg_queue); |
| 438 | l_ptr->proto_msg_queue = NULL; | 415 | l_ptr->proto_msg_queue = NULL; |
| 439 | } | 416 | } |
| 440 | 417 | ||
| 441 | void tipc_link_reset(struct tipc_link *l_ptr) | 418 | void tipc_link_reset(struct tipc_link *l_ptr) |
| 442 | { | 419 | { |
| 443 | struct sk_buff *buf; | ||
| 444 | u32 prev_state = l_ptr->state; | 420 | u32 prev_state = l_ptr->state; |
| 445 | u32 checkpoint = l_ptr->next_in_no; | 421 | u32 checkpoint = l_ptr->next_in_no; |
| 446 | int was_active_link = tipc_link_is_active(l_ptr); | 422 | int was_active_link = tipc_link_is_active(l_ptr); |
| @@ -471,12 +447,7 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
| 471 | link_release_outqueue(l_ptr); | 447 | link_release_outqueue(l_ptr); |
| 472 | kfree_skb(l_ptr->proto_msg_queue); | 448 | kfree_skb(l_ptr->proto_msg_queue); |
| 473 | l_ptr->proto_msg_queue = NULL; | 449 | l_ptr->proto_msg_queue = NULL; |
| 474 | buf = l_ptr->oldest_deferred_in; | 450 | kfree_skb_list(l_ptr->oldest_deferred_in); |
| 475 | while (buf) { | ||
| 476 | struct sk_buff *next = buf->next; | ||
| 477 | kfree_skb(buf); | ||
| 478 | buf = next; | ||
| 479 | } | ||
| 480 | if (!list_empty(&l_ptr->waiting_ports)) | 451 | if (!list_empty(&l_ptr->waiting_ports)) |
| 481 | tipc_link_wakeup_ports(l_ptr, 1); | 452 | tipc_link_wakeup_ports(l_ptr, 1); |
| 482 | 453 | ||
| @@ -517,10 +488,11 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 517 | if (!l_ptr->started && (event != STARTING_EVT)) | 488 | if (!l_ptr->started && (event != STARTING_EVT)) |
| 518 | return; /* Not yet. */ | 489 | return; /* Not yet. */ |
| 519 | 490 | ||
| 520 | if (link_blocked(l_ptr)) { | 491 | /* Check whether changeover is going on */ |
| 492 | if (l_ptr->exp_msg_count) { | ||
| 521 | if (event == TIMEOUT_EVT) | 493 | if (event == TIMEOUT_EVT) |
| 522 | link_set_timer(l_ptr, cont_intv); | 494 | link_set_timer(l_ptr, cont_intv); |
| 523 | return; /* Changeover going on */ | 495 | return; |
| 524 | } | 496 | } |
| 525 | 497 | ||
| 526 | switch (l_ptr->state) { | 498 | switch (l_ptr->state) { |
| @@ -790,8 +762,7 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 790 | return link_send_long_buf(l_ptr, buf); | 762 | return link_send_long_buf(l_ptr, buf); |
| 791 | 763 | ||
| 792 | /* Packet can be queued or sent. */ | 764 | /* Packet can be queued or sent. */ |
| 793 | if (likely(!tipc_bearer_blocked(l_ptr->b_ptr) && | 765 | if (likely(!link_congested(l_ptr))) { |
| 794 | !link_congested(l_ptr))) { | ||
| 795 | link_add_to_outqueue(l_ptr, buf, msg); | 766 | link_add_to_outqueue(l_ptr, buf, msg); |
| 796 | 767 | ||
| 797 | tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr); | 768 | tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr); |
| @@ -957,14 +928,13 @@ static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, | |||
| 957 | 928 | ||
| 958 | if (likely(!link_congested(l_ptr))) { | 929 | if (likely(!link_congested(l_ptr))) { |
| 959 | if (likely(msg_size(msg) <= l_ptr->max_pkt)) { | 930 | if (likely(msg_size(msg) <= l_ptr->max_pkt)) { |
| 960 | if (likely(!tipc_bearer_blocked(l_ptr->b_ptr))) { | 931 | link_add_to_outqueue(l_ptr, buf, msg); |
| 961 | link_add_to_outqueue(l_ptr, buf, msg); | 932 | tipc_bearer_send(l_ptr->b_ptr, buf, |
| 962 | tipc_bearer_send(l_ptr->b_ptr, buf, | 933 | &l_ptr->media_addr); |
| 963 | &l_ptr->media_addr); | 934 | l_ptr->unacked_window = 0; |
| 964 | l_ptr->unacked_window = 0; | 935 | return res; |
| 965 | return res; | 936 | } |
| 966 | } | 937 | else |
| 967 | } else | ||
| 968 | *used_max_pkt = l_ptr->max_pkt; | 938 | *used_max_pkt = l_ptr->max_pkt; |
| 969 | } | 939 | } |
| 970 | return tipc_link_send_buf(l_ptr, buf); /* All other cases */ | 940 | return tipc_link_send_buf(l_ptr, buf); /* All other cases */ |
| @@ -1013,8 +983,7 @@ exit: | |||
| 1013 | } | 983 | } |
| 1014 | 984 | ||
| 1015 | /* Exit if link (or bearer) is congested */ | 985 | /* Exit if link (or bearer) is congested */ |
| 1016 | if (link_congested(l_ptr) || | 986 | if (link_congested(l_ptr)) { |
| 1017 | tipc_bearer_blocked(l_ptr->b_ptr)) { | ||
| 1018 | res = link_schedule_port(l_ptr, | 987 | res = link_schedule_port(l_ptr, |
| 1019 | sender->ref, res); | 988 | sender->ref, res); |
| 1020 | goto exit; | 989 | goto exit; |
| @@ -1127,10 +1096,7 @@ again: | |||
| 1127 | if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) { | 1096 | if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) { |
| 1128 | res = -EFAULT; | 1097 | res = -EFAULT; |
| 1129 | error: | 1098 | error: |
| 1130 | for (; buf_chain; buf_chain = buf) { | 1099 | kfree_skb_list(buf_chain); |
| 1131 | buf = buf_chain->next; | ||
| 1132 | kfree_skb(buf_chain); | ||
| 1133 | } | ||
| 1134 | return res; | 1100 | return res; |
| 1135 | } | 1101 | } |
| 1136 | sect_crs += sz; | 1102 | sect_crs += sz; |
| @@ -1180,18 +1146,12 @@ error: | |||
| 1180 | if (l_ptr->max_pkt < max_pkt) { | 1146 | if (l_ptr->max_pkt < max_pkt) { |
| 1181 | sender->max_pkt = l_ptr->max_pkt; | 1147 | sender->max_pkt = l_ptr->max_pkt; |
| 1182 | tipc_node_unlock(node); | 1148 | tipc_node_unlock(node); |
| 1183 | for (; buf_chain; buf_chain = buf) { | 1149 | kfree_skb_list(buf_chain); |
| 1184 | buf = buf_chain->next; | ||
| 1185 | kfree_skb(buf_chain); | ||
| 1186 | } | ||
| 1187 | goto again; | 1150 | goto again; |
| 1188 | } | 1151 | } |
| 1189 | } else { | 1152 | } else { |
| 1190 | reject: | 1153 | reject: |
| 1191 | for (; buf_chain; buf_chain = buf) { | 1154 | kfree_skb_list(buf_chain); |
| 1192 | buf = buf_chain->next; | ||
| 1193 | kfree_skb(buf_chain); | ||
| 1194 | } | ||
| 1195 | return tipc_port_reject_sections(sender, hdr, msg_sect, | 1155 | return tipc_port_reject_sections(sender, hdr, msg_sect, |
| 1196 | len, TIPC_ERR_NO_NODE); | 1156 | len, TIPC_ERR_NO_NODE); |
| 1197 | } | 1157 | } |
| @@ -1281,9 +1241,6 @@ void tipc_link_push_queue(struct tipc_link *l_ptr) | |||
| 1281 | { | 1241 | { |
| 1282 | u32 res; | 1242 | u32 res; |
| 1283 | 1243 | ||
| 1284 | if (tipc_bearer_blocked(l_ptr->b_ptr)) | ||
| 1285 | return; | ||
| 1286 | |||
| 1287 | do { | 1244 | do { |
| 1288 | res = tipc_link_push_packet(l_ptr); | 1245 | res = tipc_link_push_packet(l_ptr); |
| 1289 | } while (!res); | 1246 | } while (!res); |
| @@ -1370,26 +1327,15 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *buf, | |||
| 1370 | 1327 | ||
| 1371 | msg = buf_msg(buf); | 1328 | msg = buf_msg(buf); |
| 1372 | 1329 | ||
| 1373 | if (tipc_bearer_blocked(l_ptr->b_ptr)) { | 1330 | /* Detect repeated retransmit failures */ |
| 1374 | if (l_ptr->retransm_queue_size == 0) { | 1331 | if (l_ptr->last_retransmitted == msg_seqno(msg)) { |
| 1375 | l_ptr->retransm_queue_head = msg_seqno(msg); | 1332 | if (++l_ptr->stale_count > 100) { |
| 1376 | l_ptr->retransm_queue_size = retransmits; | 1333 | link_retransmit_failure(l_ptr, buf); |
| 1377 | } else { | 1334 | return; |
| 1378 | pr_err("Unexpected retransmit on link %s (qsize=%d)\n", | ||
| 1379 | l_ptr->name, l_ptr->retransm_queue_size); | ||
| 1380 | } | 1335 | } |
| 1381 | return; | ||
| 1382 | } else { | 1336 | } else { |
| 1383 | /* Detect repeated retransmit failures on unblocked bearer */ | 1337 | l_ptr->last_retransmitted = msg_seqno(msg); |
| 1384 | if (l_ptr->last_retransmitted == msg_seqno(msg)) { | 1338 | l_ptr->stale_count = 1; |
| 1385 | if (++l_ptr->stale_count > 100) { | ||
| 1386 | link_retransmit_failure(l_ptr, buf); | ||
| 1387 | return; | ||
| 1388 | } | ||
| 1389 | } else { | ||
| 1390 | l_ptr->last_retransmitted = msg_seqno(msg); | ||
| 1391 | l_ptr->stale_count = 1; | ||
| 1392 | } | ||
| 1393 | } | 1339 | } |
| 1394 | 1340 | ||
| 1395 | while (retransmits && (buf != l_ptr->next_out) && buf) { | 1341 | while (retransmits && (buf != l_ptr->next_out) && buf) { |
| @@ -1786,7 +1732,8 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 1786 | l_ptr->proto_msg_queue = NULL; | 1732 | l_ptr->proto_msg_queue = NULL; |
| 1787 | } | 1733 | } |
| 1788 | 1734 | ||
| 1789 | if (link_blocked(l_ptr)) | 1735 | /* Don't send protocol message during link changeover */ |
| 1736 | if (l_ptr->exp_msg_count) | ||
| 1790 | return; | 1737 | return; |
| 1791 | 1738 | ||
| 1792 | /* Abort non-RESET send if communication with node is prohibited */ | 1739 | /* Abort non-RESET send if communication with node is prohibited */ |
| @@ -1861,12 +1808,6 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 1861 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); | 1808 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); |
| 1862 | buf->priority = TC_PRIO_CONTROL; | 1809 | buf->priority = TC_PRIO_CONTROL; |
| 1863 | 1810 | ||
| 1864 | /* Defer message if bearer is already blocked */ | ||
| 1865 | if (tipc_bearer_blocked(l_ptr->b_ptr)) { | ||
| 1866 | l_ptr->proto_msg_queue = buf; | ||
| 1867 | return; | ||
| 1868 | } | ||
| 1869 | |||
| 1870 | tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr); | 1811 | tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr); |
| 1871 | l_ptr->unacked_window = 0; | 1812 | l_ptr->unacked_window = 0; |
| 1872 | kfree_skb(buf); | 1813 | kfree_skb(buf); |
| @@ -1885,7 +1826,8 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 1885 | u32 msg_tol; | 1826 | u32 msg_tol; |
| 1886 | struct tipc_msg *msg = buf_msg(buf); | 1827 | struct tipc_msg *msg = buf_msg(buf); |
| 1887 | 1828 | ||
| 1888 | if (link_blocked(l_ptr)) | 1829 | /* Discard protocol message during link changeover */ |
| 1830 | if (l_ptr->exp_msg_count) | ||
| 1889 | goto exit; | 1831 | goto exit; |
| 1890 | 1832 | ||
| 1891 | /* record unnumbered packet arrival (force mismatch on next timeout) */ | 1833 | /* record unnumbered packet arrival (force mismatch on next timeout) */ |
| @@ -2306,11 +2248,7 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2306 | fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE); | 2248 | fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE); |
| 2307 | if (fragm == NULL) { | 2249 | if (fragm == NULL) { |
| 2308 | kfree_skb(buf); | 2250 | kfree_skb(buf); |
| 2309 | while (buf_chain) { | 2251 | kfree_skb_list(buf_chain); |
| 2310 | buf = buf_chain; | ||
| 2311 | buf_chain = buf_chain->next; | ||
| 2312 | kfree_skb(buf); | ||
| 2313 | } | ||
| 2314 | return -ENOMEM; | 2252 | return -ENOMEM; |
| 2315 | } | 2253 | } |
| 2316 | msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); | 2254 | msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); |
diff --git a/net/tipc/link.h b/net/tipc/link.h index 8a6c1026644d..424b1dfe436b 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
| @@ -112,7 +112,6 @@ struct tipc_stats { | |||
| 112 | * @continuity_interval: link continuity testing interval [in ms] | 112 | * @continuity_interval: link continuity testing interval [in ms] |
| 113 | * @abort_limit: # of unacknowledged continuity probes needed to reset link | 113 | * @abort_limit: # of unacknowledged continuity probes needed to reset link |
| 114 | * @state: current state of link FSM | 114 | * @state: current state of link FSM |
| 115 | * @blocked: indicates if link has been administratively blocked | ||
| 116 | * @fsm_msg_cnt: # of protocol messages link FSM has sent in current state | 115 | * @fsm_msg_cnt: # of protocol messages link FSM has sent in current state |
| 117 | * @proto_msg: template for control messages generated by link | 116 | * @proto_msg: template for control messages generated by link |
| 118 | * @pmsg: convenience pointer to "proto_msg" field | 117 | * @pmsg: convenience pointer to "proto_msg" field |
| @@ -162,7 +161,6 @@ struct tipc_link { | |||
| 162 | u32 continuity_interval; | 161 | u32 continuity_interval; |
| 163 | u32 abort_limit; | 162 | u32 abort_limit; |
| 164 | int state; | 163 | int state; |
| 165 | int blocked; | ||
| 166 | u32 fsm_msg_cnt; | 164 | u32 fsm_msg_cnt; |
| 167 | struct { | 165 | struct { |
| 168 | unchar hdr[INT_H_SIZE]; | 166 | unchar hdr[INT_H_SIZE]; |
| @@ -312,11 +310,6 @@ static inline int link_reset_reset(struct tipc_link *l_ptr) | |||
| 312 | return l_ptr->state == RESET_RESET; | 310 | return l_ptr->state == RESET_RESET; |
| 313 | } | 311 | } |
| 314 | 312 | ||
| 315 | static inline int link_blocked(struct tipc_link *l_ptr) | ||
| 316 | { | ||
| 317 | return l_ptr->exp_msg_count || l_ptr->blocked; | ||
| 318 | } | ||
| 319 | |||
| 320 | static inline int link_congested(struct tipc_link *l_ptr) | 313 | static inline int link_congested(struct tipc_link *l_ptr) |
| 321 | { | 314 | { |
| 322 | return l_ptr->out_queue_size >= l_ptr->queue_limit[0]; | 315 | return l_ptr->out_queue_size >= l_ptr->queue_limit[0]; |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 25100c0a6fe8..bf1ac89b4806 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
| @@ -291,11 +291,7 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 291 | 291 | ||
| 292 | /* Flush broadcast link info associated with lost node */ | 292 | /* Flush broadcast link info associated with lost node */ |
| 293 | if (n_ptr->bclink.recv_permitted) { | 293 | if (n_ptr->bclink.recv_permitted) { |
| 294 | while (n_ptr->bclink.deferred_head) { | 294 | kfree_skb_list(n_ptr->bclink.deferred_head); |
| 295 | struct sk_buff *buf = n_ptr->bclink.deferred_head; | ||
| 296 | n_ptr->bclink.deferred_head = buf->next; | ||
| 297 | kfree_skb(buf); | ||
| 298 | } | ||
| 299 | n_ptr->bclink.deferred_size = 0; | 295 | n_ptr->bclink.deferred_size = 0; |
| 300 | 296 | ||
| 301 | if (n_ptr->bclink.reasm_head) { | 297 | if (n_ptr->bclink.reasm_head) { |
