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

jeff.liu jeff.liu at oracle.com
Fri Aug 14 20:00:44 PDT 2009


Hi Sunil,

the patch-series will include the dlm_query_join_reponse fix as well, 
please check them.

Thanks,
Jeff

Sunil Mushran 写道:
> Jeff,
>
> Please can you resend me the four patches as a patch-series.
> I am getting merge conflicts.
>
> Thanks
> Sunil
>
> 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 | 106 
>> ++++++++++++++++++++++++++++++++++++++-
>> 1 files changed, 103 insertions(+), 3 deletions(-)
>>
>> diff --git a/epan/dissectors/packet-ocfs2.c 
>> b/epan/dissectors/packet-ocfs2.c
>> index ce57c3f..1523e22 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,79 @@ 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[65];
>> + 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));
>> + /* line[65], the valid buf size is 64, the latest char
>> + * is used to cut off the string
>> + */
>> + for (j = 0; j < (sizeof(line) - 1); j++)
>> + 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 +1336,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