[SNMP4J] NotificationOriginatorImpl

Matthias Wiesmann matthias.wiesmann at gmail.com
Fri Feb 17 04:06:51 CET 2006


Hello everybody,

I think I have found a bug in the class NotificationOriginatorImpl:
the code seems to send two notifications to a single target. From what
I have gathered, the problem lies in method 
SnmpTargetMIB.getTargetAddrRowsForTag that returns a list with twice
the same row.

Actually, this method should not return a list, but a set (each
individual row can only be present once, and order is irrelevant).

Below is some information to find the problem.

Cheers

Matthias

-------------------------------------------------------------------------------------------


Here is the content of the different tables:

SNMP table: SNMP-TARGET-MIB::snmpTargetAddrTable

                     index                                      
TDomain             TAddress Timeout RetryCount                 
TagList                   Params StorageType RowStatus
                    'Test'
TRANSPORT-ADDRESS-MIB::transportDomainUdpIpv4 "96 41 F0 35 07 E0 "    
200          0                     Test       application_params
nonVolatile    active
'hb-kt-dhcp23.jaist.ac.jp'
TRANSPORT-ADDRESS-MIB::transportDomainUdpIpv4 "96 41 F0 35 06 50 "    
200          0 hb-kt-dhcp23.jaist.ac.jp hb-kt-dhcp23.jaist.ac.jp
nonVolatile    active

SNMP table: SNMP-TARGET-MIB::snmpTargetParamsTable

                     index MPModel SecurityModel SecurityName
SecurityLevel StorageType RowStatus
      'application_params'       1             2       public 
noAuthNoPriv   permanent    active
'hb-kt-dhcp23.jaist.ac.jp'       1             2       public 
noAuthNoPriv nonVolatile    active

SNMP table: SNMP-NOTIFICATION-MIB::snmpNotifyTable

                     index                      Tag Type StorageType RowStatus
                    'Test'                     Test trap nonVolatile    active
'hb-kt-dhcp23.jaist.ac.jp' hb-kt-dhcp23.jaist.ac.jp trap nonVolatile    active

I have added some crude debugging lines in NotificationOriginatorImpl.notify

  public ResponseEvent[] notify(OctetString context, OID notificationID,
                                VariableBinding[] vbs) {
    if (logger.isInfoEnabled()) {
      logger.info("Notification " + notificationID + " issued with " +
                  Arrays.asList(vbs));
    }
      System.err.println("notification start") ;
    List responses = new LinkedList();
    for (Iterator it = notificationMIB.getNotifyTable().getModel().iterator();
         it.hasNext(); ) {
      MOTableRow notifyRow = (MOTableRow) it.next();
      OctetString tag = (OctetString)
          notifyRow.getValue(SnmpNotificationMIB.idxSnmpNotifyTag);

      Integer32 type =
          (Integer32) notifyRow.getValue(SnmpNotificationMIB.idxSnmpNotifyType);
      List addresses =
          targetMIB.getTargetAddrRowsForTag(new String(tag.getValue()));
      MOTableRowFilter aFilter =
          new RowStatus.ActiveRowsFilter(SnmpTargetMIB.idxSnmpTargetAddrRowStatus);
      for (Iterator ait = addresses.iterator(); ait.hasNext(); ) {
        MOTableRow addr = (MOTableRow) ait.next();
        if (aFilter.passesFilter(addr)) {
          OctetString params =
              (OctetString)addr.getValue(SnmpTargetMIB.idxSnmpTargetAddrParams);
          MOTableRow paramsRow = targetMIB.getTargetParamsRow(params);
	  if (paramsRow==null) throw new RuntimeException("could not find row
for "+params);
          if (RowStatus.isRowActive(paramsRow,
                                   
SnmpTargetMIB.idxSnmpTargetParamsRowStatus)) {
            if (isAccessGranted(addr, paramsRow, context,
notificationID, vbs)) {
		System.err.println("tag "+tag+" matches "+paramsRow.getIndex()) ;
              ResponseEvent response =
                  sendNotification(addr, paramsRow, context,
                                   notificationID, vbs, type.getValue());
              responses.add(response);
            }
            else {
              if (logger.isWarnEnabled()) {
                logger.warn("Access denied by VACM for "+notificationID);
              }
            }
          }
          else {
            logger.warn("Found active target address but corrsponding params"+
                        " are not active");
          }
        }
      }
    }
    System.err.println("notification done");
    return (ResponseEvent[]) responses.toArray(new ResponseEvent[0]);
  }


I get the following output.

tag hb-kt-dhcp23.jaist.ac.jp matches
104.98.45.107.116.45.100.104.99.112.50.51.46.106.97.105.115.116.46.97.99.46.106.112
send to CommunityTarget[address=150.65.240.53/1616, version=1,
timeout=2000, retries=0, community=public]
tag hb-kt-dhcp23.jaist.ac.jp matches
104.98.45.107.116.45.100.104.99.112.50.51.46.106.97.105.115.116.46.97.99.46.106.112
send to CommunityTarget[address=150.65.240.53/1616, version=1,
timeout=2000, retries=0, community=public]



More information about the SNMP4J mailing list