diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/Kconfig | 75 | ||||
-rw-r--r-- | net/tipc/bearer.c | 37 | ||||
-rw-r--r-- | net/tipc/bearer.h | 2 | ||||
-rw-r--r-- | net/tipc/cluster.c | 16 | ||||
-rw-r--r-- | net/tipc/core.c | 10 | ||||
-rw-r--r-- | net/tipc/core.h | 1 | ||||
-rw-r--r-- | net/tipc/eth_media.c | 1 | ||||
-rw-r--r-- | net/tipc/link.c | 21 | ||||
-rw-r--r-- | net/tipc/net.c | 25 | ||||
-rw-r--r-- | net/tipc/ref.c | 26 | ||||
-rw-r--r-- | net/tipc/socket.c | 28 | ||||
-rw-r--r-- | net/tipc/subscr.c | 63 | ||||
-rw-r--r-- | net/tipc/subscr.h | 2 |
13 files changed, 127 insertions, 180 deletions
diff --git a/net/tipc/Kconfig b/net/tipc/Kconfig index 3b30d1130b61..b74f78d0c033 100644 --- a/net/tipc/Kconfig +++ b/net/tipc/Kconfig | |||
@@ -10,7 +10,7 @@ menuconfig TIPC | |||
10 | specially designed for intra cluster communication. This protocol | 10 | specially designed for intra cluster communication. This protocol |
11 | originates from Ericsson where it has been used in carrier grade | 11 | originates from Ericsson where it has been used in carrier grade |
12 | cluster applications for many years. | 12 | cluster applications for many years. |
13 | 13 | ||
14 | For more information about TIPC, see http://tipc.sourceforge.net. | 14 | For more information about TIPC, see http://tipc.sourceforge.net. |
15 | 15 | ||
16 | This protocol support is also available as a module ( = code which | 16 | This protocol support is also available as a module ( = code which |
@@ -23,91 +23,76 @@ menuconfig TIPC | |||
23 | if TIPC | 23 | if TIPC |
24 | 24 | ||
25 | config TIPC_ADVANCED | 25 | config TIPC_ADVANCED |
26 | bool "TIPC: Advanced configuration" | 26 | bool "Advanced TIPC configuration" |
27 | default n | 27 | default n |
28 | help | 28 | help |
29 | Saying Y here will open some advanced configuration | 29 | Saying Y here will open some advanced configuration for TIPC. |
30 | for TIPC. Most users do not need to bother, so if | 30 | Most users do not need to bother; if unsure, just say N. |
31 | unsure, just say N. | ||
32 | 31 | ||
33 | config TIPC_ZONES | 32 | config TIPC_ZONES |
34 | int "Maximum number of zones in network" | 33 | int "Maximum number of zones in a network" |
35 | depends on TIPC_ADVANCED | 34 | depends on TIPC_ADVANCED |
35 | range 1 255 | ||
36 | default "3" | 36 | default "3" |
37 | help | 37 | help |
38 | Max number of zones inside TIPC network. Max supported value | 38 | Specifies how many zones can be supported in a TIPC network. |
39 | is 255 zones, minimum is 1 | 39 | Can range from 1 to 255 zones; default is 3. |
40 | 40 | ||
41 | Default is 3 zones in a network; setting this to higher | 41 | Setting this to a smaller value saves some memory; |
42 | allows more zones but might use more memory. | 42 | setting it to a higher value allows for more zones. |
43 | 43 | ||
44 | config TIPC_CLUSTERS | 44 | config TIPC_CLUSTERS |
45 | int "Maximum number of clusters in a zone" | 45 | int "Maximum number of clusters in a zone" |
46 | depends on TIPC_ADVANCED | 46 | depends on TIPC_ADVANCED |
47 | range 1 1 | ||
47 | default "1" | 48 | default "1" |
48 | help | 49 | help |
49 | ***Only 1 (one cluster in a zone) is supported by current code. | 50 | Specifies how many clusters can be supported in a TIPC zone. |
50 | Any value set here will be overridden.*** | ||
51 | |||
52 | (Max number of clusters inside TIPC zone. Max supported | ||
53 | value is 4095 clusters, minimum is 1. | ||
54 | 51 | ||
55 | Default is 1; setting this to smaller value might save | 52 | *** Currently TIPC only supports a single cluster per zone. *** |
56 | some memory, setting it to higher | ||
57 | allows more clusters and might consume more memory.) | ||
58 | 53 | ||
59 | config TIPC_NODES | 54 | config TIPC_NODES |
60 | int "Maximum number of nodes in cluster" | 55 | int "Maximum number of nodes in a cluster" |
61 | depends on TIPC_ADVANCED | 56 | depends on TIPC_ADVANCED |
57 | range 8 2047 | ||
62 | default "255" | 58 | default "255" |
63 | help | 59 | help |
64 | Maximum number of nodes inside a TIPC cluster. Maximum | 60 | Specifies how many nodes can be supported in a TIPC cluster. |
65 | supported value is 2047 nodes, minimum is 8. | 61 | Can range from 8 to 2047 nodes; default is 255. |
66 | |||
67 | Setting this to a smaller value saves some memory, | ||
68 | setting it to higher allows more nodes. | ||
69 | |||
70 | config TIPC_SLAVE_NODES | ||
71 | int "Maximum number of slave nodes in cluster" | ||
72 | depends on TIPC_ADVANCED | ||
73 | default "0" | ||
74 | help | ||
75 | ***This capability is not supported by current code.*** | ||
76 | |||
77 | Maximum number of slave nodes inside a TIPC cluster. Maximum | ||
78 | supported value is 2047 nodes, minimum is 0. | ||
79 | 62 | ||
80 | Setting this to a smaller value saves some memory, | 63 | Setting this to a smaller value saves some memory; |
81 | setting it to higher allows more nodes. | 64 | setting it to higher allows for more nodes. |
82 | 65 | ||
83 | config TIPC_PORTS | 66 | config TIPC_PORTS |
84 | int "Maximum number of ports in a node" | 67 | int "Maximum number of ports in a node" |
85 | depends on TIPC_ADVANCED | 68 | depends on TIPC_ADVANCED |
69 | range 127 65535 | ||
86 | default "8191" | 70 | default "8191" |
87 | help | 71 | help |
88 | Maximum number of ports within a node. Maximum | 72 | Specifies how many ports can be supported by a node. |
89 | supported value is 64535 nodes, minimum is 127. | 73 | Can range from 127 to 65535 ports; default is 8191. |
90 | 74 | ||
91 | Setting this to a smaller value saves some memory, | 75 | Setting this to a smaller value saves some memory, |
92 | setting it to higher allows more ports. | 76 | setting it to higher allows for more ports. |
93 | 77 | ||
94 | config TIPC_LOG | 78 | config TIPC_LOG |
95 | int "Size of log buffer" | 79 | int "Size of log buffer" |
96 | depends on TIPC_ADVANCED | 80 | depends on TIPC_ADVANCED |
97 | default 0 | 81 | range 0 32768 |
82 | default "0" | ||
98 | help | 83 | help |
99 | Size (in bytes) of TIPC's internal log buffer, which records the | 84 | Size (in bytes) of TIPC's internal log buffer, which records the |
100 | occurrence of significant events. Maximum supported value | 85 | occurrence of significant events. Can range from 0 to 32768 bytes; |
101 | is 32768 bytes, minimum is 0. | 86 | default is 0. |
102 | 87 | ||
103 | There is no need to enable the log buffer unless the node will be | 88 | There is no need to enable the log buffer unless the node will be |
104 | managed remotely via TIPC. | 89 | managed remotely via TIPC. |
105 | 90 | ||
106 | config TIPC_DEBUG | 91 | config TIPC_DEBUG |
107 | bool "Enable debugging support" | 92 | bool "Enable debug messages" |
108 | default n | 93 | default n |
109 | help | 94 | help |
110 | This will enable debugging of TIPC. | 95 | This enables debugging of TIPC. |
111 | 96 | ||
112 | Only say Y here if you are having trouble with TIPC. It will | 97 | Only say Y here if you are having trouble with TIPC. It will |
113 | enable the display of detailed information about what is going on. | 98 | enable the display of detailed information about what is going on. |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 327011fcc407..78091375ca12 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -45,10 +45,10 @@ | |||
45 | 45 | ||
46 | #define MAX_ADDR_STR 32 | 46 | #define MAX_ADDR_STR 32 |
47 | 47 | ||
48 | static struct media *media_list = NULL; | 48 | static struct media media_list[MAX_MEDIA]; |
49 | static u32 media_count = 0; | 49 | static u32 media_count = 0; |
50 | 50 | ||
51 | struct bearer *tipc_bearers = NULL; | 51 | struct bearer tipc_bearers[MAX_BEARERS]; |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * media_name_valid - validate media name | 54 | * media_name_valid - validate media name |
@@ -108,9 +108,11 @@ int tipc_register_media(u32 media_type, | |||
108 | int res = -EINVAL; | 108 | int res = -EINVAL; |
109 | 109 | ||
110 | write_lock_bh(&tipc_net_lock); | 110 | write_lock_bh(&tipc_net_lock); |
111 | if (!media_list) | ||
112 | goto exit; | ||
113 | 111 | ||
112 | if (tipc_mode != TIPC_NET_MODE) { | ||
113 | warn("Media <%s> rejected, not in networked mode yet\n", name); | ||
114 | goto exit; | ||
115 | } | ||
114 | if (!media_name_valid(name)) { | 116 | if (!media_name_valid(name)) { |
115 | warn("Media <%s> rejected, illegal name\n", name); | 117 | warn("Media <%s> rejected, illegal name\n", name); |
116 | goto exit; | 118 | goto exit; |
@@ -660,33 +662,10 @@ int tipc_disable_bearer(const char *name) | |||
660 | 662 | ||
661 | 663 | ||
662 | 664 | ||
663 | int tipc_bearer_init(void) | ||
664 | { | ||
665 | int res; | ||
666 | |||
667 | write_lock_bh(&tipc_net_lock); | ||
668 | tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC); | ||
669 | media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC); | ||
670 | if (tipc_bearers && media_list) { | ||
671 | res = 0; | ||
672 | } else { | ||
673 | kfree(tipc_bearers); | ||
674 | kfree(media_list); | ||
675 | tipc_bearers = NULL; | ||
676 | media_list = NULL; | ||
677 | res = -ENOMEM; | ||
678 | } | ||
679 | write_unlock_bh(&tipc_net_lock); | ||
680 | return res; | ||
681 | } | ||
682 | |||
683 | void tipc_bearer_stop(void) | 665 | void tipc_bearer_stop(void) |
684 | { | 666 | { |
685 | u32 i; | 667 | u32 i; |
686 | 668 | ||
687 | if (!tipc_bearers) | ||
688 | return; | ||
689 | |||
690 | for (i = 0; i < MAX_BEARERS; i++) { | 669 | for (i = 0; i < MAX_BEARERS; i++) { |
691 | if (tipc_bearers[i].active) | 670 | if (tipc_bearers[i].active) |
692 | tipc_bearers[i].publ.blocked = 1; | 671 | tipc_bearers[i].publ.blocked = 1; |
@@ -695,10 +674,6 @@ void tipc_bearer_stop(void) | |||
695 | if (tipc_bearers[i].active) | 674 | if (tipc_bearers[i].active) |
696 | bearer_disable(tipc_bearers[i].publ.name); | 675 | bearer_disable(tipc_bearers[i].publ.name); |
697 | } | 676 | } |
698 | kfree(tipc_bearers); | ||
699 | kfree(media_list); | ||
700 | tipc_bearers = NULL; | ||
701 | media_list = NULL; | ||
702 | media_count = 0; | 677 | media_count = 0; |
703 | } | 678 | } |
704 | 679 | ||
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index ca5734892713..000228e93f9e 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -114,7 +114,7 @@ struct bearer_name { | |||
114 | 114 | ||
115 | struct link; | 115 | struct link; |
116 | 116 | ||
117 | extern struct bearer *tipc_bearers; | 117 | extern struct bearer tipc_bearers[]; |
118 | 118 | ||
119 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); | 119 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); |
120 | struct sk_buff *tipc_media_get_names(void); | 120 | struct sk_buff *tipc_media_get_names(void); |
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index 689fdefe9d04..a7eac00cd363 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
@@ -437,11 +437,11 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
437 | break; | 437 | break; |
438 | case ROUTE_ADDITION: | 438 | case ROUTE_ADDITION: |
439 | if (!is_slave(tipc_own_addr)) { | 439 | if (!is_slave(tipc_own_addr)) { |
440 | assert(!in_own_cluster(c_ptr->addr) | 440 | assert(!in_own_cluster(c_ptr->addr) || |
441 | || is_slave(rem_node)); | 441 | is_slave(rem_node)); |
442 | } else { | 442 | } else { |
443 | assert(in_own_cluster(c_ptr->addr) | 443 | assert(in_own_cluster(c_ptr->addr) && |
444 | && !is_slave(rem_node)); | 444 | !is_slave(rem_node)); |
445 | } | 445 | } |
446 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; | 446 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; |
447 | if (!n_ptr) | 447 | if (!n_ptr) |
@@ -451,11 +451,11 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
451 | break; | 451 | break; |
452 | case ROUTE_REMOVAL: | 452 | case ROUTE_REMOVAL: |
453 | if (!is_slave(tipc_own_addr)) { | 453 | if (!is_slave(tipc_own_addr)) { |
454 | assert(!in_own_cluster(c_ptr->addr) | 454 | assert(!in_own_cluster(c_ptr->addr) || |
455 | || is_slave(rem_node)); | 455 | is_slave(rem_node)); |
456 | } else { | 456 | } else { |
457 | assert(in_own_cluster(c_ptr->addr) | 457 | assert(in_own_cluster(c_ptr->addr) && |
458 | && !is_slave(rem_node)); | 458 | !is_slave(rem_node)); |
459 | } | 459 | } |
460 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; | 460 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; |
461 | if (n_ptr) | 461 | if (n_ptr) |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 3256bd7d398f..52c571fedbe0 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
@@ -189,11 +189,11 @@ static int __init tipc_init(void) | |||
189 | tipc_remote_management = 1; | 189 | tipc_remote_management = 1; |
190 | tipc_max_publications = 10000; | 190 | tipc_max_publications = 10000; |
191 | tipc_max_subscriptions = 2000; | 191 | tipc_max_subscriptions = 2000; |
192 | tipc_max_ports = delimit(CONFIG_TIPC_PORTS, 127, 65536); | 192 | tipc_max_ports = CONFIG_TIPC_PORTS; |
193 | tipc_max_zones = delimit(CONFIG_TIPC_ZONES, 1, 255); | 193 | tipc_max_zones = CONFIG_TIPC_ZONES; |
194 | tipc_max_clusters = delimit(CONFIG_TIPC_CLUSTERS, 1, 1); | 194 | tipc_max_clusters = CONFIG_TIPC_CLUSTERS; |
195 | tipc_max_nodes = delimit(CONFIG_TIPC_NODES, 8, 2047); | 195 | tipc_max_nodes = CONFIG_TIPC_NODES; |
196 | tipc_max_slaves = delimit(CONFIG_TIPC_SLAVE_NODES, 0, 2047); | 196 | tipc_max_slaves = CONFIG_TIPC_SLAVE_NODES; |
197 | tipc_net_id = 4711; | 197 | tipc_net_id = 4711; |
198 | 198 | ||
199 | if ((res = tipc_core_start())) | 199 | if ((res = tipc_core_start())) |
diff --git a/net/tipc/core.h b/net/tipc/core.h index a881f92a8537..c58a1d16563a 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/netdevice.h> | 56 | #include <linux/netdevice.h> |
57 | #include <linux/in.h> | 57 | #include <linux/in.h> |
58 | #include <linux/list.h> | 58 | #include <linux/list.h> |
59 | #include <linux/slab.h> | ||
59 | #include <linux/vmalloc.h> | 60 | #include <linux/vmalloc.h> |
60 | 61 | ||
61 | /* | 62 | /* |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 524ba5696d4d..6230d16020c4 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <net/tipc/tipc_bearer.h> | 38 | #include <net/tipc/tipc_bearer.h> |
39 | #include <net/tipc/tipc_msg.h> | 39 | #include <net/tipc/tipc_msg.h> |
40 | #include <linux/netdevice.h> | 40 | #include <linux/netdevice.h> |
41 | #include <linux/slab.h> | ||
41 | #include <net/net_namespace.h> | 42 | #include <net/net_namespace.h> |
42 | 43 | ||
43 | #define MAX_ETH_BEARERS 2 | 44 | #define MAX_ETH_BEARERS 2 |
diff --git a/net/tipc/link.c b/net/tipc/link.c index dd4c18b9a35b..1a7e4665af80 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -378,8 +378,8 @@ static void link_timeout(struct link *l_ptr) | |||
378 | struct tipc_msg *msg = buf_msg(l_ptr->first_out); | 378 | struct tipc_msg *msg = buf_msg(l_ptr->first_out); |
379 | u32 length = msg_size(msg); | 379 | u32 length = msg_size(msg); |
380 | 380 | ||
381 | if ((msg_user(msg) == MSG_FRAGMENTER) | 381 | if ((msg_user(msg) == MSG_FRAGMENTER) && |
382 | && (msg_type(msg) == FIRST_FRAGMENT)) { | 382 | (msg_type(msg) == FIRST_FRAGMENT)) { |
383 | length = msg_size(msg_get_wrapped(msg)); | 383 | length = msg_size(msg_get_wrapped(msg)); |
384 | } | 384 | } |
385 | if (length) { | 385 | if (length) { |
@@ -1882,6 +1882,15 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) | |||
1882 | (msg_destnode(msg) != tipc_own_addr))) | 1882 | (msg_destnode(msg) != tipc_own_addr))) |
1883 | goto cont; | 1883 | goto cont; |
1884 | 1884 | ||
1885 | /* Discard non-routeable messages destined for another node */ | ||
1886 | |||
1887 | if (unlikely(!msg_isdata(msg) && | ||
1888 | (msg_destnode(msg) != tipc_own_addr))) { | ||
1889 | if ((msg_user(msg) != CONN_MANAGER) && | ||
1890 | (msg_user(msg) != MSG_FRAGMENTER)) | ||
1891 | goto cont; | ||
1892 | } | ||
1893 | |||
1885 | /* Locate unicast link endpoint that should handle message */ | 1894 | /* Locate unicast link endpoint that should handle message */ |
1886 | 1895 | ||
1887 | n_ptr = tipc_node_find(msg_prevnode(msg)); | 1896 | n_ptr = tipc_node_find(msg_prevnode(msg)); |
@@ -2788,8 +2797,8 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
2788 | 2797 | ||
2789 | /* Is there an incomplete message waiting for this fragment? */ | 2798 | /* Is there an incomplete message waiting for this fragment? */ |
2790 | 2799 | ||
2791 | while (pbuf && ((msg_seqno(buf_msg(pbuf)) != long_msg_seq_no) | 2800 | while (pbuf && ((msg_seqno(buf_msg(pbuf)) != long_msg_seq_no) || |
2792 | || (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) { | 2801 | (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) { |
2793 | prev = pbuf; | 2802 | prev = pbuf; |
2794 | pbuf = pbuf->next; | 2803 | pbuf = pbuf->next; |
2795 | } | 2804 | } |
@@ -3325,8 +3334,8 @@ static void link_print(struct link *l_ptr, struct print_buf *buf, | |||
3325 | (l_ptr->last_out)), l_ptr->out_queue_size); | 3334 | (l_ptr->last_out)), l_ptr->out_queue_size); |
3326 | if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - | 3335 | if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - |
3327 | msg_seqno(buf_msg(l_ptr->first_out))) | 3336 | msg_seqno(buf_msg(l_ptr->first_out))) |
3328 | != (l_ptr->out_queue_size - 1)) | 3337 | != (l_ptr->out_queue_size - 1)) || |
3329 | || (l_ptr->last_out->next != NULL)) { | 3338 | (l_ptr->last_out->next != NULL)) { |
3330 | tipc_printf(buf, "\nSend queue inconsistency\n"); | 3339 | tipc_printf(buf, "\nSend queue inconsistency\n"); |
3331 | tipc_printf(buf, "first_out= %x ", l_ptr->first_out); | 3340 | tipc_printf(buf, "first_out= %x ", l_ptr->first_out); |
3332 | tipc_printf(buf, "next_out= %x ", l_ptr->next_out); | 3341 | tipc_printf(buf, "next_out= %x ", l_ptr->next_out); |
diff --git a/net/tipc/net.c b/net/tipc/net.c index 7906608bf510..f25b1cdb64eb 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -116,7 +116,8 @@ | |||
116 | */ | 116 | */ |
117 | 117 | ||
118 | DEFINE_RWLOCK(tipc_net_lock); | 118 | DEFINE_RWLOCK(tipc_net_lock); |
119 | struct network tipc_net = { NULL }; | 119 | struct _zone *tipc_zones[256] = { NULL, }; |
120 | struct network tipc_net = { tipc_zones }; | ||
120 | 121 | ||
121 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) | 122 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) |
122 | { | 123 | { |
@@ -158,28 +159,12 @@ void tipc_net_send_external_routes(u32 dest) | |||
158 | } | 159 | } |
159 | } | 160 | } |
160 | 161 | ||
161 | static int net_init(void) | ||
162 | { | ||
163 | memset(&tipc_net, 0, sizeof(tipc_net)); | ||
164 | tipc_net.zones = kcalloc(tipc_max_zones + 1, sizeof(struct _zone *), GFP_ATOMIC); | ||
165 | if (!tipc_net.zones) { | ||
166 | return -ENOMEM; | ||
167 | } | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static void net_stop(void) | 162 | static void net_stop(void) |
172 | { | 163 | { |
173 | u32 z_num; | 164 | u32 z_num; |
174 | 165 | ||
175 | if (!tipc_net.zones) | 166 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) |
176 | return; | ||
177 | |||
178 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) { | ||
179 | tipc_zone_delete(tipc_net.zones[z_num]); | 167 | tipc_zone_delete(tipc_net.zones[z_num]); |
180 | } | ||
181 | kfree(tipc_net.zones); | ||
182 | tipc_net.zones = NULL; | ||
183 | } | 168 | } |
184 | 169 | ||
185 | static void net_route_named_msg(struct sk_buff *buf) | 170 | static void net_route_named_msg(struct sk_buff *buf) |
@@ -282,9 +267,7 @@ int tipc_net_start(u32 addr) | |||
282 | tipc_named_reinit(); | 267 | tipc_named_reinit(); |
283 | tipc_port_reinit(); | 268 | tipc_port_reinit(); |
284 | 269 | ||
285 | if ((res = tipc_bearer_init()) || | 270 | if ((res = tipc_cltr_init()) || |
286 | (res = net_init()) || | ||
287 | (res = tipc_cltr_init()) || | ||
288 | (res = tipc_bclink_init())) { | 271 | (res = tipc_bclink_init())) { |
289 | return res; | 272 | return res; |
290 | } | 273 | } |
diff --git a/net/tipc/ref.c b/net/tipc/ref.c index 414fc34b8bea..8dea66500cf5 100644 --- a/net/tipc/ref.c +++ b/net/tipc/ref.c | |||
@@ -153,11 +153,11 @@ void tipc_ref_table_stop(void) | |||
153 | 153 | ||
154 | u32 tipc_ref_acquire(void *object, spinlock_t **lock) | 154 | u32 tipc_ref_acquire(void *object, spinlock_t **lock) |
155 | { | 155 | { |
156 | struct reference *entry; | ||
157 | u32 index; | 156 | u32 index; |
158 | u32 index_mask; | 157 | u32 index_mask; |
159 | u32 next_plus_upper; | 158 | u32 next_plus_upper; |
160 | u32 ref; | 159 | u32 ref; |
160 | struct reference *entry = NULL; | ||
161 | 161 | ||
162 | if (!object) { | 162 | if (!object) { |
163 | err("Attempt to acquire reference to non-existent object\n"); | 163 | err("Attempt to acquire reference to non-existent object\n"); |
@@ -175,30 +175,36 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) | |||
175 | index = tipc_ref_table.first_free; | 175 | index = tipc_ref_table.first_free; |
176 | entry = &(tipc_ref_table.entries[index]); | 176 | entry = &(tipc_ref_table.entries[index]); |
177 | index_mask = tipc_ref_table.index_mask; | 177 | index_mask = tipc_ref_table.index_mask; |
178 | /* take lock in case a previous user of entry still holds it */ | ||
179 | spin_lock_bh(&entry->lock); | ||
180 | next_plus_upper = entry->ref; | 178 | next_plus_upper = entry->ref; |
181 | tipc_ref_table.first_free = next_plus_upper & index_mask; | 179 | tipc_ref_table.first_free = next_plus_upper & index_mask; |
182 | ref = (next_plus_upper & ~index_mask) + index; | 180 | ref = (next_plus_upper & ~index_mask) + index; |
183 | entry->ref = ref; | ||
184 | entry->object = object; | ||
185 | *lock = &entry->lock; | ||
186 | } | 181 | } |
187 | else if (tipc_ref_table.init_point < tipc_ref_table.capacity) { | 182 | else if (tipc_ref_table.init_point < tipc_ref_table.capacity) { |
188 | index = tipc_ref_table.init_point++; | 183 | index = tipc_ref_table.init_point++; |
189 | entry = &(tipc_ref_table.entries[index]); | 184 | entry = &(tipc_ref_table.entries[index]); |
190 | spin_lock_init(&entry->lock); | 185 | spin_lock_init(&entry->lock); |
191 | spin_lock_bh(&entry->lock); | ||
192 | ref = tipc_ref_table.start_mask + index; | 186 | ref = tipc_ref_table.start_mask + index; |
193 | entry->ref = ref; | ||
194 | entry->object = object; | ||
195 | *lock = &entry->lock; | ||
196 | } | 187 | } |
197 | else { | 188 | else { |
198 | ref = 0; | 189 | ref = 0; |
199 | } | 190 | } |
200 | write_unlock_bh(&ref_table_lock); | 191 | write_unlock_bh(&ref_table_lock); |
201 | 192 | ||
193 | /* | ||
194 | * Grab the lock so no one else can modify this entry | ||
195 | * While we assign its ref value & object pointer | ||
196 | */ | ||
197 | if (entry) { | ||
198 | spin_lock_bh(&entry->lock); | ||
199 | entry->ref = ref; | ||
200 | entry->object = object; | ||
201 | *lock = &entry->lock; | ||
202 | /* | ||
203 | * keep it locked, the caller is responsible | ||
204 | * for unlocking this when they're done with it | ||
205 | */ | ||
206 | } | ||
207 | |||
202 | return ref; | 208 | return ref; |
203 | } | 209 | } |
204 | 210 | ||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e6d9abf7440e..cfb20b80b3a1 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -40,9 +40,9 @@ | |||
40 | #include <linux/socket.h> | 40 | #include <linux/socket.h> |
41 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
42 | #include <linux/mm.h> | 42 | #include <linux/mm.h> |
43 | #include <linux/slab.h> | ||
44 | #include <linux/poll.h> | 43 | #include <linux/poll.h> |
45 | #include <linux/fcntl.h> | 44 | #include <linux/fcntl.h> |
45 | #include <linux/gfp.h> | ||
46 | #include <asm/string.h> | 46 | #include <asm/string.h> |
47 | #include <asm/atomic.h> | 47 | #include <asm/atomic.h> |
48 | #include <net/sock.h> | 48 | #include <net/sock.h> |
@@ -177,6 +177,7 @@ static void reject_rx_queue(struct sock *sk) | |||
177 | * @net: network namespace (must be default network) | 177 | * @net: network namespace (must be default network) |
178 | * @sock: pre-allocated socket structure | 178 | * @sock: pre-allocated socket structure |
179 | * @protocol: protocol indicator (must be 0) | 179 | * @protocol: protocol indicator (must be 0) |
180 | * @kern: caused by kernel or by userspace? | ||
180 | * | 181 | * |
181 | * This routine creates additional data structures used by the TIPC socket, | 182 | * This routine creates additional data structures used by the TIPC socket, |
182 | * initializes them, and links them together. | 183 | * initializes them, and links them together. |
@@ -184,7 +185,8 @@ static void reject_rx_queue(struct sock *sk) | |||
184 | * Returns 0 on success, errno otherwise | 185 | * Returns 0 on success, errno otherwise |
185 | */ | 186 | */ |
186 | 187 | ||
187 | static int tipc_create(struct net *net, struct socket *sock, int protocol) | 188 | static int tipc_create(struct net *net, struct socket *sock, int protocol, |
189 | int kern) | ||
188 | { | 190 | { |
189 | const struct proto_ops *ops; | 191 | const struct proto_ops *ops; |
190 | socket_state state; | 192 | socket_state state; |
@@ -193,7 +195,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol) | |||
193 | 195 | ||
194 | /* Validate arguments */ | 196 | /* Validate arguments */ |
195 | 197 | ||
196 | if (net != &init_net) | 198 | if (!net_eq(net, &init_net)) |
197 | return -EAFNOSUPPORT; | 199 | return -EAFNOSUPPORT; |
198 | 200 | ||
199 | if (unlikely(protocol != 0)) | 201 | if (unlikely(protocol != 0)) |
@@ -1134,13 +1136,11 @@ restart: | |||
1134 | 1136 | ||
1135 | /* Loop around if more data is required */ | 1137 | /* Loop around if more data is required */ |
1136 | 1138 | ||
1137 | if ((sz_copied < buf_len) /* didn't get all requested data */ | 1139 | if ((sz_copied < buf_len) && /* didn't get all requested data */ |
1138 | && (!skb_queue_empty(&sk->sk_receive_queue) || | 1140 | (!skb_queue_empty(&sk->sk_receive_queue) || |
1139 | (flags & MSG_WAITALL)) | 1141 | (flags & MSG_WAITALL)) && /* and more is ready or required */ |
1140 | /* ... and more is ready or required */ | 1142 | (!(flags & MSG_PEEK)) && /* and aren't just peeking at data */ |
1141 | && (!(flags & MSG_PEEK)) /* ... and aren't just peeking at data */ | 1143 | (!err)) /* and haven't reached a FIN */ |
1142 | && (!err) /* ... and haven't reached a FIN */ | ||
1143 | ) | ||
1144 | goto restart; | 1144 | goto restart; |
1145 | 1145 | ||
1146 | exit: | 1146 | exit: |
@@ -1322,8 +1322,10 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) | |||
1322 | if (!sock_owned_by_user(sk)) { | 1322 | if (!sock_owned_by_user(sk)) { |
1323 | res = filter_rcv(sk, buf); | 1323 | res = filter_rcv(sk, buf); |
1324 | } else { | 1324 | } else { |
1325 | sk_add_backlog(sk, buf); | 1325 | if (sk_add_backlog(sk, buf)) |
1326 | res = TIPC_OK; | 1326 | res = TIPC_ERR_OVERLOAD; |
1327 | else | ||
1328 | res = TIPC_OK; | ||
1327 | } | 1329 | } |
1328 | bh_unlock_sock(sk); | 1330 | bh_unlock_sock(sk); |
1329 | 1331 | ||
@@ -1528,7 +1530,7 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) | |||
1528 | 1530 | ||
1529 | buf = skb_peek(&sk->sk_receive_queue); | 1531 | buf = skb_peek(&sk->sk_receive_queue); |
1530 | 1532 | ||
1531 | res = tipc_create(sock_net(sock->sk), new_sock, 0); | 1533 | res = tipc_create(sock_net(sock->sk), new_sock, 0, 0); |
1532 | if (!res) { | 1534 | if (!res) { |
1533 | struct sock *new_sk = new_sock->sk; | 1535 | struct sock *new_sk = new_sock->sk; |
1534 | struct tipc_sock *new_tsock = tipc_sk(new_sk); | 1536 | struct tipc_sock *new_tsock = tipc_sk(new_sk); |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 0747d8a9232f..ff123e56114a 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -76,19 +76,6 @@ struct top_srv { | |||
76 | static struct top_srv topsrv = { 0 }; | 76 | static struct top_srv topsrv = { 0 }; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * htohl - convert value to endianness used by destination | ||
80 | * @in: value to convert | ||
81 | * @swap: non-zero if endianness must be reversed | ||
82 | * | ||
83 | * Returns converted value | ||
84 | */ | ||
85 | |||
86 | static u32 htohl(u32 in, int swap) | ||
87 | { | ||
88 | return swap ? swab32(in) : in; | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * subscr_send_event - send a message containing a tipc_event to the subscriber | 79 | * subscr_send_event - send a message containing a tipc_event to the subscriber |
93 | * | 80 | * |
94 | * Note: Must not hold subscriber's server port lock, since tipc_send() will | 81 | * Note: Must not hold subscriber's server port lock, since tipc_send() will |
@@ -107,11 +94,11 @@ static void subscr_send_event(struct subscription *sub, | |||
107 | msg_sect.iov_base = (void *)&sub->evt; | 94 | msg_sect.iov_base = (void *)&sub->evt; |
108 | msg_sect.iov_len = sizeof(struct tipc_event); | 95 | msg_sect.iov_len = sizeof(struct tipc_event); |
109 | 96 | ||
110 | sub->evt.event = htohl(event, sub->swap); | 97 | sub->evt.event = htonl(event); |
111 | sub->evt.found_lower = htohl(found_lower, sub->swap); | 98 | sub->evt.found_lower = htonl(found_lower); |
112 | sub->evt.found_upper = htohl(found_upper, sub->swap); | 99 | sub->evt.found_upper = htonl(found_upper); |
113 | sub->evt.port.ref = htohl(port_ref, sub->swap); | 100 | sub->evt.port.ref = htonl(port_ref); |
114 | sub->evt.port.node = htohl(node, sub->swap); | 101 | sub->evt.port.node = htonl(node); |
115 | tipc_send(sub->server_ref, 1, &msg_sect); | 102 | tipc_send(sub->server_ref, 1, &msg_sect); |
116 | } | 103 | } |
117 | 104 | ||
@@ -287,16 +274,23 @@ static void subscr_cancel(struct tipc_subscr *s, | |||
287 | { | 274 | { |
288 | struct subscription *sub; | 275 | struct subscription *sub; |
289 | struct subscription *sub_temp; | 276 | struct subscription *sub_temp; |
277 | __u32 type, lower, upper; | ||
290 | int found = 0; | 278 | int found = 0; |
291 | 279 | ||
292 | /* Find first matching subscription, exit if not found */ | 280 | /* Find first matching subscription, exit if not found */ |
293 | 281 | ||
282 | type = ntohl(s->seq.type); | ||
283 | lower = ntohl(s->seq.lower); | ||
284 | upper = ntohl(s->seq.upper); | ||
285 | |||
294 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, | 286 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, |
295 | subscription_list) { | 287 | subscription_list) { |
296 | if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { | 288 | if ((type == sub->seq.type) && |
297 | found = 1; | 289 | (lower == sub->seq.lower) && |
298 | break; | 290 | (upper == sub->seq.upper)) { |
299 | } | 291 | found = 1; |
292 | break; | ||
293 | } | ||
300 | } | 294 | } |
301 | if (!found) | 295 | if (!found) |
302 | return; | 296 | return; |
@@ -325,16 +319,10 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s, | |||
325 | struct subscriber *subscriber) | 319 | struct subscriber *subscriber) |
326 | { | 320 | { |
327 | struct subscription *sub; | 321 | struct subscription *sub; |
328 | int swap; | ||
329 | |||
330 | /* Determine subscriber's endianness */ | ||
331 | |||
332 | swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE)); | ||
333 | 322 | ||
334 | /* Detect & process a subscription cancellation request */ | 323 | /* Detect & process a subscription cancellation request */ |
335 | 324 | ||
336 | if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) { | 325 | if (ntohl(s->filter) & TIPC_SUB_CANCEL) { |
337 | s->filter &= ~htohl(TIPC_SUB_CANCEL, swap); | ||
338 | subscr_cancel(s, subscriber); | 326 | subscr_cancel(s, subscriber); |
339 | return NULL; | 327 | return NULL; |
340 | } | 328 | } |
@@ -359,14 +347,14 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s, | |||
359 | 347 | ||
360 | /* Initialize subscription object */ | 348 | /* Initialize subscription object */ |
361 | 349 | ||
362 | sub->seq.type = htohl(s->seq.type, swap); | 350 | sub->seq.type = ntohl(s->seq.type); |
363 | sub->seq.lower = htohl(s->seq.lower, swap); | 351 | sub->seq.lower = ntohl(s->seq.lower); |
364 | sub->seq.upper = htohl(s->seq.upper, swap); | 352 | sub->seq.upper = ntohl(s->seq.upper); |
365 | sub->timeout = htohl(s->timeout, swap); | 353 | sub->timeout = ntohl(s->timeout); |
366 | sub->filter = htohl(s->filter, swap); | 354 | sub->filter = ntohl(s->filter); |
367 | if ((!(sub->filter & TIPC_SUB_PORTS) | 355 | if ((!(sub->filter & TIPC_SUB_PORTS) == |
368 | == !(sub->filter & TIPC_SUB_SERVICE)) | 356 | !(sub->filter & TIPC_SUB_SERVICE)) || |
369 | || (sub->seq.lower > sub->seq.upper)) { | 357 | (sub->seq.lower > sub->seq.upper)) { |
370 | warn("Subscription rejected, illegal request\n"); | 358 | warn("Subscription rejected, illegal request\n"); |
371 | kfree(sub); | 359 | kfree(sub); |
372 | subscr_terminate(subscriber); | 360 | subscr_terminate(subscriber); |
@@ -376,7 +364,6 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s, | |||
376 | INIT_LIST_HEAD(&sub->nameseq_list); | 364 | INIT_LIST_HEAD(&sub->nameseq_list); |
377 | list_add(&sub->subscription_list, &subscriber->subscription_list); | 365 | list_add(&sub->subscription_list, &subscriber->subscription_list); |
378 | sub->server_ref = subscriber->port_ref; | 366 | sub->server_ref = subscriber->port_ref; |
379 | sub->swap = swap; | ||
380 | memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr)); | 367 | memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr)); |
381 | atomic_inc(&topsrv.subscription_count); | 368 | atomic_inc(&topsrv.subscription_count); |
382 | if (sub->timeout != TIPC_WAIT_FOREVER) { | 369 | if (sub->timeout != TIPC_WAIT_FOREVER) { |
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h index 45d89bf4d202..c20f496d95b2 100644 --- a/net/tipc/subscr.h +++ b/net/tipc/subscr.h | |||
@@ -53,7 +53,6 @@ typedef void (*tipc_subscr_event) (struct subscription *sub, | |||
53 | * @nameseq_list: adjacent subscriptions in name sequence's subscription list | 53 | * @nameseq_list: adjacent subscriptions in name sequence's subscription list |
54 | * @subscription_list: adjacent subscriptions in subscriber's subscription list | 54 | * @subscription_list: adjacent subscriptions in subscriber's subscription list |
55 | * @server_ref: object reference of server port associated with subscription | 55 | * @server_ref: object reference of server port associated with subscription |
56 | * @swap: indicates if subscriber uses opposite endianness in its messages | ||
57 | * @evt: template for events generated by subscription | 56 | * @evt: template for events generated by subscription |
58 | */ | 57 | */ |
59 | 58 | ||
@@ -66,7 +65,6 @@ struct subscription { | |||
66 | struct list_head nameseq_list; | 65 | struct list_head nameseq_list; |
67 | struct list_head subscription_list; | 66 | struct list_head subscription_list; |
68 | u32 server_ref; | 67 | u32 server_ref; |
69 | int swap; | ||
70 | struct tipc_event evt; | 68 | struct tipc_event evt; |
71 | }; | 69 | }; |
72 | 70 | ||