Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceID should be uint32 #158

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

SourceID should be uint32 #158

wants to merge 2 commits into from

Conversation

D3luxee
Copy link

@D3luxee D3luxee commented Feb 1, 2022

According to https://sflow.org/SFLOW-DATAGRAM5.txt the SourceID should be treated as uint32.
The current implementation only allows decoding of one byte instead of the whole data in source_id.

/* sFlowDataSource encoded as follows:
     The most significant byte of the source_id is used to indicate the type
     of sFlowDataSource:
        0 = ifIndex
        1 = smonVlanDataSource
        2 = entPhysicalEntry
     The lower three bytes contain the relevant index value. */

typedef unsigned int sflow_data_source;
struct flow_sample {
   unsigned int sequence_number;  /* Incremented with each flow sample
                                     generated by this source_id.
                                     Note: If the agent resets the
                                           sample_pool then it must
                                           also reset the sequence_number.*/
   sflow_data_source source_id;   /* sFlowDataSource */
   unsigned int sampling_rate;    /* sFlowPacketSamplingRate */
   unsigned int sample_pool;      /* Total number of packets that could have
                                     been sampled (i.e. packets skipped by
                                     sampling process + total number of
                                     samples) */
   unsigned int drops;            /* Number of times that the sFlow agent
                                     detected that a packet marked to be 
                                     sampled was dropped due to
                                     lack of resources. The drops counter
                                     reports the total number of drops
                                     detected since the agent was last reset.
                                     A high drop rate indicates that the 
                                     management agent is unable to process 
                                     samples as fast as they are being 
                                     generated by hardware. Increasing 
                                     sampling_rate will reduce the drop 
                                     rate. Note: An agent that cannot 
                                     detect drops will always report
                                     zero. */

   interface input;               /* Interface packet was received on. */
   interface output;              /* Interface packet was sent on. */

   flow_record flow_records<>;    /* Information about a sampled packet */
}

According to https://sflow.org/SFLOW-DATAGRAM5.txt the SourceID should be treated as uint32.
SourceID is now a uint32 (4byte) instead of a byte.
Previously the r.Seek skipped the 3 bytes that were not read, this is not necessary because we read in all the data.
@dbardbar
Copy link
Contributor

dbardbar commented Jan 5, 2023

Actually, the SourceID field should be split into SourceIDType and SourceIDIdx, exactly like was done for flow_counter.go, and should be read in the same way as in flow_counter.go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants