diff options
Diffstat (limited to 'net/tipc')
| -rw-r--r-- | net/tipc/Makefile | 2 | ||||
| -rw-r--r-- | net/tipc/addr.c | 3 | ||||
| -rw-r--r-- | net/tipc/addr.h | 19 | ||||
| -rw-r--r-- | net/tipc/bcast.c | 22 | ||||
| -rw-r--r-- | net/tipc/bcast.h | 3 | ||||
| -rw-r--r-- | net/tipc/bearer.c | 24 | ||||
| -rw-r--r-- | net/tipc/bearer.h | 4 | ||||
| -rw-r--r-- | net/tipc/config.c | 30 | ||||
| -rw-r--r-- | net/tipc/config.h | 1 | ||||
| -rw-r--r-- | net/tipc/core.c | 11 | ||||
| -rw-r--r-- | net/tipc/core.h | 14 | ||||
| -rw-r--r-- | net/tipc/discover.c | 14 | ||||
| -rw-r--r-- | net/tipc/eth_media.c | 19 | ||||
| -rw-r--r-- | net/tipc/handler.c | 1 | ||||
| -rw-r--r-- | net/tipc/link.c | 122 | ||||
| -rw-r--r-- | net/tipc/link.h | 6 | ||||
| -rw-r--r-- | net/tipc/log.c | 14 | ||||
| -rw-r--r-- | net/tipc/log.h | 1 | ||||
| -rw-r--r-- | net/tipc/msg.c | 3 | ||||
| -rw-r--r-- | net/tipc/msg.h | 21 | ||||
| -rw-r--r-- | net/tipc/name_distr.c | 130 | ||||
| -rw-r--r-- | net/tipc/name_table.c | 98 | ||||
| -rw-r--r-- | net/tipc/name_table.h | 3 | ||||
| -rw-r--r-- | net/tipc/net.c | 9 | ||||
| -rw-r--r-- | net/tipc/node.c | 17 | ||||
| -rw-r--r-- | net/tipc/node.h | 2 | ||||
| -rw-r--r-- | net/tipc/node_subscr.c | 5 | ||||
| -rw-r--r-- | net/tipc/node_subscr.h | 1 | ||||
| -rw-r--r-- | net/tipc/port.c | 130 | ||||
| -rw-r--r-- | net/tipc/port.h | 14 | ||||
| -rw-r--r-- | net/tipc/ref.c | 13 | ||||
| -rw-r--r-- | net/tipc/socket.c | 103 | ||||
| -rw-r--r-- | net/tipc/subscr.c | 45 | ||||
| -rw-r--r-- | net/tipc/subscr.h | 2 |
34 files changed, 231 insertions, 675 deletions
diff --git a/net/tipc/Makefile b/net/tipc/Makefile index 521d24d04ab2..6cd55d671d3a 100644 --- a/net/tipc/Makefile +++ b/net/tipc/Makefile | |||
| @@ -9,5 +9,3 @@ tipc-y += addr.o bcast.o bearer.o config.o \ | |||
| 9 | name_distr.o subscr.o name_table.o net.o \ | 9 | name_distr.o subscr.o name_table.o net.o \ |
| 10 | netlink.o node.o node_subscr.o port.o ref.o \ | 10 | netlink.o node.o node_subscr.o port.o ref.o \ |
| 11 | socket.o log.o eth_media.o | 11 | socket.o log.o eth_media.o |
| 12 | |||
| 13 | # End of file | ||
diff --git a/net/tipc/addr.c b/net/tipc/addr.c index a6fdab33877e..357b74b26f9e 100644 --- a/net/tipc/addr.c +++ b/net/tipc/addr.c | |||
| @@ -45,7 +45,6 @@ | |||
| 45 | * | 45 | * |
| 46 | * Returns 1 if domain address is valid, otherwise 0 | 46 | * Returns 1 if domain address is valid, otherwise 0 |
| 47 | */ | 47 | */ |
| 48 | |||
| 49 | int tipc_addr_domain_valid(u32 addr) | 48 | int tipc_addr_domain_valid(u32 addr) |
| 50 | { | 49 | { |
| 51 | u32 n = tipc_node(addr); | 50 | u32 n = tipc_node(addr); |
| @@ -66,7 +65,6 @@ int tipc_addr_domain_valid(u32 addr) | |||
| 66 | * | 65 | * |
| 67 | * Returns 1 if address can be used, otherwise 0 | 66 | * Returns 1 if address can be used, otherwise 0 |
| 68 | */ | 67 | */ |
| 69 | |||
| 70 | int tipc_addr_node_valid(u32 addr) | 68 | int tipc_addr_node_valid(u32 addr) |
| 71 | { | 69 | { |
| 72 | return tipc_addr_domain_valid(addr) && tipc_node(addr); | 70 | return tipc_addr_domain_valid(addr) && tipc_node(addr); |
| @@ -86,7 +84,6 @@ int tipc_in_scope(u32 domain, u32 addr) | |||
| 86 | /** | 84 | /** |
| 87 | * tipc_addr_scope - convert message lookup domain to a 2-bit scope value | 85 | * tipc_addr_scope - convert message lookup domain to a 2-bit scope value |
| 88 | */ | 86 | */ |
| 89 | |||
| 90 | int tipc_addr_scope(u32 domain) | 87 | int tipc_addr_scope(u32 domain) |
| 91 | { | 88 | { |
| 92 | if (likely(!domain)) | 89 | if (likely(!domain)) |
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index e4f35afe3207..60b00ab93d74 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
| @@ -50,18 +50,33 @@ static inline u32 tipc_cluster_mask(u32 addr) | |||
| 50 | return addr & TIPC_CLUSTER_MASK; | 50 | return addr & TIPC_CLUSTER_MASK; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | static inline int in_own_cluster(u32 addr) | 53 | static inline int in_own_cluster_exact(u32 addr) |
| 54 | { | 54 | { |
| 55 | return !((addr ^ tipc_own_addr) >> 12); | 55 | return !((addr ^ tipc_own_addr) >> 12); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | * in_own_node - test for node inclusion; <0.0.0> always matches | ||
| 60 | */ | ||
| 61 | static inline int in_own_node(u32 addr) | ||
| 62 | { | ||
| 63 | return (addr == tipc_own_addr) || !addr; | ||
| 64 | } | ||
| 65 | |||
| 66 | /** | ||
| 67 | * in_own_cluster - test for cluster inclusion; <0.0.0> always matches | ||
| 68 | */ | ||
| 69 | static inline int in_own_cluster(u32 addr) | ||
| 70 | { | ||
| 71 | return in_own_cluster_exact(addr) || !addr; | ||
| 72 | } | ||
| 73 | |||
| 74 | /** | ||
| 59 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | 75 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain |
| 60 | * | 76 | * |
| 61 | * Needed when address of a named message must be looked up a second time | 77 | * Needed when address of a named message must be looked up a second time |
| 62 | * after a network hop. | 78 | * after a network hop. |
| 63 | */ | 79 | */ |
| 64 | |||
| 65 | static inline u32 addr_domain(u32 sc) | 80 | static inline u32 addr_domain(u32 sc) |
| 66 | { | 81 | { |
| 67 | if (likely(sc == TIPC_NODE_SCOPE)) | 82 | if (likely(sc == TIPC_NODE_SCOPE)) |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index e00441a2092f..2625f5ebe3e8 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
| @@ -73,7 +73,6 @@ struct tipc_bcbearer_pair { | |||
| 73 | * large local variables within multicast routines. Concurrent access is | 73 | * large local variables within multicast routines. Concurrent access is |
| 74 | * prevented through use of the spinlock "bc_lock". | 74 | * prevented through use of the spinlock "bc_lock". |
| 75 | */ | 75 | */ |
| 76 | |||
| 77 | struct tipc_bcbearer { | 76 | struct tipc_bcbearer { |
| 78 | struct tipc_bearer bearer; | 77 | struct tipc_bearer bearer; |
| 79 | struct tipc_media media; | 78 | struct tipc_media media; |
| @@ -92,7 +91,6 @@ struct tipc_bcbearer { | |||
| 92 | * | 91 | * |
| 93 | * Handles sequence numbering, fragmentation, bundling, etc. | 92 | * Handles sequence numbering, fragmentation, bundling, etc. |
| 94 | */ | 93 | */ |
| 95 | |||
| 96 | struct tipc_bclink { | 94 | struct tipc_bclink { |
| 97 | struct tipc_link link; | 95 | struct tipc_link link; |
| 98 | struct tipc_node node; | 96 | struct tipc_node node; |
| @@ -169,7 +167,6 @@ static void bclink_update_last_sent(struct tipc_node *node, u32 seqno) | |||
| 169 | * | 167 | * |
| 170 | * Called with bc_lock locked | 168 | * Called with bc_lock locked |
| 171 | */ | 169 | */ |
| 172 | |||
| 173 | struct tipc_node *tipc_bclink_retransmit_to(void) | 170 | struct tipc_node *tipc_bclink_retransmit_to(void) |
| 174 | { | 171 | { |
| 175 | return bclink->retransmit_to; | 172 | return bclink->retransmit_to; |
| @@ -182,7 +179,6 @@ struct tipc_node *tipc_bclink_retransmit_to(void) | |||
| 182 | * | 179 | * |
| 183 | * Called with bc_lock locked | 180 | * Called with bc_lock locked |
| 184 | */ | 181 | */ |
| 185 | |||
| 186 | static void bclink_retransmit_pkt(u32 after, u32 to) | 182 | static void bclink_retransmit_pkt(u32 after, u32 to) |
| 187 | { | 183 | { |
| 188 | struct sk_buff *buf; | 184 | struct sk_buff *buf; |
| @@ -200,7 +196,6 @@ static void bclink_retransmit_pkt(u32 after, u32 to) | |||
| 200 | * | 196 | * |
| 201 | * Node is locked, bc_lock unlocked. | 197 | * Node is locked, bc_lock unlocked. |
| 202 | */ | 198 | */ |
| 203 | |||
| 204 | void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked) | 199 | void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked) |
| 205 | { | 200 | { |
| 206 | struct sk_buff *crs; | 201 | struct sk_buff *crs; |
| @@ -280,7 +275,6 @@ exit: | |||
| 280 | * | 275 | * |
| 281 | * tipc_net_lock and node lock set | 276 | * tipc_net_lock and node lock set |
| 282 | */ | 277 | */ |
| 283 | |||
| 284 | void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent) | 278 | void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent) |
| 285 | { | 279 | { |
| 286 | struct sk_buff *buf; | 280 | struct sk_buff *buf; |
| @@ -344,7 +338,6 @@ void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent) | |||
| 344 | * | 338 | * |
| 345 | * Only tipc_net_lock set. | 339 | * Only tipc_net_lock set. |
| 346 | */ | 340 | */ |
| 347 | |||
| 348 | static void bclink_peek_nack(struct tipc_msg *msg) | 341 | static void bclink_peek_nack(struct tipc_msg *msg) |
| 349 | { | 342 | { |
| 350 | struct tipc_node *n_ptr = tipc_node_find(msg_destnode(msg)); | 343 | struct tipc_node *n_ptr = tipc_node_find(msg_destnode(msg)); |
| @@ -365,7 +358,6 @@ static void bclink_peek_nack(struct tipc_msg *msg) | |||
| 365 | /* | 358 | /* |
| 366 | * tipc_bclink_send_msg - broadcast a packet to all nodes in cluster | 359 | * tipc_bclink_send_msg - broadcast a packet to all nodes in cluster |
| 367 | */ | 360 | */ |
| 368 | |||
| 369 | int tipc_bclink_send_msg(struct sk_buff *buf) | 361 | int tipc_bclink_send_msg(struct sk_buff *buf) |
| 370 | { | 362 | { |
| 371 | int res; | 363 | int res; |
| @@ -394,7 +386,6 @@ exit: | |||
| 394 | * | 386 | * |
| 395 | * Called with both sending node's lock and bc_lock taken. | 387 | * Called with both sending node's lock and bc_lock taken. |
| 396 | */ | 388 | */ |
| 397 | |||
| 398 | static void bclink_accept_pkt(struct tipc_node *node, u32 seqno) | 389 | static void bclink_accept_pkt(struct tipc_node *node, u32 seqno) |
| 399 | { | 390 | { |
| 400 | bclink_update_last_sent(node, seqno); | 391 | bclink_update_last_sent(node, seqno); |
| @@ -420,7 +411,6 @@ static void bclink_accept_pkt(struct tipc_node *node, u32 seqno) | |||
| 420 | * | 411 | * |
| 421 | * tipc_net_lock is read_locked, no other locks set | 412 | * tipc_net_lock is read_locked, no other locks set |
| 422 | */ | 413 | */ |
| 423 | |||
| 424 | void tipc_bclink_recv_pkt(struct sk_buff *buf) | 414 | void tipc_bclink_recv_pkt(struct sk_buff *buf) |
| 425 | { | 415 | { |
| 426 | struct tipc_msg *msg = buf_msg(buf); | 416 | struct tipc_msg *msg = buf_msg(buf); |
| @@ -588,7 +578,6 @@ u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr) | |||
| 588 | * Returns 0 (packet sent successfully) under all circumstances, | 578 | * Returns 0 (packet sent successfully) under all circumstances, |
| 589 | * since the broadcast link's pseudo-bearer never blocks | 579 | * since the broadcast link's pseudo-bearer never blocks |
| 590 | */ | 580 | */ |
| 591 | |||
| 592 | static int tipc_bcbearer_send(struct sk_buff *buf, | 581 | static int tipc_bcbearer_send(struct sk_buff *buf, |
| 593 | struct tipc_bearer *unused1, | 582 | struct tipc_bearer *unused1, |
| 594 | struct tipc_media_addr *unused2) | 583 | struct tipc_media_addr *unused2) |
| @@ -601,7 +590,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf, | |||
| 601 | * preparation is skipped for broadcast link protocol messages | 590 | * preparation is skipped for broadcast link protocol messages |
| 602 | * since they are sent in an unreliable manner and don't need it | 591 | * since they are sent in an unreliable manner and don't need it |
| 603 | */ | 592 | */ |
| 604 | |||
| 605 | if (likely(!msg_non_seq(buf_msg(buf)))) { | 593 | if (likely(!msg_non_seq(buf_msg(buf)))) { |
| 606 | struct tipc_msg *msg; | 594 | struct tipc_msg *msg; |
| 607 | 595 | ||
| @@ -618,7 +606,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf, | |||
| 618 | } | 606 | } |
| 619 | 607 | ||
| 620 | /* Send buffer over bearers until all targets reached */ | 608 | /* Send buffer over bearers until all targets reached */ |
| 621 | |||
| 622 | bcbearer->remains = bclink->bcast_nodes; | 609 | bcbearer->remains = bclink->bcast_nodes; |
| 623 | 610 | ||
| 624 | for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) { | 611 | for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) { |
| @@ -660,7 +647,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf, | |||
| 660 | /** | 647 | /** |
| 661 | * tipc_bcbearer_sort - create sets of bearer pairs used by broadcast bearer | 648 | * tipc_bcbearer_sort - create sets of bearer pairs used by broadcast bearer |
| 662 | */ | 649 | */ |
| 663 | |||
| 664 | void tipc_bcbearer_sort(void) | 650 | void tipc_bcbearer_sort(void) |
| 665 | { | 651 | { |
| 666 | struct tipc_bcbearer_pair *bp_temp = bcbearer->bpairs_temp; | 652 | struct tipc_bcbearer_pair *bp_temp = bcbearer->bpairs_temp; |
| @@ -671,7 +657,6 @@ void tipc_bcbearer_sort(void) | |||
| 671 | spin_lock_bh(&bc_lock); | 657 | spin_lock_bh(&bc_lock); |
| 672 | 658 | ||
| 673 | /* Group bearers by priority (can assume max of two per priority) */ | 659 | /* Group bearers by priority (can assume max of two per priority) */ |
| 674 | |||
| 675 | memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp)); | 660 | memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp)); |
| 676 | 661 | ||
| 677 | for (b_index = 0; b_index < MAX_BEARERS; b_index++) { | 662 | for (b_index = 0; b_index < MAX_BEARERS; b_index++) { |
| @@ -687,7 +672,6 @@ void tipc_bcbearer_sort(void) | |||
| 687 | } | 672 | } |
| 688 | 673 | ||
| 689 | /* Create array of bearer pairs for broadcasting */ | 674 | /* Create array of bearer pairs for broadcasting */ |
| 690 | |||
| 691 | bp_curr = bcbearer->bpairs; | 675 | bp_curr = bcbearer->bpairs; |
| 692 | memset(bcbearer->bpairs, 0, sizeof(bcbearer->bpairs)); | 676 | memset(bcbearer->bpairs, 0, sizeof(bcbearer->bpairs)); |
| 693 | 677 | ||
| @@ -817,7 +801,6 @@ void tipc_bclink_stop(void) | |||
| 817 | /** | 801 | /** |
| 818 | * tipc_nmap_add - add a node to a node map | 802 | * tipc_nmap_add - add a node to a node map |
| 819 | */ | 803 | */ |
| 820 | |||
| 821 | void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node) | 804 | void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node) |
| 822 | { | 805 | { |
| 823 | int n = tipc_node(node); | 806 | int n = tipc_node(node); |
| @@ -833,7 +816,6 @@ void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node) | |||
| 833 | /** | 816 | /** |
| 834 | * tipc_nmap_remove - remove a node from a node map | 817 | * tipc_nmap_remove - remove a node from a node map |
| 835 | */ | 818 | */ |
| 836 | |||
| 837 | void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) | 819 | void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) |
| 838 | { | 820 | { |
| 839 | int n = tipc_node(node); | 821 | int n = tipc_node(node); |
| @@ -852,7 +834,6 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) | |||
| 852 | * @nm_b: input node map B | 834 | * @nm_b: input node map B |
| 853 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) | 835 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) |
| 854 | */ | 836 | */ |
| 855 | |||
| 856 | static void tipc_nmap_diff(struct tipc_node_map *nm_a, | 837 | static void tipc_nmap_diff(struct tipc_node_map *nm_a, |
| 857 | struct tipc_node_map *nm_b, | 838 | struct tipc_node_map *nm_b, |
| 858 | struct tipc_node_map *nm_diff) | 839 | struct tipc_node_map *nm_diff) |
| @@ -878,7 +859,6 @@ static void tipc_nmap_diff(struct tipc_node_map *nm_a, | |||
| 878 | /** | 859 | /** |
| 879 | * tipc_port_list_add - add a port to a port list, ensuring no duplicates | 860 | * tipc_port_list_add - add a port to a port list, ensuring no duplicates |
| 880 | */ | 861 | */ |
| 881 | |||
| 882 | void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port) | 862 | void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port) |
| 883 | { | 863 | { |
| 884 | struct tipc_port_list *item = pl_ptr; | 864 | struct tipc_port_list *item = pl_ptr; |
| @@ -912,7 +892,6 @@ void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port) | |||
| 912 | * tipc_port_list_free - free dynamically created entries in port_list chain | 892 | * tipc_port_list_free - free dynamically created entries in port_list chain |
| 913 | * | 893 | * |
| 914 | */ | 894 | */ |
| 915 | |||
| 916 | void tipc_port_list_free(struct tipc_port_list *pl_ptr) | 895 | void tipc_port_list_free(struct tipc_port_list *pl_ptr) |
| 917 | { | 896 | { |
| 918 | struct tipc_port_list *item; | 897 | struct tipc_port_list *item; |
| @@ -923,4 +902,3 @@ void tipc_port_list_free(struct tipc_port_list *pl_ptr) | |||
| 923 | kfree(item); | 902 | kfree(item); |
| 924 | } | 903 | } |
| 925 | } | 904 | } |
| 926 | |||
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index 5571394098f9..a93306557e00 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
| @@ -45,7 +45,6 @@ | |||
| 45 | * @count: # of nodes in set | 45 | * @count: # of nodes in set |
| 46 | * @map: bitmap of node identifiers that are in the set | 46 | * @map: bitmap of node identifiers that are in the set |
| 47 | */ | 47 | */ |
| 48 | |||
| 49 | struct tipc_node_map { | 48 | struct tipc_node_map { |
| 50 | u32 count; | 49 | u32 count; |
| 51 | u32 map[MAX_NODES / WSIZE]; | 50 | u32 map[MAX_NODES / WSIZE]; |
| @@ -59,7 +58,6 @@ struct tipc_node_map { | |||
| 59 | * @next: pointer to next entry in list | 58 | * @next: pointer to next entry in list |
| 60 | * @ports: array of port references | 59 | * @ports: array of port references |
| 61 | */ | 60 | */ |
| 62 | |||
| 63 | struct tipc_port_list { | 61 | struct tipc_port_list { |
| 64 | int count; | 62 | int count; |
| 65 | struct tipc_port_list *next; | 63 | struct tipc_port_list *next; |
| @@ -77,7 +75,6 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node); | |||
| 77 | /** | 75 | /** |
| 78 | * tipc_nmap_equal - test for equality of node maps | 76 | * tipc_nmap_equal - test for equality of node maps |
| 79 | */ | 77 | */ |
| 80 | |||
| 81 | static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) | 78 | static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) |
| 82 | { | 79 | { |
| 83 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); | 80 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 5dfd89c40429..a297e3a2e3e7 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
| @@ -53,7 +53,6 @@ static void bearer_disable(struct tipc_bearer *b_ptr); | |||
| 53 | * | 53 | * |
| 54 | * Returns 1 if media name is valid, otherwise 0. | 54 | * Returns 1 if media name is valid, otherwise 0. |
| 55 | */ | 55 | */ |
| 56 | |||
| 57 | static int media_name_valid(const char *name) | 56 | static int media_name_valid(const char *name) |
| 58 | { | 57 | { |
| 59 | u32 len; | 58 | u32 len; |
| @@ -67,7 +66,6 @@ static int media_name_valid(const char *name) | |||
| 67 | /** | 66 | /** |
| 68 | * tipc_media_find - locates specified media object by name | 67 | * tipc_media_find - locates specified media object by name |
| 69 | */ | 68 | */ |
| 70 | |||
| 71 | struct tipc_media *tipc_media_find(const char *name) | 69 | struct tipc_media *tipc_media_find(const char *name) |
| 72 | { | 70 | { |
| 73 | u32 i; | 71 | u32 i; |
| @@ -82,7 +80,6 @@ struct tipc_media *tipc_media_find(const char *name) | |||
| 82 | /** | 80 | /** |
| 83 | * media_find_id - locates specified media object by type identifier | 81 | * media_find_id - locates specified media object by type identifier |
| 84 | */ | 82 | */ |
| 85 | |||
| 86 | static struct tipc_media *media_find_id(u8 type) | 83 | static struct tipc_media *media_find_id(u8 type) |
| 87 | { | 84 | { |
| 88 | u32 i; | 85 | u32 i; |
| @@ -99,7 +96,6 @@ static struct tipc_media *media_find_id(u8 type) | |||
| 99 | * | 96 | * |
| 100 | * Bearers for this media type must be activated separately at a later stage. | 97 | * Bearers for this media type must be activated separately at a later stage. |
| 101 | */ | 98 | */ |
| 102 | |||
| 103 | int tipc_register_media(struct tipc_media *m_ptr) | 99 | int tipc_register_media(struct tipc_media *m_ptr) |
| 104 | { | 100 | { |
| 105 | int res = -EINVAL; | 101 | int res = -EINVAL; |
| @@ -134,7 +130,6 @@ exit: | |||
| 134 | /** | 130 | /** |
| 135 | * tipc_media_addr_printf - record media address in print buffer | 131 | * tipc_media_addr_printf - record media address in print buffer |
| 136 | */ | 132 | */ |
| 137 | |||
| 138 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) | 133 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) |
| 139 | { | 134 | { |
| 140 | char addr_str[MAX_ADDR_STR]; | 135 | char addr_str[MAX_ADDR_STR]; |
| @@ -156,7 +151,6 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) | |||
| 156 | /** | 151 | /** |
| 157 | * tipc_media_get_names - record names of registered media in buffer | 152 | * tipc_media_get_names - record names of registered media in buffer |
| 158 | */ | 153 | */ |
| 159 | |||
| 160 | struct sk_buff *tipc_media_get_names(void) | 154 | struct sk_buff *tipc_media_get_names(void) |
| 161 | { | 155 | { |
| 162 | struct sk_buff *buf; | 156 | struct sk_buff *buf; |
| @@ -183,7 +177,6 @@ struct sk_buff *tipc_media_get_names(void) | |||
| 183 | * | 177 | * |
| 184 | * Returns 1 if bearer name is valid, otherwise 0. | 178 | * Returns 1 if bearer name is valid, otherwise 0. |
| 185 | */ | 179 | */ |
| 186 | |||
| 187 | static int bearer_name_validate(const char *name, | 180 | static int bearer_name_validate(const char *name, |
| 188 | struct tipc_bearer_names *name_parts) | 181 | struct tipc_bearer_names *name_parts) |
| 189 | { | 182 | { |
| @@ -194,7 +187,6 @@ static int bearer_name_validate(const char *name, | |||
| 194 | u32 if_len; | 187 | u32 if_len; |
| 195 | 188 | ||
| 196 | /* copy bearer name & ensure length is OK */ | 189 | /* copy bearer name & ensure length is OK */ |
| 197 | |||
| 198 | name_copy[TIPC_MAX_BEARER_NAME - 1] = 0; | 190 | name_copy[TIPC_MAX_BEARER_NAME - 1] = 0; |
| 199 | /* need above in case non-Posix strncpy() doesn't pad with nulls */ | 191 | /* need above in case non-Posix strncpy() doesn't pad with nulls */ |
| 200 | strncpy(name_copy, name, TIPC_MAX_BEARER_NAME); | 192 | strncpy(name_copy, name, TIPC_MAX_BEARER_NAME); |
| @@ -202,7 +194,6 @@ static int bearer_name_validate(const char *name, | |||
| 202 | return 0; | 194 | return 0; |
| 203 | 195 | ||
| 204 | /* ensure all component parts of bearer name are present */ | 196 | /* ensure all component parts of bearer name are present */ |
| 205 | |||
| 206 | media_name = name_copy; | 197 | media_name = name_copy; |
| 207 | if_name = strchr(media_name, ':'); | 198 | if_name = strchr(media_name, ':'); |
| 208 | if (if_name == NULL) | 199 | if (if_name == NULL) |
| @@ -212,7 +203,6 @@ static int bearer_name_validate(const char *name, | |||
| 212 | if_len = strlen(if_name) + 1; | 203 | if_len = strlen(if_name) + 1; |
| 213 | 204 | ||
| 214 | /* validate component parts of bearer name */ | 205 | /* validate component parts of bearer name */ |
| 215 | |||
| 216 | if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) || | 206 | if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) || |
| 217 | (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) || | 207 | (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) || |
| 218 | (strspn(media_name, tipc_alphabet) != (media_len - 1)) || | 208 | (strspn(media_name, tipc_alphabet) != (media_len - 1)) || |
| @@ -220,7 +210,6 @@ static int bearer_name_validate(const char *name, | |||
| 220 | return 0; | 210 | return 0; |
| 221 | 211 | ||
| 222 | /* return bearer name components, if necessary */ | 212 | /* return bearer name components, if necessary */ |
| 223 | |||
| 224 | if (name_parts) { | 213 | if (name_parts) { |
| 225 | strcpy(name_parts->media_name, media_name); | 214 | strcpy(name_parts->media_name, media_name); |
| 226 | strcpy(name_parts->if_name, if_name); | 215 | strcpy(name_parts->if_name, if_name); |
| @@ -231,7 +220,6 @@ static int bearer_name_validate(const char *name, | |||
| 231 | /** | 220 | /** |
| 232 | * tipc_bearer_find - locates bearer object with matching bearer name | 221 | * tipc_bearer_find - locates bearer object with matching bearer name |
| 233 | */ | 222 | */ |
| 234 | |||
| 235 | struct tipc_bearer *tipc_bearer_find(const char *name) | 223 | struct tipc_bearer *tipc_bearer_find(const char *name) |
| 236 | { | 224 | { |
| 237 | struct tipc_bearer *b_ptr; | 225 | struct tipc_bearer *b_ptr; |
| @@ -247,7 +235,6 @@ struct tipc_bearer *tipc_bearer_find(const char *name) | |||
| 247 | /** | 235 | /** |
| 248 | * tipc_bearer_find_interface - locates bearer object with matching interface name | 236 | * tipc_bearer_find_interface - locates bearer object with matching interface name |
| 249 | */ | 237 | */ |
| 250 | |||
| 251 | struct tipc_bearer *tipc_bearer_find_interface(const char *if_name) | 238 | struct tipc_bearer *tipc_bearer_find_interface(const char *if_name) |
| 252 | { | 239 | { |
| 253 | struct tipc_bearer *b_ptr; | 240 | struct tipc_bearer *b_ptr; |
| @@ -267,7 +254,6 @@ struct tipc_bearer *tipc_bearer_find_interface(const char *if_name) | |||
| 267 | /** | 254 | /** |
| 268 | * tipc_bearer_get_names - record names of bearers in buffer | 255 | * tipc_bearer_get_names - record names of bearers in buffer |
| 269 | */ | 256 | */ |
| 270 | |||
| 271 | struct sk_buff *tipc_bearer_get_names(void) | 257 | struct sk_buff *tipc_bearer_get_names(void) |
| 272 | { | 258 | { |
| 273 | struct sk_buff *buf; | 259 | struct sk_buff *buf; |
| @@ -363,7 +349,6 @@ void tipc_continue(struct tipc_bearer *b_ptr) | |||
| 363 | * the bearer is congested. 'tipc_net_lock' is in read_lock here | 349 | * the bearer is congested. 'tipc_net_lock' is in read_lock here |
| 364 | * bearer.lock is busy | 350 | * bearer.lock is busy |
| 365 | */ | 351 | */ |
| 366 | |||
| 367 | static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr, | 352 | static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr, |
| 368 | struct tipc_link *l_ptr) | 353 | struct tipc_link *l_ptr) |
| 369 | { | 354 | { |
| @@ -377,7 +362,6 @@ static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr, | |||
| 377 | * the bearer is congested. 'tipc_net_lock' is in read_lock here, | 362 | * the bearer is congested. 'tipc_net_lock' is in read_lock here, |
| 378 | * bearer.lock is free | 363 | * bearer.lock is free |
| 379 | */ | 364 | */ |
| 380 | |||
| 381 | void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr) | 365 | void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr) |
| 382 | { | 366 | { |
| 383 | spin_lock_bh(&b_ptr->lock); | 367 | spin_lock_bh(&b_ptr->lock); |
| @@ -410,7 +394,6 @@ int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, | |||
| 410 | /** | 394 | /** |
| 411 | * tipc_bearer_congested - determines if bearer is currently congested | 395 | * tipc_bearer_congested - determines if bearer is currently congested |
| 412 | */ | 396 | */ |
| 413 | |||
| 414 | int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr) | 397 | int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr) |
| 415 | { | 398 | { |
| 416 | if (unlikely(b_ptr->blocked)) | 399 | if (unlikely(b_ptr->blocked)) |
| @@ -423,7 +406,6 @@ int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr) | |||
| 423 | /** | 406 | /** |
| 424 | * tipc_enable_bearer - enable bearer with the given name | 407 | * tipc_enable_bearer - enable bearer with the given name |
| 425 | */ | 408 | */ |
| 426 | |||
| 427 | int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) | 409 | int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) |
| 428 | { | 410 | { |
| 429 | struct tipc_bearer *b_ptr; | 411 | struct tipc_bearer *b_ptr; |
| @@ -449,7 +431,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) | |||
| 449 | if (tipc_in_scope(disc_domain, tipc_own_addr)) { | 431 | if (tipc_in_scope(disc_domain, tipc_own_addr)) { |
| 450 | disc_domain = tipc_own_addr & TIPC_CLUSTER_MASK; | 432 | disc_domain = tipc_own_addr & TIPC_CLUSTER_MASK; |
| 451 | res = 0; /* accept any node in own cluster */ | 433 | res = 0; /* accept any node in own cluster */ |
| 452 | } else if (in_own_cluster(disc_domain)) | 434 | } else if (in_own_cluster_exact(disc_domain)) |
| 453 | res = 0; /* accept specified node in own cluster */ | 435 | res = 0; /* accept specified node in own cluster */ |
| 454 | } | 436 | } |
| 455 | if (res) { | 437 | if (res) { |
| @@ -541,7 +523,6 @@ exit: | |||
| 541 | * tipc_block_bearer(): Block the bearer with the given name, | 523 | * tipc_block_bearer(): Block the bearer with the given name, |
| 542 | * and reset all its links | 524 | * and reset all its links |
| 543 | */ | 525 | */ |
| 544 | |||
| 545 | int tipc_block_bearer(const char *name) | 526 | int tipc_block_bearer(const char *name) |
| 546 | { | 527 | { |
| 547 | struct tipc_bearer *b_ptr = NULL; | 528 | struct tipc_bearer *b_ptr = NULL; |
| @@ -573,11 +554,10 @@ int tipc_block_bearer(const char *name) | |||
| 573 | } | 554 | } |
| 574 | 555 | ||
| 575 | /** | 556 | /** |
| 576 | * bearer_disable - | 557 | * bearer_disable |
| 577 | * | 558 | * |
| 578 | * Note: This routine assumes caller holds tipc_net_lock. | 559 | * Note: This routine assumes caller holds tipc_net_lock. |
| 579 | */ | 560 | */ |
| 580 | |||
| 581 | static void bearer_disable(struct tipc_bearer *b_ptr) | 561 | static void bearer_disable(struct tipc_bearer *b_ptr) |
| 582 | { | 562 | { |
| 583 | struct tipc_link *l_ptr; | 563 | struct tipc_link *l_ptr; |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index d3eac56b8c21..e3b2be37fb31 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
| @@ -49,7 +49,6 @@ | |||
| 49 | * - media type identifier located at offset 3 | 49 | * - media type identifier located at offset 3 |
| 50 | * - remaining bytes vary according to media type | 50 | * - remaining bytes vary according to media type |
| 51 | */ | 51 | */ |
| 52 | |||
| 53 | #define TIPC_MEDIA_ADDR_SIZE 20 | 52 | #define TIPC_MEDIA_ADDR_SIZE 20 |
| 54 | #define TIPC_MEDIA_TYPE_OFFSET 3 | 53 | #define TIPC_MEDIA_TYPE_OFFSET 3 |
| 55 | 54 | ||
| @@ -64,7 +63,6 @@ | |||
| 64 | * @media_id: TIPC media type identifier | 63 | * @media_id: TIPC media type identifier |
| 65 | * @broadcast: non-zero if address is a broadcast address | 64 | * @broadcast: non-zero if address is a broadcast address |
| 66 | */ | 65 | */ |
| 67 | |||
| 68 | struct tipc_media_addr { | 66 | struct tipc_media_addr { |
| 69 | u8 value[TIPC_MEDIA_ADDR_SIZE]; | 67 | u8 value[TIPC_MEDIA_ADDR_SIZE]; |
| 70 | u8 media_id; | 68 | u8 media_id; |
| @@ -89,7 +87,6 @@ struct tipc_bearer; | |||
| 89 | * @type_id: TIPC media identifier | 87 | * @type_id: TIPC media identifier |
| 90 | * @name: media name | 88 | * @name: media name |
| 91 | */ | 89 | */ |
| 92 | |||
| 93 | struct tipc_media { | 90 | struct tipc_media { |
| 94 | int (*send_msg)(struct sk_buff *buf, | 91 | int (*send_msg)(struct sk_buff *buf, |
| 95 | struct tipc_bearer *b_ptr, | 92 | struct tipc_bearer *b_ptr, |
| @@ -216,7 +213,6 @@ void tipc_bearer_lock_push(struct tipc_bearer *b_ptr); | |||
| 216 | * send routine always returns success -- even if the buffer was not sent -- | 213 | * send routine always returns success -- even if the buffer was not sent -- |
| 217 | * and let TIPC's link code deal with the undelivered message. | 214 | * and let TIPC's link code deal with the undelivered message. |
| 218 | */ | 215 | */ |
| 219 | |||
| 220 | static inline int tipc_bearer_send(struct tipc_bearer *b_ptr, | 216 | static inline int tipc_bearer_send(struct tipc_bearer *b_ptr, |
| 221 | struct sk_buff *buf, | 217 | struct sk_buff *buf, |
| 222 | struct tipc_media_addr *dest) | 218 | struct tipc_media_addr *dest) |
diff --git a/net/tipc/config.c b/net/tipc/config.c index f76d3b15e4e2..c5712a343810 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -131,7 +131,6 @@ static struct sk_buff *tipc_show_stats(void) | |||
| 131 | tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n"); | 131 | tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n"); |
| 132 | 132 | ||
| 133 | /* Use additional tipc_printf()'s to return more info ... */ | 133 | /* Use additional tipc_printf()'s to return more info ... */ |
| 134 | |||
| 135 | str_len = tipc_printbuf_validate(&pb); | 134 | str_len = tipc_printbuf_validate(&pb); |
| 136 | skb_put(buf, TLV_SPACE(str_len)); | 135 | skb_put(buf, TLV_SPACE(str_len)); |
| 137 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | 136 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); |
| @@ -191,7 +190,6 @@ static struct sk_buff *cfg_set_own_addr(void) | |||
| 191 | * configuration commands can't be received until a local configuration | 190 | * configuration commands can't be received until a local configuration |
| 192 | * command to enable the first bearer is received and processed. | 191 | * command to enable the first bearer is received and processed. |
| 193 | */ | 192 | */ |
| 194 | |||
| 195 | spin_unlock_bh(&config_lock); | 193 | spin_unlock_bh(&config_lock); |
| 196 | tipc_core_start_net(addr); | 194 | tipc_core_start_net(addr); |
| 197 | spin_lock_bh(&config_lock); | 195 | spin_lock_bh(&config_lock); |
| @@ -283,14 +281,12 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 283 | spin_lock_bh(&config_lock); | 281 | spin_lock_bh(&config_lock); |
| 284 | 282 | ||
| 285 | /* Save request and reply details in a well-known location */ | 283 | /* Save request and reply details in a well-known location */ |
| 286 | |||
| 287 | req_tlv_area = request_area; | 284 | req_tlv_area = request_area; |
| 288 | req_tlv_space = request_space; | 285 | req_tlv_space = request_space; |
| 289 | rep_headroom = reply_headroom; | 286 | rep_headroom = reply_headroom; |
| 290 | 287 | ||
| 291 | /* Check command authorization */ | 288 | /* Check command authorization */ |
| 292 | 289 | if (likely(in_own_node(orig_node))) { | |
| 293 | if (likely(orig_node == tipc_own_addr)) { | ||
| 294 | /* command is permitted */ | 290 | /* command is permitted */ |
| 295 | } else if (cmd >= 0x8000) { | 291 | } else if (cmd >= 0x8000) { |
| 296 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 292 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
| @@ -310,7 +306,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 310 | } | 306 | } |
| 311 | 307 | ||
| 312 | /* Call appropriate processing routine */ | 308 | /* Call appropriate processing routine */ |
| 313 | |||
| 314 | switch (cmd) { | 309 | switch (cmd) { |
| 315 | case TIPC_CMD_NOOP: | 310 | case TIPC_CMD_NOOP: |
| 316 | rep_tlv_buf = tipc_cfg_reply_none(); | 311 | rep_tlv_buf = tipc_cfg_reply_none(); |
| @@ -433,7 +428,6 @@ static void cfg_named_msg_event(void *userdata, | |||
| 433 | struct sk_buff *rep_buf; | 428 | struct sk_buff *rep_buf; |
| 434 | 429 | ||
| 435 | /* Validate configuration message header (ignore invalid message) */ | 430 | /* Validate configuration message header (ignore invalid message) */ |
| 436 | |||
| 437 | req_hdr = (struct tipc_cfg_msg_hdr *)msg; | 431 | req_hdr = (struct tipc_cfg_msg_hdr *)msg; |
| 438 | if ((size < sizeof(*req_hdr)) || | 432 | if ((size < sizeof(*req_hdr)) || |
| 439 | (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) || | 433 | (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) || |
| @@ -443,7 +437,6 @@ static void cfg_named_msg_event(void *userdata, | |||
| 443 | } | 437 | } |
| 444 | 438 | ||
| 445 | /* Generate reply for request (if can't, return request) */ | 439 | /* Generate reply for request (if can't, return request) */ |
| 446 | |||
| 447 | rep_buf = tipc_cfg_do_cmd(orig->node, | 440 | rep_buf = tipc_cfg_do_cmd(orig->node, |
| 448 | ntohs(req_hdr->tcm_type), | 441 | ntohs(req_hdr->tcm_type), |
| 449 | msg + sizeof(*req_hdr), | 442 | msg + sizeof(*req_hdr), |
| @@ -489,10 +482,23 @@ failed: | |||
| 489 | return res; | 482 | return res; |
| 490 | } | 483 | } |
| 491 | 484 | ||
| 485 | void tipc_cfg_reinit(void) | ||
| 486 | { | ||
| 487 | struct tipc_name_seq seq; | ||
| 488 | int res; | ||
| 489 | |||
| 490 | seq.type = TIPC_CFG_SRV; | ||
| 491 | seq.lower = seq.upper = 0; | ||
| 492 | tipc_withdraw(config_port_ref, TIPC_ZONE_SCOPE, &seq); | ||
| 493 | |||
| 494 | seq.lower = seq.upper = tipc_own_addr; | ||
| 495 | res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq); | ||
| 496 | if (res) | ||
| 497 | err("Unable to reinitialize configuration service\n"); | ||
| 498 | } | ||
| 499 | |||
| 492 | void tipc_cfg_stop(void) | 500 | void tipc_cfg_stop(void) |
| 493 | { | 501 | { |
| 494 | if (config_port_ref) { | 502 | tipc_deleteport(config_port_ref); |
| 495 | tipc_deleteport(config_port_ref); | 503 | config_port_ref = 0; |
| 496 | config_port_ref = 0; | ||
| 497 | } | ||
| 498 | } | 504 | } |
diff --git a/net/tipc/config.h b/net/tipc/config.h index 80da6ebc2785..1f252f3fa058 100644 --- a/net/tipc/config.h +++ b/net/tipc/config.h | |||
| @@ -66,6 +66,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, | |||
| 66 | int headroom); | 66 | int headroom); |
| 67 | 67 | ||
| 68 | int tipc_cfg_init(void); | 68 | int tipc_cfg_init(void); |
| 69 | void tipc_cfg_reinit(void); | ||
| 69 | void tipc_cfg_stop(void); | 70 | void tipc_cfg_stop(void); |
| 70 | 71 | ||
| 71 | #endif | 72 | #endif |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 68eba03e7955..f7b95239ebda 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
| @@ -52,14 +52,12 @@ | |||
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | /* global variables used by multiple sub-systems within TIPC */ | 54 | /* global variables used by multiple sub-systems within TIPC */ |
| 55 | |||
| 56 | int tipc_random; | 55 | int tipc_random; |
| 57 | 56 | ||
| 58 | const char tipc_alphabet[] = | 57 | const char tipc_alphabet[] = |
| 59 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."; | 58 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."; |
| 60 | 59 | ||
| 61 | /* configurable TIPC parameters */ | 60 | /* configurable TIPC parameters */ |
| 62 | |||
| 63 | u32 tipc_own_addr; | 61 | u32 tipc_own_addr; |
| 64 | int tipc_max_ports; | 62 | int tipc_max_ports; |
| 65 | int tipc_max_subscriptions; | 63 | int tipc_max_subscriptions; |
| @@ -77,7 +75,6 @@ int tipc_remote_management; | |||
| 77 | * NOTE: Headroom is reserved to allow prepending of a data link header. | 75 | * NOTE: Headroom is reserved to allow prepending of a data link header. |
| 78 | * There may also be unrequested tailroom present at the buffer's end. | 76 | * There may also be unrequested tailroom present at the buffer's end. |
| 79 | */ | 77 | */ |
| 80 | |||
| 81 | struct sk_buff *tipc_buf_acquire(u32 size) | 78 | struct sk_buff *tipc_buf_acquire(u32 size) |
| 82 | { | 79 | { |
| 83 | struct sk_buff *skb; | 80 | struct sk_buff *skb; |
| @@ -95,7 +92,6 @@ struct sk_buff *tipc_buf_acquire(u32 size) | |||
| 95 | /** | 92 | /** |
| 96 | * tipc_core_stop_net - shut down TIPC networking sub-systems | 93 | * tipc_core_stop_net - shut down TIPC networking sub-systems |
| 97 | */ | 94 | */ |
| 98 | |||
| 99 | static void tipc_core_stop_net(void) | 95 | static void tipc_core_stop_net(void) |
| 100 | { | 96 | { |
| 101 | tipc_net_stop(); | 97 | tipc_net_stop(); |
| @@ -105,7 +101,6 @@ static void tipc_core_stop_net(void) | |||
| 105 | /** | 101 | /** |
| 106 | * start_net - start TIPC networking sub-systems | 102 | * start_net - start TIPC networking sub-systems |
| 107 | */ | 103 | */ |
| 108 | |||
| 109 | int tipc_core_start_net(unsigned long addr) | 104 | int tipc_core_start_net(unsigned long addr) |
| 110 | { | 105 | { |
| 111 | int res; | 106 | int res; |
| @@ -121,7 +116,6 @@ int tipc_core_start_net(unsigned long addr) | |||
| 121 | /** | 116 | /** |
| 122 | * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode | 117 | * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode |
| 123 | */ | 118 | */ |
| 124 | |||
| 125 | static void tipc_core_stop(void) | 119 | static void tipc_core_stop(void) |
| 126 | { | 120 | { |
| 127 | tipc_netlink_stop(); | 121 | tipc_netlink_stop(); |
| @@ -137,7 +131,6 @@ static void tipc_core_stop(void) | |||
| 137 | /** | 131 | /** |
| 138 | * tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode | 132 | * tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode |
| 139 | */ | 133 | */ |
| 140 | |||
| 141 | static int tipc_core_start(void) | 134 | static int tipc_core_start(void) |
| 142 | { | 135 | { |
| 143 | int res; | 136 | int res; |
| @@ -150,9 +143,9 @@ static int tipc_core_start(void) | |||
| 150 | if (!res) | 143 | if (!res) |
| 151 | res = tipc_nametbl_init(); | 144 | res = tipc_nametbl_init(); |
| 152 | if (!res) | 145 | if (!res) |
| 153 | res = tipc_k_signal((Handler)tipc_subscr_start, 0); | 146 | res = tipc_subscr_start(); |
| 154 | if (!res) | 147 | if (!res) |
| 155 | res = tipc_k_signal((Handler)tipc_cfg_init, 0); | 148 | res = tipc_cfg_init(); |
| 156 | if (!res) | 149 | if (!res) |
| 157 | res = tipc_netlink_start(); | 150 | res = tipc_netlink_start(); |
| 158 | if (!res) | 151 | if (!res) |
diff --git a/net/tipc/core.h b/net/tipc/core.h index 13837e0e56b1..2a9bb99537b3 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
| @@ -85,7 +85,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...); | |||
| 85 | /* | 85 | /* |
| 86 | * TIPC_OUTPUT is the destination print buffer for system messages. | 86 | * TIPC_OUTPUT is the destination print buffer for system messages. |
| 87 | */ | 87 | */ |
| 88 | |||
| 89 | #ifndef TIPC_OUTPUT | 88 | #ifndef TIPC_OUTPUT |
| 90 | #define TIPC_OUTPUT TIPC_LOG | 89 | #define TIPC_OUTPUT TIPC_LOG |
| 91 | #endif | 90 | #endif |
| @@ -102,7 +101,6 @@ void tipc_printf(struct print_buf *, const char *fmt, ...); | |||
| 102 | /* | 101 | /* |
| 103 | * DBG_OUTPUT is the destination print buffer for debug messages. | 102 | * DBG_OUTPUT is the destination print buffer for debug messages. |
| 104 | */ | 103 | */ |
| 105 | |||
| 106 | #ifndef DBG_OUTPUT | 104 | #ifndef DBG_OUTPUT |
| 107 | #define DBG_OUTPUT TIPC_LOG | 105 | #define DBG_OUTPUT TIPC_LOG |
| 108 | #endif | 106 | #endif |
| @@ -126,13 +124,11 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); | |||
| 126 | /* | 124 | /* |
| 127 | * TIPC-specific error codes | 125 | * TIPC-specific error codes |
| 128 | */ | 126 | */ |
| 129 | |||
| 130 | #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ | 127 | #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ |
| 131 | 128 | ||
| 132 | /* | 129 | /* |
| 133 | * Global configuration variables | 130 | * Global configuration variables |
| 134 | */ | 131 | */ |
| 135 | |||
| 136 | extern u32 tipc_own_addr; | 132 | extern u32 tipc_own_addr; |
| 137 | extern int tipc_max_ports; | 133 | extern int tipc_max_ports; |
| 138 | extern int tipc_max_subscriptions; | 134 | extern int tipc_max_subscriptions; |
| @@ -143,7 +139,6 @@ extern int tipc_remote_management; | |||
| 143 | /* | 139 | /* |
| 144 | * Other global variables | 140 | * Other global variables |
| 145 | */ | 141 | */ |
| 146 | |||
| 147 | extern int tipc_random; | 142 | extern int tipc_random; |
| 148 | extern const char tipc_alphabet[]; | 143 | extern const char tipc_alphabet[]; |
| 149 | 144 | ||
| @@ -151,7 +146,6 @@ extern const char tipc_alphabet[]; | |||
| 151 | /* | 146 | /* |
| 152 | * Routines available to privileged subsystems | 147 | * Routines available to privileged subsystems |
| 153 | */ | 148 | */ |
| 154 | |||
| 155 | extern int tipc_core_start_net(unsigned long); | 149 | extern int tipc_core_start_net(unsigned long); |
| 156 | extern int tipc_handler_start(void); | 150 | extern int tipc_handler_start(void); |
| 157 | extern void tipc_handler_stop(void); | 151 | extern void tipc_handler_stop(void); |
| @@ -163,7 +157,6 @@ extern void tipc_socket_stop(void); | |||
| 163 | /* | 157 | /* |
| 164 | * TIPC timer and signal code | 158 | * TIPC timer and signal code |
| 165 | */ | 159 | */ |
| 166 | |||
| 167 | typedef void (*Handler) (unsigned long); | 160 | typedef void (*Handler) (unsigned long); |
| 168 | 161 | ||
| 169 | u32 tipc_k_signal(Handler routine, unsigned long argument); | 162 | u32 tipc_k_signal(Handler routine, unsigned long argument); |
| @@ -176,7 +169,6 @@ u32 tipc_k_signal(Handler routine, unsigned long argument); | |||
| 176 | * | 169 | * |
| 177 | * Timer must be initialized before use (and terminated when no longer needed). | 170 | * Timer must be initialized before use (and terminated when no longer needed). |
| 178 | */ | 171 | */ |
| 179 | |||
| 180 | static inline void k_init_timer(struct timer_list *timer, Handler routine, | 172 | static inline void k_init_timer(struct timer_list *timer, Handler routine, |
| 181 | unsigned long argument) | 173 | unsigned long argument) |
| 182 | { | 174 | { |
| @@ -196,7 +188,6 @@ static inline void k_init_timer(struct timer_list *timer, Handler routine, | |||
| 196 | * then an additional jiffy is added to account for the fact that | 188 | * then an additional jiffy is added to account for the fact that |
| 197 | * the starting time may be in the middle of the current jiffy. | 189 | * the starting time may be in the middle of the current jiffy. |
| 198 | */ | 190 | */ |
| 199 | |||
| 200 | static inline void k_start_timer(struct timer_list *timer, unsigned long msec) | 191 | static inline void k_start_timer(struct timer_list *timer, unsigned long msec) |
| 201 | { | 192 | { |
| 202 | mod_timer(timer, jiffies + msecs_to_jiffies(msec) + 1); | 193 | mod_timer(timer, jiffies + msecs_to_jiffies(msec) + 1); |
| @@ -212,7 +203,6 @@ static inline void k_start_timer(struct timer_list *timer, unsigned long msec) | |||
| 212 | * WARNING: Must not be called when holding locks required by the timer's | 203 | * WARNING: Must not be called when holding locks required by the timer's |
| 213 | * timeout routine, otherwise deadlock can occur on SMP systems! | 204 | * timeout routine, otherwise deadlock can occur on SMP systems! |
| 214 | */ | 205 | */ |
| 215 | |||
| 216 | static inline void k_cancel_timer(struct timer_list *timer) | 206 | static inline void k_cancel_timer(struct timer_list *timer) |
| 217 | { | 207 | { |
| 218 | del_timer_sync(timer); | 208 | del_timer_sync(timer); |
| @@ -229,12 +219,10 @@ static inline void k_cancel_timer(struct timer_list *timer) | |||
| 229 | * (Do not "enhance" this routine to automatically cancel an active timer, | 219 | * (Do not "enhance" this routine to automatically cancel an active timer, |
| 230 | * otherwise deadlock can arise when a timeout routine calls k_term_timer.) | 220 | * otherwise deadlock can arise when a timeout routine calls k_term_timer.) |
| 231 | */ | 221 | */ |
| 232 | |||
| 233 | static inline void k_term_timer(struct timer_list *timer) | 222 | static inline void k_term_timer(struct timer_list *timer) |
| 234 | { | 223 | { |
| 235 | } | 224 | } |
| 236 | 225 | ||
| 237 | |||
| 238 | /* | 226 | /* |
| 239 | * TIPC message buffer code | 227 | * TIPC message buffer code |
| 240 | * | 228 | * |
| @@ -244,7 +232,6 @@ static inline void k_term_timer(struct timer_list *timer) | |||
| 244 | * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields | 232 | * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields |
| 245 | * are word aligned for quicker access | 233 | * are word aligned for quicker access |
| 246 | */ | 234 | */ |
| 247 | |||
| 248 | #define BUF_HEADROOM LL_MAX_HEADER | 235 | #define BUF_HEADROOM LL_MAX_HEADER |
| 249 | 236 | ||
| 250 | struct tipc_skb_cb { | 237 | struct tipc_skb_cb { |
| @@ -253,7 +240,6 @@ struct tipc_skb_cb { | |||
| 253 | 240 | ||
| 254 | #define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0])) | 241 | #define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0])) |
| 255 | 242 | ||
| 256 | |||
| 257 | static inline struct tipc_msg *buf_msg(struct sk_buff *skb) | 243 | static inline struct tipc_msg *buf_msg(struct sk_buff *skb) |
| 258 | { | 244 | { |
| 259 | return (struct tipc_msg *)skb->data; | 245 | return (struct tipc_msg *)skb->data; |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index c630a21b2bed..ae054cfe179f 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
| @@ -70,7 +70,6 @@ struct tipc_link_req { | |||
| 70 | * @dest_domain: network domain of node(s) which should respond to message | 70 | * @dest_domain: network domain of node(s) which should respond to message |
| 71 | * @b_ptr: ptr to bearer issuing message | 71 | * @b_ptr: ptr to bearer issuing message |
| 72 | */ | 72 | */ |
| 73 | |||
| 74 | static struct sk_buff *tipc_disc_init_msg(u32 type, | 73 | static struct sk_buff *tipc_disc_init_msg(u32 type, |
| 75 | u32 dest_domain, | 74 | u32 dest_domain, |
| 76 | struct tipc_bearer *b_ptr) | 75 | struct tipc_bearer *b_ptr) |
| @@ -96,7 +95,6 @@ static struct sk_buff *tipc_disc_init_msg(u32 type, | |||
| 96 | * @node_addr: duplicated node address | 95 | * @node_addr: duplicated node address |
| 97 | * @media_addr: media address advertised by duplicated node | 96 | * @media_addr: media address advertised by duplicated node |
| 98 | */ | 97 | */ |
| 99 | |||
| 100 | static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr, | 98 | static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr, |
| 101 | struct tipc_media_addr *media_addr) | 99 | struct tipc_media_addr *media_addr) |
| 102 | { | 100 | { |
| @@ -117,7 +115,6 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr, | |||
| 117 | * @buf: buffer containing message | 115 | * @buf: buffer containing message |
| 118 | * @b_ptr: bearer that message arrived on | 116 | * @b_ptr: bearer that message arrived on |
| 119 | */ | 117 | */ |
| 120 | |||
| 121 | void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) | 118 | void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) |
| 122 | { | 119 | { |
| 123 | struct tipc_node *n_ptr; | 120 | struct tipc_node *n_ptr; |
| @@ -221,7 +218,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) | |||
| 221 | * the new media address and reset the link to ensure it starts up | 218 | * the new media address and reset the link to ensure it starts up |
| 222 | * cleanly. | 219 | * cleanly. |
| 223 | */ | 220 | */ |
| 224 | |||
| 225 | if (addr_mismatch) { | 221 | if (addr_mismatch) { |
| 226 | if (tipc_link_is_up(link)) { | 222 | if (tipc_link_is_up(link)) { |
| 227 | disc_dupl_alert(b_ptr, orig, &media_addr); | 223 | disc_dupl_alert(b_ptr, orig, &media_addr); |
| @@ -264,7 +260,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) | |||
| 264 | * Reinitiates discovery process if discovery object has no associated nodes | 260 | * Reinitiates discovery process if discovery object has no associated nodes |
| 265 | * and is either not currently searching or is searching at a slow rate | 261 | * and is either not currently searching or is searching at a slow rate |
| 266 | */ | 262 | */ |
| 267 | |||
| 268 | static void disc_update(struct tipc_link_req *req) | 263 | static void disc_update(struct tipc_link_req *req) |
| 269 | { | 264 | { |
| 270 | if (!req->num_nodes) { | 265 | if (!req->num_nodes) { |
| @@ -280,7 +275,6 @@ static void disc_update(struct tipc_link_req *req) | |||
| 280 | * tipc_disc_add_dest - increment set of discovered nodes | 275 | * tipc_disc_add_dest - increment set of discovered nodes |
| 281 | * @req: ptr to link request structure | 276 | * @req: ptr to link request structure |
| 282 | */ | 277 | */ |
| 283 | |||
| 284 | void tipc_disc_add_dest(struct tipc_link_req *req) | 278 | void tipc_disc_add_dest(struct tipc_link_req *req) |
| 285 | { | 279 | { |
| 286 | req->num_nodes++; | 280 | req->num_nodes++; |
| @@ -290,7 +284,6 @@ void tipc_disc_add_dest(struct tipc_link_req *req) | |||
| 290 | * tipc_disc_remove_dest - decrement set of discovered nodes | 284 | * tipc_disc_remove_dest - decrement set of discovered nodes |
| 291 | * @req: ptr to link request structure | 285 | * @req: ptr to link request structure |
| 292 | */ | 286 | */ |
| 293 | |||
| 294 | void tipc_disc_remove_dest(struct tipc_link_req *req) | 287 | void tipc_disc_remove_dest(struct tipc_link_req *req) |
| 295 | { | 288 | { |
| 296 | req->num_nodes--; | 289 | req->num_nodes--; |
| @@ -301,7 +294,6 @@ void tipc_disc_remove_dest(struct tipc_link_req *req) | |||
| 301 | * disc_send_msg - send link setup request message | 294 | * disc_send_msg - send link setup request message |
| 302 | * @req: ptr to link request structure | 295 | * @req: ptr to link request structure |
| 303 | */ | 296 | */ |
| 304 | |||
| 305 | static void disc_send_msg(struct tipc_link_req *req) | 297 | static void disc_send_msg(struct tipc_link_req *req) |
| 306 | { | 298 | { |
| 307 | if (!req->bearer->blocked) | 299 | if (!req->bearer->blocked) |
| @@ -314,7 +306,6 @@ static void disc_send_msg(struct tipc_link_req *req) | |||
| 314 | * | 306 | * |
| 315 | * Called whenever a link setup request timer associated with a bearer expires. | 307 | * Called whenever a link setup request timer associated with a bearer expires. |
| 316 | */ | 308 | */ |
| 317 | |||
| 318 | static void disc_timeout(struct tipc_link_req *req) | 309 | static void disc_timeout(struct tipc_link_req *req) |
| 319 | { | 310 | { |
| 320 | int max_delay; | 311 | int max_delay; |
| @@ -322,7 +313,6 @@ static void disc_timeout(struct tipc_link_req *req) | |||
| 322 | spin_lock_bh(&req->bearer->lock); | 313 | spin_lock_bh(&req->bearer->lock); |
| 323 | 314 | ||
| 324 | /* Stop searching if only desired node has been found */ | 315 | /* Stop searching if only desired node has been found */ |
| 325 | |||
| 326 | if (tipc_node(req->domain) && req->num_nodes) { | 316 | if (tipc_node(req->domain) && req->num_nodes) { |
| 327 | req->timer_intv = TIPC_LINK_REQ_INACTIVE; | 317 | req->timer_intv = TIPC_LINK_REQ_INACTIVE; |
| 328 | goto exit; | 318 | goto exit; |
| @@ -335,7 +325,6 @@ static void disc_timeout(struct tipc_link_req *req) | |||
| 335 | * hold at fast polling rate if don't have any associated nodes, | 325 | * hold at fast polling rate if don't have any associated nodes, |
| 336 | * otherwise hold at slow polling rate | 326 | * otherwise hold at slow polling rate |
| 337 | */ | 327 | */ |
| 338 | |||
| 339 | disc_send_msg(req); | 328 | disc_send_msg(req); |
| 340 | 329 | ||
| 341 | req->timer_intv *= 2; | 330 | req->timer_intv *= 2; |
| @@ -359,7 +348,6 @@ exit: | |||
| 359 | * | 348 | * |
| 360 | * Returns 0 if successful, otherwise -errno. | 349 | * Returns 0 if successful, otherwise -errno. |
| 361 | */ | 350 | */ |
| 362 | |||
| 363 | int tipc_disc_create(struct tipc_bearer *b_ptr, | 351 | int tipc_disc_create(struct tipc_bearer *b_ptr, |
| 364 | struct tipc_media_addr *dest, u32 dest_domain) | 352 | struct tipc_media_addr *dest, u32 dest_domain) |
| 365 | { | 353 | { |
| @@ -391,7 +379,6 @@ int tipc_disc_create(struct tipc_bearer *b_ptr, | |||
| 391 | * tipc_disc_delete - destroy object sending periodic link setup requests | 379 | * tipc_disc_delete - destroy object sending periodic link setup requests |
| 392 | * @req: ptr to link request structure | 380 | * @req: ptr to link request structure |
| 393 | */ | 381 | */ |
| 394 | |||
| 395 | void tipc_disc_delete(struct tipc_link_req *req) | 382 | void tipc_disc_delete(struct tipc_link_req *req) |
| 396 | { | 383 | { |
| 397 | k_cancel_timer(&req->timer); | 384 | k_cancel_timer(&req->timer); |
| @@ -399,4 +386,3 @@ void tipc_disc_delete(struct tipc_link_req *req) | |||
| 399 | kfree_skb(req->buf); | 386 | kfree_skb(req->buf); |
| 400 | kfree(req); | 387 | kfree(req); |
| 401 | } | 388 | } |
| 402 | |||
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 527e3f0e165d..90ac9bfa7abb 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
| @@ -48,7 +48,6 @@ | |||
| 48 | * @tipc_packet_type: used in binding TIPC to Ethernet driver | 48 | * @tipc_packet_type: used in binding TIPC to Ethernet driver |
| 49 | * @cleanup: work item used when disabling bearer | 49 | * @cleanup: work item used when disabling bearer |
| 50 | */ | 50 | */ |
| 51 | |||
| 52 | struct eth_bearer { | 51 | struct eth_bearer { |
| 53 | struct tipc_bearer *bearer; | 52 | struct tipc_bearer *bearer; |
| 54 | struct net_device *dev; | 53 | struct net_device *dev; |
| @@ -67,7 +66,6 @@ static struct notifier_block notifier; | |||
| 67 | * Media-dependent "value" field stores MAC address in first 6 bytes | 66 | * Media-dependent "value" field stores MAC address in first 6 bytes |
| 68 | * and zeroes out the remaining bytes. | 67 | * and zeroes out the remaining bytes. |
| 69 | */ | 68 | */ |
| 70 | |||
| 71 | static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) | 69 | static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) |
| 72 | { | 70 | { |
| 73 | memcpy(a->value, mac, ETH_ALEN); | 71 | memcpy(a->value, mac, ETH_ALEN); |
| @@ -79,7 +77,6 @@ static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) | |||
| 79 | /** | 77 | /** |
| 80 | * send_msg - send a TIPC message out over an Ethernet interface | 78 | * send_msg - send a TIPC message out over an Ethernet interface |
| 81 | */ | 79 | */ |
| 82 | |||
| 83 | static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | 80 | static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, |
| 84 | struct tipc_media_addr *dest) | 81 | struct tipc_media_addr *dest) |
| 85 | { | 82 | { |
| @@ -115,7 +112,6 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
| 115 | * ignores packets sent using Ethernet multicast, and traffic sent to other | 112 | * ignores packets sent using Ethernet multicast, and traffic sent to other |
| 116 | * nodes (which can happen if interface is running in promiscuous mode). | 113 | * nodes (which can happen if interface is running in promiscuous mode). |
| 117 | */ | 114 | */ |
| 118 | |||
| 119 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, | 115 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, |
| 120 | struct packet_type *pt, struct net_device *orig_dev) | 116 | struct packet_type *pt, struct net_device *orig_dev) |
| 121 | { | 117 | { |
| @@ -140,7 +136,6 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev, | |||
| 140 | /** | 136 | /** |
| 141 | * enable_bearer - attach TIPC bearer to an Ethernet interface | 137 | * enable_bearer - attach TIPC bearer to an Ethernet interface |
| 142 | */ | 138 | */ |
| 143 | |||
| 144 | static int enable_bearer(struct tipc_bearer *tb_ptr) | 139 | static int enable_bearer(struct tipc_bearer *tb_ptr) |
| 145 | { | 140 | { |
| 146 | struct net_device *dev = NULL; | 141 | struct net_device *dev = NULL; |
| @@ -151,7 +146,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
| 151 | int pending_dev = 0; | 146 | int pending_dev = 0; |
| 152 | 147 | ||
| 153 | /* Find unused Ethernet bearer structure */ | 148 | /* Find unused Ethernet bearer structure */ |
| 154 | |||
| 155 | while (eb_ptr->dev) { | 149 | while (eb_ptr->dev) { |
| 156 | if (!eb_ptr->bearer) | 150 | if (!eb_ptr->bearer) |
| 157 | pending_dev++; | 151 | pending_dev++; |
| @@ -160,7 +154,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
| 160 | } | 154 | } |
| 161 | 155 | ||
| 162 | /* Find device with specified name */ | 156 | /* Find device with specified name */ |
| 163 | |||
| 164 | read_lock(&dev_base_lock); | 157 | read_lock(&dev_base_lock); |
| 165 | for_each_netdev(&init_net, pdev) { | 158 | for_each_netdev(&init_net, pdev) { |
| 166 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { | 159 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { |
| @@ -174,7 +167,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
| 174 | return -ENODEV; | 167 | return -ENODEV; |
| 175 | 168 | ||
| 176 | /* Create Ethernet bearer for device */ | 169 | /* Create Ethernet bearer for device */ |
| 177 | |||
| 178 | eb_ptr->dev = dev; | 170 | eb_ptr->dev = dev; |
| 179 | eb_ptr->tipc_packet_type.type = htons(ETH_P_TIPC); | 171 | eb_ptr->tipc_packet_type.type = htons(ETH_P_TIPC); |
| 180 | eb_ptr->tipc_packet_type.dev = dev; | 172 | eb_ptr->tipc_packet_type.dev = dev; |
| @@ -184,7 +176,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
| 184 | dev_add_pack(&eb_ptr->tipc_packet_type); | 176 | dev_add_pack(&eb_ptr->tipc_packet_type); |
| 185 | 177 | ||
| 186 | /* Associate TIPC bearer with Ethernet bearer */ | 178 | /* Associate TIPC bearer with Ethernet bearer */ |
| 187 | |||
| 188 | eb_ptr->bearer = tb_ptr; | 179 | eb_ptr->bearer = tb_ptr; |
| 189 | tb_ptr->usr_handle = (void *)eb_ptr; | 180 | tb_ptr->usr_handle = (void *)eb_ptr; |
| 190 | tb_ptr->mtu = dev->mtu; | 181 | tb_ptr->mtu = dev->mtu; |
| @@ -198,7 +189,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
| 198 | * | 189 | * |
| 199 | * This routine must be invoked from a work queue because it can sleep. | 190 | * This routine must be invoked from a work queue because it can sleep. |
| 200 | */ | 191 | */ |
| 201 | |||
| 202 | static void cleanup_bearer(struct work_struct *work) | 192 | static void cleanup_bearer(struct work_struct *work) |
| 203 | { | 193 | { |
| 204 | struct eth_bearer *eb_ptr = | 194 | struct eth_bearer *eb_ptr = |
| @@ -216,7 +206,6 @@ static void cleanup_bearer(struct work_struct *work) | |||
| 216 | * then get worker thread to complete bearer cleanup. (Can't do cleanup | 206 | * then get worker thread to complete bearer cleanup. (Can't do cleanup |
| 217 | * here because cleanup code needs to sleep and caller holds spinlocks.) | 207 | * here because cleanup code needs to sleep and caller holds spinlocks.) |
| 218 | */ | 208 | */ |
| 219 | |||
| 220 | static void disable_bearer(struct tipc_bearer *tb_ptr) | 209 | static void disable_bearer(struct tipc_bearer *tb_ptr) |
| 221 | { | 210 | { |
| 222 | struct eth_bearer *eb_ptr = (struct eth_bearer *)tb_ptr->usr_handle; | 211 | struct eth_bearer *eb_ptr = (struct eth_bearer *)tb_ptr->usr_handle; |
| @@ -232,7 +221,6 @@ static void disable_bearer(struct tipc_bearer *tb_ptr) | |||
| 232 | * Change the state of the Ethernet bearer (if any) associated with the | 221 | * Change the state of the Ethernet bearer (if any) associated with the |
| 233 | * specified device. | 222 | * specified device. |
| 234 | */ | 223 | */ |
| 235 | |||
| 236 | static int recv_notification(struct notifier_block *nb, unsigned long evt, | 224 | static int recv_notification(struct notifier_block *nb, unsigned long evt, |
| 237 | void *dv) | 225 | void *dv) |
| 238 | { | 226 | { |
| @@ -281,7 +269,6 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, | |||
| 281 | /** | 269 | /** |
| 282 | * eth_addr2str - convert Ethernet address to string | 270 | * eth_addr2str - convert Ethernet address to string |
| 283 | */ | 271 | */ |
| 284 | |||
| 285 | static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | 272 | static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) |
| 286 | { | 273 | { |
| 287 | if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ | 274 | if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ |
| @@ -294,7 +281,6 @@ static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | |||
| 294 | /** | 281 | /** |
| 295 | * eth_str2addr - convert string to Ethernet address | 282 | * eth_str2addr - convert string to Ethernet address |
| 296 | */ | 283 | */ |
| 297 | |||
| 298 | static int eth_str2addr(struct tipc_media_addr *a, char *str_buf) | 284 | static int eth_str2addr(struct tipc_media_addr *a, char *str_buf) |
| 299 | { | 285 | { |
| 300 | char mac[ETH_ALEN]; | 286 | char mac[ETH_ALEN]; |
| @@ -314,7 +300,6 @@ static int eth_str2addr(struct tipc_media_addr *a, char *str_buf) | |||
| 314 | /** | 300 | /** |
| 315 | * eth_str2addr - convert Ethernet address format to message header format | 301 | * eth_str2addr - convert Ethernet address format to message header format |
| 316 | */ | 302 | */ |
| 317 | |||
| 318 | static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) | 303 | static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) |
| 319 | { | 304 | { |
| 320 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); | 305 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); |
| @@ -326,7 +311,6 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) | |||
| 326 | /** | 311 | /** |
| 327 | * eth_str2addr - convert message header address format to Ethernet format | 312 | * eth_str2addr - convert message header address format to Ethernet format |
| 328 | */ | 313 | */ |
| 329 | |||
| 330 | static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area) | 314 | static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area) |
| 331 | { | 315 | { |
| 332 | if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) | 316 | if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) |
| @@ -339,7 +323,6 @@ static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area) | |||
| 339 | /* | 323 | /* |
| 340 | * Ethernet media registration info | 324 | * Ethernet media registration info |
| 341 | */ | 325 | */ |
| 342 | |||
| 343 | static struct tipc_media eth_media_info = { | 326 | static struct tipc_media eth_media_info = { |
| 344 | .send_msg = send_msg, | 327 | .send_msg = send_msg, |
| 345 | .enable_bearer = enable_bearer, | 328 | .enable_bearer = enable_bearer, |
| @@ -363,7 +346,6 @@ static struct tipc_media eth_media_info = { | |||
| 363 | * Register Ethernet media type with TIPC bearer code. Also register | 346 | * Register Ethernet media type with TIPC bearer code. Also register |
| 364 | * with OS for notifications about device state changes. | 347 | * with OS for notifications about device state changes. |
| 365 | */ | 348 | */ |
| 366 | |||
| 367 | int tipc_eth_media_start(void) | 349 | int tipc_eth_media_start(void) |
| 368 | { | 350 | { |
| 369 | int res; | 351 | int res; |
| @@ -386,7 +368,6 @@ int tipc_eth_media_start(void) | |||
| 386 | /** | 368 | /** |
| 387 | * tipc_eth_media_stop - deactivate Ethernet bearer support | 369 | * tipc_eth_media_stop - deactivate Ethernet bearer support |
| 388 | */ | 370 | */ |
| 389 | |||
| 390 | void tipc_eth_media_stop(void) | 371 | void tipc_eth_media_stop(void) |
| 391 | { | 372 | { |
| 392 | if (!eth_started) | 373 | if (!eth_started) |
diff --git a/net/tipc/handler.c b/net/tipc/handler.c index 274c98e164b7..9c6f22ff1c6d 100644 --- a/net/tipc/handler.c +++ b/net/tipc/handler.c | |||
| @@ -129,4 +129,3 @@ void tipc_handler_stop(void) | |||
| 129 | 129 | ||
| 130 | kmem_cache_destroy(tipc_queue_item_cache); | 130 | kmem_cache_destroy(tipc_queue_item_cache); |
| 131 | } | 131 | } |
| 132 | |||
diff --git a/net/tipc/link.c b/net/tipc/link.c index b4b9b30167a3..7a614f43549d 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -45,13 +45,11 @@ | |||
| 45 | /* | 45 | /* |
| 46 | * Out-of-range value for link session numbers | 46 | * Out-of-range value for link session numbers |
| 47 | */ | 47 | */ |
| 48 | |||
| 49 | #define INVALID_SESSION 0x10000 | 48 | #define INVALID_SESSION 0x10000 |
| 50 | 49 | ||
| 51 | /* | 50 | /* |
| 52 | * Link state events: | 51 | * Link state events: |
| 53 | */ | 52 | */ |
| 54 | |||
| 55 | #define STARTING_EVT 856384768 /* link processing trigger */ | 53 | #define STARTING_EVT 856384768 /* link processing trigger */ |
| 56 | #define TRAFFIC_MSG_EVT 560815u /* rx'd ??? */ | 54 | #define TRAFFIC_MSG_EVT 560815u /* rx'd ??? */ |
| 57 | #define TIMEOUT_EVT 560817u /* link timer expired */ | 55 | #define TIMEOUT_EVT 560817u /* link timer expired */ |
| @@ -67,7 +65,6 @@ | |||
| 67 | /* | 65 | /* |
| 68 | * State value stored in 'exp_msg_count' | 66 | * State value stored in 'exp_msg_count' |
| 69 | */ | 67 | */ |
| 70 | |||
| 71 | #define START_CHANGEOVER 100000u | 68 | #define START_CHANGEOVER 100000u |
| 72 | 69 | ||
| 73 | /** | 70 | /** |
| @@ -77,7 +74,6 @@ | |||
| 77 | * @addr_peer: network address of node at far end | 74 | * @addr_peer: network address of node at far end |
| 78 | * @if_peer: name of interface at far end | 75 | * @if_peer: name of interface at far end |
| 79 | */ | 76 | */ |
| 80 | |||
| 81 | struct tipc_link_name { | 77 | struct tipc_link_name { |
| 82 | u32 addr_local; | 78 | u32 addr_local; |
| 83 | char if_local[TIPC_MAX_IF_NAME]; | 79 | char if_local[TIPC_MAX_IF_NAME]; |
| @@ -105,7 +101,6 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf); | |||
| 105 | /* | 101 | /* |
| 106 | * Simple link routines | 102 | * Simple link routines |
| 107 | */ | 103 | */ |
| 108 | |||
| 109 | static unsigned int align(unsigned int i) | 104 | static unsigned int align(unsigned int i) |
| 110 | { | 105 | { |
| 111 | return (i + 3) & ~3u; | 106 | return (i + 3) & ~3u; |
| @@ -143,7 +138,6 @@ static u32 link_last_sent(struct tipc_link *l_ptr) | |||
| 143 | /* | 138 | /* |
| 144 | * Simple non-static link routines (i.e. referenced outside this file) | 139 | * Simple non-static link routines (i.e. referenced outside this file) |
| 145 | */ | 140 | */ |
| 146 | |||
| 147 | int tipc_link_is_up(struct tipc_link *l_ptr) | 141 | int tipc_link_is_up(struct tipc_link *l_ptr) |
| 148 | { | 142 | { |
| 149 | if (!l_ptr) | 143 | if (!l_ptr) |
| @@ -164,7 +158,6 @@ int tipc_link_is_active(struct tipc_link *l_ptr) | |||
| 164 | * | 158 | * |
| 165 | * Returns 1 if link name is valid, otherwise 0. | 159 | * Returns 1 if link name is valid, otherwise 0. |
| 166 | */ | 160 | */ |
| 167 | |||
| 168 | static int link_name_validate(const char *name, | 161 | static int link_name_validate(const char *name, |
| 169 | struct tipc_link_name *name_parts) | 162 | struct tipc_link_name *name_parts) |
| 170 | { | 163 | { |
| @@ -180,7 +173,6 @@ static int link_name_validate(const char *name, | |||
| 180 | u32 if_peer_len; | 173 | u32 if_peer_len; |
| 181 | 174 | ||
| 182 | /* copy link name & ensure length is OK */ | 175 | /* copy link name & ensure length is OK */ |
| 183 | |||
| 184 | name_copy[TIPC_MAX_LINK_NAME - 1] = 0; | 176 | name_copy[TIPC_MAX_LINK_NAME - 1] = 0; |
| 185 | /* need above in case non-Posix strncpy() doesn't pad with nulls */ | 177 | /* need above in case non-Posix strncpy() doesn't pad with nulls */ |
| 186 | strncpy(name_copy, name, TIPC_MAX_LINK_NAME); | 178 | strncpy(name_copy, name, TIPC_MAX_LINK_NAME); |
| @@ -188,7 +180,6 @@ static int link_name_validate(const char *name, | |||
| 188 | return 0; | 180 | return 0; |
| 189 | 181 | ||
| 190 | /* ensure all component parts of link name are present */ | 182 | /* ensure all component parts of link name are present */ |
| 191 | |||
| 192 | addr_local = name_copy; | 183 | addr_local = name_copy; |
| 193 | if_local = strchr(addr_local, ':'); | 184 | if_local = strchr(addr_local, ':'); |
| 194 | if (if_local == NULL) | 185 | if (if_local == NULL) |
| @@ -206,7 +197,6 @@ static int link_name_validate(const char *name, | |||
| 206 | if_peer_len = strlen(if_peer) + 1; | 197 | if_peer_len = strlen(if_peer) + 1; |
| 207 | 198 | ||
| 208 | /* validate component parts of link name */ | 199 | /* validate component parts of link name */ |
| 209 | |||
| 210 | if ((sscanf(addr_local, "%u.%u.%u%c", | 200 | if ((sscanf(addr_local, "%u.%u.%u%c", |
| 211 | &z_local, &c_local, &n_local, &dummy) != 3) || | 201 | &z_local, &c_local, &n_local, &dummy) != 3) || |
| 212 | (sscanf(addr_peer, "%u.%u.%u%c", | 202 | (sscanf(addr_peer, "%u.%u.%u%c", |
| @@ -220,7 +210,6 @@ static int link_name_validate(const char *name, | |||
| 220 | return 0; | 210 | return 0; |
| 221 | 211 | ||
| 222 | /* return link name components, if necessary */ | 212 | /* return link name components, if necessary */ |
| 223 | |||
| 224 | if (name_parts) { | 213 | if (name_parts) { |
| 225 | name_parts->addr_local = tipc_addr(z_local, c_local, n_local); | 214 | name_parts->addr_local = tipc_addr(z_local, c_local, n_local); |
| 226 | strcpy(name_parts->if_local, if_local); | 215 | strcpy(name_parts->if_local, if_local); |
| @@ -239,13 +228,11 @@ static int link_name_validate(const char *name, | |||
| 239 | * another thread because tipc_link_delete() always cancels the link timer before | 228 | * another thread because tipc_link_delete() always cancels the link timer before |
| 240 | * tipc_node_delete() is called.) | 229 | * tipc_node_delete() is called.) |
| 241 | */ | 230 | */ |
| 242 | |||
| 243 | static void link_timeout(struct tipc_link *l_ptr) | 231 | static void link_timeout(struct tipc_link *l_ptr) |
| 244 | { | 232 | { |
| 245 | tipc_node_lock(l_ptr->owner); | 233 | tipc_node_lock(l_ptr->owner); |
| 246 | 234 | ||
| 247 | /* update counters used in statistical profiling of send traffic */ | 235 | /* update counters used in statistical profiling of send traffic */ |
| 248 | |||
| 249 | l_ptr->stats.accu_queue_sz += l_ptr->out_queue_size; | 236 | l_ptr->stats.accu_queue_sz += l_ptr->out_queue_size; |
| 250 | l_ptr->stats.queue_sz_counts++; | 237 | l_ptr->stats.queue_sz_counts++; |
| 251 | 238 | ||
| @@ -278,7 +265,6 @@ static void link_timeout(struct tipc_link *l_ptr) | |||
| 278 | } | 265 | } |
| 279 | 266 | ||
| 280 | /* do all other link processing performed on a periodic basis */ | 267 | /* do all other link processing performed on a periodic basis */ |
| 281 | |||
| 282 | link_check_defragm_bufs(l_ptr); | 268 | link_check_defragm_bufs(l_ptr); |
| 283 | 269 | ||
| 284 | link_state_event(l_ptr, TIMEOUT_EVT); | 270 | link_state_event(l_ptr, TIMEOUT_EVT); |
| @@ -302,7 +288,6 @@ static void link_set_timer(struct tipc_link *l_ptr, u32 time) | |||
| 302 | * | 288 | * |
| 303 | * Returns pointer to link. | 289 | * Returns pointer to link. |
| 304 | */ | 290 | */ |
| 305 | |||
| 306 | struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | 291 | struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, |
| 307 | struct tipc_bearer *b_ptr, | 292 | struct tipc_bearer *b_ptr, |
| 308 | const struct tipc_media_addr *media_addr) | 293 | const struct tipc_media_addr *media_addr) |
| @@ -383,7 +368,6 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
| 383 | * This routine must not grab the node lock until after link timer cancellation | 368 | * This routine must not grab the node lock until after link timer cancellation |
| 384 | * to avoid a potential deadlock situation. | 369 | * to avoid a potential deadlock situation. |
| 385 | */ | 370 | */ |
| 386 | |||
| 387 | void tipc_link_delete(struct tipc_link *l_ptr) | 371 | void tipc_link_delete(struct tipc_link *l_ptr) |
| 388 | { | 372 | { |
| 389 | if (!l_ptr) { | 373 | if (!l_ptr) { |
| @@ -419,7 +403,6 @@ static void link_start(struct tipc_link *l_ptr) | |||
| 419 | * Schedules port for renewed sending of messages after link congestion | 403 | * Schedules port for renewed sending of messages after link congestion |
| 420 | * has abated. | 404 | * has abated. |
| 421 | */ | 405 | */ |
| 422 | |||
| 423 | static int link_schedule_port(struct tipc_link *l_ptr, u32 origport, u32 sz) | 406 | static int link_schedule_port(struct tipc_link *l_ptr, u32 origport, u32 sz) |
| 424 | { | 407 | { |
| 425 | struct tipc_port *p_ptr; | 408 | struct tipc_port *p_ptr; |
| @@ -476,7 +459,6 @@ exit: | |||
| 476 | * link_release_outqueue - purge link's outbound message queue | 459 | * link_release_outqueue - purge link's outbound message queue |
| 477 | * @l_ptr: pointer to link | 460 | * @l_ptr: pointer to link |
| 478 | */ | 461 | */ |
| 479 | |||
| 480 | static void link_release_outqueue(struct tipc_link *l_ptr) | 462 | static void link_release_outqueue(struct tipc_link *l_ptr) |
| 481 | { | 463 | { |
| 482 | struct sk_buff *buf = l_ptr->first_out; | 464 | struct sk_buff *buf = l_ptr->first_out; |
| @@ -495,7 +477,6 @@ static void link_release_outqueue(struct tipc_link *l_ptr) | |||
| 495 | * tipc_link_reset_fragments - purge link's inbound message fragments queue | 477 | * tipc_link_reset_fragments - purge link's inbound message fragments queue |
| 496 | * @l_ptr: pointer to link | 478 | * @l_ptr: pointer to link |
| 497 | */ | 479 | */ |
| 498 | |||
| 499 | void tipc_link_reset_fragments(struct tipc_link *l_ptr) | 480 | void tipc_link_reset_fragments(struct tipc_link *l_ptr) |
| 500 | { | 481 | { |
| 501 | struct sk_buff *buf = l_ptr->defragm_buf; | 482 | struct sk_buff *buf = l_ptr->defragm_buf; |
| @@ -513,7 +494,6 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr) | |||
| 513 | * tipc_link_stop - purge all inbound and outbound messages associated with link | 494 | * tipc_link_stop - purge all inbound and outbound messages associated with link |
| 514 | * @l_ptr: pointer to link | 495 | * @l_ptr: pointer to link |
| 515 | */ | 496 | */ |
| 516 | |||
| 517 | void tipc_link_stop(struct tipc_link *l_ptr) | 497 | void tipc_link_stop(struct tipc_link *l_ptr) |
| 518 | { | 498 | { |
| 519 | struct sk_buff *buf; | 499 | struct sk_buff *buf; |
| @@ -569,7 +549,6 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
| 569 | } | 549 | } |
| 570 | 550 | ||
| 571 | /* Clean up all queues: */ | 551 | /* Clean up all queues: */ |
| 572 | |||
| 573 | link_release_outqueue(l_ptr); | 552 | link_release_outqueue(l_ptr); |
| 574 | kfree_skb(l_ptr->proto_msg_queue); | 553 | kfree_skb(l_ptr->proto_msg_queue); |
| 575 | l_ptr->proto_msg_queue = NULL; | 554 | l_ptr->proto_msg_queue = NULL; |
| @@ -611,8 +590,7 @@ static void link_activate(struct tipc_link *l_ptr) | |||
| 611 | * @l_ptr: pointer to link | 590 | * @l_ptr: pointer to link |
| 612 | * @event: state machine event to process | 591 | * @event: state machine event to process |
| 613 | */ | 592 | */ |
| 614 | 593 | static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |
| 615 | static void link_state_event(struct tipc_link *l_ptr, unsigned event) | ||
| 616 | { | 594 | { |
| 617 | struct tipc_link *other; | 595 | struct tipc_link *other; |
| 618 | u32 cont_intv = l_ptr->continuity_interval; | 596 | u32 cont_intv = l_ptr->continuity_interval; |
| @@ -785,7 +763,6 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned event) | |||
| 785 | * link_bundle_buf(): Append contents of a buffer to | 763 | * link_bundle_buf(): Append contents of a buffer to |
| 786 | * the tail of an existing one. | 764 | * the tail of an existing one. |
| 787 | */ | 765 | */ |
| 788 | |||
| 789 | static int link_bundle_buf(struct tipc_link *l_ptr, | 766 | static int link_bundle_buf(struct tipc_link *l_ptr, |
| 790 | struct sk_buff *bundler, | 767 | struct sk_buff *bundler, |
| 791 | struct sk_buff *buf) | 768 | struct sk_buff *buf) |
| @@ -860,7 +837,6 @@ static void link_add_chain_to_outqueue(struct tipc_link *l_ptr, | |||
| 860 | * inside TIPC when the 'fast path' in tipc_send_buf | 837 | * inside TIPC when the 'fast path' in tipc_send_buf |
| 861 | * has failed, and from link_send() | 838 | * has failed, and from link_send() |
| 862 | */ | 839 | */ |
| 863 | |||
| 864 | int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | 840 | int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) |
| 865 | { | 841 | { |
| 866 | struct tipc_msg *msg = buf_msg(buf); | 842 | struct tipc_msg *msg = buf_msg(buf); |
| @@ -872,7 +848,6 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 872 | u32 max_packet = l_ptr->max_pkt; | 848 | u32 max_packet = l_ptr->max_pkt; |
| 873 | 849 | ||
| 874 | /* Match msg importance against queue limits: */ | 850 | /* Match msg importance against queue limits: */ |
| 875 | |||
| 876 | if (unlikely(queue_size >= queue_limit)) { | 851 | if (unlikely(queue_size >= queue_limit)) { |
| 877 | if (imp <= TIPC_CRITICAL_IMPORTANCE) { | 852 | if (imp <= TIPC_CRITICAL_IMPORTANCE) { |
| 878 | link_schedule_port(l_ptr, msg_origport(msg), size); | 853 | link_schedule_port(l_ptr, msg_origport(msg), size); |
| @@ -888,12 +863,10 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 888 | } | 863 | } |
| 889 | 864 | ||
| 890 | /* Fragmentation needed ? */ | 865 | /* Fragmentation needed ? */ |
| 891 | |||
| 892 | if (size > max_packet) | 866 | if (size > max_packet) |
| 893 | return link_send_long_buf(l_ptr, buf); | 867 | return link_send_long_buf(l_ptr, buf); |
| 894 | 868 | ||
| 895 | /* Packet can be queued or sent: */ | 869 | /* Packet can be queued or sent. */ |
| 896 | |||
| 897 | if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) && | 870 | if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) && |
| 898 | !link_congested(l_ptr))) { | 871 | !link_congested(l_ptr))) { |
| 899 | link_add_to_outqueue(l_ptr, buf, msg); | 872 | link_add_to_outqueue(l_ptr, buf, msg); |
| @@ -907,13 +880,11 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 907 | } | 880 | } |
| 908 | return dsz; | 881 | return dsz; |
| 909 | } | 882 | } |
| 910 | /* Congestion: can message be bundled ?: */ | 883 | /* Congestion: can message be bundled ? */ |
| 911 | |||
| 912 | if ((msg_user(msg) != CHANGEOVER_PROTOCOL) && | 884 | if ((msg_user(msg) != CHANGEOVER_PROTOCOL) && |
| 913 | (msg_user(msg) != MSG_FRAGMENTER)) { | 885 | (msg_user(msg) != MSG_FRAGMENTER)) { |
| 914 | 886 | ||
| 915 | /* Try adding message to an existing bundle */ | 887 | /* Try adding message to an existing bundle */ |
| 916 | |||
| 917 | if (l_ptr->next_out && | 888 | if (l_ptr->next_out && |
| 918 | link_bundle_buf(l_ptr, l_ptr->last_out, buf)) { | 889 | link_bundle_buf(l_ptr, l_ptr->last_out, buf)) { |
| 919 | tipc_bearer_resolve_congestion(l_ptr->b_ptr, l_ptr); | 890 | tipc_bearer_resolve_congestion(l_ptr->b_ptr, l_ptr); |
| @@ -921,7 +892,6 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 921 | } | 892 | } |
| 922 | 893 | ||
| 923 | /* Try creating a new bundle */ | 894 | /* Try creating a new bundle */ |
| 924 | |||
| 925 | if (size <= max_packet * 2 / 3) { | 895 | if (size <= max_packet * 2 / 3) { |
| 926 | struct sk_buff *bundler = tipc_buf_acquire(max_packet); | 896 | struct sk_buff *bundler = tipc_buf_acquire(max_packet); |
| 927 | struct tipc_msg bundler_hdr; | 897 | struct tipc_msg bundler_hdr; |
| @@ -951,7 +921,6 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 951 | * not been selected yet, and the the owner node is not locked | 921 | * not been selected yet, and the the owner node is not locked |
| 952 | * Called by TIPC internal users, e.g. the name distributor | 922 | * Called by TIPC internal users, e.g. the name distributor |
| 953 | */ | 923 | */ |
| 954 | |||
| 955 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | 924 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) |
| 956 | { | 925 | { |
| 957 | struct tipc_link *l_ptr; | 926 | struct tipc_link *l_ptr; |
| @@ -984,7 +953,6 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | |||
| 984 | * small enough not to require fragmentation. | 953 | * small enough not to require fragmentation. |
| 985 | * Called without any locks held. | 954 | * Called without any locks held. |
| 986 | */ | 955 | */ |
| 987 | |||
| 988 | void tipc_link_send_names(struct list_head *message_list, u32 dest) | 956 | void tipc_link_send_names(struct list_head *message_list, u32 dest) |
| 989 | { | 957 | { |
| 990 | struct tipc_node *n_ptr; | 958 | struct tipc_node *n_ptr; |
| @@ -1013,7 +981,6 @@ void tipc_link_send_names(struct list_head *message_list, u32 dest) | |||
| 1013 | read_unlock_bh(&tipc_net_lock); | 981 | read_unlock_bh(&tipc_net_lock); |
| 1014 | 982 | ||
| 1015 | /* discard the messages if they couldn't be sent */ | 983 | /* discard the messages if they couldn't be sent */ |
| 1016 | |||
| 1017 | list_for_each_safe(buf, temp_buf, ((struct sk_buff *)message_list)) { | 984 | list_for_each_safe(buf, temp_buf, ((struct sk_buff *)message_list)) { |
| 1018 | list_del((struct list_head *)buf); | 985 | list_del((struct list_head *)buf); |
| 1019 | kfree_skb(buf); | 986 | kfree_skb(buf); |
| @@ -1026,7 +993,6 @@ void tipc_link_send_names(struct list_head *message_list, u32 dest) | |||
| 1026 | * inclusive total message length. Very time critical. | 993 | * inclusive total message length. Very time critical. |
| 1027 | * Link is locked. Returns user data length. | 994 | * Link is locked. Returns user data length. |
| 1028 | */ | 995 | */ |
| 1029 | |||
| 1030 | static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, | 996 | static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, |
| 1031 | u32 *used_max_pkt) | 997 | u32 *used_max_pkt) |
| 1032 | { | 998 | { |
| @@ -1111,7 +1077,6 @@ again: | |||
| 1111 | * Try building message using port's max_pkt hint. | 1077 | * Try building message using port's max_pkt hint. |
| 1112 | * (Must not hold any locks while building message.) | 1078 | * (Must not hold any locks while building message.) |
| 1113 | */ | 1079 | */ |
| 1114 | |||
| 1115 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, | 1080 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, |
| 1116 | sender->max_pkt, !sender->user_port, &buf); | 1081 | sender->max_pkt, !sender->user_port, &buf); |
| 1117 | 1082 | ||
| @@ -1131,12 +1096,10 @@ exit: | |||
| 1131 | } | 1096 | } |
| 1132 | 1097 | ||
| 1133 | /* Exit if build request was invalid */ | 1098 | /* Exit if build request was invalid */ |
| 1134 | |||
| 1135 | if (unlikely(res < 0)) | 1099 | if (unlikely(res < 0)) |
| 1136 | goto exit; | 1100 | goto exit; |
| 1137 | 1101 | ||
| 1138 | /* Exit if link (or bearer) is congested */ | 1102 | /* Exit if link (or bearer) is congested */ |
| 1139 | |||
| 1140 | if (link_congested(l_ptr) || | 1103 | if (link_congested(l_ptr) || |
| 1141 | !list_empty(&l_ptr->b_ptr->cong_links)) { | 1104 | !list_empty(&l_ptr->b_ptr->cong_links)) { |
| 1142 | res = link_schedule_port(l_ptr, | 1105 | res = link_schedule_port(l_ptr, |
| @@ -1148,7 +1111,6 @@ exit: | |||
| 1148 | * Message size exceeds max_pkt hint; update hint, | 1111 | * Message size exceeds max_pkt hint; update hint, |
| 1149 | * then re-try fast path or fragment the message | 1112 | * then re-try fast path or fragment the message |
| 1150 | */ | 1113 | */ |
| 1151 | |||
| 1152 | sender->max_pkt = l_ptr->max_pkt; | 1114 | sender->max_pkt = l_ptr->max_pkt; |
| 1153 | tipc_node_unlock(node); | 1115 | tipc_node_unlock(node); |
| 1154 | read_unlock_bh(&tipc_net_lock); | 1116 | read_unlock_bh(&tipc_net_lock); |
| @@ -1166,7 +1128,6 @@ exit: | |||
| 1166 | read_unlock_bh(&tipc_net_lock); | 1128 | read_unlock_bh(&tipc_net_lock); |
| 1167 | 1129 | ||
| 1168 | /* Couldn't find a link to the destination node */ | 1130 | /* Couldn't find a link to the destination node */ |
| 1169 | |||
| 1170 | if (buf) | 1131 | if (buf) |
| 1171 | return tipc_reject_msg(buf, TIPC_ERR_NO_NODE); | 1132 | return tipc_reject_msg(buf, TIPC_ERR_NO_NODE); |
| 1172 | if (res >= 0) | 1133 | if (res >= 0) |
| @@ -1220,15 +1181,13 @@ again: | |||
| 1220 | sect_crs = NULL; | 1181 | sect_crs = NULL; |
| 1221 | curr_sect = -1; | 1182 | curr_sect = -1; |
| 1222 | 1183 | ||
| 1223 | /* Prepare reusable fragment header: */ | 1184 | /* Prepare reusable fragment header */ |
| 1224 | |||
| 1225 | tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, | 1185 | tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, |
| 1226 | INT_H_SIZE, msg_destnode(hdr)); | 1186 | INT_H_SIZE, msg_destnode(hdr)); |
| 1227 | msg_set_size(&fragm_hdr, max_pkt); | 1187 | msg_set_size(&fragm_hdr, max_pkt); |
| 1228 | msg_set_fragm_no(&fragm_hdr, 1); | 1188 | msg_set_fragm_no(&fragm_hdr, 1); |
| 1229 | 1189 | ||
| 1230 | /* Prepare header of first fragment: */ | 1190 | /* Prepare header of first fragment */ |
| 1231 | |||
| 1232 | buf_chain = buf = tipc_buf_acquire(max_pkt); | 1191 | buf_chain = buf = tipc_buf_acquire(max_pkt); |
| 1233 | if (!buf) | 1192 | if (!buf) |
| 1234 | return -ENOMEM; | 1193 | return -ENOMEM; |
| @@ -1237,8 +1196,7 @@ again: | |||
| 1237 | hsz = msg_hdr_sz(hdr); | 1196 | hsz = msg_hdr_sz(hdr); |
| 1238 | skb_copy_to_linear_data_offset(buf, INT_H_SIZE, hdr, hsz); | 1197 | skb_copy_to_linear_data_offset(buf, INT_H_SIZE, hdr, hsz); |
| 1239 | 1198 | ||
| 1240 | /* Chop up message: */ | 1199 | /* Chop up message */ |
| 1241 | |||
| 1242 | fragm_crs = INT_H_SIZE + hsz; | 1200 | fragm_crs = INT_H_SIZE + hsz; |
| 1243 | fragm_rest = fragm_sz - hsz; | 1201 | fragm_rest = fragm_sz - hsz; |
| 1244 | 1202 | ||
| @@ -1329,7 +1287,6 @@ reject: | |||
| 1329 | } | 1287 | } |
| 1330 | 1288 | ||
| 1331 | /* Append chain of fragments to send queue & send them */ | 1289 | /* Append chain of fragments to send queue & send them */ |
| 1332 | |||
| 1333 | l_ptr->long_msg_seq_no++; | 1290 | l_ptr->long_msg_seq_no++; |
| 1334 | link_add_chain_to_outqueue(l_ptr, buf_chain, l_ptr->long_msg_seq_no); | 1291 | link_add_chain_to_outqueue(l_ptr, buf_chain, l_ptr->long_msg_seq_no); |
| 1335 | l_ptr->stats.sent_fragments += fragm_no; | 1292 | l_ptr->stats.sent_fragments += fragm_no; |
| @@ -1350,7 +1307,6 @@ u32 tipc_link_push_packet(struct tipc_link *l_ptr) | |||
| 1350 | 1307 | ||
| 1351 | /* Step to position where retransmission failed, if any, */ | 1308 | /* Step to position where retransmission failed, if any, */ |
| 1352 | /* consider that buffers may have been released in meantime */ | 1309 | /* consider that buffers may have been released in meantime */ |
| 1353 | |||
| 1354 | if (r_q_size && buf) { | 1310 | if (r_q_size && buf) { |
| 1355 | u32 last = lesser(mod(r_q_head + r_q_size), | 1311 | u32 last = lesser(mod(r_q_head + r_q_size), |
| 1356 | link_last_sent(l_ptr)); | 1312 | link_last_sent(l_ptr)); |
| @@ -1365,7 +1321,6 @@ u32 tipc_link_push_packet(struct tipc_link *l_ptr) | |||
| 1365 | } | 1321 | } |
| 1366 | 1322 | ||
| 1367 | /* Continue retransmission now, if there is anything: */ | 1323 | /* Continue retransmission now, if there is anything: */ |
| 1368 | |||
| 1369 | if (r_q_size && buf) { | 1324 | if (r_q_size && buf) { |
| 1370 | msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); | 1325 | msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); |
| 1371 | msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); | 1326 | msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); |
| @@ -1381,7 +1336,6 @@ u32 tipc_link_push_packet(struct tipc_link *l_ptr) | |||
| 1381 | } | 1336 | } |
| 1382 | 1337 | ||
| 1383 | /* Send deferred protocol message, if any: */ | 1338 | /* Send deferred protocol message, if any: */ |
| 1384 | |||
| 1385 | buf = l_ptr->proto_msg_queue; | 1339 | buf = l_ptr->proto_msg_queue; |
| 1386 | if (buf) { | 1340 | if (buf) { |
| 1387 | msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); | 1341 | msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); |
| @@ -1398,7 +1352,6 @@ u32 tipc_link_push_packet(struct tipc_link *l_ptr) | |||
| 1398 | } | 1352 | } |
| 1399 | 1353 | ||
| 1400 | /* Send one deferred data message, if send window not full: */ | 1354 | /* Send one deferred data message, if send window not full: */ |
| 1401 | |||
| 1402 | buf = l_ptr->next_out; | 1355 | buf = l_ptr->next_out; |
| 1403 | if (buf) { | 1356 | if (buf) { |
| 1404 | struct tipc_msg *msg = buf_msg(buf); | 1357 | struct tipc_msg *msg = buf_msg(buf); |
| @@ -1478,16 +1431,12 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, | |||
| 1478 | warn("Retransmission failure on link <%s>\n", l_ptr->name); | 1431 | warn("Retransmission failure on link <%s>\n", l_ptr->name); |
| 1479 | 1432 | ||
| 1480 | if (l_ptr->addr) { | 1433 | if (l_ptr->addr) { |
| 1481 | |||
| 1482 | /* Handle failure on standard link */ | 1434 | /* Handle failure on standard link */ |
| 1483 | |||
| 1484 | link_print(l_ptr, "Resetting link\n"); | 1435 | link_print(l_ptr, "Resetting link\n"); |
| 1485 | tipc_link_reset(l_ptr); | 1436 | tipc_link_reset(l_ptr); |
| 1486 | 1437 | ||
| 1487 | } else { | 1438 | } else { |
| 1488 | |||
| 1489 | /* Handle failure on broadcast link */ | 1439 | /* Handle failure on broadcast link */ |
| 1490 | |||
| 1491 | struct tipc_node *n_ptr; | 1440 | struct tipc_node *n_ptr; |
| 1492 | char addr_string[16]; | 1441 | char addr_string[16]; |
| 1493 | 1442 | ||
| @@ -1536,7 +1485,6 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *buf, | |||
| 1536 | return; | 1485 | return; |
| 1537 | } else { | 1486 | } else { |
| 1538 | /* Detect repeated retransmit failures on uncongested bearer */ | 1487 | /* Detect repeated retransmit failures on uncongested bearer */ |
| 1539 | |||
| 1540 | if (l_ptr->last_retransmitted == msg_seqno(msg)) { | 1488 | if (l_ptr->last_retransmitted == msg_seqno(msg)) { |
| 1541 | if (++l_ptr->stale_count > 100) { | 1489 | if (++l_ptr->stale_count > 100) { |
| 1542 | link_retransmit_failure(l_ptr, buf); | 1490 | link_retransmit_failure(l_ptr, buf); |
| @@ -1571,7 +1519,6 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *buf, | |||
| 1571 | /** | 1519 | /** |
| 1572 | * link_insert_deferred_queue - insert deferred messages back into receive chain | 1520 | * link_insert_deferred_queue - insert deferred messages back into receive chain |
| 1573 | */ | 1521 | */ |
| 1574 | |||
| 1575 | static struct sk_buff *link_insert_deferred_queue(struct tipc_link *l_ptr, | 1522 | static struct sk_buff *link_insert_deferred_queue(struct tipc_link *l_ptr, |
| 1576 | struct sk_buff *buf) | 1523 | struct sk_buff *buf) |
| 1577 | { | 1524 | { |
| @@ -1602,7 +1549,6 @@ static struct sk_buff *link_insert_deferred_queue(struct tipc_link *l_ptr, | |||
| 1602 | * TIPC will ignore the excess, under the assumption that it is optional info | 1549 | * TIPC will ignore the excess, under the assumption that it is optional info |
| 1603 | * introduced by a later release of the protocol. | 1550 | * introduced by a later release of the protocol. |
| 1604 | */ | 1551 | */ |
| 1605 | |||
| 1606 | static int link_recv_buf_validate(struct sk_buff *buf) | 1552 | static int link_recv_buf_validate(struct sk_buff *buf) |
| 1607 | { | 1553 | { |
| 1608 | static u32 min_data_hdr_size[8] = { | 1554 | static u32 min_data_hdr_size[8] = { |
| @@ -1648,7 +1594,6 @@ static int link_recv_buf_validate(struct sk_buff *buf) | |||
| 1648 | * Invoked with no locks held. Bearer pointer must point to a valid bearer | 1594 | * Invoked with no locks held. Bearer pointer must point to a valid bearer |
| 1649 | * structure (i.e. cannot be NULL), but bearer can be inactive. | 1595 | * structure (i.e. cannot be NULL), but bearer can be inactive. |
| 1650 | */ | 1596 | */ |
| 1651 | |||
| 1652 | void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | 1597 | void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) |
| 1653 | { | 1598 | { |
| 1654 | read_lock_bh(&tipc_net_lock); | 1599 | read_lock_bh(&tipc_net_lock); |
| @@ -1666,22 +1611,18 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1666 | head = head->next; | 1611 | head = head->next; |
| 1667 | 1612 | ||
| 1668 | /* Ensure bearer is still enabled */ | 1613 | /* Ensure bearer is still enabled */ |
| 1669 | |||
| 1670 | if (unlikely(!b_ptr->active)) | 1614 | if (unlikely(!b_ptr->active)) |
| 1671 | goto cont; | 1615 | goto cont; |
| 1672 | 1616 | ||
| 1673 | /* Ensure message is well-formed */ | 1617 | /* Ensure message is well-formed */ |
| 1674 | |||
| 1675 | if (unlikely(!link_recv_buf_validate(buf))) | 1618 | if (unlikely(!link_recv_buf_validate(buf))) |
| 1676 | goto cont; | 1619 | goto cont; |
| 1677 | 1620 | ||
| 1678 | /* Ensure message data is a single contiguous unit */ | 1621 | /* Ensure message data is a single contiguous unit */ |
| 1679 | |||
| 1680 | if (unlikely(skb_linearize(buf))) | 1622 | if (unlikely(skb_linearize(buf))) |
| 1681 | goto cont; | 1623 | goto cont; |
| 1682 | 1624 | ||
| 1683 | /* Handle arrival of a non-unicast link message */ | 1625 | /* Handle arrival of a non-unicast link message */ |
| 1684 | |||
| 1685 | msg = buf_msg(buf); | 1626 | msg = buf_msg(buf); |
| 1686 | 1627 | ||
| 1687 | if (unlikely(msg_non_seq(msg))) { | 1628 | if (unlikely(msg_non_seq(msg))) { |
| @@ -1693,20 +1634,17 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1693 | } | 1634 | } |
| 1694 | 1635 | ||
| 1695 | /* Discard unicast link messages destined for another node */ | 1636 | /* Discard unicast link messages destined for another node */ |
| 1696 | |||
| 1697 | if (unlikely(!msg_short(msg) && | 1637 | if (unlikely(!msg_short(msg) && |
| 1698 | (msg_destnode(msg) != tipc_own_addr))) | 1638 | (msg_destnode(msg) != tipc_own_addr))) |
| 1699 | goto cont; | 1639 | goto cont; |
| 1700 | 1640 | ||
| 1701 | /* Locate neighboring node that sent message */ | 1641 | /* Locate neighboring node that sent message */ |
| 1702 | |||
| 1703 | n_ptr = tipc_node_find(msg_prevnode(msg)); | 1642 | n_ptr = tipc_node_find(msg_prevnode(msg)); |
| 1704 | if (unlikely(!n_ptr)) | 1643 | if (unlikely(!n_ptr)) |
| 1705 | goto cont; | 1644 | goto cont; |
| 1706 | tipc_node_lock(n_ptr); | 1645 | tipc_node_lock(n_ptr); |
| 1707 | 1646 | ||
| 1708 | /* Locate unicast link endpoint that should handle message */ | 1647 | /* Locate unicast link endpoint that should handle message */ |
| 1709 | |||
| 1710 | l_ptr = n_ptr->links[b_ptr->identity]; | 1648 | l_ptr = n_ptr->links[b_ptr->identity]; |
| 1711 | if (unlikely(!l_ptr)) { | 1649 | if (unlikely(!l_ptr)) { |
| 1712 | tipc_node_unlock(n_ptr); | 1650 | tipc_node_unlock(n_ptr); |
| @@ -1714,7 +1652,6 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1714 | } | 1652 | } |
| 1715 | 1653 | ||
| 1716 | /* Verify that communication with node is currently allowed */ | 1654 | /* Verify that communication with node is currently allowed */ |
| 1717 | |||
| 1718 | if ((n_ptr->block_setup & WAIT_PEER_DOWN) && | 1655 | if ((n_ptr->block_setup & WAIT_PEER_DOWN) && |
| 1719 | msg_user(msg) == LINK_PROTOCOL && | 1656 | msg_user(msg) == LINK_PROTOCOL && |
| 1720 | (msg_type(msg) == RESET_MSG || | 1657 | (msg_type(msg) == RESET_MSG || |
| @@ -1728,12 +1665,10 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1728 | } | 1665 | } |
| 1729 | 1666 | ||
| 1730 | /* Validate message sequence number info */ | 1667 | /* Validate message sequence number info */ |
| 1731 | |||
| 1732 | seq_no = msg_seqno(msg); | 1668 | seq_no = msg_seqno(msg); |
| 1733 | ackd = msg_ack(msg); | 1669 | ackd = msg_ack(msg); |
| 1734 | 1670 | ||
| 1735 | /* Release acked messages */ | 1671 | /* Release acked messages */ |
| 1736 | |||
| 1737 | if (n_ptr->bclink.supported) | 1672 | if (n_ptr->bclink.supported) |
| 1738 | tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg)); | 1673 | tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg)); |
| 1739 | 1674 | ||
| @@ -1752,7 +1687,6 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1752 | } | 1687 | } |
| 1753 | 1688 | ||
| 1754 | /* Try sending any messages link endpoint has pending */ | 1689 | /* Try sending any messages link endpoint has pending */ |
| 1755 | |||
| 1756 | if (unlikely(l_ptr->next_out)) | 1690 | if (unlikely(l_ptr->next_out)) |
| 1757 | tipc_link_push_queue(l_ptr); | 1691 | tipc_link_push_queue(l_ptr); |
| 1758 | if (unlikely(!list_empty(&l_ptr->waiting_ports))) | 1692 | if (unlikely(!list_empty(&l_ptr->waiting_ports))) |
| @@ -1763,7 +1697,6 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1763 | } | 1697 | } |
| 1764 | 1698 | ||
| 1765 | /* Now (finally!) process the incoming message */ | 1699 | /* Now (finally!) process the incoming message */ |
| 1766 | |||
| 1767 | protocol_check: | 1700 | protocol_check: |
| 1768 | if (likely(link_working_working(l_ptr))) { | 1701 | if (likely(link_working_working(l_ptr))) { |
| 1769 | if (likely(seq_no == mod(l_ptr->next_in_no))) { | 1702 | if (likely(seq_no == mod(l_ptr->next_in_no))) { |
| @@ -1859,7 +1792,6 @@ cont: | |||
| 1859 | * | 1792 | * |
| 1860 | * Returns increase in queue length (i.e. 0 or 1) | 1793 | * Returns increase in queue length (i.e. 0 or 1) |
| 1861 | */ | 1794 | */ |
| 1862 | |||
| 1863 | u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail, | 1795 | u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail, |
| 1864 | struct sk_buff *buf) | 1796 | struct sk_buff *buf) |
| 1865 | { | 1797 | { |
| @@ -1908,7 +1840,6 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail, | |||
| 1908 | /* | 1840 | /* |
| 1909 | * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet | 1841 | * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet |
| 1910 | */ | 1842 | */ |
| 1911 | |||
| 1912 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | 1843 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, |
| 1913 | struct sk_buff *buf) | 1844 | struct sk_buff *buf) |
| 1914 | { | 1845 | { |
| @@ -1920,14 +1851,12 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | |||
| 1920 | } | 1851 | } |
| 1921 | 1852 | ||
| 1922 | /* Record OOS packet arrival (force mismatch on next timeout) */ | 1853 | /* Record OOS packet arrival (force mismatch on next timeout) */ |
| 1923 | |||
| 1924 | l_ptr->checkpoint--; | 1854 | l_ptr->checkpoint--; |
| 1925 | 1855 | ||
| 1926 | /* | 1856 | /* |
| 1927 | * Discard packet if a duplicate; otherwise add it to deferred queue | 1857 | * Discard packet if a duplicate; otherwise add it to deferred queue |
| 1928 | * and notify peer of gap as per protocol specification | 1858 | * and notify peer of gap as per protocol specification |
| 1929 | */ | 1859 | */ |
| 1930 | |||
| 1931 | if (less(seq_no, mod(l_ptr->next_in_no))) { | 1860 | if (less(seq_no, mod(l_ptr->next_in_no))) { |
| 1932 | l_ptr->stats.duplicates++; | 1861 | l_ptr->stats.duplicates++; |
| 1933 | kfree_skb(buf); | 1862 | kfree_skb(buf); |
| @@ -1957,7 +1886,6 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 1957 | int r_flag; | 1886 | int r_flag; |
| 1958 | 1887 | ||
| 1959 | /* Discard any previous message that was deferred due to congestion */ | 1888 | /* Discard any previous message that was deferred due to congestion */ |
| 1960 | |||
| 1961 | if (l_ptr->proto_msg_queue) { | 1889 | if (l_ptr->proto_msg_queue) { |
| 1962 | kfree_skb(l_ptr->proto_msg_queue); | 1890 | kfree_skb(l_ptr->proto_msg_queue); |
| 1963 | l_ptr->proto_msg_queue = NULL; | 1891 | l_ptr->proto_msg_queue = NULL; |
| @@ -1967,12 +1895,10 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 1967 | return; | 1895 | return; |
| 1968 | 1896 | ||
| 1969 | /* Abort non-RESET send if communication with node is prohibited */ | 1897 | /* Abort non-RESET send if communication with node is prohibited */ |
| 1970 | |||
| 1971 | if ((l_ptr->owner->block_setup) && (msg_typ != RESET_MSG)) | 1898 | if ((l_ptr->owner->block_setup) && (msg_typ != RESET_MSG)) |
| 1972 | return; | 1899 | return; |
| 1973 | 1900 | ||
| 1974 | /* Create protocol message with "out-of-sequence" sequence number */ | 1901 | /* Create protocol message with "out-of-sequence" sequence number */ |
| 1975 | |||
| 1976 | msg_set_type(msg, msg_typ); | 1902 | msg_set_type(msg, msg_typ); |
| 1977 | msg_set_net_plane(msg, l_ptr->b_ptr->net_plane); | 1903 | msg_set_net_plane(msg, l_ptr->b_ptr->net_plane); |
| 1978 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 1904 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
| @@ -2040,14 +1966,12 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 2040 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); | 1966 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); |
| 2041 | 1967 | ||
| 2042 | /* Defer message if bearer is already congested */ | 1968 | /* Defer message if bearer is already congested */ |
| 2043 | |||
| 2044 | if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { | 1969 | if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { |
| 2045 | l_ptr->proto_msg_queue = buf; | 1970 | l_ptr->proto_msg_queue = buf; |
| 2046 | return; | 1971 | return; |
| 2047 | } | 1972 | } |
| 2048 | 1973 | ||
| 2049 | /* Defer message if attempting to send results in bearer congestion */ | 1974 | /* Defer message if attempting to send results in bearer congestion */ |
| 2050 | |||
| 2051 | if (!tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { | 1975 | if (!tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { |
| 2052 | tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); | 1976 | tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); |
| 2053 | l_ptr->proto_msg_queue = buf; | 1977 | l_ptr->proto_msg_queue = buf; |
| @@ -2056,7 +1980,6 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 2056 | } | 1980 | } |
| 2057 | 1981 | ||
| 2058 | /* Discard message if it was sent successfully */ | 1982 | /* Discard message if it was sent successfully */ |
| 2059 | |||
| 2060 | l_ptr->unacked_window = 0; | 1983 | l_ptr->unacked_window = 0; |
| 2061 | kfree_skb(buf); | 1984 | kfree_skb(buf); |
| 2062 | } | 1985 | } |
| @@ -2066,7 +1989,6 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 2066 | * Note that network plane id propagates through the network, and may | 1989 | * Note that network plane id propagates through the network, and may |
| 2067 | * change at any time. The node with lowest address rules | 1990 | * change at any time. The node with lowest address rules |
| 2068 | */ | 1991 | */ |
| 2069 | |||
| 2070 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | 1992 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) |
| 2071 | { | 1993 | { |
| 2072 | u32 rec_gap = 0; | 1994 | u32 rec_gap = 0; |
| @@ -2079,7 +2001,6 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2079 | goto exit; | 2001 | goto exit; |
| 2080 | 2002 | ||
| 2081 | /* record unnumbered packet arrival (force mismatch on next timeout) */ | 2003 | /* record unnumbered packet arrival (force mismatch on next timeout) */ |
| 2082 | |||
| 2083 | l_ptr->checkpoint--; | 2004 | l_ptr->checkpoint--; |
| 2084 | 2005 | ||
| 2085 | if (l_ptr->b_ptr->net_plane != msg_net_plane(msg)) | 2006 | if (l_ptr->b_ptr->net_plane != msg_net_plane(msg)) |
| @@ -2111,7 +2032,6 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2111 | /* fall thru' */ | 2032 | /* fall thru' */ |
| 2112 | case ACTIVATE_MSG: | 2033 | case ACTIVATE_MSG: |
| 2113 | /* Update link settings according other endpoint's values */ | 2034 | /* Update link settings according other endpoint's values */ |
| 2114 | |||
| 2115 | strcpy((strrchr(l_ptr->name, ':') + 1), (char *)msg_data(msg)); | 2035 | strcpy((strrchr(l_ptr->name, ':') + 1), (char *)msg_data(msg)); |
| 2116 | 2036 | ||
| 2117 | msg_tol = msg_link_tolerance(msg); | 2037 | msg_tol = msg_link_tolerance(msg); |
| @@ -2133,7 +2053,6 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2133 | l_ptr->owner->bclink.supportable = (max_pkt_info != 0); | 2053 | l_ptr->owner->bclink.supportable = (max_pkt_info != 0); |
| 2134 | 2054 | ||
| 2135 | /* Synchronize broadcast link info, if not done previously */ | 2055 | /* Synchronize broadcast link info, if not done previously */ |
| 2136 | |||
| 2137 | if (!tipc_node_is_up(l_ptr->owner)) { | 2056 | if (!tipc_node_is_up(l_ptr->owner)) { |
| 2138 | l_ptr->owner->bclink.last_sent = | 2057 | l_ptr->owner->bclink.last_sent = |
| 2139 | l_ptr->owner->bclink.last_in = | 2058 | l_ptr->owner->bclink.last_in = |
| @@ -2185,7 +2104,6 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2185 | } | 2104 | } |
| 2186 | 2105 | ||
| 2187 | /* Protocol message before retransmits, reduce loss risk */ | 2106 | /* Protocol message before retransmits, reduce loss risk */ |
| 2188 | |||
| 2189 | if (l_ptr->owner->bclink.supported) | 2107 | if (l_ptr->owner->bclink.supported) |
| 2190 | tipc_bclink_update_link_state(l_ptr->owner, | 2108 | tipc_bclink_update_link_state(l_ptr->owner, |
| 2191 | msg_last_bcast(msg)); | 2109 | msg_last_bcast(msg)); |
| @@ -2243,7 +2161,6 @@ static void tipc_link_tunnel(struct tipc_link *l_ptr, | |||
| 2243 | * changeover(): Send whole message queue via the remaining link | 2161 | * changeover(): Send whole message queue via the remaining link |
| 2244 | * Owner node is locked. | 2162 | * Owner node is locked. |
| 2245 | */ | 2163 | */ |
| 2246 | |||
| 2247 | void tipc_link_changeover(struct tipc_link *l_ptr) | 2164 | void tipc_link_changeover(struct tipc_link *l_ptr) |
| 2248 | { | 2165 | { |
| 2249 | u32 msgcount = l_ptr->out_queue_size; | 2166 | u32 msgcount = l_ptr->out_queue_size; |
| @@ -2343,8 +2260,6 @@ void tipc_link_send_duplicate(struct tipc_link *l_ptr, struct tipc_link *tunnel) | |||
| 2343 | } | 2260 | } |
| 2344 | } | 2261 | } |
| 2345 | 2262 | ||
| 2346 | |||
| 2347 | |||
| 2348 | /** | 2263 | /** |
| 2349 | * buf_extract - extracts embedded TIPC message from another message | 2264 | * buf_extract - extracts embedded TIPC message from another message |
| 2350 | * @skb: encapsulating message buffer | 2265 | * @skb: encapsulating message buffer |
| @@ -2353,7 +2268,6 @@ void tipc_link_send_duplicate(struct tipc_link *l_ptr, struct tipc_link *tunnel) | |||
| 2353 | * Returns a new message buffer containing an embedded message. The | 2268 | * Returns a new message buffer containing an embedded message. The |
| 2354 | * encapsulating message itself is left unchanged. | 2269 | * encapsulating message itself is left unchanged. |
| 2355 | */ | 2270 | */ |
| 2356 | |||
| 2357 | static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | 2271 | static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) |
| 2358 | { | 2272 | { |
| 2359 | struct tipc_msg *msg = (struct tipc_msg *)(skb->data + from_pos); | 2273 | struct tipc_msg *msg = (struct tipc_msg *)(skb->data + from_pos); |
| @@ -2370,7 +2284,6 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | |||
| 2370 | * link_recv_changeover_msg(): Receive tunneled packet sent | 2284 | * link_recv_changeover_msg(): Receive tunneled packet sent |
| 2371 | * via other link. Node is locked. Return extracted buffer. | 2285 | * via other link. Node is locked. Return extracted buffer. |
| 2372 | */ | 2286 | */ |
| 2373 | |||
| 2374 | static int link_recv_changeover_msg(struct tipc_link **l_ptr, | 2287 | static int link_recv_changeover_msg(struct tipc_link **l_ptr, |
| 2375 | struct sk_buff **buf) | 2288 | struct sk_buff **buf) |
| 2376 | { | 2289 | { |
| @@ -2405,7 +2318,6 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr, | |||
| 2405 | } | 2318 | } |
| 2406 | 2319 | ||
| 2407 | /* First original message ?: */ | 2320 | /* First original message ?: */ |
| 2408 | |||
| 2409 | if (tipc_link_is_up(dest_link)) { | 2321 | if (tipc_link_is_up(dest_link)) { |
| 2410 | info("Resetting link <%s>, changeover initiated by peer\n", | 2322 | info("Resetting link <%s>, changeover initiated by peer\n", |
| 2411 | dest_link->name); | 2323 | dest_link->name); |
| @@ -2420,7 +2332,6 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr, | |||
| 2420 | } | 2332 | } |
| 2421 | 2333 | ||
| 2422 | /* Receive original message */ | 2334 | /* Receive original message */ |
| 2423 | |||
| 2424 | if (dest_link->exp_msg_count == 0) { | 2335 | if (dest_link->exp_msg_count == 0) { |
| 2425 | warn("Link switchover error, " | 2336 | warn("Link switchover error, " |
| 2426 | "got too many tunnelled messages\n"); | 2337 | "got too many tunnelled messages\n"); |
| @@ -2469,7 +2380,6 @@ void tipc_link_recv_bundle(struct sk_buff *buf) | |||
| 2469 | * Fragmentation/defragmentation: | 2380 | * Fragmentation/defragmentation: |
| 2470 | */ | 2381 | */ |
| 2471 | 2382 | ||
| 2472 | |||
| 2473 | /* | 2383 | /* |
| 2474 | * link_send_long_buf: Entry for buffers needing fragmentation. | 2384 | * link_send_long_buf: Entry for buffers needing fragmentation. |
| 2475 | * The buffer is complete, inclusive total message length. | 2385 | * The buffer is complete, inclusive total message length. |
| @@ -2496,12 +2406,10 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2496 | destaddr = msg_destnode(inmsg); | 2406 | destaddr = msg_destnode(inmsg); |
| 2497 | 2407 | ||
| 2498 | /* Prepare reusable fragment header: */ | 2408 | /* Prepare reusable fragment header: */ |
| 2499 | |||
| 2500 | tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, | 2409 | tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, |
| 2501 | INT_H_SIZE, destaddr); | 2410 | INT_H_SIZE, destaddr); |
| 2502 | 2411 | ||
| 2503 | /* Chop up message: */ | 2412 | /* Chop up message: */ |
| 2504 | |||
| 2505 | while (rest > 0) { | 2413 | while (rest > 0) { |
| 2506 | struct sk_buff *fragm; | 2414 | struct sk_buff *fragm; |
| 2507 | 2415 | ||
| @@ -2535,7 +2443,6 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2535 | kfree_skb(buf); | 2443 | kfree_skb(buf); |
| 2536 | 2444 | ||
| 2537 | /* Append chain of fragments to send queue & send them */ | 2445 | /* Append chain of fragments to send queue & send them */ |
| 2538 | |||
| 2539 | l_ptr->long_msg_seq_no++; | 2446 | l_ptr->long_msg_seq_no++; |
| 2540 | link_add_chain_to_outqueue(l_ptr, buf_chain, l_ptr->long_msg_seq_no); | 2447 | link_add_chain_to_outqueue(l_ptr, buf_chain, l_ptr->long_msg_seq_no); |
| 2541 | l_ptr->stats.sent_fragments += fragm_no; | 2448 | l_ptr->stats.sent_fragments += fragm_no; |
| @@ -2551,7 +2458,6 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2551 | * help storing these values in unused, available fields in the | 2458 | * help storing these values in unused, available fields in the |
| 2552 | * pending message. This makes dynamic memory allocation unnecessary. | 2459 | * pending message. This makes dynamic memory allocation unnecessary. |
| 2553 | */ | 2460 | */ |
| 2554 | |||
| 2555 | static void set_long_msg_seqno(struct sk_buff *buf, u32 seqno) | 2461 | static void set_long_msg_seqno(struct sk_buff *buf, u32 seqno) |
| 2556 | { | 2462 | { |
| 2557 | msg_set_seqno(buf_msg(buf), seqno); | 2463 | msg_set_seqno(buf_msg(buf), seqno); |
| @@ -2603,7 +2509,6 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
| 2603 | *fb = NULL; | 2509 | *fb = NULL; |
| 2604 | 2510 | ||
| 2605 | /* Is there an incomplete message waiting for this fragment? */ | 2511 | /* Is there an incomplete message waiting for this fragment? */ |
| 2606 | |||
| 2607 | while (pbuf && ((buf_seqno(pbuf) != long_msg_seq_no) || | 2512 | while (pbuf && ((buf_seqno(pbuf) != long_msg_seq_no) || |
| 2608 | (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) { | 2513 | (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) { |
| 2609 | prev = pbuf; | 2514 | prev = pbuf; |
| @@ -2629,7 +2534,6 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
| 2629 | skb_copy_to_linear_data(pbuf, imsg, | 2534 | skb_copy_to_linear_data(pbuf, imsg, |
| 2630 | msg_data_sz(fragm)); | 2535 | msg_data_sz(fragm)); |
| 2631 | /* Prepare buffer for subsequent fragments. */ | 2536 | /* Prepare buffer for subsequent fragments. */ |
| 2632 | |||
| 2633 | set_long_msg_seqno(pbuf, long_msg_seq_no); | 2537 | set_long_msg_seqno(pbuf, long_msg_seq_no); |
| 2634 | set_fragm_size(pbuf, fragm_sz); | 2538 | set_fragm_size(pbuf, fragm_sz); |
| 2635 | set_expected_frags(pbuf, exp_fragm_cnt - 1); | 2539 | set_expected_frags(pbuf, exp_fragm_cnt - 1); |
| @@ -2650,7 +2554,6 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
| 2650 | kfree_skb(fbuf); | 2554 | kfree_skb(fbuf); |
| 2651 | 2555 | ||
| 2652 | /* Is message complete? */ | 2556 | /* Is message complete? */ |
| 2653 | |||
| 2654 | if (exp_frags == 0) { | 2557 | if (exp_frags == 0) { |
| 2655 | if (prev) | 2558 | if (prev) |
| 2656 | prev->next = pbuf->next; | 2559 | prev->next = pbuf->next; |
| @@ -2672,7 +2575,6 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
| 2672 | * link_check_defragm_bufs - flush stale incoming message fragments | 2575 | * link_check_defragm_bufs - flush stale incoming message fragments |
| 2673 | * @l_ptr: pointer to link | 2576 | * @l_ptr: pointer to link |
| 2674 | */ | 2577 | */ |
| 2675 | |||
| 2676 | static void link_check_defragm_bufs(struct tipc_link *l_ptr) | 2578 | static void link_check_defragm_bufs(struct tipc_link *l_ptr) |
| 2677 | { | 2579 | { |
| 2678 | struct sk_buff *prev = NULL; | 2580 | struct sk_buff *prev = NULL; |
| @@ -2701,8 +2603,6 @@ static void link_check_defragm_bufs(struct tipc_link *l_ptr) | |||
| 2701 | } | 2603 | } |
| 2702 | } | 2604 | } |
| 2703 | 2605 | ||
| 2704 | |||
| 2705 | |||
| 2706 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance) | 2606 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance) |
| 2707 | { | 2607 | { |
| 2708 | if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) | 2608 | if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) |
| @@ -2714,7 +2614,6 @@ static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance) | |||
| 2714 | l_ptr->abort_limit = tolerance / (l_ptr->continuity_interval / 4); | 2614 | l_ptr->abort_limit = tolerance / (l_ptr->continuity_interval / 4); |
| 2715 | } | 2615 | } |
| 2716 | 2616 | ||
| 2717 | |||
| 2718 | void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | 2617 | void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) |
| 2719 | { | 2618 | { |
| 2720 | /* Data messages from this node, inclusive FIRST_FRAGM */ | 2619 | /* Data messages from this node, inclusive FIRST_FRAGM */ |
| @@ -2744,7 +2643,6 @@ void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | |||
| 2744 | * | 2643 | * |
| 2745 | * Returns pointer to link (or 0 if invalid link name). | 2644 | * Returns pointer to link (or 0 if invalid link name). |
| 2746 | */ | 2645 | */ |
| 2747 | |||
| 2748 | static struct tipc_link *link_find_link(const char *name, | 2646 | static struct tipc_link *link_find_link(const char *name, |
| 2749 | struct tipc_node **node) | 2647 | struct tipc_node **node) |
| 2750 | { | 2648 | { |
| @@ -2778,7 +2676,6 @@ static struct tipc_link *link_find_link(const char *name, | |||
| 2778 | * | 2676 | * |
| 2779 | * Returns 1 if value is within range, 0 if not. | 2677 | * Returns 1 if value is within range, 0 if not. |
| 2780 | */ | 2678 | */ |
| 2781 | |||
| 2782 | static int link_value_is_valid(u16 cmd, u32 new_value) | 2679 | static int link_value_is_valid(u16 cmd, u32 new_value) |
| 2783 | { | 2680 | { |
| 2784 | switch (cmd) { | 2681 | switch (cmd) { |
| @@ -2794,7 +2691,6 @@ static int link_value_is_valid(u16 cmd, u32 new_value) | |||
| 2794 | return 0; | 2691 | return 0; |
| 2795 | } | 2692 | } |
| 2796 | 2693 | ||
| 2797 | |||
| 2798 | /** | 2694 | /** |
| 2799 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media | 2695 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media |
| 2800 | * @name - ptr to link, bearer, or media name | 2696 | * @name - ptr to link, bearer, or media name |
| @@ -2805,7 +2701,6 @@ static int link_value_is_valid(u16 cmd, u32 new_value) | |||
| 2805 | * | 2701 | * |
| 2806 | * Returns 0 if value updated and negative value on error. | 2702 | * Returns 0 if value updated and negative value on error. |
| 2807 | */ | 2703 | */ |
| 2808 | |||
| 2809 | static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | 2704 | static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) |
| 2810 | { | 2705 | { |
| 2811 | struct tipc_node *node; | 2706 | struct tipc_node *node; |
| @@ -2910,7 +2805,6 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
| 2910 | * link_reset_statistics - reset link statistics | 2805 | * link_reset_statistics - reset link statistics |
| 2911 | * @l_ptr: pointer to link | 2806 | * @l_ptr: pointer to link |
| 2912 | */ | 2807 | */ |
| 2913 | |||
| 2914 | static void link_reset_statistics(struct tipc_link *l_ptr) | 2808 | static void link_reset_statistics(struct tipc_link *l_ptr) |
| 2915 | { | 2809 | { |
| 2916 | memset(&l_ptr->stats, 0, sizeof(l_ptr->stats)); | 2810 | memset(&l_ptr->stats, 0, sizeof(l_ptr->stats)); |
| @@ -2951,7 +2845,6 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_ | |||
| 2951 | /** | 2845 | /** |
| 2952 | * percent - convert count to a percentage of total (rounding up or down) | 2846 | * percent - convert count to a percentage of total (rounding up or down) |
| 2953 | */ | 2847 | */ |
| 2954 | |||
| 2955 | static u32 percent(u32 count, u32 total) | 2848 | static u32 percent(u32 count, u32 total) |
| 2956 | { | 2849 | { |
| 2957 | return (count * 100 + (total / 2)) / total; | 2850 | return (count * 100 + (total / 2)) / total; |
| @@ -2965,7 +2858,6 @@ static u32 percent(u32 count, u32 total) | |||
| 2965 | * | 2858 | * |
| 2966 | * Returns length of print buffer data string (or 0 if error) | 2859 | * Returns length of print buffer data string (or 0 if error) |
| 2967 | */ | 2860 | */ |
| 2968 | |||
| 2969 | static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | 2861 | static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) |
| 2970 | { | 2862 | { |
| 2971 | struct print_buf pb; | 2863 | struct print_buf pb; |
| @@ -3087,7 +2979,6 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s | |||
| 3087 | * | 2979 | * |
| 3088 | * If no active link can be found, uses default maximum packet size. | 2980 | * If no active link can be found, uses default maximum packet size. |
| 3089 | */ | 2981 | */ |
| 3090 | |||
| 3091 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | 2982 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) |
| 3092 | { | 2983 | { |
| 3093 | struct tipc_node *n_ptr; | 2984 | struct tipc_node *n_ptr; |
| @@ -3171,4 +3062,3 @@ print_state: | |||
| 3171 | tipc_printbuf_validate(buf); | 3062 | tipc_printbuf_validate(buf); |
| 3172 | info("%s", print_area); | 3063 | info("%s", print_area); |
| 3173 | } | 3064 | } |
| 3174 | |||
diff --git a/net/tipc/link.h b/net/tipc/link.h index 73c18c140e1d..d6a60a963ce6 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
| @@ -47,13 +47,11 @@ | |||
| 47 | /* | 47 | /* |
| 48 | * Out-of-range value for link sequence numbers | 48 | * Out-of-range value for link sequence numbers |
| 49 | */ | 49 | */ |
| 50 | |||
| 51 | #define INVALID_LINK_SEQ 0x10000 | 50 | #define INVALID_LINK_SEQ 0x10000 |
| 52 | 51 | ||
| 53 | /* | 52 | /* |
| 54 | * Link states | 53 | * Link states |
| 55 | */ | 54 | */ |
| 56 | |||
| 57 | #define WORKING_WORKING 560810u | 55 | #define WORKING_WORKING 560810u |
| 58 | #define WORKING_UNKNOWN 560811u | 56 | #define WORKING_UNKNOWN 560811u |
| 59 | #define RESET_UNKNOWN 560812u | 57 | #define RESET_UNKNOWN 560812u |
| @@ -63,7 +61,6 @@ | |||
| 63 | * Starting value for maximum packet size negotiation on unicast links | 61 | * Starting value for maximum packet size negotiation on unicast links |
| 64 | * (unless bearer MTU is less) | 62 | * (unless bearer MTU is less) |
| 65 | */ | 63 | */ |
| 66 | |||
| 67 | #define MAX_PKT_DEFAULT 1500 | 64 | #define MAX_PKT_DEFAULT 1500 |
| 68 | 65 | ||
| 69 | /** | 66 | /** |
| @@ -114,7 +111,6 @@ | |||
| 114 | * @defragm_buf: list of partially reassembled inbound message fragments | 111 | * @defragm_buf: list of partially reassembled inbound message fragments |
| 115 | * @stats: collects statistics regarding link activity | 112 | * @stats: collects statistics regarding link activity |
| 116 | */ | 113 | */ |
| 117 | |||
| 118 | struct tipc_link { | 114 | struct tipc_link { |
| 119 | u32 addr; | 115 | u32 addr; |
| 120 | char name[TIPC_MAX_LINK_NAME]; | 116 | char name[TIPC_MAX_LINK_NAME]; |
| @@ -255,7 +251,6 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, | |||
| 255 | /* | 251 | /* |
| 256 | * Link sequence number manipulation routines (uses modulo 2**16 arithmetic) | 252 | * Link sequence number manipulation routines (uses modulo 2**16 arithmetic) |
| 257 | */ | 253 | */ |
| 258 | |||
| 259 | static inline u32 buf_seqno(struct sk_buff *buf) | 254 | static inline u32 buf_seqno(struct sk_buff *buf) |
| 260 | { | 255 | { |
| 261 | return msg_seqno(buf_msg(buf)); | 256 | return msg_seqno(buf_msg(buf)); |
| @@ -294,7 +289,6 @@ static inline u32 lesser(u32 left, u32 right) | |||
| 294 | /* | 289 | /* |
| 295 | * Link status checking routines | 290 | * Link status checking routines |
| 296 | */ | 291 | */ |
| 297 | |||
| 298 | static inline int link_working_working(struct tipc_link *l_ptr) | 292 | static inline int link_working_working(struct tipc_link *l_ptr) |
| 299 | { | 293 | { |
| 300 | return l_ptr->state == WORKING_WORKING; | 294 | return l_ptr->state == WORKING_WORKING; |
diff --git a/net/tipc/log.c b/net/tipc/log.c index 895c6e530b0b..026733f24919 100644 --- a/net/tipc/log.c +++ b/net/tipc/log.c | |||
| @@ -47,7 +47,6 @@ | |||
| 47 | * | 47 | * |
| 48 | * Additional user-defined print buffers are also permitted. | 48 | * Additional user-defined print buffers are also permitted. |
| 49 | */ | 49 | */ |
| 50 | |||
| 51 | static struct print_buf null_buf = { NULL, 0, NULL, 0 }; | 50 | static struct print_buf null_buf = { NULL, 0, NULL, 0 }; |
| 52 | struct print_buf *const TIPC_NULL = &null_buf; | 51 | struct print_buf *const TIPC_NULL = &null_buf; |
| 53 | 52 | ||
| @@ -72,7 +71,6 @@ struct print_buf *const TIPC_LOG = &log_buf; | |||
| 72 | * on the caller to prevent simultaneous use of the print buffer(s) being | 71 | * on the caller to prevent simultaneous use of the print buffer(s) being |
| 73 | * manipulated. | 72 | * manipulated. |
| 74 | */ | 73 | */ |
| 75 | |||
| 76 | static char print_string[TIPC_PB_MAX_STR]; | 74 | static char print_string[TIPC_PB_MAX_STR]; |
| 77 | static DEFINE_SPINLOCK(print_lock); | 75 | static DEFINE_SPINLOCK(print_lock); |
| 78 | 76 | ||
| @@ -97,7 +95,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to, | |||
| 97 | * Note: If the character array is too small (or absent), the print buffer | 95 | * Note: If the character array is too small (or absent), the print buffer |
| 98 | * becomes a null device that discards anything written to it. | 96 | * becomes a null device that discards anything written to it. |
| 99 | */ | 97 | */ |
| 100 | |||
| 101 | void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size) | 98 | void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size) |
| 102 | { | 99 | { |
| 103 | pb->buf = raw; | 100 | pb->buf = raw; |
| @@ -117,7 +114,6 @@ void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size) | |||
| 117 | * tipc_printbuf_reset - reinitialize print buffer to empty state | 114 | * tipc_printbuf_reset - reinitialize print buffer to empty state |
| 118 | * @pb: pointer to print buffer structure | 115 | * @pb: pointer to print buffer structure |
| 119 | */ | 116 | */ |
| 120 | |||
| 121 | static void tipc_printbuf_reset(struct print_buf *pb) | 117 | static void tipc_printbuf_reset(struct print_buf *pb) |
| 122 | { | 118 | { |
| 123 | if (pb->buf) { | 119 | if (pb->buf) { |
| @@ -133,7 +129,6 @@ static void tipc_printbuf_reset(struct print_buf *pb) | |||
| 133 | * | 129 | * |
| 134 | * Returns non-zero if print buffer is empty. | 130 | * Returns non-zero if print buffer is empty. |
| 135 | */ | 131 | */ |
| 136 | |||
| 137 | static int tipc_printbuf_empty(struct print_buf *pb) | 132 | static int tipc_printbuf_empty(struct print_buf *pb) |
| 138 | { | 133 | { |
| 139 | return !pb->buf || (pb->crs == pb->buf); | 134 | return !pb->buf || (pb->crs == pb->buf); |
| @@ -148,7 +143,6 @@ static int tipc_printbuf_empty(struct print_buf *pb) | |||
| 148 | * | 143 | * |
| 149 | * Returns length of print buffer data string (including trailing NUL) | 144 | * Returns length of print buffer data string (including trailing NUL) |
| 150 | */ | 145 | */ |
| 151 | |||
| 152 | int tipc_printbuf_validate(struct print_buf *pb) | 146 | int tipc_printbuf_validate(struct print_buf *pb) |
| 153 | { | 147 | { |
| 154 | char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n"; | 148 | char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n"; |
| @@ -182,14 +176,12 @@ int tipc_printbuf_validate(struct print_buf *pb) | |||
| 182 | * Current contents of destination print buffer (if any) are discarded. | 176 | * Current contents of destination print buffer (if any) are discarded. |
| 183 | * Source print buffer becomes empty if a successful move occurs. | 177 | * Source print buffer becomes empty if a successful move occurs. |
| 184 | */ | 178 | */ |
| 185 | |||
| 186 | static void tipc_printbuf_move(struct print_buf *pb_to, | 179 | static void tipc_printbuf_move(struct print_buf *pb_to, |
| 187 | struct print_buf *pb_from) | 180 | struct print_buf *pb_from) |
| 188 | { | 181 | { |
| 189 | int len; | 182 | int len; |
| 190 | 183 | ||
| 191 | /* Handle the cases where contents can't be moved */ | 184 | /* Handle the cases where contents can't be moved */ |
| 192 | |||
| 193 | if (!pb_to->buf) | 185 | if (!pb_to->buf) |
| 194 | return; | 186 | return; |
| 195 | 187 | ||
| @@ -206,7 +198,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to, | |||
| 206 | } | 198 | } |
| 207 | 199 | ||
| 208 | /* Copy data from char after cursor to end (if used) */ | 200 | /* Copy data from char after cursor to end (if used) */ |
| 209 | |||
| 210 | len = pb_from->buf + pb_from->size - pb_from->crs - 2; | 201 | len = pb_from->buf + pb_from->size - pb_from->crs - 2; |
| 211 | if ((pb_from->buf[pb_from->size - 1] == 0) && (len > 0)) { | 202 | if ((pb_from->buf[pb_from->size - 1] == 0) && (len > 0)) { |
| 212 | strcpy(pb_to->buf, pb_from->crs + 1); | 203 | strcpy(pb_to->buf, pb_from->crs + 1); |
| @@ -215,7 +206,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to, | |||
| 215 | pb_to->crs = pb_to->buf; | 206 | pb_to->crs = pb_to->buf; |
| 216 | 207 | ||
| 217 | /* Copy data from start to cursor (always) */ | 208 | /* Copy data from start to cursor (always) */ |
| 218 | |||
| 219 | len = pb_from->crs - pb_from->buf; | 209 | len = pb_from->crs - pb_from->buf; |
| 220 | strcpy(pb_to->crs, pb_from->buf); | 210 | strcpy(pb_to->crs, pb_from->buf); |
| 221 | pb_to->crs += len; | 211 | pb_to->crs += len; |
| @@ -228,7 +218,6 @@ static void tipc_printbuf_move(struct print_buf *pb_to, | |||
| 228 | * @pb: pointer to print buffer | 218 | * @pb: pointer to print buffer |
| 229 | * @fmt: formatted info to be printed | 219 | * @fmt: formatted info to be printed |
| 230 | */ | 220 | */ |
| 231 | |||
| 232 | void tipc_printf(struct print_buf *pb, const char *fmt, ...) | 221 | void tipc_printf(struct print_buf *pb, const char *fmt, ...) |
| 233 | { | 222 | { |
| 234 | int chars_to_add; | 223 | int chars_to_add; |
| @@ -270,7 +259,6 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...) | |||
| 270 | * tipc_log_resize - change the size of the TIPC log buffer | 259 | * tipc_log_resize - change the size of the TIPC log buffer |
| 271 | * @log_size: print buffer size to use | 260 | * @log_size: print buffer size to use |
| 272 | */ | 261 | */ |
| 273 | |||
| 274 | int tipc_log_resize(int log_size) | 262 | int tipc_log_resize(int log_size) |
| 275 | { | 263 | { |
| 276 | int res = 0; | 264 | int res = 0; |
| @@ -295,7 +283,6 @@ int tipc_log_resize(int log_size) | |||
| 295 | /** | 283 | /** |
| 296 | * tipc_log_resize_cmd - reconfigure size of TIPC log buffer | 284 | * tipc_log_resize_cmd - reconfigure size of TIPC log buffer |
| 297 | */ | 285 | */ |
| 298 | |||
| 299 | struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space) | 286 | struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space) |
| 300 | { | 287 | { |
| 301 | u32 value; | 288 | u32 value; |
| @@ -316,7 +303,6 @@ struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space) | |||
| 316 | /** | 303 | /** |
| 317 | * tipc_log_dump - capture TIPC log buffer contents in configuration message | 304 | * tipc_log_dump - capture TIPC log buffer contents in configuration message |
| 318 | */ | 305 | */ |
| 319 | |||
| 320 | struct sk_buff *tipc_log_dump(void) | 306 | struct sk_buff *tipc_log_dump(void) |
| 321 | { | 307 | { |
| 322 | struct sk_buff *reply; | 308 | struct sk_buff *reply; |
diff --git a/net/tipc/log.h b/net/tipc/log.h index 2248d96238e6..d1f5eb967fd8 100644 --- a/net/tipc/log.h +++ b/net/tipc/log.h | |||
| @@ -44,7 +44,6 @@ | |||
| 44 | * @crs: pointer to first unused space in character array (i.e. final NUL) | 44 | * @crs: pointer to first unused space in character array (i.e. final NUL) |
| 45 | * @echo: echo output to system console if non-zero | 45 | * @echo: echo output to system console if non-zero |
| 46 | */ | 46 | */ |
| 47 | |||
| 48 | struct print_buf { | 47 | struct print_buf { |
| 49 | char *buf; | 48 | char *buf; |
| 50 | u32 size; | 49 | u32 size; |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index e3afe162c0ac..deea0d232dca 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
| @@ -72,7 +72,6 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, | |||
| 72 | * | 72 | * |
| 73 | * Returns message data size or errno | 73 | * Returns message data size or errno |
| 74 | */ | 74 | */ |
| 75 | |||
| 76 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | 75 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, |
| 77 | u32 num_sect, unsigned int total_len, | 76 | u32 num_sect, unsigned int total_len, |
| 78 | int max_size, int usrmem, struct sk_buff **buf) | 77 | int max_size, int usrmem, struct sk_buff **buf) |
| @@ -112,7 +111,6 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | |||
| 112 | } | 111 | } |
| 113 | 112 | ||
| 114 | #ifdef CONFIG_TIPC_DEBUG | 113 | #ifdef CONFIG_TIPC_DEBUG |
| 115 | |||
| 116 | void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str) | 114 | void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str) |
| 117 | { | 115 | { |
| 118 | u32 usr = msg_user(msg); | 116 | u32 usr = msg_user(msg); |
| @@ -352,5 +350,4 @@ void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str) | |||
| 352 | if ((usr == MSG_FRAGMENTER) && (msg_type(msg) == FIRST_FRAGMENT)) | 350 | if ((usr == MSG_FRAGMENTER) && (msg_type(msg) == FIRST_FRAGMENT)) |
| 353 | tipc_msg_dbg(buf, msg_get_wrapped(msg), " /"); | 351 | tipc_msg_dbg(buf, msg_get_wrapped(msg), " /"); |
| 354 | } | 352 | } |
| 355 | |||
| 356 | #endif | 353 | #endif |
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index eba524e34a6b..ba2a72beea68 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
| @@ -44,7 +44,6 @@ | |||
| 44 | * | 44 | * |
| 45 | * Note: Some items are also used with TIPC internal message headers | 45 | * Note: Some items are also used with TIPC internal message headers |
| 46 | */ | 46 | */ |
| 47 | |||
| 48 | #define TIPC_VERSION 2 | 47 | #define TIPC_VERSION 2 |
| 49 | 48 | ||
| 50 | /* | 49 | /* |
| @@ -58,7 +57,6 @@ | |||
| 58 | /* | 57 | /* |
| 59 | * Payload message types | 58 | * Payload message types |
| 60 | */ | 59 | */ |
| 61 | |||
| 62 | #define TIPC_CONN_MSG 0 | 60 | #define TIPC_CONN_MSG 0 |
| 63 | #define TIPC_MCAST_MSG 1 | 61 | #define TIPC_MCAST_MSG 1 |
| 64 | #define TIPC_NAMED_MSG 2 | 62 | #define TIPC_NAMED_MSG 2 |
| @@ -67,7 +65,6 @@ | |||
| 67 | /* | 65 | /* |
| 68 | * Message header sizes | 66 | * Message header sizes |
| 69 | */ | 67 | */ |
| 70 | |||
| 71 | #define SHORT_H_SIZE 24 /* In-cluster basic payload message */ | 68 | #define SHORT_H_SIZE 24 /* In-cluster basic payload message */ |
| 72 | #define BASIC_H_SIZE 32 /* Basic payload message */ | 69 | #define BASIC_H_SIZE 32 /* Basic payload message */ |
| 73 | #define NAMED_H_SIZE 40 /* Named payload message */ | 70 | #define NAMED_H_SIZE 40 /* Named payload message */ |
| @@ -121,7 +118,6 @@ static inline void msg_swap_words(struct tipc_msg *msg, u32 a, u32 b) | |||
| 121 | /* | 118 | /* |
| 122 | * Word 0 | 119 | * Word 0 |
| 123 | */ | 120 | */ |
| 124 | |||
| 125 | static inline u32 msg_version(struct tipc_msg *m) | 121 | static inline u32 msg_version(struct tipc_msg *m) |
| 126 | { | 122 | { |
| 127 | return msg_bits(m, 0, 29, 7); | 123 | return msg_bits(m, 0, 29, 7); |
| @@ -216,7 +212,6 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz) | |||
| 216 | /* | 212 | /* |
| 217 | * Word 1 | 213 | * Word 1 |
| 218 | */ | 214 | */ |
| 219 | |||
| 220 | static inline u32 msg_type(struct tipc_msg *m) | 215 | static inline u32 msg_type(struct tipc_msg *m) |
| 221 | { | 216 | { |
| 222 | return msg_bits(m, 1, 29, 0x7); | 217 | return msg_bits(m, 1, 29, 0x7); |
| @@ -291,7 +286,6 @@ static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n) | |||
| 291 | /* | 286 | /* |
| 292 | * Word 2 | 287 | * Word 2 |
| 293 | */ | 288 | */ |
| 294 | |||
| 295 | static inline u32 msg_ack(struct tipc_msg *m) | 289 | static inline u32 msg_ack(struct tipc_msg *m) |
| 296 | { | 290 | { |
| 297 | return msg_bits(m, 2, 16, 0xffff); | 291 | return msg_bits(m, 2, 16, 0xffff); |
| @@ -315,8 +309,6 @@ static inline void msg_set_seqno(struct tipc_msg *m, u32 n) | |||
| 315 | /* | 309 | /* |
| 316 | * Words 3-10 | 310 | * Words 3-10 |
| 317 | */ | 311 | */ |
| 318 | |||
| 319 | |||
| 320 | static inline u32 msg_prevnode(struct tipc_msg *m) | 312 | static inline u32 msg_prevnode(struct tipc_msg *m) |
| 321 | { | 313 | { |
| 322 | return msg_word(m, 3); | 314 | return msg_word(m, 3); |
| @@ -434,7 +426,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 434 | return (struct tipc_msg *)msg_data(m); | 426 | return (struct tipc_msg *)msg_data(m); |
| 435 | } | 427 | } |
| 436 | 428 | ||
| 437 | |||
| 438 | /* | 429 | /* |
| 439 | * Constants and routines used to read and write TIPC internal message headers | 430 | * Constants and routines used to read and write TIPC internal message headers |
| 440 | */ | 431 | */ |
| @@ -442,7 +433,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 442 | /* | 433 | /* |
| 443 | * Internal message users | 434 | * Internal message users |
| 444 | */ | 435 | */ |
| 445 | |||
| 446 | #define BCAST_PROTOCOL 5 | 436 | #define BCAST_PROTOCOL 5 |
| 447 | #define MSG_BUNDLER 6 | 437 | #define MSG_BUNDLER 6 |
| 448 | #define LINK_PROTOCOL 7 | 438 | #define LINK_PROTOCOL 7 |
| @@ -456,7 +446,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 456 | /* | 446 | /* |
| 457 | * Connection management protocol message types | 447 | * Connection management protocol message types |
| 458 | */ | 448 | */ |
| 459 | |||
| 460 | #define CONN_PROBE 0 | 449 | #define CONN_PROBE 0 |
| 461 | #define CONN_PROBE_REPLY 1 | 450 | #define CONN_PROBE_REPLY 1 |
| 462 | #define CONN_ACK 2 | 451 | #define CONN_ACK 2 |
| @@ -464,14 +453,12 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 464 | /* | 453 | /* |
| 465 | * Name distributor message types | 454 | * Name distributor message types |
| 466 | */ | 455 | */ |
| 467 | |||
| 468 | #define PUBLICATION 0 | 456 | #define PUBLICATION 0 |
| 469 | #define WITHDRAWAL 1 | 457 | #define WITHDRAWAL 1 |
| 470 | 458 | ||
| 471 | /* | 459 | /* |
| 472 | * Segmentation message types | 460 | * Segmentation message types |
| 473 | */ | 461 | */ |
| 474 | |||
| 475 | #define FIRST_FRAGMENT 0 | 462 | #define FIRST_FRAGMENT 0 |
| 476 | #define FRAGMENT 1 | 463 | #define FRAGMENT 1 |
| 477 | #define LAST_FRAGMENT 2 | 464 | #define LAST_FRAGMENT 2 |
| @@ -479,7 +466,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 479 | /* | 466 | /* |
| 480 | * Link management protocol message types | 467 | * Link management protocol message types |
| 481 | */ | 468 | */ |
| 482 | |||
| 483 | #define STATE_MSG 0 | 469 | #define STATE_MSG 0 |
| 484 | #define RESET_MSG 1 | 470 | #define RESET_MSG 1 |
| 485 | #define ACTIVATE_MSG 2 | 471 | #define ACTIVATE_MSG 2 |
| @@ -493,7 +479,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 493 | /* | 479 | /* |
| 494 | * Config protocol message types | 480 | * Config protocol message types |
| 495 | */ | 481 | */ |
| 496 | |||
| 497 | #define DSC_REQ_MSG 0 | 482 | #define DSC_REQ_MSG 0 |
| 498 | #define DSC_RESP_MSG 1 | 483 | #define DSC_RESP_MSG 1 |
| 499 | 484 | ||
| @@ -501,7 +486,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 501 | /* | 486 | /* |
| 502 | * Word 1 | 487 | * Word 1 |
| 503 | */ | 488 | */ |
| 504 | |||
| 505 | static inline u32 msg_seq_gap(struct tipc_msg *m) | 489 | static inline u32 msg_seq_gap(struct tipc_msg *m) |
| 506 | { | 490 | { |
| 507 | return msg_bits(m, 1, 16, 0x1fff); | 491 | return msg_bits(m, 1, 16, 0x1fff); |
| @@ -526,7 +510,6 @@ static inline void msg_set_node_sig(struct tipc_msg *m, u32 n) | |||
| 526 | /* | 510 | /* |
| 527 | * Word 2 | 511 | * Word 2 |
| 528 | */ | 512 | */ |
| 529 | |||
| 530 | static inline u32 msg_dest_domain(struct tipc_msg *m) | 513 | static inline u32 msg_dest_domain(struct tipc_msg *m) |
| 531 | { | 514 | { |
| 532 | return msg_word(m, 2); | 515 | return msg_word(m, 2); |
| @@ -561,7 +544,6 @@ static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n) | |||
| 561 | /* | 544 | /* |
| 562 | * Word 4 | 545 | * Word 4 |
| 563 | */ | 546 | */ |
| 564 | |||
| 565 | static inline u32 msg_last_bcast(struct tipc_msg *m) | 547 | static inline u32 msg_last_bcast(struct tipc_msg *m) |
| 566 | { | 548 | { |
| 567 | return msg_bits(m, 4, 16, 0xffff); | 549 | return msg_bits(m, 4, 16, 0xffff); |
| @@ -628,7 +610,6 @@ static inline void msg_set_link_selector(struct tipc_msg *m, u32 n) | |||
| 628 | /* | 610 | /* |
| 629 | * Word 5 | 611 | * Word 5 |
| 630 | */ | 612 | */ |
| 631 | |||
| 632 | static inline u32 msg_session(struct tipc_msg *m) | 613 | static inline u32 msg_session(struct tipc_msg *m) |
| 633 | { | 614 | { |
| 634 | return msg_bits(m, 5, 16, 0xffff); | 615 | return msg_bits(m, 5, 16, 0xffff); |
| @@ -697,7 +678,6 @@ static inline char *msg_media_addr(struct tipc_msg *m) | |||
| 697 | /* | 678 | /* |
| 698 | * Word 9 | 679 | * Word 9 |
| 699 | */ | 680 | */ |
| 700 | |||
| 701 | static inline u32 msg_msgcnt(struct tipc_msg *m) | 681 | static inline u32 msg_msgcnt(struct tipc_msg *m) |
| 702 | { | 682 | { |
| 703 | return msg_bits(m, 9, 16, 0xffff); | 683 | return msg_bits(m, 9, 16, 0xffff); |
| @@ -744,5 +724,4 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, | |||
| 744 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | 724 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, |
| 745 | u32 num_sect, unsigned int total_len, | 725 | u32 num_sect, unsigned int total_len, |
| 746 | int max_size, int usrmem, struct sk_buff **buf); | 726 | int max_size, int usrmem, struct sk_buff **buf); |
| 747 | |||
| 748 | #endif | 727 | #endif |
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index d57da6159616..158318e67b08 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
| @@ -58,7 +58,6 @@ | |||
| 58 | * Note: There is no field that identifies the publishing node because it is | 58 | * Note: There is no field that identifies the publishing node because it is |
| 59 | * the same for all items contained within a publication message. | 59 | * the same for all items contained within a publication message. |
| 60 | */ | 60 | */ |
| 61 | |||
| 62 | struct distr_item { | 61 | struct distr_item { |
| 63 | __be32 type; | 62 | __be32 type; |
| 64 | __be32 lower; | 63 | __be32 lower; |
| @@ -68,17 +67,41 @@ struct distr_item { | |||
| 68 | }; | 67 | }; |
| 69 | 68 | ||
| 70 | /** | 69 | /** |
| 71 | * List of externally visible publications by this node -- | 70 | * struct publ_list - list of publications made by this node |
| 72 | * that is, all publications having scope > TIPC_NODE_SCOPE. | 71 | * @list: circular list of publications |
| 72 | * @list_size: number of entries in list | ||
| 73 | */ | 73 | */ |
| 74 | struct publ_list { | ||
| 75 | struct list_head list; | ||
| 76 | u32 size; | ||
| 77 | }; | ||
| 78 | |||
| 79 | static struct publ_list publ_zone = { | ||
| 80 | .list = LIST_HEAD_INIT(publ_zone.list), | ||
| 81 | .size = 0, | ||
| 82 | }; | ||
| 83 | |||
| 84 | static struct publ_list publ_cluster = { | ||
| 85 | .list = LIST_HEAD_INIT(publ_cluster.list), | ||
| 86 | .size = 0, | ||
| 87 | }; | ||
| 88 | |||
| 89 | static struct publ_list publ_node = { | ||
| 90 | .list = LIST_HEAD_INIT(publ_node.list), | ||
| 91 | .size = 0, | ||
| 92 | }; | ||
| 93 | |||
| 94 | static struct publ_list *publ_lists[] = { | ||
| 95 | NULL, | ||
| 96 | &publ_zone, /* publ_lists[TIPC_ZONE_SCOPE] */ | ||
| 97 | &publ_cluster, /* publ_lists[TIPC_CLUSTER_SCOPE] */ | ||
| 98 | &publ_node /* publ_lists[TIPC_NODE_SCOPE] */ | ||
| 99 | }; | ||
| 74 | 100 | ||
| 75 | static LIST_HEAD(publ_root); | ||
| 76 | static u32 publ_cnt; | ||
| 77 | 101 | ||
| 78 | /** | 102 | /** |
| 79 | * publ_to_item - add publication info to a publication message | 103 | * publ_to_item - add publication info to a publication message |
| 80 | */ | 104 | */ |
| 81 | |||
| 82 | static void publ_to_item(struct distr_item *i, struct publication *p) | 105 | static void publ_to_item(struct distr_item *i, struct publication *p) |
| 83 | { | 106 | { |
| 84 | i->type = htonl(p->type); | 107 | i->type = htonl(p->type); |
| @@ -91,7 +114,6 @@ static void publ_to_item(struct distr_item *i, struct publication *p) | |||
| 91 | /** | 114 | /** |
| 92 | * named_prepare_buf - allocate & initialize a publication message | 115 | * named_prepare_buf - allocate & initialize a publication message |
| 93 | */ | 116 | */ |
| 94 | |||
| 95 | static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) | 117 | static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) |
| 96 | { | 118 | { |
| 97 | struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size); | 119 | struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size); |
| @@ -126,14 +148,16 @@ static void named_cluster_distribute(struct sk_buff *buf) | |||
| 126 | /** | 148 | /** |
| 127 | * tipc_named_publish - tell other nodes about a new publication by this node | 149 | * tipc_named_publish - tell other nodes about a new publication by this node |
| 128 | */ | 150 | */ |
| 129 | |||
| 130 | void tipc_named_publish(struct publication *publ) | 151 | void tipc_named_publish(struct publication *publ) |
| 131 | { | 152 | { |
| 132 | struct sk_buff *buf; | 153 | struct sk_buff *buf; |
| 133 | struct distr_item *item; | 154 | struct distr_item *item; |
| 134 | 155 | ||
| 135 | list_add_tail(&publ->local_list, &publ_root); | 156 | list_add_tail(&publ->local_list, &publ_lists[publ->scope]->list); |
| 136 | publ_cnt++; | 157 | publ_lists[publ->scope]->size++; |
| 158 | |||
| 159 | if (publ->scope == TIPC_NODE_SCOPE) | ||
| 160 | return; | ||
| 137 | 161 | ||
| 138 | buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0); | 162 | buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0); |
| 139 | if (!buf) { | 163 | if (!buf) { |
| @@ -149,14 +173,16 @@ void tipc_named_publish(struct publication *publ) | |||
| 149 | /** | 173 | /** |
| 150 | * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node | 174 | * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node |
| 151 | */ | 175 | */ |
| 152 | |||
| 153 | void tipc_named_withdraw(struct publication *publ) | 176 | void tipc_named_withdraw(struct publication *publ) |
| 154 | { | 177 | { |
| 155 | struct sk_buff *buf; | 178 | struct sk_buff *buf; |
| 156 | struct distr_item *item; | 179 | struct distr_item *item; |
| 157 | 180 | ||
| 158 | list_del(&publ->local_list); | 181 | list_del(&publ->local_list); |
| 159 | publ_cnt--; | 182 | publ_lists[publ->scope]->size--; |
| 183 | |||
| 184 | if (publ->scope == TIPC_NODE_SCOPE) | ||
| 185 | return; | ||
| 160 | 186 | ||
| 161 | buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0); | 187 | buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0); |
| 162 | if (!buf) { | 188 | if (!buf) { |
| @@ -169,25 +195,51 @@ void tipc_named_withdraw(struct publication *publ) | |||
| 169 | named_cluster_distribute(buf); | 195 | named_cluster_distribute(buf); |
| 170 | } | 196 | } |
| 171 | 197 | ||
| 198 | /* | ||
| 199 | * named_distribute - prepare name info for bulk distribution to another node | ||
| 200 | */ | ||
| 201 | static void named_distribute(struct list_head *message_list, u32 node, | ||
| 202 | struct publ_list *pls, u32 max_item_buf) | ||
| 203 | { | ||
| 204 | struct publication *publ; | ||
| 205 | struct sk_buff *buf = NULL; | ||
| 206 | struct distr_item *item = NULL; | ||
| 207 | u32 left = 0; | ||
| 208 | u32 rest = pls->size * ITEM_SIZE; | ||
| 209 | |||
| 210 | list_for_each_entry(publ, &pls->list, local_list) { | ||
| 211 | if (!buf) { | ||
| 212 | left = (rest <= max_item_buf) ? rest : max_item_buf; | ||
| 213 | rest -= left; | ||
| 214 | buf = named_prepare_buf(PUBLICATION, left, node); | ||
| 215 | if (!buf) { | ||
| 216 | warn("Bulk publication failure\n"); | ||
| 217 | return; | ||
| 218 | } | ||
| 219 | item = (struct distr_item *)msg_data(buf_msg(buf)); | ||
| 220 | } | ||
| 221 | publ_to_item(item, publ); | ||
| 222 | item++; | ||
| 223 | left -= ITEM_SIZE; | ||
| 224 | if (!left) { | ||
| 225 | list_add_tail((struct list_head *)buf, message_list); | ||
| 226 | buf = NULL; | ||
| 227 | } | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 172 | /** | 231 | /** |
| 173 | * tipc_named_node_up - tell specified node about all publications by this node | 232 | * tipc_named_node_up - tell specified node about all publications by this node |
| 174 | */ | 233 | */ |
| 175 | |||
| 176 | void tipc_named_node_up(unsigned long nodearg) | 234 | void tipc_named_node_up(unsigned long nodearg) |
| 177 | { | 235 | { |
| 178 | struct tipc_node *n_ptr; | 236 | struct tipc_node *n_ptr; |
| 179 | struct tipc_link *l_ptr; | 237 | struct tipc_link *l_ptr; |
| 180 | struct publication *publ; | ||
| 181 | struct distr_item *item = NULL; | ||
| 182 | struct sk_buff *buf = NULL; | ||
| 183 | struct list_head message_list; | 238 | struct list_head message_list; |
| 184 | u32 node = (u32)nodearg; | 239 | u32 node = (u32)nodearg; |
| 185 | u32 left = 0; | ||
| 186 | u32 rest; | ||
| 187 | u32 max_item_buf = 0; | 240 | u32 max_item_buf = 0; |
| 188 | 241 | ||
| 189 | /* compute maximum amount of publication data to send per message */ | 242 | /* compute maximum amount of publication data to send per message */ |
| 190 | |||
| 191 | read_lock_bh(&tipc_net_lock); | 243 | read_lock_bh(&tipc_net_lock); |
| 192 | n_ptr = tipc_node_find(node); | 244 | n_ptr = tipc_node_find(node); |
| 193 | if (n_ptr) { | 245 | if (n_ptr) { |
| @@ -203,32 +255,11 @@ void tipc_named_node_up(unsigned long nodearg) | |||
| 203 | return; | 255 | return; |
| 204 | 256 | ||
| 205 | /* create list of publication messages, then send them as a unit */ | 257 | /* create list of publication messages, then send them as a unit */ |
| 206 | |||
| 207 | INIT_LIST_HEAD(&message_list); | 258 | INIT_LIST_HEAD(&message_list); |
| 208 | 259 | ||
| 209 | read_lock_bh(&tipc_nametbl_lock); | 260 | read_lock_bh(&tipc_nametbl_lock); |
| 210 | rest = publ_cnt * ITEM_SIZE; | 261 | named_distribute(&message_list, node, &publ_cluster, max_item_buf); |
| 211 | 262 | named_distribute(&message_list, node, &publ_zone, max_item_buf); | |
| 212 | list_for_each_entry(publ, &publ_root, local_list) { | ||
| 213 | if (!buf) { | ||
| 214 | left = (rest <= max_item_buf) ? rest : max_item_buf; | ||
| 215 | rest -= left; | ||
| 216 | buf = named_prepare_buf(PUBLICATION, left, node); | ||
| 217 | if (!buf) { | ||
| 218 | warn("Bulk publication distribution failure\n"); | ||
| 219 | goto exit; | ||
| 220 | } | ||
| 221 | item = (struct distr_item *)msg_data(buf_msg(buf)); | ||
| 222 | } | ||
| 223 | publ_to_item(item, publ); | ||
| 224 | item++; | ||
| 225 | left -= ITEM_SIZE; | ||
| 226 | if (!left) { | ||
| 227 | list_add_tail((struct list_head *)buf, &message_list); | ||
| 228 | buf = NULL; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | exit: | ||
| 232 | read_unlock_bh(&tipc_nametbl_lock); | 263 | read_unlock_bh(&tipc_nametbl_lock); |
| 233 | 264 | ||
| 234 | tipc_link_send_names(&message_list, (u32)node); | 265 | tipc_link_send_names(&message_list, (u32)node); |
| @@ -240,7 +271,6 @@ exit: | |||
| 240 | * Invoked for each publication issued by a newly failed node. | 271 | * Invoked for each publication issued by a newly failed node. |
| 241 | * Removes publication structure from name table & deletes it. | 272 | * Removes publication structure from name table & deletes it. |
| 242 | */ | 273 | */ |
| 243 | |||
| 244 | static void named_purge_publ(struct publication *publ) | 274 | static void named_purge_publ(struct publication *publ) |
| 245 | { | 275 | { |
| 246 | struct publication *p; | 276 | struct publication *p; |
| @@ -264,7 +294,6 @@ static void named_purge_publ(struct publication *publ) | |||
| 264 | /** | 294 | /** |
| 265 | * tipc_named_recv - process name table update message sent by another node | 295 | * tipc_named_recv - process name table update message sent by another node |
| 266 | */ | 296 | */ |
| 267 | |||
| 268 | void tipc_named_recv(struct sk_buff *buf) | 297 | void tipc_named_recv(struct sk_buff *buf) |
| 269 | { | 298 | { |
| 270 | struct publication *publ; | 299 | struct publication *publ; |
| @@ -316,21 +345,22 @@ void tipc_named_recv(struct sk_buff *buf) | |||
| 316 | } | 345 | } |
| 317 | 346 | ||
| 318 | /** | 347 | /** |
| 319 | * tipc_named_reinit - re-initialize local publication list | 348 | * tipc_named_reinit - re-initialize local publications |
| 320 | * | 349 | * |
| 321 | * This routine is called whenever TIPC networking is enabled. | 350 | * This routine is called whenever TIPC networking is enabled. |
| 322 | * All existing publications by this node that have "cluster" or "zone" scope | 351 | * All name table entries published by this node are updated to reflect |
| 323 | * are updated to reflect the node's new network address. | 352 | * the node's new network address. |
| 324 | */ | 353 | */ |
| 325 | |||
| 326 | void tipc_named_reinit(void) | 354 | void tipc_named_reinit(void) |
| 327 | { | 355 | { |
| 328 | struct publication *publ; | 356 | struct publication *publ; |
| 357 | int scope; | ||
| 329 | 358 | ||
| 330 | write_lock_bh(&tipc_nametbl_lock); | 359 | write_lock_bh(&tipc_nametbl_lock); |
| 331 | 360 | ||
| 332 | list_for_each_entry(publ, &publ_root, local_list) | 361 | for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++) |
| 333 | publ->node = tipc_own_addr; | 362 | list_for_each_entry(publ, &publ_lists[scope]->list, local_list) |
| 363 | publ->node = tipc_own_addr; | ||
| 334 | 364 | ||
| 335 | write_unlock_bh(&tipc_nametbl_lock); | 365 | write_unlock_bh(&tipc_nametbl_lock); |
| 336 | } | 366 | } |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index c6a1ae36952e..010f24a59da2 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
| @@ -56,7 +56,6 @@ static int tipc_nametbl_size = 1024; /* must be a power of 2 */ | |||
| 56 | * publications of the associated name sequence belong to it. | 56 | * publications of the associated name sequence belong to it. |
| 57 | * (The cluster and node lists may be empty.) | 57 | * (The cluster and node lists may be empty.) |
| 58 | */ | 58 | */ |
| 59 | |||
| 60 | struct name_info { | 59 | struct name_info { |
| 61 | struct list_head node_list; | 60 | struct list_head node_list; |
| 62 | struct list_head cluster_list; | 61 | struct list_head cluster_list; |
| @@ -72,7 +71,6 @@ struct name_info { | |||
| 72 | * @upper: name sequence upper bound | 71 | * @upper: name sequence upper bound |
| 73 | * @info: pointer to name sequence publication info | 72 | * @info: pointer to name sequence publication info |
| 74 | */ | 73 | */ |
| 75 | |||
| 76 | struct sub_seq { | 74 | struct sub_seq { |
| 77 | u32 lower; | 75 | u32 lower; |
| 78 | u32 upper; | 76 | u32 upper; |
| @@ -90,7 +88,6 @@ struct sub_seq { | |||
| 90 | * @subscriptions: list of subscriptions for this 'type' | 88 | * @subscriptions: list of subscriptions for this 'type' |
| 91 | * @lock: spinlock controlling access to publication lists of all sub-sequences | 89 | * @lock: spinlock controlling access to publication lists of all sub-sequences |
| 92 | */ | 90 | */ |
| 93 | |||
| 94 | struct name_seq { | 91 | struct name_seq { |
| 95 | u32 type; | 92 | u32 type; |
| 96 | struct sub_seq *sseqs; | 93 | struct sub_seq *sseqs; |
| @@ -107,7 +104,6 @@ struct name_seq { | |||
| 107 | * accessed via hashing on 'type'; name sequence lists are *not* sorted | 104 | * accessed via hashing on 'type'; name sequence lists are *not* sorted |
| 108 | * @local_publ_count: number of publications issued by this node | 105 | * @local_publ_count: number of publications issued by this node |
| 109 | */ | 106 | */ |
| 110 | |||
| 111 | struct name_table { | 107 | struct name_table { |
| 112 | struct hlist_head *types; | 108 | struct hlist_head *types; |
| 113 | u32 local_publ_count; | 109 | u32 local_publ_count; |
| @@ -124,7 +120,6 @@ static int hash(int x) | |||
| 124 | /** | 120 | /** |
| 125 | * publ_create - create a publication structure | 121 | * publ_create - create a publication structure |
| 126 | */ | 122 | */ |
| 127 | |||
| 128 | static struct publication *publ_create(u32 type, u32 lower, u32 upper, | 123 | static struct publication *publ_create(u32 type, u32 lower, u32 upper, |
| 129 | u32 scope, u32 node, u32 port_ref, | 124 | u32 scope, u32 node, u32 port_ref, |
| 130 | u32 key) | 125 | u32 key) |
| @@ -151,7 +146,6 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper, | |||
| 151 | /** | 146 | /** |
| 152 | * tipc_subseq_alloc - allocate a specified number of sub-sequence structures | 147 | * tipc_subseq_alloc - allocate a specified number of sub-sequence structures |
| 153 | */ | 148 | */ |
| 154 | |||
| 155 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) | 149 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) |
| 156 | { | 150 | { |
| 157 | struct sub_seq *sseq = kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC); | 151 | struct sub_seq *sseq = kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC); |
| @@ -163,7 +157,6 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt) | |||
| 163 | * | 157 | * |
| 164 | * Allocates a single sub-sequence structure and sets it to all 0's. | 158 | * Allocates a single sub-sequence structure and sets it to all 0's. |
| 165 | */ | 159 | */ |
| 166 | |||
| 167 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) | 160 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) |
| 168 | { | 161 | { |
| 169 | struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC); | 162 | struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC); |
| @@ -186,12 +179,23 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea | |||
| 186 | return nseq; | 179 | return nseq; |
| 187 | } | 180 | } |
| 188 | 181 | ||
| 189 | /** | 182 | /* |
| 183 | * nameseq_delete_empty - deletes a name sequence structure if now unused | ||
| 184 | */ | ||
| 185 | static void nameseq_delete_empty(struct name_seq *seq) | ||
| 186 | { | ||
| 187 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | ||
| 188 | hlist_del_init(&seq->ns_list); | ||
| 189 | kfree(seq->sseqs); | ||
| 190 | kfree(seq); | ||
| 191 | } | ||
| 192 | } | ||
| 193 | |||
| 194 | /* | ||
| 190 | * nameseq_find_subseq - find sub-sequence (if any) matching a name instance | 195 | * nameseq_find_subseq - find sub-sequence (if any) matching a name instance |
| 191 | * | 196 | * |
| 192 | * Very time-critical, so binary searches through sub-sequence array. | 197 | * Very time-critical, so binary searches through sub-sequence array. |
| 193 | */ | 198 | */ |
| 194 | |||
| 195 | static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, | 199 | static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, |
| 196 | u32 instance) | 200 | u32 instance) |
| 197 | { | 201 | { |
| @@ -221,7 +225,6 @@ static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, | |||
| 221 | * | 225 | * |
| 222 | * Note: Similar to binary search code for locating a sub-sequence. | 226 | * Note: Similar to binary search code for locating a sub-sequence. |
| 223 | */ | 227 | */ |
| 224 | |||
| 225 | static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) | 228 | static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) |
| 226 | { | 229 | { |
| 227 | struct sub_seq *sseqs = nseq->sseqs; | 230 | struct sub_seq *sseqs = nseq->sseqs; |
| @@ -242,9 +245,8 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) | |||
| 242 | } | 245 | } |
| 243 | 246 | ||
| 244 | /** | 247 | /** |
| 245 | * tipc_nameseq_insert_publ - | 248 | * tipc_nameseq_insert_publ |
| 246 | */ | 249 | */ |
| 247 | |||
| 248 | static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | 250 | static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, |
| 249 | u32 type, u32 lower, u32 upper, | 251 | u32 type, u32 lower, u32 upper, |
| 250 | u32 scope, u32 node, u32 port, u32 key) | 252 | u32 scope, u32 node, u32 port, u32 key) |
| @@ -260,7 +262,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 260 | if (sseq) { | 262 | if (sseq) { |
| 261 | 263 | ||
| 262 | /* Lower end overlaps existing entry => need an exact match */ | 264 | /* Lower end overlaps existing entry => need an exact match */ |
| 263 | |||
| 264 | if ((sseq->lower != lower) || (sseq->upper != upper)) { | 265 | if ((sseq->lower != lower) || (sseq->upper != upper)) { |
| 265 | warn("Cannot publish {%u,%u,%u}, overlap error\n", | 266 | warn("Cannot publish {%u,%u,%u}, overlap error\n", |
| 266 | type, lower, upper); | 267 | type, lower, upper); |
| @@ -280,11 +281,9 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 280 | struct sub_seq *freesseq; | 281 | struct sub_seq *freesseq; |
| 281 | 282 | ||
| 282 | /* Find where lower end should be inserted */ | 283 | /* Find where lower end should be inserted */ |
| 283 | |||
| 284 | inspos = nameseq_locate_subseq(nseq, lower); | 284 | inspos = nameseq_locate_subseq(nseq, lower); |
| 285 | 285 | ||
| 286 | /* Fail if upper end overlaps into an existing entry */ | 286 | /* Fail if upper end overlaps into an existing entry */ |
| 287 | |||
| 288 | if ((inspos < nseq->first_free) && | 287 | if ((inspos < nseq->first_free) && |
| 289 | (upper >= nseq->sseqs[inspos].lower)) { | 288 | (upper >= nseq->sseqs[inspos].lower)) { |
| 290 | warn("Cannot publish {%u,%u,%u}, overlap error\n", | 289 | warn("Cannot publish {%u,%u,%u}, overlap error\n", |
| @@ -293,7 +292,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 293 | } | 292 | } |
| 294 | 293 | ||
| 295 | /* Ensure there is space for new sub-sequence */ | 294 | /* Ensure there is space for new sub-sequence */ |
| 296 | |||
| 297 | if (nseq->first_free == nseq->alloc) { | 295 | if (nseq->first_free == nseq->alloc) { |
| 298 | struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2); | 296 | struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2); |
| 299 | 297 | ||
| @@ -321,7 +319,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 321 | INIT_LIST_HEAD(&info->zone_list); | 319 | INIT_LIST_HEAD(&info->zone_list); |
| 322 | 320 | ||
| 323 | /* Insert new sub-sequence */ | 321 | /* Insert new sub-sequence */ |
| 324 | |||
| 325 | sseq = &nseq->sseqs[inspos]; | 322 | sseq = &nseq->sseqs[inspos]; |
| 326 | freesseq = &nseq->sseqs[nseq->first_free]; | 323 | freesseq = &nseq->sseqs[nseq->first_free]; |
| 327 | memmove(sseq + 1, sseq, (freesseq - sseq) * sizeof(*sseq)); | 324 | memmove(sseq + 1, sseq, (freesseq - sseq) * sizeof(*sseq)); |
| @@ -333,8 +330,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 333 | created_subseq = 1; | 330 | created_subseq = 1; |
| 334 | } | 331 | } |
| 335 | 332 | ||
| 336 | /* Insert a publication: */ | 333 | /* Insert a publication */ |
| 337 | |||
| 338 | publ = publ_create(type, lower, upper, scope, node, port, key); | 334 | publ = publ_create(type, lower, upper, scope, node, port, key); |
| 339 | if (!publ) | 335 | if (!publ) |
| 340 | return NULL; | 336 | return NULL; |
| @@ -347,14 +343,12 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 347 | info->cluster_list_size++; | 343 | info->cluster_list_size++; |
| 348 | } | 344 | } |
| 349 | 345 | ||
| 350 | if (node == tipc_own_addr) { | 346 | if (in_own_node(node)) { |
| 351 | list_add(&publ->node_list, &info->node_list); | 347 | list_add(&publ->node_list, &info->node_list); |
| 352 | info->node_list_size++; | 348 | info->node_list_size++; |
| 353 | } | 349 | } |
| 354 | 350 | ||
| 355 | /* | 351 | /* Any subscriptions waiting for notification? */ |
| 356 | * Any subscriptions waiting for notification? | ||
| 357 | */ | ||
| 358 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { | 352 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { |
| 359 | tipc_subscr_report_overlap(s, | 353 | tipc_subscr_report_overlap(s, |
| 360 | publ->lower, | 354 | publ->lower, |
| @@ -368,7 +362,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 368 | } | 362 | } |
| 369 | 363 | ||
| 370 | /** | 364 | /** |
| 371 | * tipc_nameseq_remove_publ - | 365 | * tipc_nameseq_remove_publ |
| 372 | * | 366 | * |
| 373 | * NOTE: There may be cases where TIPC is asked to remove a publication | 367 | * NOTE: There may be cases where TIPC is asked to remove a publication |
| 374 | * that is not in the name table. For example, if another node issues a | 368 | * that is not in the name table. For example, if another node issues a |
| @@ -378,7 +372,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
| 378 | * A failed withdraw request simply returns a failure indication and lets the | 372 | * A failed withdraw request simply returns a failure indication and lets the |
| 379 | * caller issue any error or warning messages associated with such a problem. | 373 | * caller issue any error or warning messages associated with such a problem. |
| 380 | */ | 374 | */ |
| 381 | |||
| 382 | static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | 375 | static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, |
| 383 | u32 node, u32 ref, u32 key) | 376 | u32 node, u32 ref, u32 key) |
| 384 | { | 377 | { |
| @@ -395,7 +388,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i | |||
| 395 | info = sseq->info; | 388 | info = sseq->info; |
| 396 | 389 | ||
| 397 | /* Locate publication, if it exists */ | 390 | /* Locate publication, if it exists */ |
| 398 | |||
| 399 | list_for_each_entry(publ, &info->zone_list, zone_list) { | 391 | list_for_each_entry(publ, &info->zone_list, zone_list) { |
| 400 | if ((publ->key == key) && (publ->ref == ref) && | 392 | if ((publ->key == key) && (publ->ref == ref) && |
| 401 | (!publ->node || (publ->node == node))) | 393 | (!publ->node || (publ->node == node))) |
| @@ -405,26 +397,22 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i | |||
| 405 | 397 | ||
| 406 | found: | 398 | found: |
| 407 | /* Remove publication from zone scope list */ | 399 | /* Remove publication from zone scope list */ |
| 408 | |||
| 409 | list_del(&publ->zone_list); | 400 | list_del(&publ->zone_list); |
| 410 | info->zone_list_size--; | 401 | info->zone_list_size--; |
| 411 | 402 | ||
| 412 | /* Remove publication from cluster scope list, if present */ | 403 | /* Remove publication from cluster scope list, if present */ |
| 413 | |||
| 414 | if (in_own_cluster(node)) { | 404 | if (in_own_cluster(node)) { |
| 415 | list_del(&publ->cluster_list); | 405 | list_del(&publ->cluster_list); |
| 416 | info->cluster_list_size--; | 406 | info->cluster_list_size--; |
| 417 | } | 407 | } |
| 418 | 408 | ||
| 419 | /* Remove publication from node scope list, if present */ | 409 | /* Remove publication from node scope list, if present */ |
| 420 | 410 | if (in_own_node(node)) { | |
| 421 | if (node == tipc_own_addr) { | ||
| 422 | list_del(&publ->node_list); | 411 | list_del(&publ->node_list); |
| 423 | info->node_list_size--; | 412 | info->node_list_size--; |
| 424 | } | 413 | } |
| 425 | 414 | ||
| 426 | /* Contract subseq list if no more publications for that subseq */ | 415 | /* Contract subseq list if no more publications for that subseq */ |
| 427 | |||
| 428 | if (list_empty(&info->zone_list)) { | 416 | if (list_empty(&info->zone_list)) { |
| 429 | kfree(info); | 417 | kfree(info); |
| 430 | free = &nseq->sseqs[nseq->first_free--]; | 418 | free = &nseq->sseqs[nseq->first_free--]; |
| @@ -433,7 +421,6 @@ found: | |||
| 433 | } | 421 | } |
| 434 | 422 | ||
| 435 | /* Notify any waiting subscriptions */ | 423 | /* Notify any waiting subscriptions */ |
| 436 | |||
| 437 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { | 424 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { |
| 438 | tipc_subscr_report_overlap(s, | 425 | tipc_subscr_report_overlap(s, |
| 439 | publ->lower, | 426 | publ->lower, |
| @@ -452,7 +439,6 @@ found: | |||
| 452 | * the prescribed number of events if there is any sub- | 439 | * the prescribed number of events if there is any sub- |
| 453 | * sequence overlapping with the requested sequence | 440 | * sequence overlapping with the requested sequence |
| 454 | */ | 441 | */ |
| 455 | |||
| 456 | static void tipc_nameseq_subscribe(struct name_seq *nseq, | 442 | static void tipc_nameseq_subscribe(struct name_seq *nseq, |
| 457 | struct tipc_subscription *s) | 443 | struct tipc_subscription *s) |
| 458 | { | 444 | { |
| @@ -504,9 +490,10 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, | |||
| 504 | { | 490 | { |
| 505 | struct name_seq *seq = nametbl_find_seq(type); | 491 | struct name_seq *seq = nametbl_find_seq(type); |
| 506 | 492 | ||
| 507 | if (lower > upper) { | 493 | if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) || |
| 508 | warn("Failed to publish illegal {%u,%u,%u}\n", | 494 | (lower > upper)) { |
| 509 | type, lower, upper); | 495 | dbg("Failed to publish illegal {%u,%u,%u} with scope %u\n", |
| 496 | type, lower, upper, scope); | ||
| 510 | return NULL; | 497 | return NULL; |
| 511 | } | 498 | } |
| 512 | 499 | ||
| @@ -529,12 +516,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
| 529 | return NULL; | 516 | return NULL; |
| 530 | 517 | ||
| 531 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); | 518 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); |
| 532 | 519 | nameseq_delete_empty(seq); | |
| 533 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | ||
| 534 | hlist_del_init(&seq->ns_list); | ||
| 535 | kfree(seq->sseqs); | ||
| 536 | kfree(seq); | ||
| 537 | } | ||
| 538 | return publ; | 520 | return publ; |
| 539 | } | 521 | } |
| 540 | 522 | ||
| @@ -551,7 +533,6 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
| 551 | * - if name translation is attempted and fails, sets 'destnode' to 0 | 533 | * - if name translation is attempted and fails, sets 'destnode' to 0 |
| 552 | * and returns 0 | 534 | * and returns 0 |
| 553 | */ | 535 | */ |
| 554 | |||
| 555 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | 536 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) |
| 556 | { | 537 | { |
| 557 | struct sub_seq *sseq; | 538 | struct sub_seq *sseq; |
| @@ -574,7 +555,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | |||
| 574 | spin_lock_bh(&seq->lock); | 555 | spin_lock_bh(&seq->lock); |
| 575 | info = sseq->info; | 556 | info = sseq->info; |
| 576 | 557 | ||
| 577 | /* Closest-First Algorithm: */ | 558 | /* Closest-First Algorithm */ |
| 578 | if (likely(!*destnode)) { | 559 | if (likely(!*destnode)) { |
| 579 | if (!list_empty(&info->node_list)) { | 560 | if (!list_empty(&info->node_list)) { |
| 580 | publ = list_first_entry(&info->node_list, | 561 | publ = list_first_entry(&info->node_list, |
| @@ -597,14 +578,14 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | |||
| 597 | } | 578 | } |
| 598 | } | 579 | } |
| 599 | 580 | ||
| 600 | /* Round-Robin Algorithm: */ | 581 | /* Round-Robin Algorithm */ |
| 601 | else if (*destnode == tipc_own_addr) { | 582 | else if (*destnode == tipc_own_addr) { |
| 602 | if (list_empty(&info->node_list)) | 583 | if (list_empty(&info->node_list)) |
| 603 | goto no_match; | 584 | goto no_match; |
| 604 | publ = list_first_entry(&info->node_list, struct publication, | 585 | publ = list_first_entry(&info->node_list, struct publication, |
| 605 | node_list); | 586 | node_list); |
| 606 | list_move_tail(&publ->node_list, &info->node_list); | 587 | list_move_tail(&publ->node_list, &info->node_list); |
| 607 | } else if (in_own_cluster(*destnode)) { | 588 | } else if (in_own_cluster_exact(*destnode)) { |
| 608 | if (list_empty(&info->cluster_list)) | 589 | if (list_empty(&info->cluster_list)) |
| 609 | goto no_match; | 590 | goto no_match; |
| 610 | publ = list_first_entry(&info->cluster_list, struct publication, | 591 | publ = list_first_entry(&info->cluster_list, struct publication, |
| @@ -638,7 +619,6 @@ not_found: | |||
| 638 | * | 619 | * |
| 639 | * Returns non-zero if any off-node ports overlap | 620 | * Returns non-zero if any off-node ports overlap |
| 640 | */ | 621 | */ |
| 641 | |||
| 642 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, | 622 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, |
| 643 | struct tipc_port_list *dports) | 623 | struct tipc_port_list *dports) |
| 644 | { | 624 | { |
| @@ -682,7 +662,6 @@ exit: | |||
| 682 | /* | 662 | /* |
| 683 | * tipc_nametbl_publish - add name publication to network name tables | 663 | * tipc_nametbl_publish - add name publication to network name tables |
| 684 | */ | 664 | */ |
| 685 | |||
| 686 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | 665 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, |
| 687 | u32 scope, u32 port_ref, u32 key) | 666 | u32 scope, u32 port_ref, u32 key) |
| 688 | { | 667 | { |
| @@ -695,11 +674,12 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
| 695 | } | 674 | } |
| 696 | 675 | ||
| 697 | write_lock_bh(&tipc_nametbl_lock); | 676 | write_lock_bh(&tipc_nametbl_lock); |
| 698 | table.local_publ_count++; | ||
| 699 | publ = tipc_nametbl_insert_publ(type, lower, upper, scope, | 677 | publ = tipc_nametbl_insert_publ(type, lower, upper, scope, |
| 700 | tipc_own_addr, port_ref, key); | 678 | tipc_own_addr, port_ref, key); |
| 701 | if (publ && (scope != TIPC_NODE_SCOPE)) | 679 | if (likely(publ)) { |
| 680 | table.local_publ_count++; | ||
| 702 | tipc_named_publish(publ); | 681 | tipc_named_publish(publ); |
| 682 | } | ||
| 703 | write_unlock_bh(&tipc_nametbl_lock); | 683 | write_unlock_bh(&tipc_nametbl_lock); |
| 704 | return publ; | 684 | return publ; |
| 705 | } | 685 | } |
| @@ -707,7 +687,6 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
| 707 | /** | 687 | /** |
| 708 | * tipc_nametbl_withdraw - withdraw name publication from network name tables | 688 | * tipc_nametbl_withdraw - withdraw name publication from network name tables |
| 709 | */ | 689 | */ |
| 710 | |||
| 711 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | 690 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) |
| 712 | { | 691 | { |
| 713 | struct publication *publ; | 692 | struct publication *publ; |
| @@ -716,8 +695,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | |||
| 716 | publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); | 695 | publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); |
| 717 | if (likely(publ)) { | 696 | if (likely(publ)) { |
| 718 | table.local_publ_count--; | 697 | table.local_publ_count--; |
| 719 | if (publ->scope != TIPC_NODE_SCOPE) | 698 | tipc_named_withdraw(publ); |
| 720 | tipc_named_withdraw(publ); | ||
| 721 | write_unlock_bh(&tipc_nametbl_lock); | 699 | write_unlock_bh(&tipc_nametbl_lock); |
| 722 | list_del_init(&publ->pport_list); | 700 | list_del_init(&publ->pport_list); |
| 723 | kfree(publ); | 701 | kfree(publ); |
| @@ -733,7 +711,6 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | |||
| 733 | /** | 711 | /** |
| 734 | * tipc_nametbl_subscribe - add a subscription object to the name table | 712 | * tipc_nametbl_subscribe - add a subscription object to the name table |
| 735 | */ | 713 | */ |
| 736 | |||
| 737 | void tipc_nametbl_subscribe(struct tipc_subscription *s) | 714 | void tipc_nametbl_subscribe(struct tipc_subscription *s) |
| 738 | { | 715 | { |
| 739 | u32 type = s->seq.type; | 716 | u32 type = s->seq.type; |
| @@ -757,7 +734,6 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s) | |||
| 757 | /** | 734 | /** |
| 758 | * tipc_nametbl_unsubscribe - remove a subscription object from name table | 735 | * tipc_nametbl_unsubscribe - remove a subscription object from name table |
| 759 | */ | 736 | */ |
| 760 | |||
| 761 | void tipc_nametbl_unsubscribe(struct tipc_subscription *s) | 737 | void tipc_nametbl_unsubscribe(struct tipc_subscription *s) |
| 762 | { | 738 | { |
| 763 | struct name_seq *seq; | 739 | struct name_seq *seq; |
| @@ -768,11 +744,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s) | |||
| 768 | spin_lock_bh(&seq->lock); | 744 | spin_lock_bh(&seq->lock); |
| 769 | list_del_init(&s->nameseq_list); | 745 | list_del_init(&s->nameseq_list); |
| 770 | spin_unlock_bh(&seq->lock); | 746 | spin_unlock_bh(&seq->lock); |
| 771 | if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) { | 747 | nameseq_delete_empty(seq); |
| 772 | hlist_del_init(&seq->ns_list); | ||
| 773 | kfree(seq->sseqs); | ||
| 774 | kfree(seq); | ||
| 775 | } | ||
| 776 | } | 748 | } |
| 777 | write_unlock_bh(&tipc_nametbl_lock); | 749 | write_unlock_bh(&tipc_nametbl_lock); |
| 778 | } | 750 | } |
| @@ -781,7 +753,6 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s) | |||
| 781 | /** | 753 | /** |
| 782 | * subseq_list: print specified sub-sequence contents into the given buffer | 754 | * subseq_list: print specified sub-sequence contents into the given buffer |
| 783 | */ | 755 | */ |
| 784 | |||
| 785 | static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, | 756 | static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, |
| 786 | u32 index) | 757 | u32 index) |
| 787 | { | 758 | { |
| @@ -818,7 +789,6 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, | |||
| 818 | /** | 789 | /** |
| 819 | * nameseq_list: print specified name sequence contents into the given buffer | 790 | * nameseq_list: print specified name sequence contents into the given buffer |
| 820 | */ | 791 | */ |
| 821 | |||
| 822 | static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, | 792 | static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, |
| 823 | u32 type, u32 lowbound, u32 upbound, u32 index) | 793 | u32 type, u32 lowbound, u32 upbound, u32 index) |
| 824 | { | 794 | { |
| @@ -849,7 +819,6 @@ static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, | |||
| 849 | /** | 819 | /** |
| 850 | * nametbl_header - print name table header into the given buffer | 820 | * nametbl_header - print name table header into the given buffer |
| 851 | */ | 821 | */ |
| 852 | |||
| 853 | static void nametbl_header(struct print_buf *buf, u32 depth) | 822 | static void nametbl_header(struct print_buf *buf, u32 depth) |
| 854 | { | 823 | { |
| 855 | const char *header[] = { | 824 | const char *header[] = { |
| @@ -871,7 +840,6 @@ static void nametbl_header(struct print_buf *buf, u32 depth) | |||
| 871 | /** | 840 | /** |
| 872 | * nametbl_list - print specified name table contents into the given buffer | 841 | * nametbl_list - print specified name table contents into the given buffer |
| 873 | */ | 842 | */ |
| 874 | |||
| 875 | static void nametbl_list(struct print_buf *buf, u32 depth_info, | 843 | static void nametbl_list(struct print_buf *buf, u32 depth_info, |
| 876 | u32 type, u32 lowbound, u32 upbound) | 844 | u32 type, u32 lowbound, u32 upbound) |
| 877 | { | 845 | { |
| @@ -970,7 +938,6 @@ void tipc_nametbl_stop(void) | |||
| 970 | return; | 938 | return; |
| 971 | 939 | ||
| 972 | /* Verify name table is empty, then release it */ | 940 | /* Verify name table is empty, then release it */ |
| 973 | |||
| 974 | write_lock_bh(&tipc_nametbl_lock); | 941 | write_lock_bh(&tipc_nametbl_lock); |
| 975 | for (i = 0; i < tipc_nametbl_size; i++) { | 942 | for (i = 0; i < tipc_nametbl_size; i++) { |
| 976 | if (!hlist_empty(&table.types[i])) | 943 | if (!hlist_empty(&table.types[i])) |
| @@ -980,4 +947,3 @@ void tipc_nametbl_stop(void) | |||
| 980 | table.types = NULL; | 947 | table.types = NULL; |
| 981 | write_unlock_bh(&tipc_nametbl_lock); | 948 | write_unlock_bh(&tipc_nametbl_lock); |
| 982 | } | 949 | } |
| 983 | |||
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index 207d59ebf849..71cb4dc712df 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h | |||
| @@ -45,10 +45,8 @@ struct tipc_port_list; | |||
| 45 | /* | 45 | /* |
| 46 | * TIPC name types reserved for internal TIPC use (both current and planned) | 46 | * TIPC name types reserved for internal TIPC use (both current and planned) |
| 47 | */ | 47 | */ |
| 48 | |||
| 49 | #define TIPC_ZM_SRV 3 /* zone master service name type */ | 48 | #define TIPC_ZM_SRV 3 /* zone master service name type */ |
| 50 | 49 | ||
| 51 | |||
| 52 | /** | 50 | /** |
| 53 | * struct publication - info about a published (name or) name sequence | 51 | * struct publication - info about a published (name or) name sequence |
| 54 | * @type: name sequence type | 52 | * @type: name sequence type |
| @@ -67,7 +65,6 @@ struct tipc_port_list; | |||
| 67 | * | 65 | * |
| 68 | * Note that the node list, cluster list, and zone list are circular lists. | 66 | * Note that the node list, cluster list, and zone list are circular lists. |
| 69 | */ | 67 | */ |
| 70 | |||
| 71 | struct publication { | 68 | struct publication { |
| 72 | u32 type; | 69 | u32 type; |
| 73 | u32 lower; | 70 | u32 lower; |
diff --git a/net/tipc/net.c b/net/tipc/net.c index d4531b07076c..7c236c89cf5e 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
| @@ -175,17 +175,14 @@ int tipc_net_start(u32 addr) | |||
| 175 | { | 175 | { |
| 176 | char addr_string[16]; | 176 | char addr_string[16]; |
| 177 | 177 | ||
| 178 | tipc_subscr_stop(); | 178 | write_lock_bh(&tipc_net_lock); |
| 179 | tipc_cfg_stop(); | ||
| 180 | |||
| 181 | tipc_own_addr = addr; | 179 | tipc_own_addr = addr; |
| 182 | tipc_named_reinit(); | 180 | tipc_named_reinit(); |
| 183 | tipc_port_reinit(); | 181 | tipc_port_reinit(); |
| 184 | |||
| 185 | tipc_bclink_init(); | 182 | tipc_bclink_init(); |
| 183 | write_unlock_bh(&tipc_net_lock); | ||
| 186 | 184 | ||
| 187 | tipc_k_signal((Handler)tipc_subscr_start, 0); | 185 | tipc_cfg_reinit(); |
| 188 | tipc_k_signal((Handler)tipc_cfg_init, 0); | ||
| 189 | 186 | ||
| 190 | info("Started in network mode\n"); | 187 | info("Started in network mode\n"); |
| 191 | info("Own node address %s, network identity %u\n", | 188 | info("Own node address %s, network identity %u\n", |
diff --git a/net/tipc/node.c b/net/tipc/node.c index a34cabc2c43a..d4fd341e6e0d 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
| @@ -58,7 +58,7 @@ static atomic_t tipc_num_links = ATOMIC_INIT(0); | |||
| 58 | * entries has been chosen so that no hash chain exceeds 8 nodes and will | 58 | * entries has been chosen so that no hash chain exceeds 8 nodes and will |
| 59 | * usually be much smaller (typically only a single node). | 59 | * usually be much smaller (typically only a single node). |
| 60 | */ | 60 | */ |
| 61 | static inline unsigned int tipc_hashfn(u32 addr) | 61 | static unsigned int tipc_hashfn(u32 addr) |
| 62 | { | 62 | { |
| 63 | return addr & (NODE_HTABLE_SIZE - 1); | 63 | return addr & (NODE_HTABLE_SIZE - 1); |
| 64 | } | 64 | } |
| @@ -66,13 +66,12 @@ static inline unsigned int tipc_hashfn(u32 addr) | |||
| 66 | /* | 66 | /* |
| 67 | * tipc_node_find - locate specified node object, if it exists | 67 | * tipc_node_find - locate specified node object, if it exists |
| 68 | */ | 68 | */ |
| 69 | |||
| 70 | struct tipc_node *tipc_node_find(u32 addr) | 69 | struct tipc_node *tipc_node_find(u32 addr) |
| 71 | { | 70 | { |
| 72 | struct tipc_node *node; | 71 | struct tipc_node *node; |
| 73 | struct hlist_node *pos; | 72 | struct hlist_node *pos; |
| 74 | 73 | ||
| 75 | if (unlikely(!in_own_cluster(addr))) | 74 | if (unlikely(!in_own_cluster_exact(addr))) |
| 76 | return NULL; | 75 | return NULL; |
| 77 | 76 | ||
| 78 | hlist_for_each_entry(node, pos, &node_htable[tipc_hashfn(addr)], hash) { | 77 | hlist_for_each_entry(node, pos, &node_htable[tipc_hashfn(addr)], hash) { |
| @@ -91,7 +90,6 @@ struct tipc_node *tipc_node_find(u32 addr) | |||
| 91 | * time. (It would be preferable to switch to holding net_lock in write mode, | 90 | * time. (It would be preferable to switch to holding net_lock in write mode, |
| 92 | * but this is a non-trivial change.) | 91 | * but this is a non-trivial change.) |
| 93 | */ | 92 | */ |
| 94 | |||
| 95 | struct tipc_node *tipc_node_create(u32 addr) | 93 | struct tipc_node *tipc_node_create(u32 addr) |
| 96 | { | 94 | { |
| 97 | struct tipc_node *n_ptr, *temp_node; | 95 | struct tipc_node *n_ptr, *temp_node; |
| @@ -142,13 +140,11 @@ void tipc_node_delete(struct tipc_node *n_ptr) | |||
| 142 | tipc_num_nodes--; | 140 | tipc_num_nodes--; |
| 143 | } | 141 | } |
| 144 | 142 | ||
| 145 | |||
| 146 | /** | 143 | /** |
| 147 | * tipc_node_link_up - handle addition of link | 144 | * tipc_node_link_up - handle addition of link |
| 148 | * | 145 | * |
| 149 | * Link becomes active (alone or shared) or standby, depending on its priority. | 146 | * Link becomes active (alone or shared) or standby, depending on its priority. |
| 150 | */ | 147 | */ |
| 151 | |||
| 152 | void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 148 | void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
| 153 | { | 149 | { |
| 154 | struct tipc_link **active = &n_ptr->active_links[0]; | 150 | struct tipc_link **active = &n_ptr->active_links[0]; |
| @@ -181,7 +177,6 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
| 181 | /** | 177 | /** |
| 182 | * node_select_active_links - select active link | 178 | * node_select_active_links - select active link |
| 183 | */ | 179 | */ |
| 184 | |||
| 185 | static void node_select_active_links(struct tipc_node *n_ptr) | 180 | static void node_select_active_links(struct tipc_node *n_ptr) |
| 186 | { | 181 | { |
| 187 | struct tipc_link **active = &n_ptr->active_links[0]; | 182 | struct tipc_link **active = &n_ptr->active_links[0]; |
| @@ -209,7 +204,6 @@ static void node_select_active_links(struct tipc_node *n_ptr) | |||
| 209 | /** | 204 | /** |
| 210 | * tipc_node_link_down - handle loss of link | 205 | * tipc_node_link_down - handle loss of link |
| 211 | */ | 206 | */ |
| 212 | |||
| 213 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 207 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
| 214 | { | 208 | { |
| 215 | struct tipc_link **active; | 209 | struct tipc_link **active; |
| @@ -300,7 +294,6 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 300 | tipc_addr_string_fill(addr_string, n_ptr->addr)); | 294 | tipc_addr_string_fill(addr_string, n_ptr->addr)); |
| 301 | 295 | ||
| 302 | /* Flush broadcast link info associated with lost node */ | 296 | /* Flush broadcast link info associated with lost node */ |
| 303 | |||
| 304 | if (n_ptr->bclink.supported) { | 297 | if (n_ptr->bclink.supported) { |
| 305 | while (n_ptr->bclink.deferred_head) { | 298 | while (n_ptr->bclink.deferred_head) { |
| 306 | struct sk_buff *buf = n_ptr->bclink.deferred_head; | 299 | struct sk_buff *buf = n_ptr->bclink.deferred_head; |
| @@ -334,7 +327,6 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 334 | tipc_nodesub_notify(n_ptr); | 327 | tipc_nodesub_notify(n_ptr); |
| 335 | 328 | ||
| 336 | /* Prevent re-contact with node until cleanup is done */ | 329 | /* Prevent re-contact with node until cleanup is done */ |
| 337 | |||
| 338 | n_ptr->block_setup = WAIT_PEER_DOWN | WAIT_NAMES_GONE; | 330 | n_ptr->block_setup = WAIT_PEER_DOWN | WAIT_NAMES_GONE; |
| 339 | tipc_k_signal((Handler)node_name_purge_complete, n_ptr->addr); | 331 | tipc_k_signal((Handler)node_name_purge_complete, n_ptr->addr); |
| 340 | } | 332 | } |
| @@ -362,7 +354,6 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 362 | } | 354 | } |
| 363 | 355 | ||
| 364 | /* For now, get space for all other nodes */ | 356 | /* For now, get space for all other nodes */ |
| 365 | |||
| 366 | payload_size = TLV_SPACE(sizeof(node_info)) * tipc_num_nodes; | 357 | payload_size = TLV_SPACE(sizeof(node_info)) * tipc_num_nodes; |
| 367 | if (payload_size > 32768u) { | 358 | if (payload_size > 32768u) { |
| 368 | read_unlock_bh(&tipc_net_lock); | 359 | read_unlock_bh(&tipc_net_lock); |
| @@ -376,7 +367,6 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 376 | } | 367 | } |
| 377 | 368 | ||
| 378 | /* Add TLVs for all nodes in scope */ | 369 | /* Add TLVs for all nodes in scope */ |
| 379 | |||
| 380 | list_for_each_entry(n_ptr, &tipc_node_list, list) { | 370 | list_for_each_entry(n_ptr, &tipc_node_list, list) { |
| 381 | if (!tipc_in_scope(domain, n_ptr->addr)) | 371 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| 382 | continue; | 372 | continue; |
| @@ -412,7 +402,6 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 412 | read_lock_bh(&tipc_net_lock); | 402 | read_lock_bh(&tipc_net_lock); |
| 413 | 403 | ||
| 414 | /* Get space for all unicast links + broadcast link */ | 404 | /* Get space for all unicast links + broadcast link */ |
| 415 | |||
| 416 | payload_size = TLV_SPACE(sizeof(link_info)) * | 405 | payload_size = TLV_SPACE(sizeof(link_info)) * |
| 417 | (atomic_read(&tipc_num_links) + 1); | 406 | (atomic_read(&tipc_num_links) + 1); |
| 418 | if (payload_size > 32768u) { | 407 | if (payload_size > 32768u) { |
| @@ -427,14 +416,12 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 427 | } | 416 | } |
| 428 | 417 | ||
| 429 | /* Add TLV for broadcast link */ | 418 | /* Add TLV for broadcast link */ |
| 430 | |||
| 431 | link_info.dest = htonl(tipc_cluster_mask(tipc_own_addr)); | 419 | link_info.dest = htonl(tipc_cluster_mask(tipc_own_addr)); |
| 432 | link_info.up = htonl(1); | 420 | link_info.up = htonl(1); |
| 433 | strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); | 421 | strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); |
| 434 | tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); | 422 | tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); |
| 435 | 423 | ||
| 436 | /* Add TLVs for any other links in scope */ | 424 | /* Add TLVs for any other links in scope */ |
| 437 | |||
| 438 | list_for_each_entry(n_ptr, &tipc_node_list, list) { | 425 | list_for_each_entry(n_ptr, &tipc_node_list, list) { |
| 439 | u32 i; | 426 | u32 i; |
| 440 | 427 | ||
diff --git a/net/tipc/node.h b/net/tipc/node.h index 72561c971d67..cfcaf4d6e480 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
| @@ -48,7 +48,6 @@ | |||
| 48 | #define INVALID_NODE_SIG 0x10000 | 48 | #define INVALID_NODE_SIG 0x10000 |
| 49 | 49 | ||
| 50 | /* Flags used to block (re)establishment of contact with a neighboring node */ | 50 | /* Flags used to block (re)establishment of contact with a neighboring node */ |
| 51 | |||
| 52 | #define WAIT_PEER_DOWN 0x0001 /* wait to see that peer's links are down */ | 51 | #define WAIT_PEER_DOWN 0x0001 /* wait to see that peer's links are down */ |
| 53 | #define WAIT_NAMES_GONE 0x0002 /* wait for peer's publications to be purged */ | 52 | #define WAIT_NAMES_GONE 0x0002 /* wait for peer's publications to be purged */ |
| 54 | #define WAIT_NODE_DOWN 0x0004 /* wait until peer node is declared down */ | 53 | #define WAIT_NODE_DOWN 0x0004 /* wait until peer node is declared down */ |
| @@ -79,7 +78,6 @@ | |||
| 79 | * @deferred_tail: newest OOS b'cast message received from node | 78 | * @deferred_tail: newest OOS b'cast message received from node |
| 80 | * @defragm: list of partially reassembled b'cast message fragments from node | 79 | * @defragm: list of partially reassembled b'cast message fragments from node |
| 81 | */ | 80 | */ |
| 82 | |||
| 83 | struct tipc_node { | 81 | struct tipc_node { |
| 84 | u32 addr; | 82 | u32 addr; |
| 85 | spinlock_t lock; | 83 | spinlock_t lock; |
diff --git a/net/tipc/node_subscr.c b/net/tipc/node_subscr.c index c3c2815ae630..7a27344108fe 100644 --- a/net/tipc/node_subscr.c +++ b/net/tipc/node_subscr.c | |||
| @@ -41,11 +41,10 @@ | |||
| 41 | /** | 41 | /** |
| 42 | * tipc_nodesub_subscribe - create "node down" subscription for specified node | 42 | * tipc_nodesub_subscribe - create "node down" subscription for specified node |
| 43 | */ | 43 | */ |
| 44 | |||
| 45 | void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, | 44 | void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, |
| 46 | void *usr_handle, net_ev_handler handle_down) | 45 | void *usr_handle, net_ev_handler handle_down) |
| 47 | { | 46 | { |
| 48 | if (addr == tipc_own_addr) { | 47 | if (in_own_node(addr)) { |
| 49 | node_sub->node = NULL; | 48 | node_sub->node = NULL; |
| 50 | return; | 49 | return; |
| 51 | } | 50 | } |
| @@ -66,7 +65,6 @@ void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, | |||
| 66 | /** | 65 | /** |
| 67 | * tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) | 66 | * tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) |
| 68 | */ | 67 | */ |
| 69 | |||
| 70 | void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub) | 68 | void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub) |
| 71 | { | 69 | { |
| 72 | if (!node_sub->node) | 70 | if (!node_sub->node) |
| @@ -82,7 +80,6 @@ void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub) | |||
| 82 | * | 80 | * |
| 83 | * Note: node is locked by caller | 81 | * Note: node is locked by caller |
| 84 | */ | 82 | */ |
| 85 | |||
| 86 | void tipc_nodesub_notify(struct tipc_node *node) | 83 | void tipc_nodesub_notify(struct tipc_node *node) |
| 87 | { | 84 | { |
| 88 | struct tipc_node_subscr *ns; | 85 | struct tipc_node_subscr *ns; |
diff --git a/net/tipc/node_subscr.h b/net/tipc/node_subscr.h index 4bc2ca0867a1..c95d20727ded 100644 --- a/net/tipc/node_subscr.h +++ b/net/tipc/node_subscr.h | |||
| @@ -48,7 +48,6 @@ typedef void (*net_ev_handler) (void *usr_handle); | |||
| 48 | * @usr_handle: argument to pass to routine when node fails | 48 | * @usr_handle: argument to pass to routine when node fails |
| 49 | * @nodesub_list: adjacent entries in list of subscriptions for the node | 49 | * @nodesub_list: adjacent entries in list of subscriptions for the node |
| 50 | */ | 50 | */ |
| 51 | |||
| 52 | struct tipc_node_subscr { | 51 | struct tipc_node_subscr { |
| 53 | struct tipc_node *node; | 52 | struct tipc_node *node; |
| 54 | net_ev_handler handle_node_down; | 53 | net_ev_handler handle_node_down; |
diff --git a/net/tipc/port.c b/net/tipc/port.c index 94d2904cce66..2ad37a4db376 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
| @@ -69,10 +69,30 @@ static u32 port_peerport(struct tipc_port *p_ptr) | |||
| 69 | return msg_destport(&p_ptr->phdr); | 69 | return msg_destport(&p_ptr->phdr); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | /* | ||
| 73 | * tipc_port_peer_msg - verify message was sent by connected port's peer | ||
| 74 | * | ||
| 75 | * Handles cases where the node's network address has changed from | ||
| 76 | * the default of <0.0.0> to its configured setting. | ||
| 77 | */ | ||
| 78 | int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg) | ||
| 79 | { | ||
| 80 | u32 peernode; | ||
| 81 | u32 orignode; | ||
| 82 | |||
| 83 | if (msg_origport(msg) != port_peerport(p_ptr)) | ||
| 84 | return 0; | ||
| 85 | |||
| 86 | orignode = msg_orignode(msg); | ||
| 87 | peernode = port_peernode(p_ptr); | ||
| 88 | return (orignode == peernode) || | ||
| 89 | (!orignode && (peernode == tipc_own_addr)) || | ||
| 90 | (!peernode && (orignode == tipc_own_addr)); | ||
| 91 | } | ||
| 92 | |||
| 72 | /** | 93 | /** |
| 73 | * tipc_multicast - send a multicast message to local and remote destinations | 94 | * tipc_multicast - send a multicast message to local and remote destinations |
| 74 | */ | 95 | */ |
| 75 | |||
| 76 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | 96 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, |
| 77 | u32 num_sect, struct iovec const *msg_sect, | 97 | u32 num_sect, struct iovec const *msg_sect, |
| 78 | unsigned int total_len) | 98 | unsigned int total_len) |
| @@ -89,7 +109,6 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
| 89 | return -EINVAL; | 109 | return -EINVAL; |
| 90 | 110 | ||
| 91 | /* Create multicast message */ | 111 | /* Create multicast message */ |
| 92 | |||
| 93 | hdr = &oport->phdr; | 112 | hdr = &oport->phdr; |
| 94 | msg_set_type(hdr, TIPC_MCAST_MSG); | 113 | msg_set_type(hdr, TIPC_MCAST_MSG); |
| 95 | msg_set_lookup_scope(hdr, TIPC_CLUSTER_SCOPE); | 114 | msg_set_lookup_scope(hdr, TIPC_CLUSTER_SCOPE); |
| @@ -105,12 +124,10 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
| 105 | return res; | 124 | return res; |
| 106 | 125 | ||
| 107 | /* Figure out where to send multicast message */ | 126 | /* Figure out where to send multicast message */ |
| 108 | |||
| 109 | ext_targets = tipc_nametbl_mc_translate(seq->type, seq->lower, seq->upper, | 127 | ext_targets = tipc_nametbl_mc_translate(seq->type, seq->lower, seq->upper, |
| 110 | TIPC_NODE_SCOPE, &dports); | 128 | TIPC_NODE_SCOPE, &dports); |
| 111 | 129 | ||
| 112 | /* Send message to destinations (duplicate it only if necessary) */ | 130 | /* Send message to destinations (duplicate it only if necessary) */ |
| 113 | |||
| 114 | if (ext_targets) { | 131 | if (ext_targets) { |
| 115 | if (dports.count != 0) { | 132 | if (dports.count != 0) { |
| 116 | ibuf = skb_copy(buf, GFP_ATOMIC); | 133 | ibuf = skb_copy(buf, GFP_ATOMIC); |
| @@ -141,7 +158,6 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
| 141 | * | 158 | * |
| 142 | * If there is no port list, perform a lookup to create one | 159 | * If there is no port list, perform a lookup to create one |
| 143 | */ | 160 | */ |
| 144 | |||
| 145 | void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) | 161 | void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) |
| 146 | { | 162 | { |
| 147 | struct tipc_msg *msg; | 163 | struct tipc_msg *msg; |
| @@ -152,7 +168,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) | |||
| 152 | msg = buf_msg(buf); | 168 | msg = buf_msg(buf); |
| 153 | 169 | ||
| 154 | /* Create destination port list, if one wasn't supplied */ | 170 | /* Create destination port list, if one wasn't supplied */ |
| 155 | |||
| 156 | if (dp == NULL) { | 171 | if (dp == NULL) { |
| 157 | tipc_nametbl_mc_translate(msg_nametype(msg), | 172 | tipc_nametbl_mc_translate(msg_nametype(msg), |
| 158 | msg_namelower(msg), | 173 | msg_namelower(msg), |
| @@ -163,7 +178,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) | |||
| 163 | } | 178 | } |
| 164 | 179 | ||
| 165 | /* Deliver a copy of message to each destination port */ | 180 | /* Deliver a copy of message to each destination port */ |
| 166 | |||
| 167 | if (dp->count != 0) { | 181 | if (dp->count != 0) { |
| 168 | msg_set_destnode(msg, tipc_own_addr); | 182 | msg_set_destnode(msg, tipc_own_addr); |
| 169 | if (dp->count == 1) { | 183 | if (dp->count == 1) { |
| @@ -196,7 +210,6 @@ exit: | |||
| 196 | * | 210 | * |
| 197 | * Returns pointer to (locked) TIPC port, or NULL if unable to create it | 211 | * Returns pointer to (locked) TIPC port, or NULL if unable to create it |
| 198 | */ | 212 | */ |
| 199 | |||
| 200 | struct tipc_port *tipc_createport_raw(void *usr_handle, | 213 | struct tipc_port *tipc_createport_raw(void *usr_handle, |
| 201 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), | 214 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), |
| 202 | void (*wakeup)(struct tipc_port *), | 215 | void (*wakeup)(struct tipc_port *), |
| @@ -221,18 +234,24 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, | |||
| 221 | p_ptr->usr_handle = usr_handle; | 234 | p_ptr->usr_handle = usr_handle; |
| 222 | p_ptr->max_pkt = MAX_PKT_DEFAULT; | 235 | p_ptr->max_pkt = MAX_PKT_DEFAULT; |
| 223 | p_ptr->ref = ref; | 236 | p_ptr->ref = ref; |
| 224 | msg = &p_ptr->phdr; | ||
| 225 | tipc_msg_init(msg, importance, TIPC_NAMED_MSG, NAMED_H_SIZE, 0); | ||
| 226 | msg_set_origport(msg, ref); | ||
| 227 | INIT_LIST_HEAD(&p_ptr->wait_list); | 237 | INIT_LIST_HEAD(&p_ptr->wait_list); |
| 228 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); | 238 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); |
| 229 | p_ptr->dispatcher = dispatcher; | 239 | p_ptr->dispatcher = dispatcher; |
| 230 | p_ptr->wakeup = wakeup; | 240 | p_ptr->wakeup = wakeup; |
| 231 | p_ptr->user_port = NULL; | 241 | p_ptr->user_port = NULL; |
| 232 | k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref); | 242 | k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref); |
| 233 | spin_lock_bh(&tipc_port_list_lock); | ||
| 234 | INIT_LIST_HEAD(&p_ptr->publications); | 243 | INIT_LIST_HEAD(&p_ptr->publications); |
| 235 | INIT_LIST_HEAD(&p_ptr->port_list); | 244 | INIT_LIST_HEAD(&p_ptr->port_list); |
| 245 | |||
| 246 | /* | ||
| 247 | * Must hold port list lock while initializing message header template | ||
| 248 | * to ensure a change to node's own network address doesn't result | ||
| 249 | * in template containing out-dated network address information | ||
| 250 | */ | ||
| 251 | spin_lock_bh(&tipc_port_list_lock); | ||
| 252 | msg = &p_ptr->phdr; | ||
| 253 | tipc_msg_init(msg, importance, TIPC_NAMED_MSG, NAMED_H_SIZE, 0); | ||
| 254 | msg_set_origport(msg, ref); | ||
| 236 | list_add_tail(&p_ptr->port_list, &ports); | 255 | list_add_tail(&p_ptr->port_list, &ports); |
| 237 | spin_unlock_bh(&tipc_port_list_lock); | 256 | spin_unlock_bh(&tipc_port_list_lock); |
| 238 | return p_ptr; | 257 | return p_ptr; |
| @@ -361,7 +380,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
| 361 | u32 rmsg_sz; | 380 | u32 rmsg_sz; |
| 362 | 381 | ||
| 363 | /* discard rejected message if it shouldn't be returned to sender */ | 382 | /* discard rejected message if it shouldn't be returned to sender */ |
| 364 | |||
| 365 | if (WARN(!msg_isdata(msg), | 383 | if (WARN(!msg_isdata(msg), |
| 366 | "attempt to reject message with user=%u", msg_user(msg))) { | 384 | "attempt to reject message with user=%u", msg_user(msg))) { |
| 367 | dump_stack(); | 385 | dump_stack(); |
| @@ -374,7 +392,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
| 374 | * construct returned message by copying rejected message header and | 392 | * construct returned message by copying rejected message header and |
| 375 | * data (or subset), then updating header fields that need adjusting | 393 | * data (or subset), then updating header fields that need adjusting |
| 376 | */ | 394 | */ |
| 377 | |||
| 378 | hdr_sz = msg_hdr_sz(msg); | 395 | hdr_sz = msg_hdr_sz(msg); |
| 379 | rmsg_sz = hdr_sz + min_t(u32, data_sz, MAX_REJECT_SIZE); | 396 | rmsg_sz = hdr_sz + min_t(u32, data_sz, MAX_REJECT_SIZE); |
| 380 | 397 | ||
| @@ -413,9 +430,8 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
| 413 | } | 430 | } |
| 414 | 431 | ||
| 415 | /* send returned message & dispose of rejected message */ | 432 | /* send returned message & dispose of rejected message */ |
| 416 | |||
| 417 | src_node = msg_prevnode(msg); | 433 | src_node = msg_prevnode(msg); |
| 418 | if (src_node == tipc_own_addr) | 434 | if (in_own_node(src_node)) |
| 419 | tipc_port_recv_msg(rbuf); | 435 | tipc_port_recv_msg(rbuf); |
| 420 | else | 436 | else |
| 421 | tipc_link_send(rbuf, src_node, msg_link_selector(rmsg)); | 437 | tipc_link_send(rbuf, src_node, msg_link_selector(rmsg)); |
| @@ -519,25 +535,20 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) | |||
| 519 | struct tipc_msg *msg = buf_msg(buf); | 535 | struct tipc_msg *msg = buf_msg(buf); |
| 520 | struct tipc_port *p_ptr; | 536 | struct tipc_port *p_ptr; |
| 521 | struct sk_buff *r_buf = NULL; | 537 | struct sk_buff *r_buf = NULL; |
| 522 | u32 orignode = msg_orignode(msg); | ||
| 523 | u32 origport = msg_origport(msg); | ||
| 524 | u32 destport = msg_destport(msg); | 538 | u32 destport = msg_destport(msg); |
| 525 | int wakeable; | 539 | int wakeable; |
| 526 | 540 | ||
| 527 | /* Validate connection */ | 541 | /* Validate connection */ |
| 528 | |||
| 529 | p_ptr = tipc_port_lock(destport); | 542 | p_ptr = tipc_port_lock(destport); |
| 530 | if (!p_ptr || !p_ptr->connected || | 543 | if (!p_ptr || !p_ptr->connected || !tipc_port_peer_msg(p_ptr, msg)) { |
| 531 | (port_peernode(p_ptr) != orignode) || | ||
| 532 | (port_peerport(p_ptr) != origport)) { | ||
| 533 | r_buf = tipc_buf_acquire(BASIC_H_SIZE); | 544 | r_buf = tipc_buf_acquire(BASIC_H_SIZE); |
| 534 | if (r_buf) { | 545 | if (r_buf) { |
| 535 | msg = buf_msg(r_buf); | 546 | msg = buf_msg(r_buf); |
| 536 | tipc_msg_init(msg, TIPC_HIGH_IMPORTANCE, TIPC_CONN_MSG, | 547 | tipc_msg_init(msg, TIPC_HIGH_IMPORTANCE, TIPC_CONN_MSG, |
| 537 | BASIC_H_SIZE, orignode); | 548 | BASIC_H_SIZE, msg_orignode(msg)); |
| 538 | msg_set_errcode(msg, TIPC_ERR_NO_PORT); | 549 | msg_set_errcode(msg, TIPC_ERR_NO_PORT); |
| 539 | msg_set_origport(msg, destport); | 550 | msg_set_origport(msg, destport); |
| 540 | msg_set_destport(msg, origport); | 551 | msg_set_destport(msg, msg_origport(msg)); |
| 541 | } | 552 | } |
| 542 | if (p_ptr) | 553 | if (p_ptr) |
| 543 | tipc_port_unlock(p_ptr); | 554 | tipc_port_unlock(p_ptr); |
| @@ -545,7 +556,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) | |||
| 545 | } | 556 | } |
| 546 | 557 | ||
| 547 | /* Process protocol message sent by peer */ | 558 | /* Process protocol message sent by peer */ |
| 548 | |||
| 549 | switch (msg_type(msg)) { | 559 | switch (msg_type(msg)) { |
| 550 | case CONN_ACK: | 560 | case CONN_ACK: |
| 551 | wakeable = tipc_port_congested(p_ptr) && p_ptr->congested && | 561 | wakeable = tipc_port_congested(p_ptr) && p_ptr->congested && |
| @@ -646,8 +656,6 @@ void tipc_port_reinit(void) | |||
| 646 | spin_lock_bh(&tipc_port_list_lock); | 656 | spin_lock_bh(&tipc_port_list_lock); |
| 647 | list_for_each_entry(p_ptr, &ports, port_list) { | 657 | list_for_each_entry(p_ptr, &ports, port_list) { |
| 648 | msg = &p_ptr->phdr; | 658 | msg = &p_ptr->phdr; |
| 649 | if (msg_orignode(msg) == tipc_own_addr) | ||
| 650 | break; | ||
| 651 | msg_set_prevnode(msg, tipc_own_addr); | 659 | msg_set_prevnode(msg, tipc_own_addr); |
| 652 | msg_set_orignode(msg, tipc_own_addr); | 660 | msg_set_orignode(msg, tipc_own_addr); |
| 653 | } | 661 | } |
| @@ -659,7 +667,6 @@ void tipc_port_reinit(void) | |||
| 659 | * port_dispatcher_sigh(): Signal handler for messages destinated | 667 | * port_dispatcher_sigh(): Signal handler for messages destinated |
| 660 | * to the tipc_port interface. | 668 | * to the tipc_port interface. |
| 661 | */ | 669 | */ |
| 662 | |||
| 663 | static void port_dispatcher_sigh(void *dummy) | 670 | static void port_dispatcher_sigh(void *dummy) |
| 664 | { | 671 | { |
| 665 | struct sk_buff *buf; | 672 | struct sk_buff *buf; |
| @@ -676,6 +683,7 @@ static void port_dispatcher_sigh(void *dummy) | |||
| 676 | struct tipc_name_seq dseq; | 683 | struct tipc_name_seq dseq; |
| 677 | void *usr_handle; | 684 | void *usr_handle; |
| 678 | int connected; | 685 | int connected; |
| 686 | int peer_invalid; | ||
| 679 | int published; | 687 | int published; |
| 680 | u32 message_type; | 688 | u32 message_type; |
| 681 | 689 | ||
| @@ -696,6 +704,7 @@ static void port_dispatcher_sigh(void *dummy) | |||
| 696 | up_ptr = p_ptr->user_port; | 704 | up_ptr = p_ptr->user_port; |
| 697 | usr_handle = up_ptr->usr_handle; | 705 | usr_handle = up_ptr->usr_handle; |
| 698 | connected = p_ptr->connected; | 706 | connected = p_ptr->connected; |
| 707 | peer_invalid = connected && !tipc_port_peer_msg(p_ptr, msg); | ||
| 699 | published = p_ptr->published; | 708 | published = p_ptr->published; |
| 700 | 709 | ||
| 701 | if (unlikely(msg_errcode(msg))) | 710 | if (unlikely(msg_errcode(msg))) |
| @@ -705,8 +714,6 @@ static void port_dispatcher_sigh(void *dummy) | |||
| 705 | 714 | ||
| 706 | case TIPC_CONN_MSG:{ | 715 | case TIPC_CONN_MSG:{ |
| 707 | tipc_conn_msg_event cb = up_ptr->conn_msg_cb; | 716 | tipc_conn_msg_event cb = up_ptr->conn_msg_cb; |
| 708 | u32 peer_port = port_peerport(p_ptr); | ||
| 709 | u32 peer_node = port_peernode(p_ptr); | ||
| 710 | u32 dsz; | 717 | u32 dsz; |
| 711 | 718 | ||
| 712 | tipc_port_unlock(p_ptr); | 719 | tipc_port_unlock(p_ptr); |
| @@ -715,8 +722,7 @@ static void port_dispatcher_sigh(void *dummy) | |||
| 715 | if (unlikely(!connected)) { | 722 | if (unlikely(!connected)) { |
| 716 | if (tipc_connect2port(dref, &orig)) | 723 | if (tipc_connect2port(dref, &orig)) |
| 717 | goto reject; | 724 | goto reject; |
| 718 | } else if ((msg_origport(msg) != peer_port) || | 725 | } else if (peer_invalid) |
| 719 | (msg_orignode(msg) != peer_node)) | ||
| 720 | goto reject; | 726 | goto reject; |
| 721 | dsz = msg_data_sz(msg); | 727 | dsz = msg_data_sz(msg); |
| 722 | if (unlikely(dsz && | 728 | if (unlikely(dsz && |
| @@ -768,14 +774,9 @@ err: | |||
| 768 | case TIPC_CONN_MSG:{ | 774 | case TIPC_CONN_MSG:{ |
| 769 | tipc_conn_shutdown_event cb = | 775 | tipc_conn_shutdown_event cb = |
| 770 | up_ptr->conn_err_cb; | 776 | up_ptr->conn_err_cb; |
| 771 | u32 peer_port = port_peerport(p_ptr); | ||
| 772 | u32 peer_node = port_peernode(p_ptr); | ||
| 773 | 777 | ||
| 774 | tipc_port_unlock(p_ptr); | 778 | tipc_port_unlock(p_ptr); |
| 775 | if (!cb || !connected) | 779 | if (!cb || !connected || peer_invalid) |
| 776 | break; | ||
| 777 | if ((msg_origport(msg) != peer_port) || | ||
| 778 | (msg_orignode(msg) != peer_node)) | ||
| 779 | break; | 780 | break; |
| 780 | tipc_disconnect(dref); | 781 | tipc_disconnect(dref); |
| 781 | skb_pull(buf, msg_hdr_sz(msg)); | 782 | skb_pull(buf, msg_hdr_sz(msg)); |
| @@ -826,7 +827,6 @@ reject: | |||
| 826 | * port_dispatcher(): Dispatcher for messages destinated | 827 | * port_dispatcher(): Dispatcher for messages destinated |
| 827 | * to the tipc_port interface. Called with port locked. | 828 | * to the tipc_port interface. Called with port locked. |
| 828 | */ | 829 | */ |
| 829 | |||
| 830 | static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf) | 830 | static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf) |
| 831 | { | 831 | { |
| 832 | buf->next = NULL; | 832 | buf->next = NULL; |
| @@ -843,10 +843,8 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf) | |||
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | /* | 845 | /* |
| 846 | * Wake up port after congestion: Called with port locked, | 846 | * Wake up port after congestion: Called with port locked |
| 847 | * | ||
| 848 | */ | 847 | */ |
| 849 | |||
| 850 | static void port_wakeup_sh(unsigned long ref) | 848 | static void port_wakeup_sh(unsigned long ref) |
| 851 | { | 849 | { |
| 852 | struct tipc_port *p_ptr; | 850 | struct tipc_port *p_ptr; |
| @@ -892,7 +890,6 @@ void tipc_acknowledge(u32 ref, u32 ack) | |||
| 892 | /* | 890 | /* |
| 893 | * tipc_createport(): user level call. | 891 | * tipc_createport(): user level call. |
| 894 | */ | 892 | */ |
| 895 | |||
| 896 | int tipc_createport(void *usr_handle, | 893 | int tipc_createport(void *usr_handle, |
| 897 | unsigned int importance, | 894 | unsigned int importance, |
| 898 | tipc_msg_err_event error_cb, | 895 | tipc_msg_err_event error_cb, |
| @@ -901,7 +898,7 @@ int tipc_createport(void *usr_handle, | |||
| 901 | tipc_msg_event msg_cb, | 898 | tipc_msg_event msg_cb, |
| 902 | tipc_named_msg_event named_msg_cb, | 899 | tipc_named_msg_event named_msg_cb, |
| 903 | tipc_conn_msg_event conn_msg_cb, | 900 | tipc_conn_msg_event conn_msg_cb, |
| 904 | tipc_continue_event continue_event_cb,/* May be zero */ | 901 | tipc_continue_event continue_event_cb, /* May be zero */ |
| 905 | u32 *portref) | 902 | u32 *portref) |
| 906 | { | 903 | { |
| 907 | struct user_port *up_ptr; | 904 | struct user_port *up_ptr; |
| @@ -975,10 +972,6 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | |||
| 975 | 972 | ||
| 976 | if (p_ptr->connected) | 973 | if (p_ptr->connected) |
| 977 | goto exit; | 974 | goto exit; |
| 978 | if (seq->lower > seq->upper) | ||
| 979 | goto exit; | ||
| 980 | if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE)) | ||
| 981 | goto exit; | ||
| 982 | key = ref + p_ptr->pub_count + 1; | 975 | key = ref + p_ptr->pub_count + 1; |
| 983 | if (key == ref) { | 976 | if (key == ref) { |
| 984 | res = -EADDRINUSE; | 977 | res = -EADDRINUSE; |
| @@ -1078,7 +1071,6 @@ exit: | |||
| 1078 | * | 1071 | * |
| 1079 | * Port must be locked. | 1072 | * Port must be locked. |
| 1080 | */ | 1073 | */ |
| 1081 | |||
| 1082 | int tipc_disconnect_port(struct tipc_port *tp_ptr) | 1074 | int tipc_disconnect_port(struct tipc_port *tp_ptr) |
| 1083 | { | 1075 | { |
| 1084 | int res; | 1076 | int res; |
| @@ -1099,7 +1091,6 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr) | |||
| 1099 | * tipc_disconnect(): Disconnect port form peer. | 1091 | * tipc_disconnect(): Disconnect port form peer. |
| 1100 | * This is a node local operation. | 1092 | * This is a node local operation. |
| 1101 | */ | 1093 | */ |
| 1102 | |||
| 1103 | int tipc_disconnect(u32 ref) | 1094 | int tipc_disconnect(u32 ref) |
| 1104 | { | 1095 | { |
| 1105 | struct tipc_port *p_ptr; | 1096 | struct tipc_port *p_ptr; |
| @@ -1134,7 +1125,6 @@ int tipc_shutdown(u32 ref) | |||
| 1134 | /** | 1125 | /** |
| 1135 | * tipc_port_recv_msg - receive message from lower layer and deliver to port user | 1126 | * tipc_port_recv_msg - receive message from lower layer and deliver to port user |
| 1136 | */ | 1127 | */ |
| 1137 | |||
| 1138 | int tipc_port_recv_msg(struct sk_buff *buf) | 1128 | int tipc_port_recv_msg(struct sk_buff *buf) |
| 1139 | { | 1129 | { |
| 1140 | struct tipc_port *p_ptr; | 1130 | struct tipc_port *p_ptr; |
| @@ -1152,17 +1142,6 @@ int tipc_port_recv_msg(struct sk_buff *buf) | |||
| 1152 | /* validate destination & pass to port, otherwise reject message */ | 1142 | /* validate destination & pass to port, otherwise reject message */ |
| 1153 | p_ptr = tipc_port_lock(destport); | 1143 | p_ptr = tipc_port_lock(destport); |
| 1154 | if (likely(p_ptr)) { | 1144 | if (likely(p_ptr)) { |
| 1155 | if (likely(p_ptr->connected)) { | ||
| 1156 | if ((unlikely(msg_origport(msg) != | ||
| 1157 | tipc_peer_port(p_ptr))) || | ||
| 1158 | (unlikely(msg_orignode(msg) != | ||
| 1159 | tipc_peer_node(p_ptr))) || | ||
| 1160 | (unlikely(!msg_connected(msg)))) { | ||
| 1161 | err = TIPC_ERR_NO_PORT; | ||
| 1162 | tipc_port_unlock(p_ptr); | ||
| 1163 | goto reject; | ||
| 1164 | } | ||
| 1165 | } | ||
| 1166 | err = p_ptr->dispatcher(p_ptr, buf); | 1145 | err = p_ptr->dispatcher(p_ptr, buf); |
| 1167 | tipc_port_unlock(p_ptr); | 1146 | tipc_port_unlock(p_ptr); |
| 1168 | if (likely(!err)) | 1147 | if (likely(!err)) |
| @@ -1170,7 +1149,7 @@ int tipc_port_recv_msg(struct sk_buff *buf) | |||
| 1170 | } else { | 1149 | } else { |
| 1171 | err = TIPC_ERR_NO_PORT; | 1150 | err = TIPC_ERR_NO_PORT; |
| 1172 | } | 1151 | } |
| 1173 | reject: | 1152 | |
| 1174 | return tipc_reject_msg(buf, err); | 1153 | return tipc_reject_msg(buf, err); |
| 1175 | } | 1154 | } |
| 1176 | 1155 | ||
| @@ -1178,7 +1157,6 @@ reject: | |||
| 1178 | * tipc_port_recv_sections(): Concatenate and deliver sectioned | 1157 | * tipc_port_recv_sections(): Concatenate and deliver sectioned |
| 1179 | * message for this node. | 1158 | * message for this node. |
| 1180 | */ | 1159 | */ |
| 1181 | |||
| 1182 | static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect, | 1160 | static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect, |
| 1183 | struct iovec const *msg_sect, | 1161 | struct iovec const *msg_sect, |
| 1184 | unsigned int total_len) | 1162 | unsigned int total_len) |
| @@ -1196,7 +1174,6 @@ static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_se | |||
| 1196 | /** | 1174 | /** |
| 1197 | * tipc_send - send message sections on connection | 1175 | * tipc_send - send message sections on connection |
| 1198 | */ | 1176 | */ |
| 1199 | |||
| 1200 | int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | 1177 | int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, |
| 1201 | unsigned int total_len) | 1178 | unsigned int total_len) |
| 1202 | { | 1179 | { |
| @@ -1211,7 +1188,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
| 1211 | p_ptr->congested = 1; | 1188 | p_ptr->congested = 1; |
| 1212 | if (!tipc_port_congested(p_ptr)) { | 1189 | if (!tipc_port_congested(p_ptr)) { |
| 1213 | destnode = port_peernode(p_ptr); | 1190 | destnode = port_peernode(p_ptr); |
| 1214 | if (likely(destnode != tipc_own_addr)) | 1191 | if (likely(!in_own_node(destnode))) |
| 1215 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 1192 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, |
| 1216 | total_len, destnode); | 1193 | total_len, destnode); |
| 1217 | else | 1194 | else |
| @@ -1235,7 +1212,6 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
| 1235 | /** | 1212 | /** |
| 1236 | * tipc_send2name - send message sections to port name | 1213 | * tipc_send2name - send message sections to port name |
| 1237 | */ | 1214 | */ |
| 1238 | |||
| 1239 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | 1215 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, |
| 1240 | unsigned int num_sect, struct iovec const *msg_sect, | 1216 | unsigned int num_sect, struct iovec const *msg_sect, |
| 1241 | unsigned int total_len) | 1217 | unsigned int total_len) |
| @@ -1261,13 +1237,17 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | |||
| 1261 | msg_set_destport(msg, destport); | 1237 | msg_set_destport(msg, destport); |
| 1262 | 1238 | ||
| 1263 | if (likely(destport || destnode)) { | 1239 | if (likely(destport || destnode)) { |
| 1264 | if (likely(destnode == tipc_own_addr)) | 1240 | if (likely(in_own_node(destnode))) |
| 1265 | res = tipc_port_recv_sections(p_ptr, num_sect, | 1241 | res = tipc_port_recv_sections(p_ptr, num_sect, |
| 1266 | msg_sect, total_len); | 1242 | msg_sect, total_len); |
| 1267 | else | 1243 | else if (tipc_own_addr) |
| 1268 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, | 1244 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, |
| 1269 | num_sect, total_len, | 1245 | num_sect, total_len, |
| 1270 | destnode); | 1246 | destnode); |
| 1247 | else | ||
| 1248 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, | ||
| 1249 | num_sect, total_len, | ||
| 1250 | TIPC_ERR_NO_NODE); | ||
| 1271 | if (likely(res != -ELINKCONG)) { | 1251 | if (likely(res != -ELINKCONG)) { |
| 1272 | if (res > 0) | 1252 | if (res > 0) |
| 1273 | p_ptr->sent++; | 1253 | p_ptr->sent++; |
| @@ -1285,7 +1265,6 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | |||
| 1285 | /** | 1265 | /** |
| 1286 | * tipc_send2port - send message sections to port identity | 1266 | * tipc_send2port - send message sections to port identity |
| 1287 | */ | 1267 | */ |
| 1288 | |||
| 1289 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, | 1268 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, |
| 1290 | unsigned int num_sect, struct iovec const *msg_sect, | 1269 | unsigned int num_sect, struct iovec const *msg_sect, |
| 1291 | unsigned int total_len) | 1270 | unsigned int total_len) |
| @@ -1305,12 +1284,15 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest, | |||
| 1305 | msg_set_destport(msg, dest->ref); | 1284 | msg_set_destport(msg, dest->ref); |
| 1306 | msg_set_hdr_sz(msg, BASIC_H_SIZE); | 1285 | msg_set_hdr_sz(msg, BASIC_H_SIZE); |
| 1307 | 1286 | ||
| 1308 | if (dest->node == tipc_own_addr) | 1287 | if (in_own_node(dest->node)) |
| 1309 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, | 1288 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, |
| 1310 | total_len); | 1289 | total_len); |
| 1311 | else | 1290 | else if (tipc_own_addr) |
| 1312 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 1291 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, |
| 1313 | total_len, dest->node); | 1292 | total_len, dest->node); |
| 1293 | else | ||
| 1294 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, | ||
| 1295 | total_len, TIPC_ERR_NO_NODE); | ||
| 1314 | if (likely(res != -ELINKCONG)) { | 1296 | if (likely(res != -ELINKCONG)) { |
| 1315 | if (res > 0) | 1297 | if (res > 0) |
| 1316 | p_ptr->sent++; | 1298 | p_ptr->sent++; |
| @@ -1325,7 +1307,6 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest, | |||
| 1325 | /** | 1307 | /** |
| 1326 | * tipc_send_buf2port - send message buffer to port identity | 1308 | * tipc_send_buf2port - send message buffer to port identity |
| 1327 | */ | 1309 | */ |
| 1328 | |||
| 1329 | int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, | 1310 | int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, |
| 1330 | struct sk_buff *buf, unsigned int dsz) | 1311 | struct sk_buff *buf, unsigned int dsz) |
| 1331 | { | 1312 | { |
| @@ -1349,7 +1330,7 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, | |||
| 1349 | skb_push(buf, BASIC_H_SIZE); | 1330 | skb_push(buf, BASIC_H_SIZE); |
| 1350 | skb_copy_to_linear_data(buf, msg, BASIC_H_SIZE); | 1331 | skb_copy_to_linear_data(buf, msg, BASIC_H_SIZE); |
| 1351 | 1332 | ||
| 1352 | if (dest->node == tipc_own_addr) | 1333 | if (in_own_node(dest->node)) |
| 1353 | res = tipc_port_recv_msg(buf); | 1334 | res = tipc_port_recv_msg(buf); |
| 1354 | else | 1335 | else |
| 1355 | res = tipc_send_buf_fast(buf, dest->node); | 1336 | res = tipc_send_buf_fast(buf, dest->node); |
| @@ -1362,4 +1343,3 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, | |||
| 1362 | return dsz; | 1343 | return dsz; |
| 1363 | return -ELINKCONG; | 1344 | return -ELINKCONG; |
| 1364 | } | 1345 | } |
| 1365 | |||
diff --git a/net/tipc/port.h b/net/tipc/port.h index 9b88531e5a61..98cbec9c4532 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
| @@ -81,7 +81,6 @@ typedef void (*tipc_continue_event) (void *usr_handle, u32 portref); | |||
| 81 | * @ref: object reference to associated TIPC port | 81 | * @ref: object reference to associated TIPC port |
| 82 | * <various callback routines> | 82 | * <various callback routines> |
| 83 | */ | 83 | */ |
| 84 | |||
| 85 | struct user_port { | 84 | struct user_port { |
| 86 | void *usr_handle; | 85 | void *usr_handle; |
| 87 | u32 ref; | 86 | u32 ref; |
| @@ -201,6 +200,7 @@ int tipc_shutdown(u32 ref); | |||
| 201 | * The following routines require that the port be locked on entry | 200 | * The following routines require that the port be locked on entry |
| 202 | */ | 201 | */ |
| 203 | int tipc_disconnect_port(struct tipc_port *tp_ptr); | 202 | int tipc_disconnect_port(struct tipc_port *tp_ptr); |
| 203 | int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg); | ||
| 204 | 204 | ||
| 205 | /* | 205 | /* |
| 206 | * TIPC messaging routines | 206 | * TIPC messaging routines |
| @@ -235,7 +235,6 @@ void tipc_port_reinit(void); | |||
| 235 | /** | 235 | /** |
| 236 | * tipc_port_lock - lock port instance referred to and return its pointer | 236 | * tipc_port_lock - lock port instance referred to and return its pointer |
| 237 | */ | 237 | */ |
| 238 | |||
| 239 | static inline struct tipc_port *tipc_port_lock(u32 ref) | 238 | static inline struct tipc_port *tipc_port_lock(u32 ref) |
| 240 | { | 239 | { |
| 241 | return (struct tipc_port *)tipc_ref_lock(ref); | 240 | return (struct tipc_port *)tipc_ref_lock(ref); |
| @@ -246,7 +245,6 @@ static inline struct tipc_port *tipc_port_lock(u32 ref) | |||
| 246 | * | 245 | * |
| 247 | * Can use pointer instead of tipc_ref_unlock() since port is already locked. | 246 | * Can use pointer instead of tipc_ref_unlock() since port is already locked. |
| 248 | */ | 247 | */ |
| 249 | |||
| 250 | static inline void tipc_port_unlock(struct tipc_port *p_ptr) | 248 | static inline void tipc_port_unlock(struct tipc_port *p_ptr) |
| 251 | { | 249 | { |
| 252 | spin_unlock_bh(p_ptr->lock); | 250 | spin_unlock_bh(p_ptr->lock); |
| @@ -257,16 +255,6 @@ static inline struct tipc_port *tipc_port_deref(u32 ref) | |||
| 257 | return (struct tipc_port *)tipc_ref_deref(ref); | 255 | return (struct tipc_port *)tipc_ref_deref(ref); |
| 258 | } | 256 | } |
| 259 | 257 | ||
| 260 | static inline u32 tipc_peer_port(struct tipc_port *p_ptr) | ||
| 261 | { | ||
| 262 | return msg_destport(&p_ptr->phdr); | ||
| 263 | } | ||
| 264 | |||
| 265 | static inline u32 tipc_peer_node(struct tipc_port *p_ptr) | ||
| 266 | { | ||
| 267 | return msg_destnode(&p_ptr->phdr); | ||
| 268 | } | ||
| 269 | |||
| 270 | static inline int tipc_port_congested(struct tipc_port *p_ptr) | 258 | static inline int tipc_port_congested(struct tipc_port *p_ptr) |
| 271 | { | 259 | { |
| 272 | return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); | 260 | return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); |
diff --git a/net/tipc/ref.c b/net/tipc/ref.c index 9e37b7812c3c..5cada0e38e03 100644 --- a/net/tipc/ref.c +++ b/net/tipc/ref.c | |||
| @@ -43,7 +43,6 @@ | |||
| 43 | * @lock: spinlock controlling access to object | 43 | * @lock: spinlock controlling access to object |
| 44 | * @ref: reference value for object (combines instance & array index info) | 44 | * @ref: reference value for object (combines instance & array index info) |
| 45 | */ | 45 | */ |
| 46 | |||
| 47 | struct reference { | 46 | struct reference { |
| 48 | void *object; | 47 | void *object; |
| 49 | spinlock_t lock; | 48 | spinlock_t lock; |
| @@ -60,7 +59,6 @@ struct reference { | |||
| 60 | * @index_mask: bitmask for array index portion of reference values | 59 | * @index_mask: bitmask for array index portion of reference values |
| 61 | * @start_mask: initial value for instance value portion of reference values | 60 | * @start_mask: initial value for instance value portion of reference values |
| 62 | */ | 61 | */ |
| 63 | |||
| 64 | struct ref_table { | 62 | struct ref_table { |
| 65 | struct reference *entries; | 63 | struct reference *entries; |
| 66 | u32 capacity; | 64 | u32 capacity; |
| @@ -96,7 +94,6 @@ static DEFINE_RWLOCK(ref_table_lock); | |||
| 96 | /** | 94 | /** |
| 97 | * tipc_ref_table_init - create reference table for objects | 95 | * tipc_ref_table_init - create reference table for objects |
| 98 | */ | 96 | */ |
| 99 | |||
| 100 | int tipc_ref_table_init(u32 requested_size, u32 start) | 97 | int tipc_ref_table_init(u32 requested_size, u32 start) |
| 101 | { | 98 | { |
| 102 | struct reference *table; | 99 | struct reference *table; |
| @@ -109,7 +106,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start) | |||
| 109 | /* do nothing */ ; | 106 | /* do nothing */ ; |
| 110 | 107 | ||
| 111 | /* allocate table & mark all entries as uninitialized */ | 108 | /* allocate table & mark all entries as uninitialized */ |
| 112 | |||
| 113 | table = vzalloc(actual_size * sizeof(struct reference)); | 109 | table = vzalloc(actual_size * sizeof(struct reference)); |
| 114 | if (table == NULL) | 110 | if (table == NULL) |
| 115 | return -ENOMEM; | 111 | return -ENOMEM; |
| @@ -128,7 +124,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start) | |||
| 128 | /** | 124 | /** |
| 129 | * tipc_ref_table_stop - destroy reference table for objects | 125 | * tipc_ref_table_stop - destroy reference table for objects |
| 130 | */ | 126 | */ |
| 131 | |||
| 132 | void tipc_ref_table_stop(void) | 127 | void tipc_ref_table_stop(void) |
| 133 | { | 128 | { |
| 134 | if (!tipc_ref_table.entries) | 129 | if (!tipc_ref_table.entries) |
| @@ -149,7 +144,6 @@ void tipc_ref_table_stop(void) | |||
| 149 | * register a partially initialized object, without running the risk that | 144 | * register a partially initialized object, without running the risk that |
| 150 | * the object will be accessed before initialization is complete. | 145 | * the object will be accessed before initialization is complete. |
| 151 | */ | 146 | */ |
| 152 | |||
| 153 | u32 tipc_ref_acquire(void *object, spinlock_t **lock) | 147 | u32 tipc_ref_acquire(void *object, spinlock_t **lock) |
| 154 | { | 148 | { |
| 155 | u32 index; | 149 | u32 index; |
| @@ -168,7 +162,6 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) | |||
| 168 | } | 162 | } |
| 169 | 163 | ||
| 170 | /* take a free entry, if available; otherwise initialize a new entry */ | 164 | /* take a free entry, if available; otherwise initialize a new entry */ |
| 171 | |||
| 172 | write_lock_bh(&ref_table_lock); | 165 | write_lock_bh(&ref_table_lock); |
| 173 | if (tipc_ref_table.first_free) { | 166 | if (tipc_ref_table.first_free) { |
| 174 | index = tipc_ref_table.first_free; | 167 | index = tipc_ref_table.first_free; |
| @@ -211,7 +204,6 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) | |||
| 211 | * Disallow future references to an object and free up the entry for re-use. | 204 | * Disallow future references to an object and free up the entry for re-use. |
| 212 | * Note: The entry's spin_lock may still be busy after discard | 205 | * Note: The entry's spin_lock may still be busy after discard |
| 213 | */ | 206 | */ |
| 214 | |||
| 215 | void tipc_ref_discard(u32 ref) | 207 | void tipc_ref_discard(u32 ref) |
| 216 | { | 208 | { |
| 217 | struct reference *entry; | 209 | struct reference *entry; |
| @@ -242,12 +234,10 @@ void tipc_ref_discard(u32 ref) | |||
| 242 | * mark entry as unused; increment instance part of entry's reference | 234 | * mark entry as unused; increment instance part of entry's reference |
| 243 | * to invalidate any subsequent references | 235 | * to invalidate any subsequent references |
| 244 | */ | 236 | */ |
| 245 | |||
| 246 | entry->object = NULL; | 237 | entry->object = NULL; |
| 247 | entry->ref = (ref & ~index_mask) + (index_mask + 1); | 238 | entry->ref = (ref & ~index_mask) + (index_mask + 1); |
| 248 | 239 | ||
| 249 | /* append entry to free entry list */ | 240 | /* append entry to free entry list */ |
| 250 | |||
| 251 | if (tipc_ref_table.first_free == 0) | 241 | if (tipc_ref_table.first_free == 0) |
| 252 | tipc_ref_table.first_free = index; | 242 | tipc_ref_table.first_free = index; |
| 253 | else | 243 | else |
| @@ -261,7 +251,6 @@ exit: | |||
| 261 | /** | 251 | /** |
| 262 | * tipc_ref_lock - lock referenced object and return pointer to it | 252 | * tipc_ref_lock - lock referenced object and return pointer to it |
| 263 | */ | 253 | */ |
| 264 | |||
| 265 | void *tipc_ref_lock(u32 ref) | 254 | void *tipc_ref_lock(u32 ref) |
| 266 | { | 255 | { |
| 267 | if (likely(tipc_ref_table.entries)) { | 256 | if (likely(tipc_ref_table.entries)) { |
| @@ -283,7 +272,6 @@ void *tipc_ref_lock(u32 ref) | |||
| 283 | /** | 272 | /** |
| 284 | * tipc_ref_deref - return pointer referenced object (without locking it) | 273 | * tipc_ref_deref - return pointer referenced object (without locking it) |
| 285 | */ | 274 | */ |
| 286 | |||
| 287 | void *tipc_ref_deref(u32 ref) | 275 | void *tipc_ref_deref(u32 ref) |
| 288 | { | 276 | { |
| 289 | if (likely(tipc_ref_table.entries)) { | 277 | if (likely(tipc_ref_table.entries)) { |
| @@ -296,4 +284,3 @@ void *tipc_ref_deref(u32 ref) | |||
| 296 | } | 284 | } |
| 297 | return NULL; | 285 | return NULL; |
| 298 | } | 286 | } |
| 299 | |||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 29e957f64458..5577a447f531 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
| @@ -123,7 +123,6 @@ static atomic_t tipc_queue_size = ATOMIC_INIT(0); | |||
| 123 | * | 123 | * |
| 124 | * Caller must hold socket lock | 124 | * Caller must hold socket lock |
| 125 | */ | 125 | */ |
| 126 | |||
| 127 | static void advance_rx_queue(struct sock *sk) | 126 | static void advance_rx_queue(struct sock *sk) |
| 128 | { | 127 | { |
| 129 | kfree_skb(__skb_dequeue(&sk->sk_receive_queue)); | 128 | kfree_skb(__skb_dequeue(&sk->sk_receive_queue)); |
| @@ -135,7 +134,6 @@ static void advance_rx_queue(struct sock *sk) | |||
| 135 | * | 134 | * |
| 136 | * Caller must hold socket lock | 135 | * Caller must hold socket lock |
| 137 | */ | 136 | */ |
| 138 | |||
| 139 | static void discard_rx_queue(struct sock *sk) | 137 | static void discard_rx_queue(struct sock *sk) |
| 140 | { | 138 | { |
| 141 | struct sk_buff *buf; | 139 | struct sk_buff *buf; |
| @@ -151,7 +149,6 @@ static void discard_rx_queue(struct sock *sk) | |||
| 151 | * | 149 | * |
| 152 | * Caller must hold socket lock | 150 | * Caller must hold socket lock |
| 153 | */ | 151 | */ |
| 154 | |||
| 155 | static void reject_rx_queue(struct sock *sk) | 152 | static void reject_rx_queue(struct sock *sk) |
| 156 | { | 153 | { |
| 157 | struct sk_buff *buf; | 154 | struct sk_buff *buf; |
| @@ -174,7 +171,6 @@ static void reject_rx_queue(struct sock *sk) | |||
| 174 | * | 171 | * |
| 175 | * Returns 0 on success, errno otherwise | 172 | * Returns 0 on success, errno otherwise |
| 176 | */ | 173 | */ |
| 177 | |||
| 178 | static int tipc_create(struct net *net, struct socket *sock, int protocol, | 174 | static int tipc_create(struct net *net, struct socket *sock, int protocol, |
| 179 | int kern) | 175 | int kern) |
| 180 | { | 176 | { |
| @@ -184,7 +180,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, | |||
| 184 | struct tipc_port *tp_ptr; | 180 | struct tipc_port *tp_ptr; |
| 185 | 181 | ||
| 186 | /* Validate arguments */ | 182 | /* Validate arguments */ |
| 187 | |||
| 188 | if (unlikely(protocol != 0)) | 183 | if (unlikely(protocol != 0)) |
| 189 | return -EPROTONOSUPPORT; | 184 | return -EPROTONOSUPPORT; |
| 190 | 185 | ||
| @@ -207,13 +202,11 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, | |||
| 207 | } | 202 | } |
| 208 | 203 | ||
| 209 | /* Allocate socket's protocol area */ | 204 | /* Allocate socket's protocol area */ |
| 210 | |||
| 211 | sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto); | 205 | sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto); |
| 212 | if (sk == NULL) | 206 | if (sk == NULL) |
| 213 | return -ENOMEM; | 207 | return -ENOMEM; |
| 214 | 208 | ||
| 215 | /* Allocate TIPC port for socket to use */ | 209 | /* Allocate TIPC port for socket to use */ |
| 216 | |||
| 217 | tp_ptr = tipc_createport_raw(sk, &dispatch, &wakeupdispatch, | 210 | tp_ptr = tipc_createport_raw(sk, &dispatch, &wakeupdispatch, |
| 218 | TIPC_LOW_IMPORTANCE); | 211 | TIPC_LOW_IMPORTANCE); |
| 219 | if (unlikely(!tp_ptr)) { | 212 | if (unlikely(!tp_ptr)) { |
| @@ -222,7 +215,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, | |||
| 222 | } | 215 | } |
| 223 | 216 | ||
| 224 | /* Finish initializing socket data structures */ | 217 | /* Finish initializing socket data structures */ |
| 225 | |||
| 226 | sock->ops = ops; | 218 | sock->ops = ops; |
| 227 | sock->state = state; | 219 | sock->state = state; |
| 228 | 220 | ||
| @@ -258,7 +250,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, | |||
| 258 | * | 250 | * |
| 259 | * Returns 0 on success, errno otherwise | 251 | * Returns 0 on success, errno otherwise |
| 260 | */ | 252 | */ |
| 261 | |||
| 262 | static int release(struct socket *sock) | 253 | static int release(struct socket *sock) |
| 263 | { | 254 | { |
| 264 | struct sock *sk = sock->sk; | 255 | struct sock *sk = sock->sk; |
| @@ -270,7 +261,6 @@ static int release(struct socket *sock) | |||
| 270 | * Exit if socket isn't fully initialized (occurs when a failed accept() | 261 | * Exit if socket isn't fully initialized (occurs when a failed accept() |
| 271 | * releases a pre-allocated child socket that was never used) | 262 | * releases a pre-allocated child socket that was never used) |
| 272 | */ | 263 | */ |
| 273 | |||
| 274 | if (sk == NULL) | 264 | if (sk == NULL) |
| 275 | return 0; | 265 | return 0; |
| 276 | 266 | ||
| @@ -281,7 +271,6 @@ static int release(struct socket *sock) | |||
| 281 | * Reject all unreceived messages, except on an active connection | 271 | * Reject all unreceived messages, except on an active connection |
| 282 | * (which disconnects locally & sends a 'FIN+' to peer) | 272 | * (which disconnects locally & sends a 'FIN+' to peer) |
| 283 | */ | 273 | */ |
| 284 | |||
| 285 | while (sock->state != SS_DISCONNECTING) { | 274 | while (sock->state != SS_DISCONNECTING) { |
| 286 | buf = __skb_dequeue(&sk->sk_receive_queue); | 275 | buf = __skb_dequeue(&sk->sk_receive_queue); |
| 287 | if (buf == NULL) | 276 | if (buf == NULL) |
| @@ -303,15 +292,12 @@ static int release(struct socket *sock) | |||
| 303 | * Delete TIPC port; this ensures no more messages are queued | 292 | * Delete TIPC port; this ensures no more messages are queued |
| 304 | * (also disconnects an active connection & sends a 'FIN-' to peer) | 293 | * (also disconnects an active connection & sends a 'FIN-' to peer) |
| 305 | */ | 294 | */ |
| 306 | |||
| 307 | res = tipc_deleteport(tport->ref); | 295 | res = tipc_deleteport(tport->ref); |
| 308 | 296 | ||
| 309 | /* Discard any remaining (connection-based) messages in receive queue */ | 297 | /* Discard any remaining (connection-based) messages in receive queue */ |
| 310 | |||
| 311 | discard_rx_queue(sk); | 298 | discard_rx_queue(sk); |
| 312 | 299 | ||
| 313 | /* Reject any messages that accumulated in backlog queue */ | 300 | /* Reject any messages that accumulated in backlog queue */ |
| 314 | |||
| 315 | sock->state = SS_DISCONNECTING; | 301 | sock->state = SS_DISCONNECTING; |
| 316 | release_sock(sk); | 302 | release_sock(sk); |
| 317 | 303 | ||
| @@ -336,7 +322,6 @@ static int release(struct socket *sock) | |||
| 336 | * NOTE: This routine doesn't need to take the socket lock since it doesn't | 322 | * NOTE: This routine doesn't need to take the socket lock since it doesn't |
| 337 | * access any non-constant socket information. | 323 | * access any non-constant socket information. |
| 338 | */ | 324 | */ |
| 339 | |||
| 340 | static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) | 325 | static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) |
| 341 | { | 326 | { |
| 342 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; | 327 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; |
| @@ -376,7 +361,6 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) | |||
| 376 | * accesses socket information that is unchanging (or which changes in | 361 | * accesses socket information that is unchanging (or which changes in |
| 377 | * a completely predictable manner). | 362 | * a completely predictable manner). |
| 378 | */ | 363 | */ |
| 379 | |||
| 380 | static int get_name(struct socket *sock, struct sockaddr *uaddr, | 364 | static int get_name(struct socket *sock, struct sockaddr *uaddr, |
| 381 | int *uaddr_len, int peer) | 365 | int *uaddr_len, int peer) |
| 382 | { | 366 | { |
| @@ -444,7 +428,6 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr, | |||
| 444 | * imply that the operation will succeed, merely that it should be performed | 428 | * imply that the operation will succeed, merely that it should be performed |
| 445 | * and will not block. | 429 | * and will not block. |
| 446 | */ | 430 | */ |
| 447 | |||
| 448 | static unsigned int poll(struct file *file, struct socket *sock, | 431 | static unsigned int poll(struct file *file, struct socket *sock, |
| 449 | poll_table *wait) | 432 | poll_table *wait) |
| 450 | { | 433 | { |
| @@ -482,7 +465,6 @@ static unsigned int poll(struct file *file, struct socket *sock, | |||
| 482 | * | 465 | * |
| 483 | * Returns 0 if permission is granted, otherwise errno | 466 | * Returns 0 if permission is granted, otherwise errno |
| 484 | */ | 467 | */ |
| 485 | |||
| 486 | static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m) | 468 | static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m) |
| 487 | { | 469 | { |
| 488 | struct tipc_cfg_msg_hdr hdr; | 470 | struct tipc_cfg_msg_hdr hdr; |
| @@ -518,7 +500,6 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m) | |||
| 518 | * | 500 | * |
| 519 | * Returns the number of bytes sent on success, or errno otherwise | 501 | * Returns the number of bytes sent on success, or errno otherwise |
| 520 | */ | 502 | */ |
| 521 | |||
| 522 | static int send_msg(struct kiocb *iocb, struct socket *sock, | 503 | static int send_msg(struct kiocb *iocb, struct socket *sock, |
| 523 | struct msghdr *m, size_t total_len) | 504 | struct msghdr *m, size_t total_len) |
| 524 | { | 505 | { |
| @@ -535,7 +516,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
| 535 | (dest->family != AF_TIPC))) | 516 | (dest->family != AF_TIPC))) |
| 536 | return -EINVAL; | 517 | return -EINVAL; |
| 537 | if ((total_len > TIPC_MAX_USER_MSG_SIZE) || | 518 | if ((total_len > TIPC_MAX_USER_MSG_SIZE) || |
| 538 | (m->msg_iovlen > (unsigned)INT_MAX)) | 519 | (m->msg_iovlen > (unsigned int)INT_MAX)) |
| 539 | return -EMSGSIZE; | 520 | return -EMSGSIZE; |
| 540 | 521 | ||
| 541 | if (iocb) | 522 | if (iocb) |
| @@ -562,7 +543,6 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
| 562 | } | 543 | } |
| 563 | 544 | ||
| 564 | /* Abort any pending connection attempts (very unlikely) */ | 545 | /* Abort any pending connection attempts (very unlikely) */ |
| 565 | |||
| 566 | reject_rx_queue(sk); | 546 | reject_rx_queue(sk); |
| 567 | } | 547 | } |
| 568 | 548 | ||
| @@ -631,7 +611,6 @@ exit: | |||
| 631 | * | 611 | * |
| 632 | * Returns the number of bytes sent on success, or errno otherwise | 612 | * Returns the number of bytes sent on success, or errno otherwise |
| 633 | */ | 613 | */ |
| 634 | |||
| 635 | static int send_packet(struct kiocb *iocb, struct socket *sock, | 614 | static int send_packet(struct kiocb *iocb, struct socket *sock, |
| 636 | struct msghdr *m, size_t total_len) | 615 | struct msghdr *m, size_t total_len) |
| 637 | { | 616 | { |
| @@ -642,12 +621,11 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, | |||
| 642 | int res; | 621 | int res; |
| 643 | 622 | ||
| 644 | /* Handle implied connection establishment */ | 623 | /* Handle implied connection establishment */ |
| 645 | |||
| 646 | if (unlikely(dest)) | 624 | if (unlikely(dest)) |
| 647 | return send_msg(iocb, sock, m, total_len); | 625 | return send_msg(iocb, sock, m, total_len); |
| 648 | 626 | ||
| 649 | if ((total_len > TIPC_MAX_USER_MSG_SIZE) || | 627 | if ((total_len > TIPC_MAX_USER_MSG_SIZE) || |
| 650 | (m->msg_iovlen > (unsigned)INT_MAX)) | 628 | (m->msg_iovlen > (unsigned int)INT_MAX)) |
| 651 | return -EMSGSIZE; | 629 | return -EMSGSIZE; |
| 652 | 630 | ||
| 653 | if (iocb) | 631 | if (iocb) |
| @@ -695,7 +673,6 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, | |||
| 695 | * Returns the number of bytes sent on success (or partial success), | 673 | * Returns the number of bytes sent on success (or partial success), |
| 696 | * or errno if no data sent | 674 | * or errno if no data sent |
| 697 | */ | 675 | */ |
| 698 | |||
| 699 | static int send_stream(struct kiocb *iocb, struct socket *sock, | 676 | static int send_stream(struct kiocb *iocb, struct socket *sock, |
| 700 | struct msghdr *m, size_t total_len) | 677 | struct msghdr *m, size_t total_len) |
| 701 | { | 678 | { |
| @@ -715,7 +692,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, | |||
| 715 | lock_sock(sk); | 692 | lock_sock(sk); |
| 716 | 693 | ||
| 717 | /* Handle special cases where there is no connection */ | 694 | /* Handle special cases where there is no connection */ |
| 718 | |||
| 719 | if (unlikely(sock->state != SS_CONNECTED)) { | 695 | if (unlikely(sock->state != SS_CONNECTED)) { |
| 720 | if (sock->state == SS_UNCONNECTED) { | 696 | if (sock->state == SS_UNCONNECTED) { |
| 721 | res = send_packet(NULL, sock, m, total_len); | 697 | res = send_packet(NULL, sock, m, total_len); |
| @@ -734,8 +710,8 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, | |||
| 734 | goto exit; | 710 | goto exit; |
| 735 | } | 711 | } |
| 736 | 712 | ||
| 737 | if ((total_len > (unsigned)INT_MAX) || | 713 | if ((total_len > (unsigned int)INT_MAX) || |
| 738 | (m->msg_iovlen > (unsigned)INT_MAX)) { | 714 | (m->msg_iovlen > (unsigned int)INT_MAX)) { |
| 739 | res = -EMSGSIZE; | 715 | res = -EMSGSIZE; |
| 740 | goto exit; | 716 | goto exit; |
| 741 | } | 717 | } |
| @@ -747,7 +723,6 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, | |||
| 747 | * (i.e. one large iovec entry), but could be improved to pass sets | 723 | * (i.e. one large iovec entry), but could be improved to pass sets |
| 748 | * of small iovec entries into send_packet(). | 724 | * of small iovec entries into send_packet(). |
| 749 | */ | 725 | */ |
| 750 | |||
| 751 | curr_iov = m->msg_iov; | 726 | curr_iov = m->msg_iov; |
| 752 | curr_iovlen = m->msg_iovlen; | 727 | curr_iovlen = m->msg_iovlen; |
| 753 | my_msg.msg_iov = &my_iov; | 728 | my_msg.msg_iov = &my_iov; |
| @@ -796,7 +771,6 @@ exit: | |||
| 796 | * | 771 | * |
| 797 | * Returns 0 on success, errno otherwise | 772 | * Returns 0 on success, errno otherwise |
| 798 | */ | 773 | */ |
| 799 | |||
| 800 | static int auto_connect(struct socket *sock, struct tipc_msg *msg) | 774 | static int auto_connect(struct socket *sock, struct tipc_msg *msg) |
| 801 | { | 775 | { |
| 802 | struct tipc_sock *tsock = tipc_sk(sock->sk); | 776 | struct tipc_sock *tsock = tipc_sk(sock->sk); |
| @@ -821,7 +795,6 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg) | |||
| 821 | * | 795 | * |
| 822 | * Note: Address is not captured if not requested by receiver. | 796 | * Note: Address is not captured if not requested by receiver. |
| 823 | */ | 797 | */ |
| 824 | |||
| 825 | static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) | 798 | static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) |
| 826 | { | 799 | { |
| 827 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)m->msg_name; | 800 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)m->msg_name; |
| @@ -847,7 +820,6 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) | |||
| 847 | * | 820 | * |
| 848 | * Returns 0 if successful, otherwise errno | 821 | * Returns 0 if successful, otherwise errno |
| 849 | */ | 822 | */ |
| 850 | |||
| 851 | static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | 823 | static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, |
| 852 | struct tipc_port *tport) | 824 | struct tipc_port *tport) |
| 853 | { | 825 | { |
| @@ -861,7 +833,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | |||
| 861 | return 0; | 833 | return 0; |
| 862 | 834 | ||
| 863 | /* Optionally capture errored message object(s) */ | 835 | /* Optionally capture errored message object(s) */ |
| 864 | |||
| 865 | err = msg ? msg_errcode(msg) : 0; | 836 | err = msg ? msg_errcode(msg) : 0; |
| 866 | if (unlikely(err)) { | 837 | if (unlikely(err)) { |
| 867 | anc_data[0] = err; | 838 | anc_data[0] = err; |
| @@ -878,7 +849,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | |||
| 878 | } | 849 | } |
| 879 | 850 | ||
| 880 | /* Optionally capture message destination object */ | 851 | /* Optionally capture message destination object */ |
| 881 | |||
| 882 | dest_type = msg ? msg_type(msg) : TIPC_DIRECT_MSG; | 852 | dest_type = msg ? msg_type(msg) : TIPC_DIRECT_MSG; |
| 883 | switch (dest_type) { | 853 | switch (dest_type) { |
| 884 | case TIPC_NAMED_MSG: | 854 | case TIPC_NAMED_MSG: |
| @@ -923,7 +893,6 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | |||
| 923 | * | 893 | * |
| 924 | * Returns size of returned message data, errno otherwise | 894 | * Returns size of returned message data, errno otherwise |
| 925 | */ | 895 | */ |
| 926 | |||
| 927 | static int recv_msg(struct kiocb *iocb, struct socket *sock, | 896 | static int recv_msg(struct kiocb *iocb, struct socket *sock, |
| 928 | struct msghdr *m, size_t buf_len, int flags) | 897 | struct msghdr *m, size_t buf_len, int flags) |
| 929 | { | 898 | { |
| @@ -937,7 +906,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock, | |||
| 937 | int res; | 906 | int res; |
| 938 | 907 | ||
| 939 | /* Catch invalid receive requests */ | 908 | /* Catch invalid receive requests */ |
| 940 | |||
| 941 | if (unlikely(!buf_len)) | 909 | if (unlikely(!buf_len)) |
| 942 | return -EINVAL; | 910 | return -EINVAL; |
| 943 | 911 | ||
| @@ -952,7 +920,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock, | |||
| 952 | restart: | 920 | restart: |
| 953 | 921 | ||
| 954 | /* Look for a message in receive queue; wait if necessary */ | 922 | /* Look for a message in receive queue; wait if necessary */ |
| 955 | |||
| 956 | while (skb_queue_empty(&sk->sk_receive_queue)) { | 923 | while (skb_queue_empty(&sk->sk_receive_queue)) { |
| 957 | if (sock->state == SS_DISCONNECTING) { | 924 | if (sock->state == SS_DISCONNECTING) { |
| 958 | res = -ENOTCONN; | 925 | res = -ENOTCONN; |
| @@ -970,14 +937,12 @@ restart: | |||
| 970 | } | 937 | } |
| 971 | 938 | ||
| 972 | /* Look at first message in receive queue */ | 939 | /* Look at first message in receive queue */ |
| 973 | |||
| 974 | buf = skb_peek(&sk->sk_receive_queue); | 940 | buf = skb_peek(&sk->sk_receive_queue); |
| 975 | msg = buf_msg(buf); | 941 | msg = buf_msg(buf); |
| 976 | sz = msg_data_sz(msg); | 942 | sz = msg_data_sz(msg); |
| 977 | err = msg_errcode(msg); | 943 | err = msg_errcode(msg); |
| 978 | 944 | ||
| 979 | /* Complete connection setup for an implied connect */ | 945 | /* Complete connection setup for an implied connect */ |
| 980 | |||
| 981 | if (unlikely(sock->state == SS_CONNECTING)) { | 946 | if (unlikely(sock->state == SS_CONNECTING)) { |
| 982 | res = auto_connect(sock, msg); | 947 | res = auto_connect(sock, msg); |
| 983 | if (res) | 948 | if (res) |
| @@ -985,24 +950,20 @@ restart: | |||
| 985 | } | 950 | } |
| 986 | 951 | ||
| 987 | /* Discard an empty non-errored message & try again */ | 952 | /* Discard an empty non-errored message & try again */ |
| 988 | |||
| 989 | if ((!sz) && (!err)) { | 953 | if ((!sz) && (!err)) { |
| 990 | advance_rx_queue(sk); | 954 | advance_rx_queue(sk); |
| 991 | goto restart; | 955 | goto restart; |
| 992 | } | 956 | } |
| 993 | 957 | ||
| 994 | /* Capture sender's address (optional) */ | 958 | /* Capture sender's address (optional) */ |
| 995 | |||
| 996 | set_orig_addr(m, msg); | 959 | set_orig_addr(m, msg); |
| 997 | 960 | ||
| 998 | /* Capture ancillary data (optional) */ | 961 | /* Capture ancillary data (optional) */ |
| 999 | |||
| 1000 | res = anc_data_recv(m, msg, tport); | 962 | res = anc_data_recv(m, msg, tport); |
| 1001 | if (res) | 963 | if (res) |
| 1002 | goto exit; | 964 | goto exit; |
| 1003 | 965 | ||
| 1004 | /* Capture message data (if valid) & compute return value (always) */ | 966 | /* Capture message data (if valid) & compute return value (always) */ |
| 1005 | |||
| 1006 | if (!err) { | 967 | if (!err) { |
| 1007 | if (unlikely(buf_len < sz)) { | 968 | if (unlikely(buf_len < sz)) { |
| 1008 | sz = buf_len; | 969 | sz = buf_len; |
| @@ -1022,7 +983,6 @@ restart: | |||
| 1022 | } | 983 | } |
| 1023 | 984 | ||
| 1024 | /* Consume received message (optional) */ | 985 | /* Consume received message (optional) */ |
| 1025 | |||
| 1026 | if (likely(!(flags & MSG_PEEK))) { | 986 | if (likely(!(flags & MSG_PEEK))) { |
| 1027 | if ((sock->state != SS_READY) && | 987 | if ((sock->state != SS_READY) && |
| 1028 | (++tport->conn_unacked >= TIPC_FLOW_CONTROL_WIN)) | 988 | (++tport->conn_unacked >= TIPC_FLOW_CONTROL_WIN)) |
| @@ -1046,7 +1006,6 @@ exit: | |||
| 1046 | * | 1006 | * |
| 1047 | * Returns size of returned message data, errno otherwise | 1007 | * Returns size of returned message data, errno otherwise |
| 1048 | */ | 1008 | */ |
| 1049 | |||
| 1050 | static int recv_stream(struct kiocb *iocb, struct socket *sock, | 1009 | static int recv_stream(struct kiocb *iocb, struct socket *sock, |
| 1051 | struct msghdr *m, size_t buf_len, int flags) | 1010 | struct msghdr *m, size_t buf_len, int flags) |
| 1052 | { | 1011 | { |
| @@ -1062,7 +1021,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, | |||
| 1062 | int res = 0; | 1021 | int res = 0; |
| 1063 | 1022 | ||
| 1064 | /* Catch invalid receive attempts */ | 1023 | /* Catch invalid receive attempts */ |
| 1065 | |||
| 1066 | if (unlikely(!buf_len)) | 1024 | if (unlikely(!buf_len)) |
| 1067 | return -EINVAL; | 1025 | return -EINVAL; |
| 1068 | 1026 | ||
| @@ -1076,10 +1034,9 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, | |||
| 1076 | 1034 | ||
| 1077 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, buf_len); | 1035 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, buf_len); |
| 1078 | timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); | 1036 | timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); |
| 1079 | restart: | ||
| 1080 | 1037 | ||
| 1038 | restart: | ||
| 1081 | /* Look for a message in receive queue; wait if necessary */ | 1039 | /* Look for a message in receive queue; wait if necessary */ |
| 1082 | |||
| 1083 | while (skb_queue_empty(&sk->sk_receive_queue)) { | 1040 | while (skb_queue_empty(&sk->sk_receive_queue)) { |
| 1084 | if (sock->state == SS_DISCONNECTING) { | 1041 | if (sock->state == SS_DISCONNECTING) { |
| 1085 | res = -ENOTCONN; | 1042 | res = -ENOTCONN; |
| @@ -1097,21 +1054,18 @@ restart: | |||
| 1097 | } | 1054 | } |
| 1098 | 1055 | ||
| 1099 | /* Look at first message in receive queue */ | 1056 | /* Look at first message in receive queue */ |
| 1100 | |||
| 1101 | buf = skb_peek(&sk->sk_receive_queue); | 1057 | buf = skb_peek(&sk->sk_receive_queue); |
| 1102 | msg = buf_msg(buf); | 1058 | msg = buf_msg(buf); |
| 1103 | sz = msg_data_sz(msg); | 1059 | sz = msg_data_sz(msg); |
| 1104 | err = msg_errcode(msg); | 1060 | err = msg_errcode(msg); |
| 1105 | 1061 | ||
| 1106 | /* Discard an empty non-errored message & try again */ | 1062 | /* Discard an empty non-errored message & try again */ |
| 1107 | |||
| 1108 | if ((!sz) && (!err)) { | 1063 | if ((!sz) && (!err)) { |
| 1109 | advance_rx_queue(sk); | 1064 | advance_rx_queue(sk); |
| 1110 | goto restart; | 1065 | goto restart; |
| 1111 | } | 1066 | } |
| 1112 | 1067 | ||
| 1113 | /* Optionally capture sender's address & ancillary data of first msg */ | 1068 | /* Optionally capture sender's address & ancillary data of first msg */ |
| 1114 | |||
| 1115 | if (sz_copied == 0) { | 1069 | if (sz_copied == 0) { |
| 1116 | set_orig_addr(m, msg); | 1070 | set_orig_addr(m, msg); |
| 1117 | res = anc_data_recv(m, msg, tport); | 1071 | res = anc_data_recv(m, msg, tport); |
| @@ -1120,7 +1074,6 @@ restart: | |||
| 1120 | } | 1074 | } |
| 1121 | 1075 | ||
| 1122 | /* Capture message data (if valid) & compute return value (always) */ | 1076 | /* Capture message data (if valid) & compute return value (always) */ |
| 1123 | |||
| 1124 | if (!err) { | 1077 | if (!err) { |
| 1125 | u32 offset = (u32)(unsigned long)(TIPC_SKB_CB(buf)->handle); | 1078 | u32 offset = (u32)(unsigned long)(TIPC_SKB_CB(buf)->handle); |
| 1126 | 1079 | ||
| @@ -1152,7 +1105,6 @@ restart: | |||
| 1152 | } | 1105 | } |
| 1153 | 1106 | ||
| 1154 | /* Consume received message (optional) */ | 1107 | /* Consume received message (optional) */ |
| 1155 | |||
| 1156 | if (likely(!(flags & MSG_PEEK))) { | 1108 | if (likely(!(flags & MSG_PEEK))) { |
| 1157 | if (unlikely(++tport->conn_unacked >= TIPC_FLOW_CONTROL_WIN)) | 1109 | if (unlikely(++tport->conn_unacked >= TIPC_FLOW_CONTROL_WIN)) |
| 1158 | tipc_acknowledge(tport->ref, tport->conn_unacked); | 1110 | tipc_acknowledge(tport->ref, tport->conn_unacked); |
| @@ -1160,7 +1112,6 @@ restart: | |||
| 1160 | } | 1112 | } |
| 1161 | 1113 | ||
| 1162 | /* Loop around if more data is required */ | 1114 | /* Loop around if more data is required */ |
| 1163 | |||
| 1164 | if ((sz_copied < buf_len) && /* didn't get all requested data */ | 1115 | if ((sz_copied < buf_len) && /* didn't get all requested data */ |
| 1165 | (!skb_queue_empty(&sk->sk_receive_queue) || | 1116 | (!skb_queue_empty(&sk->sk_receive_queue) || |
| 1166 | (sz_copied < target)) && /* and more is ready or required */ | 1117 | (sz_copied < target)) && /* and more is ready or required */ |
| @@ -1181,7 +1132,6 @@ exit: | |||
| 1181 | * | 1132 | * |
| 1182 | * Returns 1 if queue is unable to accept message, 0 otherwise | 1133 | * Returns 1 if queue is unable to accept message, 0 otherwise |
| 1183 | */ | 1134 | */ |
| 1184 | |||
| 1185 | static int rx_queue_full(struct tipc_msg *msg, u32 queue_size, u32 base) | 1135 | static int rx_queue_full(struct tipc_msg *msg, u32 queue_size, u32 base) |
| 1186 | { | 1136 | { |
| 1187 | u32 threshold; | 1137 | u32 threshold; |
| @@ -1214,7 +1164,6 @@ static int rx_queue_full(struct tipc_msg *msg, u32 queue_size, u32 base) | |||
| 1214 | * | 1164 | * |
| 1215 | * Returns TIPC error status code (TIPC_OK if message is not to be rejected) | 1165 | * Returns TIPC error status code (TIPC_OK if message is not to be rejected) |
| 1216 | */ | 1166 | */ |
| 1217 | |||
| 1218 | static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | 1167 | static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) |
| 1219 | { | 1168 | { |
| 1220 | struct socket *sock = sk->sk_socket; | 1169 | struct socket *sock = sk->sk_socket; |
| @@ -1222,12 +1171,8 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | |||
| 1222 | u32 recv_q_len; | 1171 | u32 recv_q_len; |
| 1223 | 1172 | ||
| 1224 | /* Reject message if it is wrong sort of message for socket */ | 1173 | /* Reject message if it is wrong sort of message for socket */ |
| 1225 | 1174 | if (msg_type(msg) > TIPC_DIRECT_MSG) | |
| 1226 | /* | 1175 | return TIPC_ERR_NO_PORT; |
| 1227 | * WOULD IT BE BETTER TO JUST DISCARD THESE MESSAGES INSTEAD? | ||
| 1228 | * "NO PORT" ISN'T REALLY THE RIGHT ERROR CODE, AND THERE MAY | ||
| 1229 | * BE SECURITY IMPLICATIONS INHERENT IN REJECTING INVALID TRAFFIC | ||
| 1230 | */ | ||
| 1231 | 1176 | ||
| 1232 | if (sock->state == SS_READY) { | 1177 | if (sock->state == SS_READY) { |
| 1233 | if (msg_connected(msg)) | 1178 | if (msg_connected(msg)) |
| @@ -1236,7 +1181,8 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | |||
| 1236 | if (msg_mcast(msg)) | 1181 | if (msg_mcast(msg)) |
| 1237 | return TIPC_ERR_NO_PORT; | 1182 | return TIPC_ERR_NO_PORT; |
| 1238 | if (sock->state == SS_CONNECTED) { | 1183 | if (sock->state == SS_CONNECTED) { |
| 1239 | if (!msg_connected(msg)) | 1184 | if (!msg_connected(msg) || |
| 1185 | !tipc_port_peer_msg(tipc_sk_port(sk), msg)) | ||
| 1240 | return TIPC_ERR_NO_PORT; | 1186 | return TIPC_ERR_NO_PORT; |
| 1241 | } else if (sock->state == SS_CONNECTING) { | 1187 | } else if (sock->state == SS_CONNECTING) { |
| 1242 | if (!msg_connected(msg) && (msg_errcode(msg) == 0)) | 1188 | if (!msg_connected(msg) && (msg_errcode(msg) == 0)) |
| @@ -1253,7 +1199,6 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | |||
| 1253 | } | 1199 | } |
| 1254 | 1200 | ||
| 1255 | /* Reject message if there isn't room to queue it */ | 1201 | /* Reject message if there isn't room to queue it */ |
| 1256 | |||
| 1257 | recv_q_len = (u32)atomic_read(&tipc_queue_size); | 1202 | recv_q_len = (u32)atomic_read(&tipc_queue_size); |
| 1258 | if (unlikely(recv_q_len >= OVERLOAD_LIMIT_BASE)) { | 1203 | if (unlikely(recv_q_len >= OVERLOAD_LIMIT_BASE)) { |
| 1259 | if (rx_queue_full(msg, recv_q_len, OVERLOAD_LIMIT_BASE)) | 1204 | if (rx_queue_full(msg, recv_q_len, OVERLOAD_LIMIT_BASE)) |
| @@ -1266,13 +1211,11 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | |||
| 1266 | } | 1211 | } |
| 1267 | 1212 | ||
| 1268 | /* Enqueue message (finally!) */ | 1213 | /* Enqueue message (finally!) */ |
| 1269 | |||
| 1270 | TIPC_SKB_CB(buf)->handle = 0; | 1214 | TIPC_SKB_CB(buf)->handle = 0; |
| 1271 | atomic_inc(&tipc_queue_size); | 1215 | atomic_inc(&tipc_queue_size); |
| 1272 | __skb_queue_tail(&sk->sk_receive_queue, buf); | 1216 | __skb_queue_tail(&sk->sk_receive_queue, buf); |
| 1273 | 1217 | ||
| 1274 | /* Initiate connection termination for an incoming 'FIN' */ | 1218 | /* Initiate connection termination for an incoming 'FIN' */ |
| 1275 | |||
| 1276 | if (unlikely(msg_errcode(msg) && (sock->state == SS_CONNECTED))) { | 1219 | if (unlikely(msg_errcode(msg) && (sock->state == SS_CONNECTED))) { |
| 1277 | sock->state = SS_DISCONNECTING; | 1220 | sock->state = SS_DISCONNECTING; |
| 1278 | tipc_disconnect_port(tipc_sk_port(sk)); | 1221 | tipc_disconnect_port(tipc_sk_port(sk)); |
| @@ -1292,7 +1235,6 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | |||
| 1292 | * | 1235 | * |
| 1293 | * Returns 0 | 1236 | * Returns 0 |
| 1294 | */ | 1237 | */ |
| 1295 | |||
| 1296 | static int backlog_rcv(struct sock *sk, struct sk_buff *buf) | 1238 | static int backlog_rcv(struct sock *sk, struct sk_buff *buf) |
| 1297 | { | 1239 | { |
| 1298 | u32 res; | 1240 | u32 res; |
| @@ -1312,7 +1254,6 @@ static int backlog_rcv(struct sock *sk, struct sk_buff *buf) | |||
| 1312 | * | 1254 | * |
| 1313 | * Returns TIPC error status code (TIPC_OK if message is not to be rejected) | 1255 | * Returns TIPC error status code (TIPC_OK if message is not to be rejected) |
| 1314 | */ | 1256 | */ |
| 1315 | |||
| 1316 | static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) | 1257 | static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) |
| 1317 | { | 1258 | { |
| 1318 | struct sock *sk = (struct sock *)tport->usr_handle; | 1259 | struct sock *sk = (struct sock *)tport->usr_handle; |
| @@ -1324,12 +1265,11 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) | |||
| 1324 | * This code is based on sk_receive_skb(), but must be distinct from it | 1265 | * This code is based on sk_receive_skb(), but must be distinct from it |
| 1325 | * since a TIPC-specific filter/reject mechanism is utilized | 1266 | * since a TIPC-specific filter/reject mechanism is utilized |
| 1326 | */ | 1267 | */ |
| 1327 | |||
| 1328 | bh_lock_sock(sk); | 1268 | bh_lock_sock(sk); |
| 1329 | if (!sock_owned_by_user(sk)) { | 1269 | if (!sock_owned_by_user(sk)) { |
| 1330 | res = filter_rcv(sk, buf); | 1270 | res = filter_rcv(sk, buf); |
| 1331 | } else { | 1271 | } else { |
| 1332 | if (sk_add_backlog(sk, buf)) | 1272 | if (sk_add_backlog(sk, buf, sk->sk_rcvbuf)) |
| 1333 | res = TIPC_ERR_OVERLOAD; | 1273 | res = TIPC_ERR_OVERLOAD; |
| 1334 | else | 1274 | else |
| 1335 | res = TIPC_OK; | 1275 | res = TIPC_OK; |
| @@ -1345,7 +1285,6 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) | |||
| 1345 | * | 1285 | * |
| 1346 | * Called with port lock already taken. | 1286 | * Called with port lock already taken. |
| 1347 | */ | 1287 | */ |
| 1348 | |||
| 1349 | static void wakeupdispatch(struct tipc_port *tport) | 1288 | static void wakeupdispatch(struct tipc_port *tport) |
| 1350 | { | 1289 | { |
| 1351 | struct sock *sk = (struct sock *)tport->usr_handle; | 1290 | struct sock *sk = (struct sock *)tport->usr_handle; |
| @@ -1363,7 +1302,6 @@ static void wakeupdispatch(struct tipc_port *tport) | |||
| 1363 | * | 1302 | * |
| 1364 | * Returns 0 on success, errno otherwise | 1303 | * Returns 0 on success, errno otherwise |
| 1365 | */ | 1304 | */ |
| 1366 | |||
| 1367 | static int connect(struct socket *sock, struct sockaddr *dest, int destlen, | 1305 | static int connect(struct socket *sock, struct sockaddr *dest, int destlen, |
| 1368 | int flags) | 1306 | int flags) |
| 1369 | { | 1307 | { |
| @@ -1378,21 +1316,18 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, | |||
| 1378 | lock_sock(sk); | 1316 | lock_sock(sk); |
| 1379 | 1317 | ||
| 1380 | /* For now, TIPC does not allow use of connect() with DGRAM/RDM types */ | 1318 | /* For now, TIPC does not allow use of connect() with DGRAM/RDM types */ |
| 1381 | |||
| 1382 | if (sock->state == SS_READY) { | 1319 | if (sock->state == SS_READY) { |
| 1383 | res = -EOPNOTSUPP; | 1320 | res = -EOPNOTSUPP; |
| 1384 | goto exit; | 1321 | goto exit; |
| 1385 | } | 1322 | } |
| 1386 | 1323 | ||
| 1387 | /* For now, TIPC does not support the non-blocking form of connect() */ | 1324 | /* For now, TIPC does not support the non-blocking form of connect() */ |
| 1388 | |||
| 1389 | if (flags & O_NONBLOCK) { | 1325 | if (flags & O_NONBLOCK) { |
| 1390 | res = -EOPNOTSUPP; | 1326 | res = -EOPNOTSUPP; |
| 1391 | goto exit; | 1327 | goto exit; |
| 1392 | } | 1328 | } |
| 1393 | 1329 | ||
| 1394 | /* Issue Posix-compliant error code if socket is in the wrong state */ | 1330 | /* Issue Posix-compliant error code if socket is in the wrong state */ |
| 1395 | |||
| 1396 | if (sock->state == SS_LISTENING) { | 1331 | if (sock->state == SS_LISTENING) { |
| 1397 | res = -EOPNOTSUPP; | 1332 | res = -EOPNOTSUPP; |
| 1398 | goto exit; | 1333 | goto exit; |
| @@ -1412,18 +1347,15 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, | |||
| 1412 | * Note: send_msg() validates the rest of the address fields, | 1347 | * Note: send_msg() validates the rest of the address fields, |
| 1413 | * so there's no need to do it here | 1348 | * so there's no need to do it here |
| 1414 | */ | 1349 | */ |
| 1415 | |||
| 1416 | if (dst->addrtype == TIPC_ADDR_MCAST) { | 1350 | if (dst->addrtype == TIPC_ADDR_MCAST) { |
| 1417 | res = -EINVAL; | 1351 | res = -EINVAL; |
| 1418 | goto exit; | 1352 | goto exit; |
| 1419 | } | 1353 | } |
| 1420 | 1354 | ||
| 1421 | /* Reject any messages already in receive queue (very unlikely) */ | 1355 | /* Reject any messages already in receive queue (very unlikely) */ |
| 1422 | |||
| 1423 | reject_rx_queue(sk); | 1356 | reject_rx_queue(sk); |
| 1424 | 1357 | ||
| 1425 | /* Send a 'SYN-' to destination */ | 1358 | /* Send a 'SYN-' to destination */ |
| 1426 | |||
| 1427 | m.msg_name = dest; | 1359 | m.msg_name = dest; |
| 1428 | m.msg_namelen = destlen; | 1360 | m.msg_namelen = destlen; |
| 1429 | res = send_msg(NULL, sock, &m, 0); | 1361 | res = send_msg(NULL, sock, &m, 0); |
| @@ -1431,7 +1363,6 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, | |||
| 1431 | goto exit; | 1363 | goto exit; |
| 1432 | 1364 | ||
| 1433 | /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ | 1365 | /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ |
| 1434 | |||
| 1435 | timeout = tipc_sk(sk)->conn_timeout; | 1366 | timeout = tipc_sk(sk)->conn_timeout; |
| 1436 | release_sock(sk); | 1367 | release_sock(sk); |
| 1437 | res = wait_event_interruptible_timeout(*sk_sleep(sk), | 1368 | res = wait_event_interruptible_timeout(*sk_sleep(sk), |
| @@ -1476,7 +1407,6 @@ exit: | |||
| 1476 | * | 1407 | * |
| 1477 | * Returns 0 on success, errno otherwise | 1408 | * Returns 0 on success, errno otherwise |
| 1478 | */ | 1409 | */ |
| 1479 | |||
| 1480 | static int listen(struct socket *sock, int len) | 1410 | static int listen(struct socket *sock, int len) |
| 1481 | { | 1411 | { |
| 1482 | struct sock *sk = sock->sk; | 1412 | struct sock *sk = sock->sk; |
| @@ -1503,7 +1433,6 @@ static int listen(struct socket *sock, int len) | |||
| 1503 | * | 1433 | * |
| 1504 | * Returns 0 on success, errno otherwise | 1434 | * Returns 0 on success, errno otherwise |
| 1505 | */ | 1435 | */ |
| 1506 | |||
| 1507 | static int accept(struct socket *sock, struct socket *new_sock, int flags) | 1436 | static int accept(struct socket *sock, struct socket *new_sock, int flags) |
| 1508 | { | 1437 | { |
| 1509 | struct sock *sk = sock->sk; | 1438 | struct sock *sk = sock->sk; |
| @@ -1546,11 +1475,9 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) | |||
| 1546 | * Reject any stray messages received by new socket | 1475 | * Reject any stray messages received by new socket |
| 1547 | * before the socket lock was taken (very, very unlikely) | 1476 | * before the socket lock was taken (very, very unlikely) |
| 1548 | */ | 1477 | */ |
| 1549 | |||
| 1550 | reject_rx_queue(new_sk); | 1478 | reject_rx_queue(new_sk); |
| 1551 | 1479 | ||
| 1552 | /* Connect new socket to it's peer */ | 1480 | /* Connect new socket to it's peer */ |
| 1553 | |||
| 1554 | new_tsock->peer_name.ref = msg_origport(msg); | 1481 | new_tsock->peer_name.ref = msg_origport(msg); |
| 1555 | new_tsock->peer_name.node = msg_orignode(msg); | 1482 | new_tsock->peer_name.node = msg_orignode(msg); |
| 1556 | tipc_connect2port(new_ref, &new_tsock->peer_name); | 1483 | tipc_connect2port(new_ref, &new_tsock->peer_name); |
| @@ -1566,7 +1493,6 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) | |||
| 1566 | * Respond to 'SYN-' by discarding it & returning 'ACK'-. | 1493 | * Respond to 'SYN-' by discarding it & returning 'ACK'-. |
| 1567 | * Respond to 'SYN+' by queuing it on new socket. | 1494 | * Respond to 'SYN+' by queuing it on new socket. |
| 1568 | */ | 1495 | */ |
| 1569 | |||
| 1570 | if (!msg_data_sz(msg)) { | 1496 | if (!msg_data_sz(msg)) { |
| 1571 | struct msghdr m = {NULL,}; | 1497 | struct msghdr m = {NULL,}; |
| 1572 | 1498 | ||
| @@ -1592,7 +1518,6 @@ exit: | |||
| 1592 | * | 1518 | * |
| 1593 | * Returns 0 on success, errno otherwise | 1519 | * Returns 0 on success, errno otherwise |
| 1594 | */ | 1520 | */ |
| 1595 | |||
| 1596 | static int shutdown(struct socket *sock, int how) | 1521 | static int shutdown(struct socket *sock, int how) |
| 1597 | { | 1522 | { |
| 1598 | struct sock *sk = sock->sk; | 1523 | struct sock *sk = sock->sk; |
| @@ -1609,8 +1534,8 @@ static int shutdown(struct socket *sock, int how) | |||
| 1609 | case SS_CONNECTING: | 1534 | case SS_CONNECTING: |
| 1610 | case SS_CONNECTED: | 1535 | case SS_CONNECTED: |
| 1611 | 1536 | ||
| 1612 | /* Disconnect and send a 'FIN+' or 'FIN-' message to peer */ | ||
| 1613 | restart: | 1537 | restart: |
| 1538 | /* Disconnect and send a 'FIN+' or 'FIN-' message to peer */ | ||
| 1614 | buf = __skb_dequeue(&sk->sk_receive_queue); | 1539 | buf = __skb_dequeue(&sk->sk_receive_queue); |
| 1615 | if (buf) { | 1540 | if (buf) { |
| 1616 | atomic_dec(&tipc_queue_size); | 1541 | atomic_dec(&tipc_queue_size); |
| @@ -1631,7 +1556,6 @@ restart: | |||
| 1631 | case SS_DISCONNECTING: | 1556 | case SS_DISCONNECTING: |
| 1632 | 1557 | ||
| 1633 | /* Discard any unreceived messages; wake up sleeping tasks */ | 1558 | /* Discard any unreceived messages; wake up sleeping tasks */ |
| 1634 | |||
| 1635 | discard_rx_queue(sk); | 1559 | discard_rx_queue(sk); |
| 1636 | if (waitqueue_active(sk_sleep(sk))) | 1560 | if (waitqueue_active(sk_sleep(sk))) |
| 1637 | wake_up_interruptible(sk_sleep(sk)); | 1561 | wake_up_interruptible(sk_sleep(sk)); |
| @@ -1659,7 +1583,6 @@ restart: | |||
| 1659 | * | 1583 | * |
| 1660 | * Returns 0 on success, errno otherwise | 1584 | * Returns 0 on success, errno otherwise |
| 1661 | */ | 1585 | */ |
| 1662 | |||
| 1663 | static int setsockopt(struct socket *sock, | 1586 | static int setsockopt(struct socket *sock, |
| 1664 | int lvl, int opt, char __user *ov, unsigned int ol) | 1587 | int lvl, int opt, char __user *ov, unsigned int ol) |
| 1665 | { | 1588 | { |
| @@ -1719,7 +1642,6 @@ static int setsockopt(struct socket *sock, | |||
| 1719 | * | 1642 | * |
| 1720 | * Returns 0 on success, errno otherwise | 1643 | * Returns 0 on success, errno otherwise |
| 1721 | */ | 1644 | */ |
| 1722 | |||
| 1723 | static int getsockopt(struct socket *sock, | 1645 | static int getsockopt(struct socket *sock, |
| 1724 | int lvl, int opt, char __user *ov, int __user *ol) | 1646 | int lvl, int opt, char __user *ov, int __user *ol) |
| 1725 | { | 1647 | { |
| @@ -1780,7 +1702,6 @@ static int getsockopt(struct socket *sock, | |||
| 1780 | /** | 1702 | /** |
| 1781 | * Protocol switches for the various types of TIPC sockets | 1703 | * Protocol switches for the various types of TIPC sockets |
| 1782 | */ | 1704 | */ |
| 1783 | |||
| 1784 | static const struct proto_ops msg_ops = { | 1705 | static const struct proto_ops msg_ops = { |
| 1785 | .owner = THIS_MODULE, | 1706 | .owner = THIS_MODULE, |
| 1786 | .family = AF_TIPC, | 1707 | .family = AF_TIPC, |
| @@ -1886,7 +1807,6 @@ int tipc_socket_init(void) | |||
| 1886 | /** | 1807 | /** |
| 1887 | * tipc_socket_stop - stop TIPC socket interface | 1808 | * tipc_socket_stop - stop TIPC socket interface |
| 1888 | */ | 1809 | */ |
| 1889 | |||
| 1890 | void tipc_socket_stop(void) | 1810 | void tipc_socket_stop(void) |
| 1891 | { | 1811 | { |
| 1892 | if (!sockets_enabled) | 1812 | if (!sockets_enabled) |
| @@ -1896,4 +1816,3 @@ void tipc_socket_stop(void) | |||
| 1896 | sock_unregister(tipc_family_ops.family); | 1816 | sock_unregister(tipc_family_ops.family); |
| 1897 | proto_unregister(&tipc_proto); | 1817 | proto_unregister(&tipc_proto); |
| 1898 | } | 1818 | } |
| 1899 | |||
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index b2964e9895d3..f976e9cd6a72 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
| @@ -46,7 +46,6 @@ | |||
| 46 | * @subscriber_list: adjacent subscribers in top. server's list of subscribers | 46 | * @subscriber_list: adjacent subscribers in top. server's list of subscribers |
| 47 | * @subscription_list: list of subscription objects for this subscriber | 47 | * @subscription_list: list of subscription objects for this subscriber |
| 48 | */ | 48 | */ |
| 49 | |||
| 50 | struct tipc_subscriber { | 49 | struct tipc_subscriber { |
| 51 | u32 port_ref; | 50 | u32 port_ref; |
| 52 | spinlock_t *lock; | 51 | spinlock_t *lock; |
| @@ -56,13 +55,11 @@ struct tipc_subscriber { | |||
| 56 | 55 | ||
| 57 | /** | 56 | /** |
| 58 | * struct top_srv - TIPC network topology subscription service | 57 | * struct top_srv - TIPC network topology subscription service |
| 59 | * @user_ref: TIPC userid of subscription service | ||
| 60 | * @setup_port: reference to TIPC port that handles subscription requests | 58 | * @setup_port: reference to TIPC port that handles subscription requests |
| 61 | * @subscription_count: number of active subscriptions (not subscribers!) | 59 | * @subscription_count: number of active subscriptions (not subscribers!) |
| 62 | * @subscriber_list: list of ports subscribing to service | 60 | * @subscriber_list: list of ports subscribing to service |
| 63 | * @lock: spinlock govering access to subscriber list | 61 | * @lock: spinlock govering access to subscriber list |
| 64 | */ | 62 | */ |
| 65 | |||
| 66 | struct top_srv { | 63 | struct top_srv { |
| 67 | u32 setup_port; | 64 | u32 setup_port; |
| 68 | atomic_t subscription_count; | 65 | atomic_t subscription_count; |
| @@ -79,7 +76,6 @@ static struct top_srv topsrv; | |||
| 79 | * | 76 | * |
| 80 | * Returns converted value | 77 | * Returns converted value |
| 81 | */ | 78 | */ |
| 82 | |||
| 83 | static u32 htohl(u32 in, int swap) | 79 | static u32 htohl(u32 in, int swap) |
| 84 | { | 80 | { |
| 85 | return swap ? swab32(in) : in; | 81 | return swap ? swab32(in) : in; |
| @@ -91,7 +87,6 @@ static u32 htohl(u32 in, int swap) | |||
| 91 | * Note: Must not hold subscriber's server port lock, since tipc_send() will | 87 | * Note: Must not hold subscriber's server port lock, since tipc_send() will |
| 92 | * try to take the lock if the message is rejected and returned! | 88 | * try to take the lock if the message is rejected and returned! |
| 93 | */ | 89 | */ |
| 94 | |||
| 95 | static void subscr_send_event(struct tipc_subscription *sub, | 90 | static void subscr_send_event(struct tipc_subscription *sub, |
| 96 | u32 found_lower, | 91 | u32 found_lower, |
| 97 | u32 found_upper, | 92 | u32 found_upper, |
| @@ -117,7 +112,6 @@ static void subscr_send_event(struct tipc_subscription *sub, | |||
| 117 | * | 112 | * |
| 118 | * Returns 1 if there is overlap, otherwise 0. | 113 | * Returns 1 if there is overlap, otherwise 0. |
| 119 | */ | 114 | */ |
| 120 | |||
| 121 | int tipc_subscr_overlap(struct tipc_subscription *sub, | 115 | int tipc_subscr_overlap(struct tipc_subscription *sub, |
| 122 | u32 found_lower, | 116 | u32 found_lower, |
| 123 | u32 found_upper) | 117 | u32 found_upper) |
| @@ -137,7 +131,6 @@ int tipc_subscr_overlap(struct tipc_subscription *sub, | |||
| 137 | * | 131 | * |
| 138 | * Protected by nameseq.lock in name_table.c | 132 | * Protected by nameseq.lock in name_table.c |
| 139 | */ | 133 | */ |
| 140 | |||
| 141 | void tipc_subscr_report_overlap(struct tipc_subscription *sub, | 134 | void tipc_subscr_report_overlap(struct tipc_subscription *sub, |
| 142 | u32 found_lower, | 135 | u32 found_lower, |
| 143 | u32 found_upper, | 136 | u32 found_upper, |
| @@ -157,43 +150,35 @@ void tipc_subscr_report_overlap(struct tipc_subscription *sub, | |||
| 157 | /** | 150 | /** |
| 158 | * subscr_timeout - subscription timeout has occurred | 151 | * subscr_timeout - subscription timeout has occurred |
| 159 | */ | 152 | */ |
| 160 | |||
| 161 | static void subscr_timeout(struct tipc_subscription *sub) | 153 | static void subscr_timeout(struct tipc_subscription *sub) |
| 162 | { | 154 | { |
| 163 | struct tipc_port *server_port; | 155 | struct tipc_port *server_port; |
| 164 | 156 | ||
| 165 | /* Validate server port reference (in case subscriber is terminating) */ | 157 | /* Validate server port reference (in case subscriber is terminating) */ |
| 166 | |||
| 167 | server_port = tipc_port_lock(sub->server_ref); | 158 | server_port = tipc_port_lock(sub->server_ref); |
| 168 | if (server_port == NULL) | 159 | if (server_port == NULL) |
| 169 | return; | 160 | return; |
| 170 | 161 | ||
| 171 | /* Validate timeout (in case subscription is being cancelled) */ | 162 | /* Validate timeout (in case subscription is being cancelled) */ |
| 172 | |||
| 173 | if (sub->timeout == TIPC_WAIT_FOREVER) { | 163 | if (sub->timeout == TIPC_WAIT_FOREVER) { |
| 174 | tipc_port_unlock(server_port); | 164 | tipc_port_unlock(server_port); |
| 175 | return; | 165 | return; |
| 176 | } | 166 | } |
| 177 | 167 | ||
| 178 | /* Unlink subscription from name table */ | 168 | /* Unlink subscription from name table */ |
| 179 | |||
| 180 | tipc_nametbl_unsubscribe(sub); | 169 | tipc_nametbl_unsubscribe(sub); |
| 181 | 170 | ||
| 182 | /* Unlink subscription from subscriber */ | 171 | /* Unlink subscription from subscriber */ |
| 183 | |||
| 184 | list_del(&sub->subscription_list); | 172 | list_del(&sub->subscription_list); |
| 185 | 173 | ||
| 186 | /* Release subscriber's server port */ | 174 | /* Release subscriber's server port */ |
| 187 | |||
| 188 | tipc_port_unlock(server_port); | 175 | tipc_port_unlock(server_port); |
| 189 | 176 | ||
| 190 | /* Notify subscriber of timeout */ | 177 | /* Notify subscriber of timeout */ |
| 191 | |||
| 192 | subscr_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, | 178 | subscr_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, |
| 193 | TIPC_SUBSCR_TIMEOUT, 0, 0); | 179 | TIPC_SUBSCR_TIMEOUT, 0, 0); |
| 194 | 180 | ||
| 195 | /* Now destroy subscription */ | 181 | /* Now destroy subscription */ |
| 196 | |||
| 197 | k_term_timer(&sub->timer); | 182 | k_term_timer(&sub->timer); |
| 198 | kfree(sub); | 183 | kfree(sub); |
| 199 | atomic_dec(&topsrv.subscription_count); | 184 | atomic_dec(&topsrv.subscription_count); |
| @@ -204,7 +189,6 @@ static void subscr_timeout(struct tipc_subscription *sub) | |||
| 204 | * | 189 | * |
| 205 | * Called with subscriber port locked. | 190 | * Called with subscriber port locked. |
| 206 | */ | 191 | */ |
| 207 | |||
| 208 | static void subscr_del(struct tipc_subscription *sub) | 192 | static void subscr_del(struct tipc_subscription *sub) |
| 209 | { | 193 | { |
| 210 | tipc_nametbl_unsubscribe(sub); | 194 | tipc_nametbl_unsubscribe(sub); |
| @@ -223,7 +207,6 @@ static void subscr_del(struct tipc_subscription *sub) | |||
| 223 | * a new object reference in the interim that uses this lock; this routine will | 207 | * a new object reference in the interim that uses this lock; this routine will |
| 224 | * simply wait for it to be released, then claim it.) | 208 | * simply wait for it to be released, then claim it.) |
| 225 | */ | 209 | */ |
| 226 | |||
| 227 | static void subscr_terminate(struct tipc_subscriber *subscriber) | 210 | static void subscr_terminate(struct tipc_subscriber *subscriber) |
| 228 | { | 211 | { |
| 229 | u32 port_ref; | 212 | u32 port_ref; |
| @@ -231,18 +214,15 @@ static void subscr_terminate(struct tipc_subscriber *subscriber) | |||
| 231 | struct tipc_subscription *sub_temp; | 214 | struct tipc_subscription *sub_temp; |
| 232 | 215 | ||
| 233 | /* Invalidate subscriber reference */ | 216 | /* Invalidate subscriber reference */ |
| 234 | |||
| 235 | port_ref = subscriber->port_ref; | 217 | port_ref = subscriber->port_ref; |
| 236 | subscriber->port_ref = 0; | 218 | subscriber->port_ref = 0; |
| 237 | spin_unlock_bh(subscriber->lock); | 219 | spin_unlock_bh(subscriber->lock); |
| 238 | 220 | ||
| 239 | /* Sever connection to subscriber */ | 221 | /* Sever connection to subscriber */ |
| 240 | |||
| 241 | tipc_shutdown(port_ref); | 222 | tipc_shutdown(port_ref); |
| 242 | tipc_deleteport(port_ref); | 223 | tipc_deleteport(port_ref); |
| 243 | 224 | ||
| 244 | /* Destroy any existing subscriptions for subscriber */ | 225 | /* Destroy any existing subscriptions for subscriber */ |
| 245 | |||
| 246 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, | 226 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, |
| 247 | subscription_list) { | 227 | subscription_list) { |
| 248 | if (sub->timeout != TIPC_WAIT_FOREVER) { | 228 | if (sub->timeout != TIPC_WAIT_FOREVER) { |
| @@ -253,17 +233,14 @@ static void subscr_terminate(struct tipc_subscriber *subscriber) | |||
| 253 | } | 233 | } |
| 254 | 234 | ||
| 255 | /* Remove subscriber from topology server's subscriber list */ | 235 | /* Remove subscriber from topology server's subscriber list */ |
| 256 | |||
| 257 | spin_lock_bh(&topsrv.lock); | 236 | spin_lock_bh(&topsrv.lock); |
| 258 | list_del(&subscriber->subscriber_list); | 237 | list_del(&subscriber->subscriber_list); |
| 259 | spin_unlock_bh(&topsrv.lock); | 238 | spin_unlock_bh(&topsrv.lock); |
| 260 | 239 | ||
| 261 | /* Reclaim subscriber lock */ | 240 | /* Reclaim subscriber lock */ |
| 262 | |||
| 263 | spin_lock_bh(subscriber->lock); | 241 | spin_lock_bh(subscriber->lock); |
| 264 | 242 | ||
| 265 | /* Now destroy subscriber */ | 243 | /* Now destroy subscriber */ |
| 266 | |||
| 267 | kfree(subscriber); | 244 | kfree(subscriber); |
| 268 | } | 245 | } |
| 269 | 246 | ||
| @@ -276,7 +253,6 @@ static void subscr_terminate(struct tipc_subscriber *subscriber) | |||
| 276 | * | 253 | * |
| 277 | * Note that fields of 's' use subscriber's endianness! | 254 | * Note that fields of 's' use subscriber's endianness! |
| 278 | */ | 255 | */ |
| 279 | |||
| 280 | static void subscr_cancel(struct tipc_subscr *s, | 256 | static void subscr_cancel(struct tipc_subscr *s, |
| 281 | struct tipc_subscriber *subscriber) | 257 | struct tipc_subscriber *subscriber) |
| 282 | { | 258 | { |
| @@ -285,7 +261,6 @@ static void subscr_cancel(struct tipc_subscr *s, | |||
| 285 | int found = 0; | 261 | int found = 0; |
| 286 | 262 | ||
| 287 | /* Find first matching subscription, exit if not found */ | 263 | /* Find first matching subscription, exit if not found */ |
| 288 | |||
| 289 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, | 264 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, |
| 290 | subscription_list) { | 265 | subscription_list) { |
| 291 | if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { | 266 | if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { |
| @@ -297,7 +272,6 @@ static void subscr_cancel(struct tipc_subscr *s, | |||
| 297 | return; | 272 | return; |
| 298 | 273 | ||
| 299 | /* Cancel subscription timer (if used), then delete subscription */ | 274 | /* Cancel subscription timer (if used), then delete subscription */ |
| 300 | |||
| 301 | if (sub->timeout != TIPC_WAIT_FOREVER) { | 275 | if (sub->timeout != TIPC_WAIT_FOREVER) { |
| 302 | sub->timeout = TIPC_WAIT_FOREVER; | 276 | sub->timeout = TIPC_WAIT_FOREVER; |
| 303 | spin_unlock_bh(subscriber->lock); | 277 | spin_unlock_bh(subscriber->lock); |
| @@ -313,7 +287,6 @@ static void subscr_cancel(struct tipc_subscr *s, | |||
| 313 | * | 287 | * |
| 314 | * Called with subscriber port locked. | 288 | * Called with subscriber port locked. |
| 315 | */ | 289 | */ |
| 316 | |||
| 317 | static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, | 290 | static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, |
| 318 | struct tipc_subscriber *subscriber) | 291 | struct tipc_subscriber *subscriber) |
| 319 | { | 292 | { |
| @@ -321,11 +294,9 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 321 | int swap; | 294 | int swap; |
| 322 | 295 | ||
| 323 | /* Determine subscriber's endianness */ | 296 | /* Determine subscriber's endianness */ |
| 324 | |||
| 325 | swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE)); | 297 | swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE)); |
| 326 | 298 | ||
| 327 | /* Detect & process a subscription cancellation request */ | 299 | /* Detect & process a subscription cancellation request */ |
| 328 | |||
| 329 | if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) { | 300 | if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) { |
| 330 | s->filter &= ~htohl(TIPC_SUB_CANCEL, swap); | 301 | s->filter &= ~htohl(TIPC_SUB_CANCEL, swap); |
| 331 | subscr_cancel(s, subscriber); | 302 | subscr_cancel(s, subscriber); |
| @@ -333,7 +304,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 333 | } | 304 | } |
| 334 | 305 | ||
| 335 | /* Refuse subscription if global limit exceeded */ | 306 | /* Refuse subscription if global limit exceeded */ |
| 336 | |||
| 337 | if (atomic_read(&topsrv.subscription_count) >= tipc_max_subscriptions) { | 307 | if (atomic_read(&topsrv.subscription_count) >= tipc_max_subscriptions) { |
| 338 | warn("Subscription rejected, subscription limit reached (%u)\n", | 308 | warn("Subscription rejected, subscription limit reached (%u)\n", |
| 339 | tipc_max_subscriptions); | 309 | tipc_max_subscriptions); |
| @@ -342,7 +312,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 342 | } | 312 | } |
| 343 | 313 | ||
| 344 | /* Allocate subscription object */ | 314 | /* Allocate subscription object */ |
| 345 | |||
| 346 | sub = kmalloc(sizeof(*sub), GFP_ATOMIC); | 315 | sub = kmalloc(sizeof(*sub), GFP_ATOMIC); |
| 347 | if (!sub) { | 316 | if (!sub) { |
| 348 | warn("Subscription rejected, no memory\n"); | 317 | warn("Subscription rejected, no memory\n"); |
| @@ -351,7 +320,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 351 | } | 320 | } |
| 352 | 321 | ||
| 353 | /* Initialize subscription object */ | 322 | /* Initialize subscription object */ |
| 354 | |||
| 355 | sub->seq.type = htohl(s->seq.type, swap); | 323 | sub->seq.type = htohl(s->seq.type, swap); |
| 356 | sub->seq.lower = htohl(s->seq.lower, swap); | 324 | sub->seq.lower = htohl(s->seq.lower, swap); |
| 357 | sub->seq.upper = htohl(s->seq.upper, swap); | 325 | sub->seq.upper = htohl(s->seq.upper, swap); |
| @@ -385,7 +353,6 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, | |||
| 385 | * | 353 | * |
| 386 | * Called with subscriber's server port unlocked. | 354 | * Called with subscriber's server port unlocked. |
| 387 | */ | 355 | */ |
| 388 | |||
| 389 | static void subscr_conn_shutdown_event(void *usr_handle, | 356 | static void subscr_conn_shutdown_event(void *usr_handle, |
| 390 | u32 port_ref, | 357 | u32 port_ref, |
| 391 | struct sk_buff **buf, | 358 | struct sk_buff **buf, |
| @@ -409,7 +376,6 @@ static void subscr_conn_shutdown_event(void *usr_handle, | |||
| 409 | * | 376 | * |
| 410 | * Called with subscriber's server port unlocked. | 377 | * Called with subscriber's server port unlocked. |
| 411 | */ | 378 | */ |
| 412 | |||
| 413 | static void subscr_conn_msg_event(void *usr_handle, | 379 | static void subscr_conn_msg_event(void *usr_handle, |
| 414 | u32 port_ref, | 380 | u32 port_ref, |
| 415 | struct sk_buff **buf, | 381 | struct sk_buff **buf, |
| @@ -424,7 +390,6 @@ static void subscr_conn_msg_event(void *usr_handle, | |||
| 424 | * Lock subscriber's server port (& make a local copy of lock pointer, | 390 | * Lock subscriber's server port (& make a local copy of lock pointer, |
| 425 | * in case subscriber is deleted while processing subscription request) | 391 | * in case subscriber is deleted while processing subscription request) |
| 426 | */ | 392 | */ |
| 427 | |||
| 428 | if (tipc_port_lock(port_ref) == NULL) | 393 | if (tipc_port_lock(port_ref) == NULL) |
| 429 | return; | 394 | return; |
| 430 | 395 | ||
| @@ -452,7 +417,6 @@ static void subscr_conn_msg_event(void *usr_handle, | |||
| 452 | * timeout code cannot delete the subscription, | 417 | * timeout code cannot delete the subscription, |
| 453 | * so the subscription object is still protected. | 418 | * so the subscription object is still protected. |
| 454 | */ | 419 | */ |
| 455 | |||
| 456 | tipc_nametbl_subscribe(sub); | 420 | tipc_nametbl_subscribe(sub); |
| 457 | } | 421 | } |
| 458 | } | 422 | } |
| @@ -461,7 +425,6 @@ static void subscr_conn_msg_event(void *usr_handle, | |||
| 461 | /** | 425 | /** |
| 462 | * subscr_named_msg_event - handle request to establish a new subscriber | 426 | * subscr_named_msg_event - handle request to establish a new subscriber |
| 463 | */ | 427 | */ |
| 464 | |||
| 465 | static void subscr_named_msg_event(void *usr_handle, | 428 | static void subscr_named_msg_event(void *usr_handle, |
| 466 | u32 port_ref, | 429 | u32 port_ref, |
| 467 | struct sk_buff **buf, | 430 | struct sk_buff **buf, |
| @@ -475,7 +438,6 @@ static void subscr_named_msg_event(void *usr_handle, | |||
| 475 | u32 server_port_ref; | 438 | u32 server_port_ref; |
| 476 | 439 | ||
| 477 | /* Create subscriber object */ | 440 | /* Create subscriber object */ |
| 478 | |||
| 479 | subscriber = kzalloc(sizeof(struct tipc_subscriber), GFP_ATOMIC); | 441 | subscriber = kzalloc(sizeof(struct tipc_subscriber), GFP_ATOMIC); |
| 480 | if (subscriber == NULL) { | 442 | if (subscriber == NULL) { |
| 481 | warn("Subscriber rejected, no memory\n"); | 443 | warn("Subscriber rejected, no memory\n"); |
| @@ -485,7 +447,6 @@ static void subscr_named_msg_event(void *usr_handle, | |||
| 485 | INIT_LIST_HEAD(&subscriber->subscriber_list); | 447 | INIT_LIST_HEAD(&subscriber->subscriber_list); |
| 486 | 448 | ||
| 487 | /* Create server port & establish connection to subscriber */ | 449 | /* Create server port & establish connection to subscriber */ |
| 488 | |||
| 489 | tipc_createport(subscriber, | 450 | tipc_createport(subscriber, |
| 490 | importance, | 451 | importance, |
| 491 | NULL, | 452 | NULL, |
| @@ -504,26 +465,21 @@ static void subscr_named_msg_event(void *usr_handle, | |||
| 504 | tipc_connect2port(subscriber->port_ref, orig); | 465 | tipc_connect2port(subscriber->port_ref, orig); |
| 505 | 466 | ||
| 506 | /* Lock server port (& save lock address for future use) */ | 467 | /* Lock server port (& save lock address for future use) */ |
| 507 | |||
| 508 | subscriber->lock = tipc_port_lock(subscriber->port_ref)->lock; | 468 | subscriber->lock = tipc_port_lock(subscriber->port_ref)->lock; |
| 509 | 469 | ||
| 510 | /* Add subscriber to topology server's subscriber list */ | 470 | /* Add subscriber to topology server's subscriber list */ |
| 511 | |||
| 512 | spin_lock_bh(&topsrv.lock); | 471 | spin_lock_bh(&topsrv.lock); |
| 513 | list_add(&subscriber->subscriber_list, &topsrv.subscriber_list); | 472 | list_add(&subscriber->subscriber_list, &topsrv.subscriber_list); |
| 514 | spin_unlock_bh(&topsrv.lock); | 473 | spin_unlock_bh(&topsrv.lock); |
| 515 | 474 | ||
| 516 | /* Unlock server port */ | 475 | /* Unlock server port */ |
| 517 | |||
| 518 | server_port_ref = subscriber->port_ref; | 476 | server_port_ref = subscriber->port_ref; |
| 519 | spin_unlock_bh(subscriber->lock); | 477 | spin_unlock_bh(subscriber->lock); |
| 520 | 478 | ||
| 521 | /* Send an ACK- to complete connection handshaking */ | 479 | /* Send an ACK- to complete connection handshaking */ |
| 522 | |||
| 523 | tipc_send(server_port_ref, 0, NULL, 0); | 480 | tipc_send(server_port_ref, 0, NULL, 0); |
| 524 | 481 | ||
| 525 | /* Handle optional subscription request */ | 482 | /* Handle optional subscription request */ |
| 526 | |||
| 527 | if (size != 0) { | 483 | if (size != 0) { |
| 528 | subscr_conn_msg_event(subscriber, server_port_ref, | 484 | subscr_conn_msg_event(subscriber, server_port_ref, |
| 529 | buf, data, size); | 485 | buf, data, size); |
| @@ -535,7 +491,6 @@ int tipc_subscr_start(void) | |||
| 535 | struct tipc_name_seq seq = {TIPC_TOP_SRV, TIPC_TOP_SRV, TIPC_TOP_SRV}; | 491 | struct tipc_name_seq seq = {TIPC_TOP_SRV, TIPC_TOP_SRV, TIPC_TOP_SRV}; |
| 536 | int res; | 492 | int res; |
| 537 | 493 | ||
| 538 | memset(&topsrv, 0, sizeof(topsrv)); | ||
| 539 | spin_lock_init(&topsrv.lock); | 494 | spin_lock_init(&topsrv.lock); |
| 540 | INIT_LIST_HEAD(&topsrv.subscriber_list); | 495 | INIT_LIST_HEAD(&topsrv.subscriber_list); |
| 541 | 496 | ||
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h index ef6529c8456f..218d2e07f0cc 100644 --- a/net/tipc/subscr.h +++ b/net/tipc/subscr.h | |||
| @@ -51,7 +51,6 @@ struct tipc_subscription; | |||
| 51 | * @swap: indicates if subscriber uses opposite endianness in its messages | 51 | * @swap: indicates if subscriber uses opposite endianness in its messages |
| 52 | * @evt: template for events generated by subscription | 52 | * @evt: template for events generated by subscription |
| 53 | */ | 53 | */ |
| 54 | |||
| 55 | struct tipc_subscription { | 54 | struct tipc_subscription { |
| 56 | struct tipc_name_seq seq; | 55 | struct tipc_name_seq seq; |
| 57 | u32 timeout; | 56 | u32 timeout; |
| @@ -80,5 +79,4 @@ int tipc_subscr_start(void); | |||
| 80 | 79 | ||
| 81 | void tipc_subscr_stop(void); | 80 | void tipc_subscr_stop(void); |
| 82 | 81 | ||
| 83 | |||
| 84 | #endif | 82 | #endif |
