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