[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>

authored by Allan Stephens and committed by David S. Miller ea13847b e49060c7

+18 -10
+16 -8
net/tipc/node.c
··· 2 * net/tipc/node.c: TIPC node management routines 3 * 4 * Copyright (c) 2000-2006, Ericsson AB 5 - * Copyright (c) 2005, Wind River Systems 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without ··· 592 struct sk_buff *buf; 593 struct node *n_ptr; 594 struct tipc_node_info node_info; 595 596 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 597 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); ··· 609 /* For now, get space for all other nodes 610 (will need to modify this when slave nodes are supported */ 611 612 - buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(node_info)) * 613 - (tipc_max_nodes - 1)); 614 if (!buf) 615 return NULL; 616 ··· 637 struct sk_buff *buf; 638 struct node *n_ptr; 639 struct tipc_link_info link_info; 640 641 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 642 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); ··· 650 651 if (!tipc_nodes) 652 return tipc_cfg_reply_none(); 653 654 - /* For now, get space for 2 links to all other nodes + bcast link 655 - (will need to modify this when slave nodes are supported */ 656 - 657 - buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(link_info)) * 658 - (2 * (tipc_max_nodes - 1) + 1)); 659 if (!buf) 660 return NULL; 661
··· 2 * net/tipc/node.c: TIPC node management routines 3 * 4 * Copyright (c) 2000-2006, Ericsson AB 5 + * Copyright (c) 2005-2006, Wind River Systems 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without ··· 592 struct sk_buff *buf; 593 struct node *n_ptr; 594 struct tipc_node_info node_info; 595 + u32 payload_size; 596 597 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 598 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); ··· 608 /* For now, get space for all other nodes 609 (will need to modify this when slave nodes are supported */ 610 611 + payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1); 612 + if (payload_size > 32768u) 613 + return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED 614 + " (too many nodes)"); 615 + buf = tipc_cfg_reply_alloc(payload_size); 616 if (!buf) 617 return NULL; 618 ··· 633 struct sk_buff *buf; 634 struct node *n_ptr; 635 struct tipc_link_info link_info; 636 + u32 payload_size; 637 638 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 639 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); ··· 645 646 if (!tipc_nodes) 647 return tipc_cfg_reply_none(); 648 + 649 + /* Get space for all unicast links + multicast link */ 650 651 + payload_size = TLV_SPACE(sizeof(link_info)) * 652 + (tipc_net.zones[tipc_zone(tipc_own_addr)]->links + 1); 653 + if (payload_size > 32768u) 654 + return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED 655 + " (too many links)"); 656 + buf = tipc_cfg_reply_alloc(payload_size); 657 if (!buf) 658 return NULL; 659
+2 -2
net/tipc/zone.h
··· 2 * net/tipc/zone.h: Include file for TIPC zone management routines 3 * 4 * Copyright (c) 2000-2006, Ericsson AB 5 - * Copyright (c) 2005, Wind River Systems 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without ··· 45 * struct _zone - TIPC zone structure 46 * @addr: network address of zone 47 * @clusters: array of pointers to all clusters within zone 48 - * @links: (used for inter-zone communication) 49 */ 50 51 struct _zone {
··· 2 * net/tipc/zone.h: Include file for TIPC zone management routines 3 * 4 * Copyright (c) 2000-2006, Ericsson AB 5 + * Copyright (c) 2005-2006, Wind River Systems 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without ··· 45 * struct _zone - TIPC zone structure 46 * @addr: network address of zone 47 * @clusters: array of pointers to all clusters within zone 48 + * @links: number of (unicast) links to zone 49 */ 50 51 struct _zone {