aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2006-06-29 15:33:20 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-29 20:08:15 -0400
commitea13847b240e689e8f291355c36b46de9f44ddf9 (patch)
tree058a74fadfaf762587567ff59d87ae18db4c9d68 /net
parente49060c7cab6ca856d048e1e10d71c0e6fedf376 (diff)
[TIPC]: Improve response to requests for node/link information
Now allocates reply space for "get links" request based on number of actual links, not number of potential links. Also, limits reply to "get links" and "get nodes" requests to 32KB to match capabilities of tipc-config utility that issued request. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Per Liden <per.liden@ericsson.com>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/node.c26
-rw-r--r--net/tipc/zone.h4
2 files changed, 19 insertions, 11 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 861322b935da..fc6d09630ccd 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -2,7 +2,7 @@
2 * net/tipc/node.c: TIPC node management routines 2 * net/tipc/node.c: TIPC node management routines
3 * 3 *
4 * Copyright (c) 2000-2006, Ericsson AB 4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -592,6 +592,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
592 struct sk_buff *buf; 592 struct sk_buff *buf;
593 struct node *n_ptr; 593 struct node *n_ptr;
594 struct tipc_node_info node_info; 594 struct tipc_node_info node_info;
595 u32 payload_size;
595 596
596 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 597 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
597 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 598 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
@@ -608,8 +609,11 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
608 /* For now, get space for all other nodes 609 /* For now, get space for all other nodes
609 (will need to modify this when slave nodes are supported */ 610 (will need to modify this when slave nodes are supported */
610 611
611 buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(node_info)) * 612 payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1);
612 (tipc_max_nodes - 1)); 613 if (payload_size > 32768u)
614 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
615 " (too many nodes)");
616 buf = tipc_cfg_reply_alloc(payload_size);
613 if (!buf) 617 if (!buf)
614 return NULL; 618 return NULL;
615 619
@@ -633,6 +637,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
633 struct sk_buff *buf; 637 struct sk_buff *buf;
634 struct node *n_ptr; 638 struct node *n_ptr;
635 struct tipc_link_info link_info; 639 struct tipc_link_info link_info;
640 u32 payload_size;
636 641
637 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 642 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
638 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 643 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
@@ -645,12 +650,15 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
645 650
646 if (!tipc_nodes) 651 if (!tipc_nodes)
647 return tipc_cfg_reply_none(); 652 return tipc_cfg_reply_none();
648 653
649 /* For now, get space for 2 links to all other nodes + bcast link 654 /* Get space for all unicast links + multicast link */
650 (will need to modify this when slave nodes are supported */ 655
651 656 payload_size = TLV_SPACE(sizeof(link_info)) *
652 buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(link_info)) * 657 (tipc_net.zones[tipc_zone(tipc_own_addr)]->links + 1);
653 (2 * (tipc_max_nodes - 1) + 1)); 658 if (payload_size > 32768u)
659 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
660 " (too many links)");
661 buf = tipc_cfg_reply_alloc(payload_size);
654 if (!buf) 662 if (!buf)
655 return NULL; 663 return NULL;
656 664
diff --git a/net/tipc/zone.h b/net/tipc/zone.h
index 267999c5a240..5ab3d08602e2 100644
--- a/net/tipc/zone.h
+++ b/net/tipc/zone.h
@@ -2,7 +2,7 @@
2 * net/tipc/zone.h: Include file for TIPC zone management routines 2 * net/tipc/zone.h: Include file for TIPC zone management routines
3 * 3 *
4 * Copyright (c) 2000-2006, Ericsson AB 4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,7 @@
45 * struct _zone - TIPC zone structure 45 * struct _zone - TIPC zone structure
46 * @addr: network address of zone 46 * @addr: network address of zone
47 * @clusters: array of pointers to all clusters within zone 47 * @clusters: array of pointers to all clusters within zone
48 * @links: (used for inter-zone communication) 48 * @links: number of (unicast) links to zone
49 */ 49 */
50 50
51struct _zone { 51struct _zone {