[Ocfs2-tools-devel] [PATCH 1/5] wireshark-ocfs2: add dlm_query_join_request handler V3

Sunil Mushran sunil.mushran at oracle.com
Tue Aug 18 11:01:09 PDT 2009


Checked in.

This patch has a small bug requiring a trivial fix. It is printing Node 
Index/Domain
twice. You probably need to remove the entries for DLM_QUERY_JOIN_MSG in 
dlm_struct_defs.

    Magic: Request (0xfa55)
    Len: 104
    Type: Query Join (510)
    Sys Status: 0
    Status: 0
    Key: 0x666c6172
    Num: 0
    Payload1: 050000200100010039434430464639363646363234353833
    Payload2: 383744433038323736314633454344350000000000000000
    Payload3: 000000000000000000000000000000000000000000000000
    Payload4: 200000800301000000000000000000000000000000000000
    Payload5: 0000000000000000
    Node Index: 5
    Domain Namelen: 32
    Domain Name: 9CD0FF966F62458387DC082761F3ECD5
    Node Index: 5
    Namelen: 32
    DLM Protocol: 1.0
    FS Protocol: 1.0
    Domain Name: 9CD0FF966F62458387DC082761F3ECD5
    Node Map: 
0000010000000000000000000000000111000000100000000000000000000000
    Node Map: 
0000000000000000000000000000000000000000000000000000000000000000
    Node Map: 
0000000000000000000000000000000000000000000000000000000000000000
    Node Map: 
0000000000000000000000000000000000000000000000000000000000000000

Jeff Liu wrote:
> this patch dissect the dlm_query_join_request message as follows,
>
> Magic: Request (0xfa55)
>     ...
>     ..
>     DLM Protocol: 1.0
>     FS Protocol: 1.0
>     Domain Name: A898D073F6244E9EBEB057B4F47EF61A
>     Node Map: 0000001100000000000000000000000000000000000000000000000000000000
>     Node Map: 0000000000000000000000000000000000000000000000000000000000000000
>     Node Map: 0000000000000000000000000000000000000000000000000000000000000000
>     Node Map: 0000000000000000000000000000000000000000000000000000000000000000
>
> Signed-off-by: Jeff Liu <jeff.liu at oracle.com>
> ---
>  epan/dissectors/packet-ocfs2.c |  104 ++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 101 insertions(+), 3 deletions(-)
>
> diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c
> index ce57c3f..cc8749c 100644
> --- a/epan/dissectors/packet-ocfs2.c
> +++ b/epan/dissectors/packet-ocfs2.c
> @@ -776,13 +776,36 @@ struct dlm_master_requery {
>  	guint32 pad3;
>  	guint8 name[O2NM_MAX_NAME_LEN];
>  };
> -struct dlm_query_join_request
> -{
> +
> +#define O2NM_MAX_NODES 255
> +#define BITS_PER_BYTE 8
> +#define BITS_TO_BYTES(bits) (((bits)+BITS_PER_BYTE-1)/BITS_PER_BYTE)
> +
> +/* dlm_query_join_request for ocfs2-1.2.x */
> +struct dlm_query_join_request_129 {
>  	guint8 node_idx;
>  	guint8 pad1[2];	// unused
>  	guint8 name_len;
>  	guint8 domain[O2NM_MAX_NAME_LEN];
> +	guint8 node_map[BITS_TO_BYTES(O2NM_MAX_NODES)];
>  };
> +
> +struct dlm_protocol_version {
> +	guint8 pv_major;
> +	guint8 pv_minor;
> +};
> +
> +/* the latest msg layout */
> +struct dlm_query_join_request {
> +	guint8 node_idx;
> +	guint8 pad1[2];
> +	guint8 name_len;
> +	struct dlm_protocol_version dlm_proto;
> +	struct dlm_protocol_version fs_proto;
> +	guint8 domain[O2NM_MAX_NAME_LEN];
> +	guint8 node_map[BITS_TO_BYTES(O2NM_MAX_NODES)];
> +};
> +
>  struct dlm_assert_joined
>  {
>  	guint8 node_idx;
> @@ -1148,6 +1171,77 @@ static void msg_struct_enumerate_fields(struct dlm_msg_struct_def *def, proto_tr
>  	}
>  }
>  
> +static void dissect_dlm_query_join_request(proto_tree *tree, tvbuff_t *tvb,
> +					   int offset)
> +{
> +	proto_item *item;
> +	guint8 cc, namelen;
> +	guint8 node_bits_array[256];
> +	guint8 node_map[BITS_TO_BYTES(O2NM_MAX_NODES)];
> +	guint16 dlm_proto, fs_proto;
> +	gint len;
> +	char line[128];
> +	int i, j;
> +
> +	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, FALSE);
> +
> +	/* skip follow 2 padding bytes */
> +	offset += 3;
> +	namelen = tvb_get_guint8(tvb, offset);
> +	proto_tree_add_item(tree, hf_dlm_namelen, tvb, offset, 1, FALSE);
> +
> +	++offset;
> +	len = tvb_reported_length_remaining(tvb, offset);
> +
> +	/* if the left message length more than namelen + node_map length,
> +	 * its most likely ocfs2-1.4 or newer message comming,
> +	 * or else ocfs2-1.2 if equal to */
> +	if (len == (sizeof(struct dlm_protocol_version) * 2 +
> +		    O2NM_MAX_NAME_LEN +
> +		    BITS_TO_BYTES(O2NM_MAX_NODES))) {
> +		dlm_proto = tvb_get_ntohs(tvb, offset);
> +		proto_tree_add_text(tree, tvb, offset, 2,
> +				"DLM Protocol: %d.%d",
> +				((dlm_proto >> 8) & 0xff),
> +				(dlm_proto & 0xff));
> +
> +		offset += 2;
> +		fs_proto = tvb_get_ntohs(tvb, offset);
> +		proto_tree_add_text(tree, tvb, offset, 2,
> +				"FS Protocol: %d.%d",
> +				((fs_proto >> 8) & 0xff),
> +				(fs_proto & 0xff));
> +
> +		offset += 2;
> +		proto_tree_add_item(tree, hf_dlm_domain_name, tvb,
> +				    offset, namelen, FALSE);
> +	} else if (len == (O2NM_MAX_NAME_LEN + BITS_TO_BYTES(O2NM_MAX_NODES)))
> +		proto_tree_add_item(tree, hf_dlm_domain_name, tvb,
> +				    offset, namelen, FALSE);
> +
> +	offset += O2NM_MAX_NAME_LEN;
> +	tvb_memcpy(tvb, node_map, offset, sizeof(node_map));
> +
> +	memset(node_bits_array, 0, sizeof(node_bits_array));
> +	for (i = 0; i < sizeof(node_map); i++) {
> +		cc = node_map[i];
> +		for (j = 0; j < 8; j++)
> +			node_bits_array[i * 8 + j] = (((cc >> j) & 1) ?
> +							'1' : '0');
> +	}
> +
> +	i = 0;
> +	while (i < 256) {
> +		memset(line, 0, sizeof(line));
> +		/* print node map in binary char, 64 chars for each line */
> +		for (j = 0; j < 64; )
> +			line[j++] = node_bits_array[i++];
> +
> +		item = proto_tree_add_text(tree, tvb, offset, 10, "Node Map: ");
> +		proto_item_append_text(item, "%s", line);
> +	}
> +}
> +
>  static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
>  {
>  	proto_tree *subtree = NULL;
> @@ -1240,13 +1334,17 @@ static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
>  			}
>  		}
>  
> -
>  		if (magic == O2NET_MSG_MAGIC) {
>  			struct dlm_msg_struct_def *def;
>  			def = msg_struct_lookup_by_type(msg_type);
>  			if (def)
>  				msg_struct_enumerate_fields(def, subtree, tvb, O2NET_MSG_HDR_OFF_PAYLOAD);
>  		}
> +
> +		if (msg_type == DLM_QUERY_JOIN_MSG)
> +			if (magic == O2NET_MSG_MAGIC)
> +				dissect_dlm_query_join_request(subtree,
> +					tvb, O2NET_MSG_HDR_OFF_PAYLOAD);
>  	}
>  out:
>  	return ret;
>   




More information about the Ocfs2-tools-devel mailing list