AE-558 SNMP stop working after reboot |ePassport |AS-18023|

Review Request #803 — Created April 16, 2025 and submitted

rvempati
APV10
rel_apv_10_7_2
https://arraynetworks.atlassian.net/browse/AE-558
mmiriam, pradeep, prajesh, tanya

For Array Enterprise ID 7564, used SHA1 Hashing then base64 encoding on serial number to generate engineID to persist across reboots

APV -1:
Before reboot:
/etc/snmp/snmpd.conf
engineID gAAAHYwzRjM5NTU5RDExNUY5MDA
[root@APV-1 test]# snmpget -v 3 -u "rohith" -l authNoPriv -a SHA -A "12345678" 192.168.162.171 1.3.6.1.6.3.10.2.1.1.0
SNMP-FRAMEWORK-MIB::snmpEngineID.0 = Hex-STRING: 80 00 1F 88 04 67 41 41 41 48 59 77 7A 52 6A 4D 35 4E 54 55 35 52 44 45 78 4E 55 59 35 4D 44 41
[root@APV-1 test]#

After reboot:
/etc/snmp/snmpd.conf
engineID gAAAHYwzRjM5NTU5RDExNUY5MDA
[root@APV-1 test]# snmpget -v 3 -u "rohith" -l authNoPriv -a SHA -A "12345678" 192.168.162.171 1.3.6.1.6.3.10.2.1.1.0
SNMP-FRAMEWORK-MIB::snmpEngineID.0 = Hex-STRING: 80 00 1F 88 04 67 41 41 41 48 59 77 7A 52 6A 4D 35 4E 54 55 35 52 44 45 78 4E 55 59 35 4D 44 41
[root@APV-1 test]#

APV -2:
Before reboot:
/etc/snmp/snmpd.conf
engineID gAAAHYw3QTNBNEZFMEQ4NTRDMDA
[root@APV-2 test]# snmpget -v 3 -u "rohith" -l authNoPriv -a SHA -A "12345678" 192.168.162.148 1.3.6.1.6.3.10.2.1.1.0
SNMP-FRAMEWORK-MIB::snmpEngineID.0 = Hex-STRING: 80 00 1F 88 04 67 41 41 41 48 59 77 33 51 54 4E 42 4E 45 5A 46 4D 45 51 34 4E 54 52 44 4D 44 41
[root@APV-2 test]#

After reboot:
/etc/snmp/snmpd.conf
engineID gAAAHYw3QTNBNEZFMEQ4NTRDMDA
[root@APV-2 test]# snmpget -v 3 -u "rohith" -l authNoPriv -a SHA -A "12345678" 192.168.162.148 1.3.6.1.6.3.10.2.1.1.0
SNMP-FRAMEWORK-MIB::snmpEngineID.0 = Hex-STRING: 80 00 1F 88 04 67 41 41 41 48 59 77 33 51 54 4E 42 4E 45 5A 46 4D 45 51 34 4E 54 52 44 4D 44 41
[root@APV-2 test]#

Description From Last Updated

define MAX_CA_ENGINE_ID_LEN 28

prajeshprajesh

Update in comment format / * /

mmiriammmiriam

enterprise id for array is ::= { enterprises 7564 } in ./usr/click/lib/libca_snmp_mib/CA-SNMP-MIB.txt. Confirm if we need to use this OID?

mmiriammmiriam

use #define.

prajeshprajesh

if it fails, dont return.. just log and write other configurations.

prajeshprajesh

I dont think we need this..

prajeshprajesh

remove whitespace in red.

prajeshprajesh

we still do hash ?

prajeshprajesh

where do we do this? What is the logic now?

prajeshprajesh

Not using this function anywhere

mmiriammmiriam

In apv this file is already present. who created this? Is there already a function available filling these details?

mmiriammmiriam

Are these values used by anybody else?

mmiriammmiriam

will these values won't change? why are we giving hardcoded value?

mmiriammmiriam

We are removing the persist file.. then your changes will go away .. How is the fix working?

prajeshprajesh

calling two times

mmiriammmiriam

this goes and deletes the PERSIST FILE. Is not our then your changes are not persisting?

prajeshprajesh

Dont think it is useful. Anyway the string will be b54 encoded.

prajeshprajesh

Just log an error and do not return -1.

prajeshprajesh

directly print pInfo->engineID_b64 instead of calling generate_snmp_engineID again?

mmiriammmiriam

Or remove this call. I think new struct mem is not required. are we going to use it? if not …

mmiriammmiriam

Log and silently ignore the error so that it can still work without your changes.

prajeshprajesh

what is the need for this?

prajeshprajesh

why to take it as global? you are using it only in one function

mmiriammmiriam

Why do we need this..

prajeshprajesh

if you do unlock here it can be a problem and add call to generate_snmp_engineID in snmp_update function and remove …

mmiriammmiriam

this function already writes that into snmpd.conf.

prajeshprajesh

remove whitespace.

prajeshprajesh

this should be printed only else or success case.

prajeshprajesh
prajesh
  1. 
      
  2. define MAX_CA_ENGINE_ID_LEN 28

    1. Used as Macro in snmpcli.h file

    1. Used as Macro in snmpcli.h file

  3. if it fails, dont return.. just log and write other configurations.

    1. Sure,
      Changed as suggested.

  4. I dont think we need this..

  5. 
      
mmiriam
  1. 
      
  2. Update in comment format
    /
    *
    /

  3. enterprise id for array is ::= { enterprises 7564 }
    in ./usr/click/lib/libca_snmp_mib/CA-SNMP-MIB.txt. Confirm if we need to use this OID?

    1. Used the same Enterprise ID as Macro in snmpcli.h file

  4. 
      
rvempati
prajesh
  1. 
      
  2. remove whitespace in red.

    1. Updated the SNMP engineID generation.

  3. where do we do this? What is the logic now?

  4. 
      
rvempati
mmiriam
  1. 
      
  2. In apv this file is already present. who created this? Is there already a function available filling these details?

    1. Initially this SNMP_PERSIST_FILE is not available.
      When snmp is enabled, the SNMP daemon will generate this file automatically.

  3. Are these values used by anybody else?

    1. Uptime in seconds since the last reboot. 100 is an arbitrary value, just enough to avoid invalid/expired time.

  4. will these values won't change? why are we giving hardcoded value?

    1. These lines are writing to the SNMP persistent file, to initialize SNMP engine state when it doesn't yet exist.

  5. 
      
prajesh
  1. 
      
  2. this goes and deletes the PERSIST FILE. Is not our then your changes are not persisting?

    1. Yes, my changes are making the engineID persisting.

  3. 
      
prajesh
  1. 
      
  2. We are removing the persist file.. then your changes will go away .. How is the fix working?

    1. Here, I'm calling the persist_snmp_engine_id() function before snmpd starts again, it will:
      Create the SNMPD_PERSIST_FILE, ite the engineID and engineBoots.

      On next snmpd start, it will read this file and not auto-generate a new engineID

      We can comment out this line "remove(SNMP_PERSIST_FILE)", or we can make it to a conditional line.

  3. 
      
mmiriam
  1. 
      
  2. Not using this function anywhere

    1. Updated the code, thankyou.

    1. Updated the code, thank you.

  3. 
      
rvempati
prajesh
  1. 
      
  2. Just log an error and do not return -1.

  3. Log and silently ignore the error so that it can still work without your changes.

    1. sure, removed the return

  4. what is the need for this?

    1. After generating the B64_engineID, we are storing it in the pInfo structure which is used to print enigneID in "/etc/snmp/snmpd.conf" file

  5. 
      
mmiriam
  1. 
      
  2. directly print pInfo->engineID_b64 instead of calling generate_snmp_engineID again?

    1. Okay,
      Modified the code.

  3. 
      
mmiriam
  1. 
      
  2. Or remove this call. I think new struct mem is not required. are we going to use it? if not then remove this

  3. 
      
prajesh
  1. 
      
  2. branches/rel_apv_10_7_2/usr/click/lib/libca_snmp/snmp_cadmin.c (Diff revision 4)
     
     
     
     
     
     
     
     
     
     
     

    Dont think it is useful. Anyway the string will be b54 encoded.

    1. Enterprise ID is also encoded and included with the generated engine ID.
      we need it.
      Thanks.

  3. 
      
rvempati
prajesh
  1. 
      
  2. branches/rel_apv_10_7_2/usr/click/lib/libca_snmp/snmp_cadmin.c (Diff revision 5)
     
     
     
     
     
     
     
     

    Why do we need this..

    1. Modified this code block.

  3. this function already writes that into snmpd.conf.

  4. 
      
mmiriam
  1. 
      
  2. why to take it as global? you are using it only in one function

  3. 
      
mmiriam
  1. 
      
  2. if you do unlock here it can be a problem and add call to generate_snmp_engineID in snmp_update function and remove from here and remove global varibale for engineID

  3. 
      
rvempati
rvempati
prajesh
  1. Ship It!
  2. 
      
prajesh
  1. 
      
  2. this should be printed only else or success case.

    1. Moved the fprintf line into the else block of the above if condition.

  3. 
      
prajesh
rvempati
prajesh
  1. Ship It!
  2. 
      
mmiriam
  1. Ship It!
  2. 
      
rvempati
Review request changed

Status: Closed (submitted)

Change Summary:

Code chagnes for the persistent snmp engineID generation and saving it.

Loading...