vflow icon indicating copy to clipboard operation
vflow copied to clipboard

Parsing of sflow SourceID from sample record is wrong

Open dbardbar opened this issue 2 years ago • 0 comments

According to the sflow RFC 3176, page 19, the struct flow_sample contains 4 bytes of source id, where the first byte is the type (0 = ifindex, 1 = smonVlanDataSource, etc), and the remaining 3 bytes is the actual value (interface index, vlan id, etc)

The code in flow_sample reads only the first 1 byte, skipping the other 3, and declares this as "SourceID". See FlowSample's unmarshel method. This is wrong. The code in flow_counter does the right thing, and reads those 4 bytes into two fields, SourceIDType and SourceIDIdx. See CounterSample's unmarshal method.

I suggest we copy the code behaviour from sflow_counter.go to sflow_sample.go. This leads to breaking of the output, which isn't that great, but honestly can't think of anybody today who reads the the current SourceID field from the JSON, as it contains no useful information.

Input from the community on this would be appreciated.

dbardbar avatar Jan 01 '23 07:01 dbardbar