Menu

#2593 iucast double counted in if-mib/data_access/interface.c

64-bit
pending
None
5
2015-01-26
2015-01-23
No

When the flag NETSNMP_INTERFACE_FLAGS_CALCULATE_UCAST is not set, stats.iucast is updated twice.

I saw this with net-snmp-5.7.3 on an embedded device running linux, with proprietary interfaces for which NETSNMP_INTERFACE_FLAGS_CALCULATE_UCAST is not enabled. When retrieving the IF-MIB::ifXTable from a system passing no packets, then the initial value is correct, but if an additional unicast packet is passed through the system, then this packets is double counted.

The code in question in agent/mibgroup/if-mib/data_access/interface.c is as follows:

        if (new_vals->ns_flags & NETSNMP_INTERFACE_FLAGS_CALCULATE_UCAST) {
            if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.iall,
                                           &new_vals->stats.iall,
                                           &prev_vals->old_stats->iall,
                                           &need_wrap_check))
                DEBUGMSGTL(("access:interface",
                        "Error expanding packet count to 64bits\n"));
        } else {
            if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.iucast,
                                           &new_vals->stats.iucast,
                                           &prev_vals->old_stats->iucast,
                                           &need_wrap_check))
                DEBUGMSGTL(("access:interface",
                        "Error expanding ifHCInUcastPkts to 64bits\n"));
        }

        if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.iucast,
                                       &new_vals->stats.iucast,
                                       &prev_vals->old_stats->iucast,
                                       &need_wrap_check))
            DEBUGMSGTL(("access:interface",
                    "Error expanding ifHCInUcastPkts to 64bits\n"));

Removing one of the two netsnmp_c64_check32_and_update(&prev_vals->stats.iucast,... sections corrects the packet counts. I'm not sure whether the one within or without the if-block is the correct one to remove.

1 Attachments

Discussion

  • Niels Baggesen

    Niels Baggesen - 2015-01-26
    • status: open --> pending
    • assigned_to: Niels Baggesen
     
  • Niels Baggesen

    Niels Baggesen - 2015-01-26

    Yes, that code looks strange ... Could you try the attached patch, which makes the whole sequence look more sensible to me :-)

     

Log in to post a comment.