[Ocfs2-tools-devel] [PATCH 2/2] wireshark-ocfs2: Add dlm_query_nodeinfo message support to dissector.
Jie Liu
jeff.liu at oracle.com
Fri Dec 10 04:08:23 PST 2010
Example:
Magic: Request (0xfa55)
Len: 2108
Type: Query Node Info (520)
Sys Status: 0
Status: 0
Key: 0x666c6172
Num: 0
Payload1: 5C6420004342363337353033423141373436444542334436
Payload2: 333635364531364641343142000000000000000000000000
Payload3: 000000000000000000000000000000000000000001001E61
Payload4: 0AC4490102001E610AC4490203001E610AC4490304001E61
Payload5: 0AC4490405001E610AC4490506001E610AC4490607001E61
Payload6: 0AC4490708001E610AC4490809001E610AC449090A001E61
Node: 92
Num Nodes: 100
Domain Namelen: 32
Domain 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 | 112 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 107 insertions(+), 5 deletions(-)
diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c
index 07d760a..2847cf2 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;
@@ -115,6 +116,13 @@ 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_qr_regions = -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;
+static int hf_dlm_qn_ni_nodenum = -1;
+static int hf_dlm_qn_ni_ipv4_port = -1;
+static int hf_dlm_qn_ni_ipv4_address = -1;
#define TCP_PORT_OCFS2 7777
#define O2NM_MAX_NAME_LEN 64
@@ -288,7 +296,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" },
@@ -313,6 +322,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 }
};
@@ -870,6 +880,21 @@ struct dlm_query_region
guint8 qr_domain[O2NM_MAX_NAME_LEN];
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))
@@ -1244,6 +1269,58 @@ static void dissect_dlm_mig_lockres_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 valid_magic(guint16 magic)
{
return magic == O2NET_MSG_MAGIC ||
@@ -1502,10 +1579,18 @@ static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissect_dlm_query_join_request(subtree,
tvb, O2NET_MSG_HDR_OFF_PAYLOAD);
- if ((magic == O2NET_MSG_MAGIC) &&
- (msg_type == DLM_MIG_LOCKRES_MSG))
- dissect_dlm_mig_lockres_msg(subtree, tvb,
- O2NET_MSG_HDR_OFF_PAYLOAD);
+ if (magic == O2NET_MSG_MAGIC) {
+ switch (msg_type) {
+ case DLM_MIG_LOCKRES_MSG:
+ dissect_dlm_mig_lockres_msg(subtree, tvb,
+ O2NET_MSG_HDR_OFF_PAYLOAD);
+ case DLM_QUERY_NODEINFO_MSG:
+ dissect_dlm_query_nodeinfo_msg(subtree, tvb,
+ O2NET_MSG_HDR_OFF_PAYLOAD);
+ default:
+ break;
+ }
+ }
}
out:
return ret;
@@ -1642,6 +1727,22 @@ void proto_register_ocfs2(void)
"ocfs2.dlm.query_region.qr_regions",
FT_STRING, BASE_NONE, NULL, 0x0,
"Query Regions", 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[] = {
@@ -1665,6 +1766,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