[pnfs] wireshark

J. Bruce Fields bfields at fieldses.org
Tue Jun 3 16:37:26 EDT 2008


On Mon, May 26, 2008 at 09:13:20AM +0200, Tigran Mkrtchyan wrote:
> Subject: [PATCH 05/12] fixed layoutget reply decode according to draft >= 19
> 
> ---
>  epan/dissectors/packet-nfs.c |   88 +++++++++++++++++++++++++++++-------------
>  1 files changed, 61 insertions(+), 27 deletions(-)
> 
> diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c
> index 79a94c3..37f9512 100644
> --- a/epan/dissectors/packet-nfs.c
> +++ b/epan/dissectors/packet-nfs.c
> @@ -408,6 +408,8 @@ static int hf_nfs_layout_count = -1;
>  static int hf_nfs_pattern_offset = -1;
>  static int hf_nfs_notification_bitmap4 = -1;
>  static int hf_nfs_lrs_present = -1;
> +static int hf_nfs_nfl_util = -1;
> +static int hf_nfs_nfl_first_stripe_index = -1;
>  
>  /* Hidden field for v2, v3, and v4 status */
>  int hf_nfs_nfsstat = -1;
> @@ -565,6 +567,8 @@ static gint ett_nfs_uid4 = -1;
>  static gint ett_nfs_gid4 = -1;
>  static gint ett_nfs_service4 = -1;
>  static gint ett_nfs_sessionid4 = -1;
> +static gint ett_nfs_layoutseg = -1;
> +static gint ett_nfs_layoutseg_fh = -1;
>  
>  /* what type of fhandles shoudl we dissect as */
>  static dissector_table_t nfs_fhandle_table;
> @@ -7946,31 +7950,58 @@ static int
>  dissect_nfs_layout(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
>  {
>  	guint layout_type;
> +	guint fh_num;
> +	guint lo_seg_count;
> +	guint i, lo_seg;
> +	proto_item *fitem;
> +	proto_item *fh_fitem;
> +	proto_tree *newtree = NULL;
> +	proto_tree *fh_tree = NULL;
>  
> -	layout_type = tvb_get_ntohl(tvb, offset);
> -	offset = dissect_rpc_uint32(tvb, tree, hf_nfs_layouttype4, offset);
> +	lo_seg_count = tvb_get_ntohl(tvb, offset);
> +
> +	fitem = proto_tree_add_text(tree, tvb, offset, 4,
> +			"Layout Segment (count: %u)", lo_seg_count);
> +	offset += 4;
> +
> +	newtree = proto_item_add_subtree(fitem, ett_nfs_layoutseg);
> +
> +	for (lo_seg = 0; lo_seg < lo_seg_count; lo_seg++) {
> +		offset = dissect_rpc_uint64(tvb, newtree, hf_nfs_offset4, offset);
> +		offset = dissect_rpc_uint64(tvb, newtree, hf_nfs_length4, offset);
>  
> -	if (layout_type == 1) { /* NFS Files */
> -		guint num;
> -		guint i;
> +		offset = dissect_rpc_uint32(tvb, newtree, hf_nfs_iomode4, offset);
> +
> +		layout_type = tvb_get_ntohl(tvb, offset);
> +		offset = dissect_rpc_uint32(tvb, newtree, hf_nfs_layouttype4, offset);
> +
> +		/* If not files layout type eat the rest and move on.. */
> +		if (layout_type != 1) {
> +			offset = dissect_nfsdata(tvb, offset, newtree, hf_nfs_layout4);
> +			continue;
> +		}
> +
> +		/* NFS Files */
>  		offset += 4; /* Skip past opaque count */

It might be nice to at least display (and possibly sanity-check) this
length, say to help see implementation bugs.

--b.

> -		offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL,
> -						hf_nfs_deviceid4, TRUE, 16,
> -						FALSE, NULL, NULL);
>  
> -		offset = dissect_rpc_uint32(tvb, tree, hf_nfs_util4, offset);
> -		offset = dissect_rpc_uint32(tvb, tree, hf_nfs_first_stripe_idx4, offset);
> -		offset = dissect_rpc_uint64(tvb, tree, hf_nfs_pattern_offset, offset);
> +		offset = dissect_rpc_opaque_data(tvb, offset, newtree, NULL,
> +				hf_nfs_deviceid4, TRUE, 16, FALSE, NULL, NULL);
> +
> +		offset = dissect_rpc_uint32(tvb, newtree, hf_nfs_nfl_util, offset);
> +		offset = dissect_rpc_uint32(tvb, newtree, hf_nfs_nfl_first_stripe_index, offset);
> +		offset = dissect_rpc_uint64(tvb, newtree, hf_nfs_offset4, offset);
> +
> +		fh_num = tvb_get_ntohl(tvb, offset); /* Len of FH list */
>  
> -		num = tvb_get_ntohl(tvb, offset); /* Len of dev list */
> +		fh_fitem = proto_tree_add_text(newtree, tvb, offset, 4,
> +				"File Handles (count: %u)", fh_num);
>  		offset += 4;
> -		for (i = 0; i < num; i++) {
> -			offset = dissect_nfs_fh4(tvb, offset, pinfo, tree, "filehandle");
> +
> +		fh_tree = proto_item_add_subtree(fh_fitem, ett_nfs_layoutseg_fh);
> +		for (i = 0; i < fh_num; i++) {
> +			offset = dissect_nfs_fh4(tvb, offset, pinfo, fh_tree, "lo_filehandle");
>  		}
> -	} else {
> -		offset = dissect_nfsdata(tvb, offset, tree, hf_nfs_layout4);
>  	}
> -
>  	return offset;
>  }
>  
> @@ -8439,7 +8470,7 @@ static int
>  dissect_nfs_resop4(tvbuff_t *tvb, int offset, packet_info *pinfo,
>  	proto_tree *tree)
>  {
> -	guint32 ops, ops_counter, count;
> +	guint32 ops, ops_counter;
>  	guint32 opcode;
>  	proto_item *fitem;
>  	proto_tree *ftree = NULL;
> @@ -8652,14 +8683,7 @@ dissect_nfs_resop4(tvbuff_t *tvb, int offset, packet_info *pinfo,
>  			offset = dissect_rpc_bool(tvb, newftree, hf_nfs_return_on_close4,
>  									  offset);
>  			offset = dissect_nfs_stateid4(tvb, offset, newftree);
> -			count = tvb_get_ntohl(tvb, offset);
> -			offset = dissect_rpc_uint32(tvb, newftree, hf_nfs_layout_count, offset);
> -			while (count-- > 0) {
> -				offset = dissect_rpc_uint64(tvb, newftree, hf_nfs_offset4, offset);
> -				offset = dissect_rpc_uint64(tvb, newftree, hf_nfs_length4, offset);
> -				offset = dissect_rpc_uint32(tvb, newftree, hf_nfs_iomode4, offset);
> -				offset = dissect_nfs_layout(tvb, offset, pinfo, newftree);
> -			}
> +			offset = dissect_nfs_layout(tvb, offset, pinfo, newftree);
>  			break;
>  
>  		case NFS4_OP_LAYOUTCOMMIT:
> @@ -10148,6 +10172,14 @@ proto_register_nfs(void)
>  			"return on close?", "nfs.retclose4", FT_BOOLEAN, BASE_NONE,
>  			TFS(&tfs_yes_no), 0, NULL, HFILL }},
>  
> +		{ &hf_nfs_nfl_util, {
> +			"nfl_util", "nfs.nfl_util", FT_UINT32, BASE_HEX,
> +			NULL, 0, NULL, HFILL }},
> +
> +		{ &hf_nfs_nfl_first_stripe_index, {
> +			"first stripe to use index", "nfs.nfl_first_stripe_index", FT_UINT32, BASE_DEC,
> +			NULL, 0, NULL, HFILL }},
> +
>  		{ &hf_nfs_slotid4, {
>  			"slot ID", "nfs.slotid4", FT_UINT32, BASE_DEC,
>  			NULL, 0, NULL, HFILL }},
> @@ -10429,7 +10461,9 @@ proto_register_nfs(void)
>  		&ett_nfs_uid4,
>  		&ett_nfs_gid4,
>  		&ett_nfs_service4,
> -		&ett_nfs_sessionid4
> +		&ett_nfs_sessionid4,
> +		&ett_nfs_layoutseg,
> +		&ett_nfs_layoutseg_fh
>  	};
>  	module_t *nfs_module;
>  
> -- 
> 1.5.5.1.211.g65ea3
> 


More information about the pNFS mailing list