FC: use ETHERTYPE_UNK when applicable, no excuses

Two interlocking problems cause the dissection of FC to fail in some cases,
as shown in the capture of the related issue.

The FC dissector assumes that ETHERTYPE_UNK in the data structure passed
to it is coming from the MDS header dissector only, and thus that header
sizes have to be taken into account. This is not / no longer the case.
It always passes down ETHERTYPE_FCFT. Therefore the MDS header size
checking does not apply to ETHERTYP_UNK, so is removed as condition.

The other FC related dissectors were forced to setup a data structure to
pass to FC for it to handle that part of the frame. Because these weren't
related to ethernet, these lazily set the ethertype field in the data
structure to 0. This unfortunately matches ETHERTYPE_UNK, triggering the
MDS header size checking in FC, leading to this issue. With the first
problem resolved, now make it explicit that unknown ethertype is indicated
by ETHERTYPE_UNK, not '0'.

Addresses primary part of issue #17084


(cherry picked from commit 3f0fc1b232)
This commit is contained in:
Jaap Keuter 2020-12-15 18:14:32 +00:00 committed by Guy Harris
parent e228784c4e
commit 564ec58f6d
10 changed files with 8 additions and 12 deletions

View File

@ -12,7 +12,6 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/etypes.h>
#include <epan/proto_data.h>
#include "packet-fc.h"

View File

@ -357,7 +357,7 @@ dissect_cpfi(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *
dissect_cpfi_header(header_tvb, pinfo, cpfi_tree);
body_tvb = tvb_new_subset_length_caplen(message_tvb, 8, body_length, reported_body_length);
fc_data.ethertype = 0;
fc_data.ethertype = ETHERTYPE_UNK;
call_dissector_with_data(fc_handle, body_tvb, pinfo, tree, &fc_data);
/* add more info, now that FC added its */

View File

@ -20,7 +20,6 @@
#include <wiretap/wtap.h>
#include <epan/reassemble.h>
#include <epan/conversation_table.h>
#include <epan/etypes.h>
#include <epan/srt_table.h>
#include "packet-fc.h"
#include "packet-fclctl.h"
@ -1007,7 +1006,7 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
* and are never fragmented and so we ignore the frag_size assertion for
* these frames.
*/
if ((fc_data->ethertype == ETHERTYPE_UNK) || (fc_data->ethertype == ETHERTYPE_FCFT)) {
if (fc_data->ethertype == ETHERTYPE_FCFT) {
if ((frag_size < MDSHDR_TRAILER_SIZE) ||
((frag_size == MDSHDR_TRAILER_SIZE) && (ftype != FC_FTYPE_LINKCTL) &&
(ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS))) {
@ -1284,7 +1283,7 @@ dissect_fcsof(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
next_tvb = tvb_new_subset_length(tvb, 4, crc_offset-4);
fc_data.ethertype = 0;
fc_data.ethertype = ETHERTYPE_UNK;
fc_data.sof_eof = 0;
if (sof == FC_SOFI2 || sof == FC_SOFI3) {
fc_data.sof_eof = FC_DATA_SOF_FIRST_FRAME;

View File

@ -13,6 +13,7 @@
#define __PACKET_FC_H_
#include <epan/conversation.h>
#include <epan/etypes.h>
#include "ws_symbol_export.h"
/* R_CTL upper bits creates a classification tree */

View File

@ -477,7 +477,7 @@ dissect_fcip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Special frame bit is not set */
next_tvb = tvb_new_subset_remaining (tvb, FCIP_ENCAP_HEADER_LEN+4);
if (fc_handle) {
fc_data.ethertype = 0;
fc_data.ethertype = ETHERTYPE_UNK;
call_dissector_with_data(fc_handle, next_tvb, pinfo, tree, &fc_data);
}
else {

View File

@ -21,7 +21,6 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/crc32-tvb.h>
#include <epan/etypes.h>
#include <epan/expert.h>
#include "packet-fc.h"
@ -277,7 +276,7 @@ dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
}
/* Call the FC Dissector if this is carrying an FC frame */
fc_data.ethertype = 0;
fc_data.ethertype = ETHERTYPE_UNK;
if (fc_handle) {
call_dissector_with_data(fc_handle, next_tvb, pinfo, tree, &fc_data);

View File

@ -216,7 +216,7 @@ dissect_fcoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
}
/* Call the FC Dissector if this is carrying an FC frame */
fc_data.ethertype = 0;
fc_data.ethertype = ETHERTYPE_UNK;
if (fc_handle) {
call_dissector_with_data(fc_handle, next_tvb, pinfo, tree, &fc_data);

View File

@ -24,7 +24,6 @@
#include <epan/packet.h>
#include <epan/to_str.h>
#include <epan/etypes.h>
#include <epan/expert.h>
#include "packet-fc.h"

View File

@ -426,7 +426,7 @@ dissect_ifcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi
}
next_tvb=tvb_new_subset_length(tvb, offset, frame_len-offset-4);
fc_data.ethertype = 0;
fc_data.ethertype = ETHERTYPE_UNK;
if(fc_handle){
call_dissector_with_data(fc_handle, next_tvb, pinfo, parent_tree, &fc_data);

View File

@ -17,7 +17,6 @@
#include <wsutil/pint.h>
#include <epan/oui.h>
#include <epan/xdlc.h>
#include <epan/etypes.h>
#include <epan/llcsaps.h>
#include <epan/bridged_pids.h>
#include <epan/ppptypes.h>