All of lore.kernel.org
 help / color / mirror / Atom feed
From: fanchaoting <fanchaoting@cn.fujitsu.com>
To: jaap.keuter-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org
Cc: Developer support list for Wireshark
	<wireshark-dev@wireshark.org>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	Wireshark-bugs@wireshark.org
Subject: Re: [PATCH] wireshark:decode GETDEVINFO error when using pnfs-block
Date: Wed, 13 Mar 2013 15:42:21 +0800	[thread overview]
Message-ID: <51402DDD.2020307@cn.fujitsu.com> (raw)
In-Reply-To: <513FE66C.8040205@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 7378 bytes --]

> Hi,
> 
> I think this has a good chance of getting merged, but it's preferred to have
> patches submitted as enhancement bugs through bugs.wireshark.org. In this way
> discussion on the bug stays grouped, won't get lost in the backlog of a mailing
> list, sample captures (do you have one?) can be harvested for tests, etc.
> 

thanks for telling me, here is the sample captures.

#######################################################################

now when using pnfs block, if recieve a GETDEVINFO packet, the wireshark
decode this packect error, because GETDEVINFO(block-layout) is Different from 
GETDEVINFO(file-layout). the wireshark now only can decode GETDEVINFO(file-layout).
but when recieve GETDEVINFO(block-layout), it decode error.

 Signed-off-by: fanchaoting<fanchaoting@cn.fujitsu.com>

---

diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c
index 77b6db5..35b5926 100644
--- a/epan/dissectors/packet-nfs.c
+++ b/epan/dissectors/packet-nfs.c
@@ -407,6 +407,15 @@ static int hf_nfs_op_mask = -1;
 /* NFSv4.1 */
 static int hf_nfs_length4_minlength = -1;
 static int hf_nfs_layouttype4 = -1;
+static int hf_nfs_block_volume_type4 = -1;
+static int hf_nfs_bld_offset = -1;
+static int hf_nfs_bld_sig = -1;
+static int hf_nfs_num_vols = -1;
+static int hf_nfs_bld_start = -1;
+static int hf_nfs_bld_length = -1;
+static int hf_nfs_bld_index = -1;
+static int hf_nfs_bld_chunk_size = -1;
+static int hf_nfs_bld_stripes = -1;
 static int hf_nfs_layoutreturn_type4 = -1;
 static int hf_nfs_iomode4 = -1;
 static int hf_nfs_stripetype4 = -1;
@@ -659,7 +668,7 @@ static gint ett_nfs_fh_ex = -1;
 static gint ett_nfs_layoutseg_fh = -1;
 static gint ett_nfs_reclaim_complete4 = -1;
 static gint ett_nfs_chan_attrs = -1;
-
+static gint ett_nfs_volume = -1;
 /* what type of fhandles should we dissect as */
 static dissector_table_t nfs_fhandle_table;
 
@@ -8777,22 +8786,80 @@ dissect_nfs_devices4(tvbuff_t *tvb, int offset, proto_tree *tree)
 	return offset;
 }
 
+static int
+dissect_nfs_block_volume4(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+	guint num_vols;
+	guint i, j;
+	guint block_volume_type;
+	guint bld_stripes;
+
+	/* disect block volume's count*/
+	num_vols = tvb_get_ntohl(tvb, offset);
+	offset = dissect_rpc_uint32(tvb, tree, hf_nfs_num_vols, offset);
+
+	for (i = 0; i < num_vols; i++) {
+		proto_tree *volume_tree = NULL;
+		proto_item *volume_item = NULL;
+
+		volume_item = proto_tree_add_text(tree, tvb, offset, 4, "volume(%d)", i);
+		volume_tree = proto_item_add_subtree(volume_item, ett_nfs_volume);
+
+		block_volume_type = tvb_get_ntohl(tvb, offset);
+		offset = dissect_rpc_uint32(tvb, volume_tree, hf_nfs_block_volume_type4, offset);
+
+		switch (block_volume_type) {
+		case BLOCK_VOLUME_SIMPLE:
+			offset += 4;
+			offset = dissect_rpc_uint64(tvb, volume_tree, hf_nfs_bld_offset, offset);
+			offset = dissect_rpc_string(tvb, volume_tree, hf_nfs_bld_sig, offset, NULL);
+			break;
+		case BLOCK_VOLUME_CONCAT:
+			break;
+		case BLOCK_VOLUME_SLICE:
+			offset = dissect_rpc_uint64(tvb, volume_tree, hf_nfs_bld_start, offset);
+			offset = dissect_rpc_uint64(tvb, volume_tree, hf_nfs_bld_length, offset);
+			offset = dissect_rpc_uint32(tvb, volume_tree, hf_nfs_bld_index, offset);
+			break;
+		case BLOCK_VOLUME_STRIPE:
+			offset = dissect_rpc_uint64(tvb, volume_tree, hf_nfs_bld_chunk_size, offset);
+			bld_stripes = tvb_get_ntohl(tvb, offset);
+			offset = dissect_rpc_uint32(tvb, volume_tree, hf_nfs_bld_stripes, offset);
+			for (j = 0; j < bld_stripes; j++)
+				offset = dissect_rpc_uint32(tvb, volume_tree, hf_nfs_bld_index, offset);
+			break;
+		default:
+			break;
+		}
+	}
+
+	return offset;
+}
 
 static int
-dissect_nfs_deviceaddr4(tvbuff_t *tvb, int offset, proto_tree *tree)
+dissect_nfs_layout_devinfo4(tvbuff_t *tvb, int offset, proto_tree *tree)
 {
+	guint layout_type;
 
 	/* layout type */
+	layout_type = tvb_get_ntohl(tvb, offset);
 	offset = dissect_rpc_uint32(tvb, tree, hf_nfs_layouttype4, offset);
 
 	/* skip da_addr_body size */
 	offset+=4;
 
+	if (layout_type == LAYOUT4_BLOCK_VOLUME) {
+		offset = dissect_nfs_block_volume4(tvb, offset, tree);
+		return offset;
+	}
+
 	offset = dissect_nfs_devices4(tvb, offset, tree);
+	offset = dissect_nfs_notification_bitmap4(tvb, tree, offset);
 
 	return offset;
 }
 
+
 static int
 dissect_nfs_devicelist4(tvbuff_t *tvb, int offset, proto_tree *tree)
 {
@@ -9981,8 +10048,7 @@ dissect_nfs_resop4(tvbuff_t *tvb, int offset, packet_info *pinfo,
 			break;
 
 		case NFS4_OP_GETDEVINFO:
-			offset = dissect_nfs_deviceaddr4(tvb, offset, newftree);
-			offset = dissect_nfs_notification_bitmap4(tvb, newftree, offset);
+			offset = dissect_nfs_layout_devinfo4(tvb, offset, newftree);
 			break;
 
 		case NFS4_OP_GETDEVLIST:
@@ -10280,6 +10346,15 @@ static const value_string layouttype_names[] = {
 	{ 0, NULL }
 };
 
+static const value_string blockvolumetype_names[] = {
+	{ 0, "BLOCK_VOLUME_SIMPLE"},
+	{ 1, "BLOCK_VOLUME_SLICE"},
+	{ 2, "BLOCK_VOLUME_CONCAT"},
+	{ 3, "BLOCK_VOLUME_STRIPE"},
+	{ 0, NULL }
+};
+
+
 static const value_string layoutreturn_names[] = {
 	{ 1, "RETURN_FILE"},
 	{ 2, "RETURN_FSID"},
@@ -11834,6 +11909,42 @@ proto_register_nfs(void)
 			"layout type", "nfs.layouttype", FT_UINT32, BASE_DEC,
 			VALS(layouttype_names), 0, NULL, HFILL }},
 
+		{ &hf_nfs_block_volume_type4, {
+			"block_volume_type", "nfs.block_volume_type", FT_UINT32, BASE_DEC,
+			VALS(blockvolumetype_names), 0, NULL, HFILL }},
+
+		{ &hf_nfs_bld_offset, {
+			"bld_offset", "nfs.bld_offset", FT_UINT64, BASE_DEC,
+			NULL, 0, NULL, HFILL }},
+
+		{ &hf_nfs_bld_sig, {
+			"bld_sig", "nfs.bld_sig", FT_STRING, BASE_NONE,
+			NULL, 0, NULL, HFILL }},
+		
+		{ &hf_nfs_num_vols, {
+			"num_vols", "nfs.num_vols", FT_UINT32, BASE_DEC,
+			NULL, 0, NULL, HFILL }},
+
+		{ &hf_nfs_bld_start, {
+			"bld_start", "nfs.bld_start", FT_UINT64, BASE_DEC,
+			NULL, 0, NULL, HFILL }},
+
+		{ &hf_nfs_bld_length, {
+			"bld_length", "nfs.bld_length", FT_UINT64, BASE_DEC,
+			NULL, 0, NULL, HFILL }},
+
+		{ &hf_nfs_bld_index, {
+			"bld_index", "nfs.bld_index", FT_UINT32, BASE_DEC,
+			NULL, 0, NULL, HFILL }},
+
+		{ &hf_nfs_bld_chunk_size, {
+			"bld_chunk_size", "nfs.bld_chunk_size", FT_UINT64, BASE_DEC,
+			NULL, 0, NULL, HFILL }},
+
+		{ &hf_nfs_bld_stripes, {
+			"bld_stripes", "nfs.bld_stripes", FT_UINT32, BASE_DEC,
+			NULL, 0, NULL, HFILL }},
+	
 		{ &hf_nfs_layoutreturn_type4, {
 			"return type", "nfs.returntype", FT_UINT32, BASE_DEC,
 			VALS(layoutreturn_names), 0, NULL, HFILL }},
@@ -12474,7 +12585,9 @@ proto_register_nfs(void)
 		&ett_nfs_cb_illegal,
 		&ett_nfs_chan_attrs,
 		&ett_create_session_flags,
+		&ett_nfs_volume,
 	};
+
 	module_t *nfs_module;
 
 	proto_nfs = proto_register_protocol("Network File System", "NFS", "nfs");
diff --git a/epan/dissectors/packet-nfs.h b/epan/dissectors/packet-nfs.h
index b14bfaa..a3e81e3 100644
--- a/epan/dissectors/packet-nfs.h
+++ b/epan/dissectors/packet-nfs.h
@@ -173,6 +173,12 @@
 #define LAYOUT4_OSD2_OBJECTS   2
 #define LAYOUT4_BLOCK_VOLUME   3
 
+/* pNFS block volume types */
+#define BLOCK_VOLUME_SIMPLE    0
+#define BLOCK_VOLUME_SLICE     1
+#define BLOCK_VOLUME_CONCAT    2
+#define BLOCK_VOLUME_STRIPE    3
+
 extern gboolean nfs_file_name_snooping;
 
 extern int dissect_fhandle(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,

----

[-- Attachment #2: pnfsmount.pcap --]
[-- Type: application/octet-stream, Size: 363592 bytes --]

[-- Attachment #3: Type: text/plain, Size: 344 bytes --]

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@wireshark.org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@wireshark.org?subject=unsubscribe

      parent reply	other threads:[~2013-03-13  7:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-13  2:33 [PATCH] wireshark:decode GETDEVINFO error when using pnfs-block fanchaoting
     [not found] ` <513FE66C.8040205@cn.fujitsu.com>
2013-03-13  7:42   ` fanchaoting [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51402DDD.2020307@cn.fujitsu.com \
    --to=fanchaoting@cn.fujitsu.com \
    --cc=Wireshark-bugs@wireshark.org \
    --cc=jaap.keuter-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=wireshark-dev@wireshark.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.