diff options
Diffstat (limited to 'net/tipc')
| -rw-r--r-- | net/tipc/bearer.c | 37 | ||||
| -rw-r--r-- | net/tipc/bearer.h | 2 | ||||
| -rw-r--r-- | net/tipc/link.c | 9 | ||||
| -rw-r--r-- | net/tipc/net.c | 25 | ||||
| -rw-r--r-- | net/tipc/socket.c | 6 | ||||
| -rw-r--r-- | net/tipc/subscr.c | 57 | ||||
| -rw-r--r-- | net/tipc/subscr.h | 2 | 
7 files changed, 46 insertions, 92 deletions
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/link.c b/net/tipc/link.c index 6f50f6423f63..1a7e4665af80 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c  | |||
| @@ -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)); | 
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/socket.c b/net/tipc/socket.c index 1ea64f09cc45..4b235fc1c70f 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c  | |||
| @@ -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 | ||
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index ac91f0dfa144..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,11 +347,11 @@ 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)) { | 
| @@ -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 | ||
