Skip to content

Parsing of sflow SourceID from sample record is wrong #178

@dbardbar

Description

@dbardbar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions