[TIPC]: Improve response to requests for node/link information
authorAllan Stephens <allan.stephens@windriver.com>
Thu, 29 Jun 2006 19:33:20 +0000 (12:33 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 30 Jun 2006 00:08:15 +0000 (17:08 -0700)
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>
net/tipc/node.c
net/tipc/zone.h

index 861322b..fc6d096 100644 (file)
@@ -2,7 +2,7 @@
  * net/tipc/node.c: TIPC node management routines
  * 
  * Copyright (c) 2000-2006, Ericsson AB
  * net/tipc/node.c: TIPC node management routines
  * 
  * Copyright (c) 2000-2006, Ericsson AB
- * Copyright (c) 2005, Wind River Systems
+ * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * All rights reserved.
  *
  * 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)
        struct sk_buff *buf;
        struct node *n_ptr;
         struct tipc_node_info node_info;
        struct sk_buff *buf;
        struct node *n_ptr;
         struct tipc_node_info node_info;
+       u32 payload_size;
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
                return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
                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)
        /* For now, get space for all other nodes 
           (will need to modify this when slave nodes are supported */
 
        /* For now, get space for all other nodes 
           (will need to modify this when slave nodes are supported */
 
-       buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(node_info)) *
-                                  (tipc_max_nodes - 1));
+       payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1);
+       if (payload_size > 32768u)
+               return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
+                                                  " (too many nodes)");
+       buf = tipc_cfg_reply_alloc(payload_size);
        if (!buf)
                return NULL;
 
        if (!buf)
                return NULL;
 
@@ -633,6 +637,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
        struct sk_buff *buf;
        struct node *n_ptr;
         struct tipc_link_info link_info;
        struct sk_buff *buf;
        struct node *n_ptr;
         struct tipc_link_info link_info;
+       u32 payload_size;
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
                return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
                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)
 
         if (!tipc_nodes)
                 return tipc_cfg_reply_none();
 
         if (!tipc_nodes)
                 return tipc_cfg_reply_none();
-
-       /* For now, get space for 2 links to all other nodes + bcast link 
-          (will need to modify this when slave nodes are supported */
-
-       buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(link_info)) *
-                                  (2 * (tipc_max_nodes - 1) + 1));
+       
+       /* Get space for all unicast links + multicast link */
+
+       payload_size = TLV_SPACE(sizeof(link_info)) *
+               (tipc_net.zones[tipc_zone(tipc_own_addr)]->links + 1);
+       if (payload_size > 32768u)
+               return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
+                                                  " (too many links)");
+       buf = tipc_cfg_reply_alloc(payload_size);
        if (!buf)
                return NULL;
 
        if (!buf)
                return NULL;
 
index 267999c..5ab3d08 100644 (file)
@@ -2,7 +2,7 @@
  * net/tipc/zone.h: Include file for TIPC zone management routines
  * 
  * Copyright (c) 2000-2006, Ericsson AB
  * net/tipc/zone.h: Include file for TIPC zone management routines
  * 
  * Copyright (c) 2000-2006, Ericsson AB
- * Copyright (c) 2005, Wind River Systems
+ * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,7 @@
  * struct _zone - TIPC zone structure
  * @addr: network address of zone
  * @clusters: array of pointers to all clusters within zone
  * struct _zone - TIPC zone structure
  * @addr: network address of zone
  * @clusters: array of pointers to all clusters within zone
- * @links: (used for inter-zone communication)
+ * @links: number of (unicast) links to zone
  */
  
 struct _zone {
  */
  
 struct _zone {