[Ocfs2-tools-devel] [PATCH 2/2] wireshark-ocfs2: Add dlm_query_nodeinfo_msg support to dissector.

Jie Liu jeff.liu at oracle.com
Sat Dec 11 05:20:43 PST 2010


Add dlm_query_nodeinfo_msg support to dissector, dump it as following:

Node: 92
Num Nodes: 100
Domain Namelen: 32
omain Name: CB637503B1A746DEB3D63656E16FA41B
Node1: 10.196.73.1:7777
Node2: 10.196.73.2:7777
Node3: 10.196.73.3:7777
...
..
Node100: 10.196.73.100:7777

Signed-off-by: Jie Liu <jeff.liu at oracle.com>
---
 epan/dissectors/packet-ocfs2.c |   98 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 97 insertions(+), 1 deletions(-)

diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c
index 95c54b0..226e71d 100644
--- a/epan/dissectors/packet-ocfs2.c
+++ b/epan/dissectors/packet-ocfs2.c
@@ -72,6 +72,7 @@ static gint ett_dlm_begin_recovery = -1;
 static gint ett_dlm_finalize_recovery = -1;
 static gint ett_dlm_deref_lockres = -1;
 static gint ett_dlm_query_region = -1;
+static gint ett_dlm_query_nodeinfo = -1;
 
 static int proto_ocfs2 = -1;
 static int hf_msg_magic = -1;
@@ -114,6 +115,10 @@ static int hf_dlm_qr_node = -1;
 static int hf_dlm_qr_numregions = -1;
 static int hf_dlm_qr_namelen = -1;
 static int hf_dlm_qr_domain = -1;
+static int hf_dlm_qn_nodenum = -1;
+static int hf_dlm_qn_numnodes = -1;
+static int hf_dlm_qn_namelen = -1;
+static int hf_dlm_qn_domain = -1;
 
 #define TCP_PORT_OCFS2		7777
 #define O2NM_MAX_NAME_LEN	64
@@ -287,7 +292,8 @@ enum {
 	DLM_RECO_DATA_DONE_MSG,
 	DLM_BEGIN_RECO_MSG,
 	DLM_FINALIZE_RECO_MSG,
-	DLM_QUERY_REGION_MSG
+	DLM_QUERY_REGION_MSG,
+	DLM_QUERY_NODEINFO_MSG
 };
 static const value_string dlm_magic[] = {
 	{ OCFS2_MESSAGE_TYPE_VOTE, "FS Vote" },
@@ -312,6 +318,7 @@ static const value_string dlm_magic[] = {
 	{ DLM_BEGIN_RECO_MSG,     "Begin Recovery" },
 	{ DLM_FINALIZE_RECO_MSG,  "Finalize Recovery" },
 	{ DLM_QUERY_REGION_MSG,   "Query Region" },
+	{ DLM_QUERY_NODEINFO_MSG, "Query Node Info" },
 	{ 0x0000, NULL }
 };
 
@@ -862,6 +869,23 @@ struct dlm_query_region
 	guint8 qr_regions[O2HB_MAX_REGION_NAME_LEN * O2NM_MAX_REGIONS];
 };
 
+struct dlm_node_info {
+	guint8 ni_nodenum;
+	guint8 pad1;
+	guint16 ni_ipv4_port;
+	guint32 ni_ipv4_address;
+};
+
+struct dlm_query_nodeinfo
+{
+	guint8 qn_nodenum;
+	guint8 qn_numnodes;
+	guint8 qn_namelen;
+	guint8 pad1;
+	guint8 qn_domain[O2NM_MAX_NAME_LEN];
+	struct dlm_node_info qn_nodes[O2NM_MAX_NODES];
+};
+
 #define DLM_FIELD_BYTES_LEN	24
 #define LVB_REMAIN_BYTES_LEN	(DLM_LVB_LEN - (DLM_FIELD_BYTES_LEN << 1))
 #define LVB1_OFFSET(x)		offsetof(x, lvb[0])
@@ -1416,6 +1440,58 @@ static void dissect_dlm_query_region_msg(proto_tree *tree, tvbuff_t *tvb,
 	}
 }
 
+static void dissect_dlm_query_nodeinfo_msg(proto_tree *tree, tvbuff_t *tvb,
+					   guint offset)
+{
+	unsigned int i;
+	guint8 num_nodes = 0;
+
+	/* query node number */
+	proto_tree_add_item(tree, hf_dlm_qn_nodenum, tvb, offset, 1, FALSE);
+
+	++offset;
+	/* the number of nodes to query */
+	num_nodes = tvb_get_guint8(tvb, offset);
+	proto_tree_add_item(tree, hf_dlm_qn_numnodes, tvb, offset, 1, FALSE);
+
+	++offset;
+	/* query node name length */
+	proto_tree_add_item(tree, hf_dlm_qn_namelen, tvb, offset, 1, FALSE);
+
+	/* skip pad1, process qn_domain now */
+	offset += 2;
+	if (tvb_offset_exists(tvb, offset))
+		proto_tree_add_item(tree, hf_dlm_domain_name, tvb, offset,
+				    O2NM_MAX_NAME_LEN, FALSE);
+
+	offset += O2NM_MAX_NAME_LEN;
+
+	/* process dlm_node_info one by one */
+	for (i = 0; i < num_nodes; i++) {
+		proto_item *item;
+		guint8 node_num;
+		guint16 port;
+		guint32 ipv4_addr;
+
+		/* actually, the corresponding node num is identical to 'i' */
+		node_num = tvb_get_guint8(tvb, offset);
+		item = proto_tree_add_text(tree, tvb, offset, 1, "Node%d: ", node_num);
+
+		/* skip ni_nodenum and pad1 to handle ni_ipv4_port */
+		offset += 2;
+		port = tvb_get_ntohs(tvb, offset);
+
+		/* ni_ipv4_address */
+		offset += 2;
+		ipv4_addr = tvb_get_ipv4(tvb, offset);
+		proto_item_append_text(item, "%s:%u", ip_to_str((guint8 *)&ipv4_addr),
+				       port);
+
+		/* loop again */
+		offset += 4;
+	}
+}
+
 static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
 	proto_tree *subtree = NULL;
@@ -1529,6 +1605,9 @@ static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 				dissect_dlm_query_region_msg(subtree, tvb,
 							     O2NET_MSG_HDR_OFF_PAYLOAD);
 				break;
+			case DLM_QUERY_NODEINFO_MSG:
+				dissect_dlm_query_nodeinfo_msg(subtree, tvb,
+							       O2NET_MSG_HDR_OFF_PAYLOAD);
 			default:
 				break;
 			}
@@ -1665,6 +1744,22 @@ void proto_register_ocfs2(void)
 				"ocfs2.dlm.query_region.qr_domain",
 				FT_STRING, BASE_NONE, NULL, 0x0,
 				"Query Domain Name", HFILL } },
+		{ &hf_dlm_qn_nodenum, { "Node",
+				"ocfs2.dlm_query_nodeinfo.qn_nodenum",
+				FT_UINT8, BASE_DEC, NULL, 0x0,
+				"Query Node", HFILL }},
+		{ &hf_dlm_qn_numnodes, { "Num Nodes",
+				"ocfs2.dlm_query_nodeinfo.qn_numnodes",
+				FT_UINT8, BASE_DEC, NULL, 0x0,
+				"The number of nodes to query", HFILL }},
+		{ &hf_dlm_qn_namelen, { "Domain Namelen",
+				"ocfs2.dlm_query_nodeinfo.qn_namelen",
+				FT_UINT8, BASE_DEC, NULL, 0x0,
+				"Query Namelen", HFILL }},
+		{ &hf_dlm_qn_domain, { "Domain Name",
+				"ocfs2.dlm_query_nodeinfo.qn_domain",
+				FT_UINT8, BASE_DEC, NULL, 0x0,
+				"Query Domain Name", HFILL }},
 	};
 
 	static gint *ett[] = {
@@ -1688,6 +1783,7 @@ void proto_register_ocfs2(void)
 		&ett_dlm_begin_recovery,
 		&ett_dlm_finalize_recovery,
 		&ett_dlm_query_region,
+		&ett_dlm_query_nodeinfo
 	};
 
 	proto_ocfs2 = proto_register_protocol("OCFS2 Networking", "OCFS2",
-- 
1.5.4.3




More information about the Ocfs2-tools-devel mailing list