fanchaoting 写道:
>> 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<[email protected]>
> 
> ---
> 
> 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,
> 
> ----
> 
> 
> ------------------------------------------------------------------------
> 
> ___________________________________________________________________________
> Sent via:    Wireshark-dev mailing list <[email protected]>
> Archives:    http://www.wireshark.org/lists/wireshark-dev
> Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
>              mailto:[email protected]?subject=unsubscribe


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

Reply via email to