We are still stuck on this issue. We would really like it if someone could
guide us. Is somebody else facing the same issue?

Please let me know if I can provide more information.

Regards,

Neeraj Bansal

On Thu, 11 Jul 2024 at 15:30, Neeraj Bansal <neerajbansal54...@gmail.com>
wrote:

> Hello,
>
> Net-SNMP version: 5.9.3
> OS: Plain Vanilla Linux (kernel 6.6.23)
> Hardware: custom ARM board with many sensors
>
> Back in the net-snmp 5.4 days we created a custom mib in c using the
> example found at: netsnmp/agent/mibgroup/example.c
>
> This has worked great with one minor patch that we add to be able to go
> beyhond the 255 custom oid limitation set by a u_char magic. We would
> change that to u_short magic in the two files below, and then when calling
> an oid that has a magic number beyhond 255 it does not wrap to zero and
> start returning wrong vales.
>
> Change all u_char magic; to u_short magic; in the two files below.
> netsnmp/include/netsnmp/agent/snmp_vars.h
> netsnmp/include/netsnmp/agent/var_struct.h
>
> As mentioned our custom patch has worked for many years and many newer
> versions than net-snmp 5.4. Now fast forward to today. We want to upgrade
> our net-snmp to a newer version that supports newer openssl. So we install
> 5.9.3, test our custom mib, and all works as expected including the 255
> limitation. When walking the tree we can observe that when the 255 limit is
> reached it wraps around and outputs from the beginning. So, no problem. We
> just have to add our patches to increase the size of the magic variable
> from u_char (8-bit) to u_short (16-bit) in two files mentioned above.
>
> We recompile everything and install no problem, but instead of fixing our
> problem it caused net-snmp-5.9.3 to not be able to start. The error it
> gives is: Bad user id, which could be a red herring. example below:
> [root@testboard: /root# /etc/init.d/S59netsnmp restart
> Stopping SNMP daemon: [OK]
> Starting SNMP daemon: Bad user id: snmp
> [root@testboard: /root#
>
> So, we take our patches out and recompile and install, and it works again
> but still has the 255 custom oid limitation.
>
> A snippet from our header file. Too big to paste it all.
>
> #define TEMPC 1
> #define TEMPF 2
> #define   UPTIME_STR 3
> #define   SERIALNUMBER 4
> #define   ALLOFIT 5
> #define   ROOTFSBUILD 6
> #define   KERNELBUILD      7
> #define   OSINFO     8
> ......
> #define PRODUCT_ID 250
> #define RUNSCRIPT 251
> #define TIMER1 252
> #define TIMER2 253
> #define TIMER3 254
> #define TIMER4 255
> #define TIMER5 256 <- This outpts an error because it wraps around and 0
> is not defined.
> #define TIMER6 257 <- This outputs TEMPC value instead of TIMER6.
> #define TIMER7 258
> #define TIMER8 259
> #define TIMER9 260
> #define TIMER10 261
>
> #define    EXAMPLETIMETICKS 3333
> #define EXAMPLEIPADDRESS        4444
> #define   EXAMPLECOUNTER 7777
> #define EXAMPLEGAUGE            8888
> #define EXAMPLETRIGGERTRAP      9999
> #define EXAMPLETRIGGERTRAP2     1000
>
> Notice the example defines above that were provided in the example C
> header file, those magic numbers would have never worked because of the
> u_char (8-bit) magic variable limitation.
>
> This is a code snippet from our custom mib C file.
>
> struct variable4 testboard_variables[] = {
>    {ROOTFSBUILD, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2,
> {7, 1}},
>    {KERNELBUILD, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2,
> {7, 2}},
>    {OSINFO, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2, {7, 3}},
>    {PRODUCT_ID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, etestboard_var, 2,
> {7, 4}},
>    {UPTIME_STR, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2, {5,
> 1}},
>    {SERIALNUMBER, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2,
> {5, 2}},
>    {TEMPC, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2, {6,1}},
>    {TEMPF, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2, {6,2}},
>
> We have poured over the souce code looking for any other instance of
> u_char magic that we may have missed, but they are only defined in the two
> files mentioned above.
>
> We need some help with this. What else do we need to do in the 5.9
> versions to make the magic number not wrap around to zero after 255 and not
> crash when we do that?
>
> Thanks,
>
> Neeraj Bansal
>
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to