[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4b267700-11f3-1193-4854-566715d0d65b@gmail.com>
Date: Wed, 16 May 2018 15:13:28 -0600
From: David Ahern <dsahern@...il.com>
To: Jon Maloy <jon.maloy@...csson.com>, stephen@...workplumber.org,
netdev@...r.kernel.org
Cc: mohan.krishna.ghanta.krishnamurthy@...csson.com,
tung.q.nguyen@...tech.com.au, hoang.h.le@...tech.com.au,
canh.d.luu@...tech.com.au, ying.xue@...driver.com,
tipc-discussion@...ts.sourceforge.net
Subject: Re: [iproute2-next v2 1/1] tipc: fixed node and name table listings
On 5/15/18 7:54 AM, Jon Maloy wrote:
> We make it easier for users to correlate between 128-bit node
> identities and 32-bit node hash number by extending the 'node list'
> command to also show the hash number.
>
> We also improve the 'nametable show' command to show the node identity
> instead of the node hash number. Since the former potentially is much
> longer than the latter, we make room for it by eliminating the (to the
> user) irrelevant publication key. We also reorder some of the columns so
> that the node id comes last, since this looks nicer and is more logical.
>
> ---
> v2: Fixed compiler warning as per comment from David Ahern
>
> Signed-off-by: Jon Maloy <jon.maloy@...csson.com>
> ---
> tipc/misc.c | 18 ++++++++++++++++++
> tipc/misc.h | 1 +
> tipc/nametable.c | 18 ++++++++++--------
> tipc/node.c | 19 ++++++++-----------
> tipc/peer.c | 4 ++++
> 5 files changed, 41 insertions(+), 19 deletions(-)
>
> diff --git a/tipc/misc.c b/tipc/misc.c
> index 16849f1..e8b726f 100644
> --- a/tipc/misc.c
> +++ b/tipc/misc.c
> @@ -13,6 +13,9 @@
> #include <stdint.h>
> #include <linux/tipc.h>
> #include <string.h>
> +#include <sys/ioctl.h>
> +#include <sys/socket.h>
> +#include <errno.h>
> #include "misc.h"
>
> #define IN_RANGE(val, low, high) ((val) <= (high) && (val) >= (low))
> @@ -109,3 +112,18 @@ void nodeid2str(uint8_t *id, char *str)
> for (i = 31; str[i] == '0'; i--)
> str[i] = 0;
> }
> +
> +void hash2nodestr(uint32_t hash, char *str)
> +{
> + struct tipc_sioc_nodeid_req nr = {};
> + int sd;
> +
> + sd = socket(AF_TIPC, SOCK_RDM, 0);
> + if (sd < 0) {
> + fprintf(stderr, "opening TIPC socket: %s\n", strerror(errno));
> + return;
> + }
> + nr.peer = hash;
> + if (!ioctl(sd, SIOCGETNODEID, &nr))
> + nodeid2str((uint8_t *)nr.node_id, str);
> +}
you are leaking sd
Powered by blists - more mailing lists