[Ocfs2-tools-devel] [PATCH 3/5] wireshark-ocfs2: add dlm_migratable_lockres handler v2
Sunil Mushran
sunil.mushran at oracle.com
Tue Aug 18 11:02:20 PDT 2009
Checked in.
Have not tested it as yet. But the patch looks good.
Jeff Liu wrote:
> this message is dissected like following,
>
> ocfs2:
> ....
> ..
> master: 3
> lockname length: 31
> lock num: 2
> migres flags: 0x06
> total locks: 2
> migres cookie: 0x0000000000000000
> lockname: o000000000000000017a00900000000
> lvb1: 303030303030303030313761303039303030303030303000
> lvb2: 000000000000000000000000000000000000000000000000
> lvb3: 00000000000000000000000000000000
> locks: 0, 0x0000000000000000, 0, 0x00, 0, 0, 0
> locks: 27, 0x0000000000000000, 0, 0x00, 0, 0, 0
>
> Signed-off-by: Jeff Liu <jeff.liu at oracle.com>
> ---
> epan/dissectors/packet-ocfs2.c | 156 ++++++++++++++++++++++++++++++++++++----
> 1 files changed, 142 insertions(+), 14 deletions(-)
>
> diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c
> index 1021799..a37e0b1 100644
> --- a/epan/dissectors/packet-ocfs2.c
> +++ b/epan/dissectors/packet-ocfs2.c
> @@ -118,7 +118,12 @@ static int hf_dlm_domain_name_len = -1;
> static int hf_dlm_domain_name = -1;
> static int hf_dlm_master = -1;
> static int hf_dlm_new_master = -1;
> -
> +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_lockname = -1;
> +static int hf_dlm_lockname_len = -1;
>
> #define TCP_PORT_OCFS2 7777
> #define O2NM_MAX_NAME_LEN 64
> @@ -999,12 +1004,6 @@ static struct dlm_msg_struct_def dlm_struct_defs[] = {
> }
> };
>
> -#if 0
> -
> -/*
> - * unimplemented cuz i forgot about these
> - */
> -
> struct dlm_migratable_lock
> {
> guint64 cookie;
> @@ -1055,7 +1054,9 @@ struct dlm_migratable_lock
> * So a lockres would need more than 240 locks before it would
> * use more than one network packet to recover. Not too bad.
> */
> -#define DLM_MAX_MIGRATABLE_LOCKS 240
> +#define DLM_LOCKID_NAME_MAX 32
> +#define DLM_MAX_MIGRATABLE_LOCKS 240
> +#define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct ocfs2_msg))
>
> struct dlm_migratable_lockres
> {
> @@ -1083,15 +1084,112 @@ struct dlm_migratable_lockres
> #define DLM_MIG_LOCKRES_RESERVED (NET_MAX_PAYLOAD_BYTES - \
> DLM_MIG_LOCKRES_MAX_LEN)
>
> +static void dissect_dlm_mig_lockres_msg(proto_tree *tree, tvbuff_t *tvb,
> + guint offset)
> +{
> + int miglock_size;
> + unsigned int i;
> + guint8 master, flags;
> + guint8 num_locks = 0;
> + guint32 total_locks;
> + guint64 mig_cookie;
>
> -#endif
> + /* master */
> + proto_tree_add_item(tree, hf_dlm_master, tvb, offset, 1, FALSE);
>
> + ++offset;
> + /* lockname_len */
> + proto_tree_add_item(tree, hf_dlm_lockname_len, tvb, offset, 1, FALSE);
>
> -#if 0
> -/* EEEEK still need to do these 3 */
> -static gint ett_dlm_migrate_lockres = -1;
> -#endif
> + ++offset;
> + /* move offset ptr to num_locks */
> + num_locks = tvb_get_guint8(tvb, offset);
> + proto_tree_add_item(tree, hf_dlm_mres_num_locks, tvb, offset, 1,
> + FALSE);
> + /* no locks were found on this lockres! done! */
> + if (num_locks == 0)
> + return ;
> +
> + /* flags */
> + ++offset;
> + proto_tree_add_item(tree, hf_dlm_mres_flags, tvb, offset, 1, FALSE);
>
> + /* total_locks */
> + ++offset;
> + proto_tree_add_item(tree, hf_dlm_mres_total_locks, tvb, offset, 4,
> + FALSE);
> +
> + /* mig_cookie */
> + offset += 4;
> + proto_tree_add_item(tree, hf_dlm_mres_mig_cookie, tvb, offset, 8,
> + FALSE);
> +
> + /* lockname */
> + offset += 8;
> + if (tvb_offset_exists(tvb, offset))
> + proto_tree_add_item(tree, hf_dlm_lockname, tvb, offset,
> + DLM_LOCKID_NAME_MAX, FALSE);
> +
> + /* lvb */
> + offset += DLM_LOCKID_NAME_MAX;
> + proto_tree_add_item(tree, hf_dlm_lvb1, tvb,
> + LVB1_OFFSET(struct dlm_migratable_lockres),
> + DLM_FIELD_BYTES_LEN, FALSE);
> + proto_tree_add_item(tree, hf_dlm_lvb2, tvb,
> + LVB2_OFFSET(struct dlm_migratable_lockres),
> + DLM_FIELD_BYTES_LEN, FALSE);
> + proto_tree_add_item(tree, hf_dlm_lvb3, tvb,
> + LVB3_OFFSET(struct dlm_migratable_lockres),
> + LVB_REMAIN_BYTES_LEN, FALSE);
> +
> + offset += DLM_LVB_LEN;
> + miglock_size = sizeof(struct dlm_migratable_lock);
> +
> + /* dlm_migratable_lock */
> + for (i = 0; i < num_locks; i++) {
> + proto_item *item;
> + guint64 cookie;
> + guint8 node, list, flags, type;
> + guint8 convert_type, highest_blocked;
> +
> + item = proto_tree_add_text(tree, tvb, offset, 5, "Locks: ");
> +
> + offset = (offsetof(struct dlm_migratable_lockres, ml) +
> + miglock_size * i);
> +
> + /* cookie */
> + cookie = tvb_get_ntoh64(tvb, offset);
> +
> + offset += 10;
> + /* list */
> + list = tvb_get_guint8(tvb, offset);
> +
> + ++offset;
> + /* flags */
> + flags = tvb_get_guint8(tvb, offset);
> +
> + ++offset;
> + /* type */
> + type = tvb_get_guint8(tvb, offset);
> +
> + ++offset;
> + /* convert_type */
> + convert_type = tvb_get_guint8(tvb, offset);
> +
> + ++offset;
> + /* highest_blocked */
> + highest_blocked = tvb_get_guint8(tvb, offset);
> +
> + ++offset;
> + /* node */
> + node = tvb_get_guint8(tvb, offset);
> +
> + proto_item_append_text(item,
> + "%u, 0x%016x, %u, 0x%02x, %u, %u, %u",
> + node, cookie, list, flags, type,
> + convert_type, highest_blocked);
> + }
> +}
>
> static int valid_magic(guint16 magic)
> {
> @@ -1338,13 +1436,21 @@ static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
> 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);
> + 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);
> +
> + if ((magic == O2NET_MSG_MAGIC) &&
> + (msg_type == DLM_MIG_LOCKRES_MSG))
> + dissect_dlm_mig_lockres_msg(subtree, tvb,
> + O2NET_MSG_HDR_OFF_PAYLOAD);
> +
> }
> out:
> return ret;
> @@ -1450,6 +1556,28 @@ void proto_register_ocfs2(void)
> { &hf_dlm_new_master, { "New Master", "ocfs2.dlm.new_master",
> FT_UINT8, BASE_DEC, NULL, 0x0,
> "New Master", HFILL } },
> + { &hf_dlm_mres_num_locks, { "Lock Num", "ocfs2.dlm.num_locks",
> + FT_UINT8, BASE_DEC, NULL, 0x0,
> + "Lock Num", HFILL } },
> + { &hf_dlm_mres_flags, { "Migres Flags", "ocfs2.dlm.mres_flags",
> + FT_UINT8, BASE_HEX, NULL, 0x0,
> + "Migres Flags", HFILL } },
> + { &hf_dlm_mres_total_locks, { "Total Locks",
> + "ocfs2.dlm.total_locks",
> + FT_UINT32, BASE_DEC, NULL, 0x0,
> + "Migres Total Locks", HFILL } },
> + { &hf_dlm_mres_mig_cookie, { "Migres Cookie",
> + "ocfs2.dlm.migratable_lock.mig_cookie",
> + FT_UINT64, BASE_HEX, NULL, 0x0,
> + "Migres Cookie", HFILL } },
> + { &hf_dlm_lockname, { "Lockname",
> + "ocfs2.dlm.migratable_lock.lockname",
> + FT_STRING, BASE_NONE, NULL, 0x0,
> + "Migres Lockname", HFILL } },
> + { &hf_dlm_lockname_len, { "Lockname Length",
> + "ocfs2.dlm.migratable_lock.lockname_len",
> + FT_UINT8, BASE_DEC, NULL, 0x0,
> + "Migres Lockname Length", HFILL } },
> };
> static gint *ett[] = {
> &ett_ocfs2,
>
More information about the Ocfs2-tools-devel
mailing list