[Ocfs2-tools-devel] [PATCH 1/2] wireshark-ocfs2: Add dlm_query_region_msg support to dissector V2.
Jie Liu
jeff.liu at oracle.com
Sat Dec 11 05:20:42 PST 2010
Dump dlm_query_region_msg as following:
Node: 92
Num Regions: 2
Domain Namelen: 32
Domain Name: CB637503B1A746DEB3D63656E16FA41B
Region1: 77D95EF51C0149D2823674FCC162CF8B
Region2: DCDA2845177F4D59A0F2DCD8DE507CC3
Signed-off-by: Jie Liu <jeff.liu at oracle.com>
---
epan/dissectors/packet-ocfs2.c | 116 +++++++++++++++++++++++++++++++++-------
1 files changed, 97 insertions(+), 19 deletions(-)
diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c
index 10ffa91..95c54b0 100644
--- a/epan/dissectors/packet-ocfs2.c
+++ b/epan/dissectors/packet-ocfs2.c
@@ -71,6 +71,7 @@ static gint ett_dlm_recovery_data_done = -1;
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 int proto_ocfs2 = -1;
static int hf_msg_magic = -1;
@@ -109,10 +110,14 @@ static int hf_dlm_mres_num_locks = -1;
static int hf_dlm_mres_flags = -1;
static int hf_dlm_mres_total_locks = -1;
static int hf_dlm_mres_mig_cookie = -1;
+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;
-#define TCP_PORT_OCFS2 7777
-#define O2NM_MAX_NAME_LEN 64
-#define O2NET_MSG_HDR_LEN (2+2+2+2+4+4+4+4)
+#define TCP_PORT_OCFS2 7777
+#define O2NM_MAX_NAME_LEN 64
+#define O2NET_MSG_HDR_LEN (2+2+2+2+4+4+4+4)
struct ocfs2_msg
{
@@ -142,8 +147,8 @@ struct ocfs2_msg
#define O2NET_MSG_MAGIC 0xfa55
#define O2NET_MSG_STATUS_MAGIC 0xfa56
-#define O2NET_MSG_KEEP_REQ_MAGIC 0xfa57
-#define O2NET_MSG_KEEP_RESP_MAGIC 0xfa58
+#define O2NET_MSG_KEEP_REQ_MAGIC 0xfa57
+#define O2NET_MSG_KEEP_RESP_MAGIC 0xfa58
static const value_string o2net_magic[] = {
{ O2NET_MSG_MAGIC, "Request" },
{ O2NET_MSG_STATUS_MAGIC, "Response" },
@@ -281,7 +286,8 @@ enum {
DLM_LOCK_REQUEST_MSG,
DLM_RECO_DATA_DONE_MSG,
DLM_BEGIN_RECO_MSG,
- DLM_FINALIZE_RECO_MSG
+ DLM_FINALIZE_RECO_MSG,
+ DLM_QUERY_REGION_MSG
};
static const value_string dlm_magic[] = {
{ OCFS2_MESSAGE_TYPE_VOTE, "FS Vote" },
@@ -305,6 +311,7 @@ static const value_string dlm_magic[] = {
{ DLM_RECO_DATA_DONE_MSG, "Recovery Data Done" },
{ DLM_BEGIN_RECO_MSG, "Begin Recovery" },
{ DLM_FINALIZE_RECO_MSG, "Finalize Recovery" },
+ { DLM_QUERY_REGION_MSG, "Query Region" },
{ 0x0000, NULL }
};
@@ -669,7 +676,6 @@ void dlm_namelen_handler(proto_tree *tree, tvbuff_t *tvb, guint offset, void *pr
proto_tree_add_item(tree, *fld->hf_index, tvb, offset + fld->offset, fld->len, FALSE);
p->valid = 1;
p->u.namelen = namelen;
-
}
void dlm_node_idx_handler(proto_tree *tree, tvbuff_t *tvb, guint offset, void *priv, struct dlm_msg_field_def *fld)
{
@@ -678,7 +684,6 @@ void dlm_node_idx_handler(proto_tree *tree, tvbuff_t *tvb, guint offset, void *p
proto_tree_add_item(tree, *fld->hf_index, tvb, offset + fld->offset, fld->len, FALSE);
}
-
/* DLM structures */
struct dlm_master_request
{
@@ -845,6 +850,18 @@ struct dlm_finalize_reco
guint32 pad2; // unused
};
+#define O2NM_MAX_REGIONS 32
+#define O2HB_MAX_REGION_NAME_LEN 32
+struct dlm_query_region
+{
+ guint8 qr_node;
+ guint8 qr_numregions;
+ guint8 qr_namelen;
+ guint8 pad1; // unused
+ guint8 qr_domain[O2NM_MAX_NAME_LEN];
+ guint8 qr_regions[O2HB_MAX_REGION_NAME_LEN * O2NM_MAX_REGIONS];
+};
+
#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])
@@ -909,7 +926,7 @@ static struct dlm_msg_struct_def dlm_struct_defs[] = {
{ "cookie", &hf_dlm_cookie, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,cookie), dlm_cookie_handler},
{ "flags", &hf_dlm_flags, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,flags), dlm_lkm_flags_handler},
{ "node_idx", &hf_dlm_node_idx, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,node_idx), dlm_node_idx_handler},
- { "type", &hf_dlm_ast_type, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,type), dlm_ast_type_handler},
+ { "type", &hf_dlm_ast_type, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,type), dlm_ast_type_handler},
{ "blocked_type",&hf_dlm_blocked_type, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,blocked_type), dlm_lockmode_handler},
{ "namelen", &hf_dlm_namelen, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,namelen), dlm_namelen_handler},
{ "name", &hf_dlm_name, FIELD_OFFSET_AND_SIZE(struct dlm_proxy_ast,name), dlm_name_handler},
@@ -1039,9 +1056,9 @@ static const value_string dlm_mres_flags[] = {
*
* struct _dlm_lockres_page
* {
- * dlm_migratable_lockres mres;
- * dlm_migratable_lock ml[DLM_MAX_MIGRATABLE_LOCKS];
- * guint8 pad[DLM_MIG_LOCKRES_RESERVED];
+ * dlm_migratable_lockres mres;
+ * dlm_migratable_lock ml[DLM_MAX_MIGRATABLE_LOCKS];
+ * guint8 pad[DLM_MIG_LOCKRES_RESERVED];
* };
*
* from ../cluster/tcp.h
@@ -1173,7 +1190,7 @@ static void dissect_dlm_mig_lockres_msg(proto_tree *tree, tvbuff_t *tvb,
else {
snprintf(unkliststr, sizeof(unkliststr), "%u", list);
liststr = unkliststr;
- }
+ }
++offset;
/* flags */
@@ -1219,7 +1236,7 @@ static int valid_magic(guint16 magic)
/*
* XXX:
- * - find_header could require min header len
+ * - find_header could require min header len
*/
/* returns -ve bytes needed, or +ve/0 as the offset of the header */
@@ -1364,6 +1381,41 @@ static void dissect_dlm_query_join_request(proto_tree *tree, tvbuff_t *tvb,
}
}
+static void dissect_dlm_query_region_msg(proto_tree *tree, tvbuff_t *tvb,
+ guint offset)
+{
+ unsigned int i;
+ proto_item *item;
+ guint8 num_regions;
+ guint8 region[O2HB_MAX_REGION_NAME_LEN + 1];
+
+ /* qr_node */
+ proto_tree_add_item(tree, hf_dlm_qr_node, tvb, offset, 1, FALSE);
+
+ ++offset;
+ /* qr_numregions */
+ num_regions = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(tree, hf_dlm_qr_numregions, tvb, offset, 1, FALSE);
+
+ ++offset;
+ /* qr_namelen */
+ proto_tree_add_item(tree, hf_dlm_qr_namelen, tvb, offset, 1, FALSE);
+
+ /* qr_domain */
+ offset += 2;
+ if (tvb_offset_exists(tvb, offset))
+ proto_tree_add_item(tree, hf_dlm_qr_domain, tvb,
+ offset, O2NM_MAX_NAME_LEN, FALSE);
+
+ offset += O2NM_MAX_NAME_LEN;
+ for (i = 0; i < num_regions; i++, offset += O2HB_MAX_REGION_NAME_LEN) {
+ item = proto_tree_add_text(tree, tvb, offset, 1, "Region%d: ", i + 1);
+ memset(region, 0, sizeof(region));
+ tvb_memcpy(tvb, region, offset, O2HB_MAX_REGION_NAME_LEN);
+ proto_item_append_text(item, "%s", region);
+ }
+}
+
static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *subtree = NULL;
@@ -1467,11 +1519,20 @@ 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);
+ break;
+ case DLM_QUERY_REGION_MSG:
+ dissect_dlm_query_region_msg(subtree, tvb,
+ O2NET_MSG_HDR_OFF_PAYLOAD);
+ break;
+ default:
+ break;
+ }
+ }
}
out:
return ret;
@@ -1588,6 +1649,22 @@ void proto_register_ocfs2(void)
"ocfs2.dlm.migratable_lock.mig_cookie",
FT_UINT64, BASE_DEC, NULL, 0x0,
"Migres Cookie", HFILL } },
+ { &hf_dlm_qr_node, { "Node",
+ "ocfs2.dlm.query_region.qr_node",
+ FT_UINT8, BASE_DEC, NULL, 0x0,
+ "Query Region Node", HFILL } },
+ { &hf_dlm_qr_numregions, { "Num Regions",
+ "ocfs2.dlm.query_region.qr_numregions",
+ FT_UINT8, BASE_DEC, NULL, 0x0,
+ "The number of regions to compare with", HFILL } },
+ { &hf_dlm_qr_namelen, { "Domain Namelen",
+ "ocfs2.dlm.query_region.qr_namelen",
+ FT_UINT8, BASE_DEC, NULL, 0x0,
+ "Query Namelen", HFILL } },
+ { &hf_dlm_qr_domain, { "Domain Name",
+ "ocfs2.dlm.query_region.qr_domain",
+ FT_STRING, BASE_NONE, NULL, 0x0,
+ "Query Domain Name", HFILL } },
};
static gint *ett[] = {
@@ -1610,6 +1687,7 @@ void proto_register_ocfs2(void)
&ett_dlm_recovery_data_done,
&ett_dlm_begin_recovery,
&ett_dlm_finalize_recovery,
+ &ett_dlm_query_region,
};
proto_ocfs2 = proto_register_protocol("OCFS2 Networking", "OCFS2",
--
1.5.4.3
More information about the Ocfs2-tools-devel
mailing list