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

winExtDLL doesn't return any values on system #388

Open
rhermsen opened this issue Nov 30, 2021 · 21 comments
Open

winExtDLL doesn't return any values on system #388

rhermsen opened this issue Nov 30, 2021 · 21 comments

Comments

@rhermsen
Copy link

SNMP agent doesn't return any value when using windows dlls.
Trying to get sysDescr.0 return an error "No Such Object available on this agent at this OID".
Get the following output when enabling winExtDLL with debug enabled:

c:\usr\bin>snmpd.exe -Lo -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,system_mib,sysORTable -DwinExtDLL
registered debug token winExtDLL, 1
init_winExtDLL started.
winExtDLL: read_extension_dlls_from_registry called
registry key SOFTWARE\Microsoft\SNMP_EVENTS\CurrentVersion: DLL C:\Windows\System32\evntagnt.dll.
registry key SOFTWARE\Microsoft\HostMIB\CurrentVersion: DLL C:\Windows\System32\hostmib.dll.
registry key SOFTWARE\Microsoft\RFC1156Agent\CurrentVersion: DLL C:\Windows\System32\inetmib1.dll.
registry key SOFTWARE\Microsoft\LANManagerMIB2Agent\CurrentVersion: DLL C:\Windows\System32\lmmib2.dll.
registry key SOFTWARE\Microsoft\SNMPMIB\CurrentVersion: DLL C:\Windows\System32\snmpmib.dll.
registry key SOFTWARE\Microsoft\Wow64ProxyAgent\CurrentVersion: DLL C:\Windows\System32\wow64mib.dll.
init_winExtDLL: found 6 extension DLLs in the registry.
loading DLL C:\Windows\System32\evntagnt.dll.
init_winExtDLL: DLL C:\Windows\System32\evntagnt.dll initialization result 1
init_winExtDLL: DLL C:\Windows\System32\evntagnt.dll view length 2
loading DLL C:\Windows\System32\hostmib.dll.
init_winExtDLL: DLL C:\Windows\System32\hostmib.dll initialization result 1
init_winExtDLL: DLL C:\Windows\System32\hostmib.dll view length 7
loading DLL C:\Windows\System32\inetmib1.dll.
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll initialization result 1
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: skipping system section of DLL C:\Windows\System32\inetmib1.dll.
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 8
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 8
loading DLL C:\Windows\System32\lmmib2.dll.
init_winExtDLL: skipped DLL C:\Windows\System32\lmmib2.dll.
loading DLL C:\Windows\System32\snmpmib.dll.
init_winExtDLL: DLL C:\Windows\System32\snmpmib.dll initialization result 1
init_winExtDLL: DLL C:\Windows\System32\snmpmib.dll view length 7
loading DLL C:\Windows\System32\wow64mib.dll.
init_winExtDLL: DLL C:\Windows\System32\wow64mib.dll initialization result 0
init_winExtDLL: DLL C:\Windows\System32\wow64mib.dll view length 0
registering handler for DLL C:\Windows\System32\evntagnt.dll and OID prefix joint-iso-ccitt.0 (.2.0).
registering handler for DLL C:\Windows\System32\hostmib.dll and OID prefix iso.3.6.1.2.1.25 (.1.3.6.1.2.1.25).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.2 (.1.3.6.1.2.1.2).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.4 (.1.3.6.1.2.1.4).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.5 (.1.3.6.1.2.1.5).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.6 (.1.3.6.1.2.1.6).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.7 (.1.3.6.1.2.1.7).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.31.1 (.1.3.6.1.2.1.31.1).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.55.1 (.1.3.6.1.2.1.55.1).
duplicate registration: MIB modules mibII/snmp and C:\Windows\System32\snmpmib.dll (oid .1.3.6.1.2.1.11).
handler registration failed.
init_winExtDLL: registered 10 OID ranges.
init_winExtDLL finished.
NET-SNMP version 5.9.1

Windows 10 x64
VC++ 2017 x64
OpenSSL 1.1.1l
perl-5.32.1 built with VC++ 2017 x64
Net-SNMP 5.9.1 built with:
perl Configure --with-sdk --with-winextdll --with-ssl --with-ipv6 --config=release --linktype=static --prefix="c:/usr"
nmake
nmake install

@bvanassche
Copy link
Contributor

Does the conversation in #383 provide the information that you are looking for?

@janclod
Copy link

janclod commented Dec 2, 2021

Hi @rhermsen, do you get any value when you are not loading the Win DLLs?

Whether you do or do not load the Win DLL, you should always get an output from querying the sysDescr.0 OID according to section "Enabling the Windows SNMP extension agents" in the README.Win32 file.

Just keep in mind I am not an expert, so feel free to ignore my comments 😅

@rhermsen
Copy link
Author

rhermsen commented Dec 2, 2021

Bart, Claudio,

I didn't find a solution in #383
In my case I started building for x64 from the start [1].

With NET-SNMP (snmpd -register) I do get the following output:
SNMPv2-MIB::sysDescr.0 = STRING: Windows DESKTOP-E6DGEM9 10.0.19043 Windows 10 Home Intel64 Family 6 Model 122 Stepping 8

With MS SNMP (stopped NET-SNMP agent, start MS SNMP Service):
SNMPv2-MIB::sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 122 Stepping 8 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 19043 Multiprocessor Free)

With NET-SNMP excluding system MIB (snmpd -register -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,system_mib,sysORTable):
SNMPv2-MIB::sysDescr.0 = No Such Object available on this agent at this OID

I do get response from other OID's, just not for the System MIB.

"C:\Program Files (x86)\IP-Tools\Net-SNMP\bin\snmpwalk" -M "C:\Program Files (x86)\IP-Tools\Net-SNMP\share\snmp\mibs" -v2c -c public 192.168.178.94  1 | wc -l
5967

Which does include HOST-RESOURCES-MIB that I understood from README.Win32 must come from the MS DLL according the following:

Also, the Net-SNMP agent does not contain as many MIBs as the Microsoft agent. For example, as of August 2005, the HOST-RESOURCES (host) MIB is not yet implemented in Net-SNMP.

Btw, for me it took a bit more effort to get MS SNMP installed.
I used the following to install it (accoring this link):

Add-WindowsCapability  -Online -Name "SNMP.Client~~~~0.0.1.0"
Get-WindowsCapability -Online -Name "SNMP*"

[1] Build steps:

Start > "x64 Native Tools Command Prompt for VS 2017"
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
set Platform=x64
set TARGET_CPU=x64
set INCLUDE=%INCLUDE%;C:\OpenSSL-Win64\include
set LIB=%LIB%;C:\OpenSSL-Win64\lib;C:\OpenSSL-Win64\lib\VC
PATH=C:\perl\bin;%PATH%C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64
perl Configure --help
perl Configure --with-sdk --with-winextdll --with-ssl --with-ipv6 --config=release --linktype=static --prefix="c:/usr"
nmake help
nmake clean
nmake
nmake install
# zip the C:\usr directory to 'net-snmp-5.9.1.x86_64_openssl.zip'
nmake install_devel
# zip the C:\usr directory to 'net-snmp-5.9.1.x86_64_openssl_devel.zip'

So my Windows build system is not the same as the Windows system where I use NET-SNMP.

@janclod
Copy link

janclod commented Dec 6, 2021

I did some testing on my own system.

When I run snmpd, this is the output I get from snmpget ... localhost sysDescr.0

SNMPv2-MIB::sysDescr.0 = STRING: Win.... Intel64 Family ....

When I run snmpd -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,system_mib,sysORTable, this is the output I get from snmpget ... localhost sysDescr.0

SNMPv2-MIB::sysDescr.0 = No Such Object available on this agent at this OID

When I run snmpd -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,sysORTable, this is the output I get from snmpget ... localhost sysDescr.0

SNMPv2-MIB::sysDescr.0 = STRING: Win.... Intel64 Family ....

My testing confirms what you experience and suggests that the system_mib MIB module (which I include in my last test) is responsible for loading the information about the system.

If you run snmpd -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,sysORTable (including system_mib), what is your output (from the snmpget command)?
I notice that there is no sysDescr.0 OID (.1.3.6.1.2.1.1.1.0) registered in the debug information of the winExtDLL module. Maybe something to do with this?

@janclod
Copy link

janclod commented Dec 7, 2021

@rhermsen I did some more research and it looks like the mib-2 system section is skipped on Win Vista and later, see code here

@bvanassche should the README be improved or is it possible to attempt and read this information somehow?

@rhermsen
Copy link
Author

rhermsen commented Dec 7, 2021

Thanks for looking (digging) further.
I suspect that you indeed found the reason why it is not possible to use the Microsoft SNMP system-mib.

cd c:\usr\bin
snmpd -unregister
snmpd -register -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,sysORTable

starting the NET-SNMP agent indeed gives the output from the NET-SNMP system-mib modules.

C:\WINDOWS\system32>"C:\Program Files (x86)\IP-Tools\Net-SNMP\bin\snmpwalk" -M "C:\Program Files (x86)\IP-Tools\Net-SNMP\share\snmp\mibs" -v2c -c public 192.168.178.94  sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: Windows DESKTOP-E6DGEM9 10.0.19043 Windows 10 Home Intel64 Family 6 Model 122 Stepping 8

The readme also mentions that the Net-SNMP "modules take precedence over the modules loaded by winExtDLL".
If you exclude modules that are both in Net-SNMP and MS SNMP only than the MS SNMP modules are used. See also the -I [-] description in the snmpd man-page.

@janclod
Copy link

janclod commented Dec 9, 2021

I can confirm that the issue has to do with this if statement.

I brutally modified the code so that the if is never true and I managed to get the MS SNMP system info

snmpd (which needs to be run by excluding the NetSNMP system_mib otherwise they take precedence over MS system information) output

...
registering handler for DLL C:\Windows\System32\hostmib.dll and OID prefix iso.3.6.1.2.1.25 (.1.3.6.1.2.1.25).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.1 (.1.3.6.1.2.1.1).
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.2 (.1.3.6.1.2.1.2).
...

snmpget output

SNMPv2-MIB::sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 63 Stepping 2 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 19041 Multiprocessor Free)

The NetSNMP software was built and tested on Win 10 build 19041.

janclod added a commit to janclod/net-snmp that referenced this issue Dec 9, 2021
janclod added a commit to janclod/net-snmp that referenced this issue Dec 9, 2021
@rhermsen
Copy link
Author

rhermsen commented Dec 9, 2021

According the comment in the code "all queries in that section fail with status "generic error"".
Did you try e.g. a walk using .1.3.6.1.2.1 to look if there are still issues with Win10?

bvanassche added a commit that referenced this issue Dec 11, 2021
Commit 59b4d40 ("CHANGES: Windows: Make winExtDLL work on 64-bit
Windows systems") caused snmpd to skip MIB-II on 64-bit systems. Revert
that change such that the Windows MIB-II implementation can be used on
Windows 10. See also:
* #383
* #388

With this patch applied, I see the following output in a Windows VM:
$ /c/usr/bin/snmpwalk -v2c -cpublic localhost .1.3.6.1.2.1.2
IF-MIB::ifNumber.0 = INTEGER: 9
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifIndex.4 = INTEGER: 4
IF-MIB::ifIndex.5 = INTEGER: 5
IF-MIB::ifIndex.6 = INTEGER: 6
IF-MIB::ifIndex.7 = INTEGER: 7
IF-MIB::ifIndex.8 = INTEGER: 8
IF-MIB::ifIndex.9 = INTEGER: 9
IF-MIB::ifDescr.1 = STRING: Software Loopback Interface 1
IF-MIB::ifDescr.2 = STRING: Microsoft 6to4 Adapter
IF-MIB::ifDescr.3 = STRING: Microsoft Kernel Debug Network Adapter
IF-MIB::ifDescr.4 = STRING: Microsoft IP-HTTPS Platform Adapter
IF-MIB::ifDescr.5 = STRING: Intel(R) 82574L Gigabit Network Connection
IF-MIB::ifDescr.6 = STRING: Microsoft Teredo Tunneling Adapter
IF-MIB::ifDescr.7 = STRING: Intel(R) 82574L Gigabit Network Connection-WFP Native MAC Layer LightWeight Filter-0000
IF-MIB::ifDescr.8 = STRING: Intel(R) 82574L Gigabit Network Connection-QoS Packet Scheduler-0000
IF-MIB::ifDescr.9 = STRING: Intel(R) 82574L Gigabit Network Connection-WFP 802.3 MAC Layer LightWeight Filter-0000
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.2 = INTEGER: tunnel(131)
IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.4 = INTEGER: tunnel(131)
IF-MIB::ifType.5 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.6 = INTEGER: tunnel(131)
IF-MIB::ifType.7 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.8 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.9 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifMtu.1 = INTEGER: 1500
IF-MIB::ifMtu.2 = INTEGER: 0
IF-MIB::ifMtu.3 = INTEGER: 0
IF-MIB::ifMtu.4 = INTEGER: 0
IF-MIB::ifMtu.5 = INTEGER: 1500
IF-MIB::ifMtu.6 = INTEGER: 0
IF-MIB::ifMtu.7 = INTEGER: 1500
IF-MIB::ifMtu.8 = INTEGER: 1500
IF-MIB::ifMtu.9 = INTEGER: 1500
IF-MIB::ifSpeed.1 = Gauge32: 1073741824
IF-MIB::ifSpeed.2 = Gauge32: 0
IF-MIB::ifSpeed.3 = Gauge32: 0
IF-MIB::ifSpeed.4 = Gauge32: 0
IF-MIB::ifSpeed.5 = Gauge32: 1000000000
IF-MIB::ifSpeed.6 = Gauge32: 0
IF-MIB::ifSpeed.7 = Gauge32: 1000000000
IF-MIB::ifSpeed.8 = Gauge32: 1000000000
IF-MIB::ifSpeed.9 = Gauge32: 1000000000
IF-MIB::ifPhysAddress.1 = STRING:
IF-MIB::ifPhysAddress.2 = STRING:
IF-MIB::ifPhysAddress.3 = STRING:
IF-MIB::ifPhysAddress.4 = STRING:
IF-MIB::ifPhysAddress.5 = STRING: 52:54:0:bb:6f:2f
IF-MIB::ifPhysAddress.6 = STRING:
IF-MIB::ifPhysAddress.7 = STRING: 52:54:0:bb:6f:2f
IF-MIB::ifPhysAddress.8 = STRING: 52:54:0:bb:6f:2f
IF-MIB::ifPhysAddress.9 = STRING: 52:54:0:bb:6f:2f
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifAdminStatus.2 = INTEGER: down(2)
IF-MIB::ifAdminStatus.3 = INTEGER: down(2)
IF-MIB::ifAdminStatus.4 = INTEGER: down(2)
IF-MIB::ifAdminStatus.5 = INTEGER: up(1)
IF-MIB::ifAdminStatus.6 = INTEGER: down(2)
IF-MIB::ifAdminStatus.7 = INTEGER: up(1)
IF-MIB::ifAdminStatus.8 = INTEGER: up(1)
IF-MIB::ifAdminStatus.9 = INTEGER: up(1)
IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.2 = INTEGER: down(2)
IF-MIB::ifOperStatus.3 = INTEGER: down(2)
IF-MIB::ifOperStatus.4 = INTEGER: down(2)
IF-MIB::ifOperStatus.5 = INTEGER: up(1)
IF-MIB::ifOperStatus.6 = INTEGER: down(2)
IF-MIB::ifOperStatus.7 = INTEGER: up(1)
IF-MIB::ifOperStatus.8 = INTEGER: up(1)
IF-MIB::ifOperStatus.9 = INTEGER: up(1)
IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.3 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.4 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.5 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.6 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.7 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.8 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.9 = Timeticks: (0) 0:00:00.00
IF-MIB::ifInOctets.1 = Counter32: 0
IF-MIB::ifInOctets.2 = Counter32: 0
IF-MIB::ifInOctets.3 = Counter32: 0
IF-MIB::ifInOctets.4 = Counter32: 0
IF-MIB::ifInOctets.5 = Counter32: 3902284436
IF-MIB::ifInOctets.6 = Counter32: 0
IF-MIB::ifInOctets.7 = Counter32: 3902284436
IF-MIB::ifInOctets.8 = Counter32: 3902284436
IF-MIB::ifInOctets.9 = Counter32: 3902284436
IF-MIB::ifInUcastPkts.1 = Counter32: 0
IF-MIB::ifInUcastPkts.2 = Counter32: 0
IF-MIB::ifInUcastPkts.3 = Counter32: 0
IF-MIB::ifInUcastPkts.4 = Counter32: 0
IF-MIB::ifInUcastPkts.5 = Counter32: 265150678
IF-MIB::ifInUcastPkts.6 = Counter32: 0
IF-MIB::ifInUcastPkts.7 = Counter32: 265150678
IF-MIB::ifInUcastPkts.8 = Counter32: 265150678
IF-MIB::ifInUcastPkts.9 = Counter32: 265150678
IF-MIB::ifInNUcastPkts.1 = Counter32: 0
IF-MIB::ifInNUcastPkts.2 = Counter32: 0
IF-MIB::ifInNUcastPkts.3 = Counter32: 0
IF-MIB::ifInNUcastPkts.4 = Counter32: 0
IF-MIB::ifInNUcastPkts.5 = Counter32: 28
IF-MIB::ifInNUcastPkts.6 = Counter32: 0
IF-MIB::ifInNUcastPkts.7 = Counter32: 28
IF-MIB::ifInNUcastPkts.8 = Counter32: 28
IF-MIB::ifInNUcastPkts.9 = Counter32: 28
IF-MIB::ifInDiscards.1 = Counter32: 0
IF-MIB::ifInDiscards.2 = Counter32: 0
IF-MIB::ifInDiscards.3 = Counter32: 0
IF-MIB::ifInDiscards.4 = Counter32: 0
IF-MIB::ifInDiscards.5 = Counter32: 0
IF-MIB::ifInDiscards.6 = Counter32: 0
IF-MIB::ifInDiscards.7 = Counter32: 0
IF-MIB::ifInDiscards.8 = Counter32: 0
IF-MIB::ifInDiscards.9 = Counter32: 0
IF-MIB::ifInErrors.1 = Counter32: 0
IF-MIB::ifInErrors.2 = Counter32: 0
IF-MIB::ifInErrors.3 = Counter32: 0
IF-MIB::ifInErrors.4 = Counter32: 0
IF-MIB::ifInErrors.5 = Counter32: 0
IF-MIB::ifInErrors.6 = Counter32: 0
IF-MIB::ifInErrors.7 = Counter32: 0
IF-MIB::ifInErrors.8 = Counter32: 0
IF-MIB::ifInErrors.9 = Counter32: 0
IF-MIB::ifInUnknownProtos.1 = Counter32: 0
IF-MIB::ifInUnknownProtos.2 = Counter32: 0
IF-MIB::ifInUnknownProtos.3 = Counter32: 0
IF-MIB::ifInUnknownProtos.4 = Counter32: 0
IF-MIB::ifInUnknownProtos.5 = Counter32: 0
IF-MIB::ifInUnknownProtos.6 = Counter32: 0
IF-MIB::ifInUnknownProtos.7 = Counter32: 0
IF-MIB::ifInUnknownProtos.8 = Counter32: 0
IF-MIB::ifInUnknownProtos.9 = Counter32: 0
IF-MIB::ifOutOctets.1 = Counter32: 0
IF-MIB::ifOutOctets.2 = Counter32: 0
IF-MIB::ifOutOctets.3 = Counter32: 0
IF-MIB::ifOutOctets.4 = Counter32: 0
IF-MIB::ifOutOctets.5 = Counter32: 1952733666
IF-MIB::ifOutOctets.6 = Counter32: 0
IF-MIB::ifOutOctets.7 = Counter32: 1952733666
IF-MIB::ifOutOctets.8 = Counter32: 1952733666
IF-MIB::ifOutOctets.9 = Counter32: 1952733666
IF-MIB::ifOutUcastPkts.1 = Counter32: 0
IF-MIB::ifOutUcastPkts.2 = Counter32: 0
IF-MIB::ifOutUcastPkts.3 = Counter32: 0
IF-MIB::ifOutUcastPkts.4 = Counter32: 0
IF-MIB::ifOutUcastPkts.5 = Counter32: 137686780
IF-MIB::ifOutUcastPkts.6 = Counter32: 0
IF-MIB::ifOutUcastPkts.7 = Counter32: 137686780
IF-MIB::ifOutUcastPkts.8 = Counter32: 137686780
IF-MIB::ifOutUcastPkts.9 = Counter32: 137686780
IF-MIB::ifOutNUcastPkts.1 = Counter32: 0
IF-MIB::ifOutNUcastPkts.2 = Counter32: 0
IF-MIB::ifOutNUcastPkts.3 = Counter32: 0
IF-MIB::ifOutNUcastPkts.4 = Counter32: 0
IF-MIB::ifOutNUcastPkts.5 = Counter32: 115
IF-MIB::ifOutNUcastPkts.6 = Counter32: 0
IF-MIB::ifOutNUcastPkts.7 = Counter32: 115
IF-MIB::ifOutNUcastPkts.8 = Counter32: 115
IF-MIB::ifOutNUcastPkts.9 = Counter32: 115
IF-MIB::ifOutDiscards.1 = Counter32: 0
IF-MIB::ifOutDiscards.2 = Counter32: 0
IF-MIB::ifOutDiscards.3 = Counter32: 0
IF-MIB::ifOutDiscards.4 = Counter32: 0
IF-MIB::ifOutDiscards.5 = Counter32: 0
IF-MIB::ifOutDiscards.6 = Counter32: 0
IF-MIB::ifOutDiscards.7 = Counter32: 0
IF-MIB::ifOutDiscards.8 = Counter32: 0
IF-MIB::ifOutDiscards.9 = Counter32: 0
IF-MIB::ifOutErrors.1 = Counter32: 0
IF-MIB::ifOutErrors.2 = Counter32: 0
IF-MIB::ifOutErrors.3 = Counter32: 0
IF-MIB::ifOutErrors.4 = Counter32: 0
IF-MIB::ifOutErrors.5 = Counter32: 0
IF-MIB::ifOutErrors.6 = Counter32: 0
IF-MIB::ifOutErrors.7 = Counter32: 0
IF-MIB::ifOutErrors.8 = Counter32: 0
IF-MIB::ifOutErrors.9 = Counter32: 0
IF-MIB::ifOutQLen.1 = Gauge32: 0
IF-MIB::ifOutQLen.2 = Gauge32: 0
IF-MIB::ifOutQLen.3 = Gauge32: 0
IF-MIB::ifOutQLen.4 = Gauge32: 0
IF-MIB::ifOutQLen.5 = Gauge32: 0
IF-MIB::ifOutQLen.6 = Gauge32: 0
IF-MIB::ifOutQLen.7 = Gauge32: 0
IF-MIB::ifOutQLen.8 = Gauge32: 0
IF-MIB::ifOutQLen.9 = Gauge32: 0
IF-MIB::ifSpecific.1 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.2 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.3 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.4 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.5 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.6 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.7 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.8 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.9 = OID: SNMPv2-SMI::zeroDotZero
@rhermsen
Copy link
Author

rhermsen commented Dec 11, 2021

@janclod I just tried the same (sed -i 's(s_versioninfo.dwMajorVersion >= 6(5 >= 6\g' /home/rhermsen/workdir/net-snmp/net-snmp-5.9.1/agent/mibgroup/winExtDLL.c)
(this will also enable evntagnt.dll and lmmib2.dll)
Don't see any errors with a walk of .1.3.6.1.2.1

"C:\Program Files (x86)\IP-Tools\Net-SNMP\bin\snmpwalk" -M "C:\Program Files (x86)\IP-Tools\Net-SNMP\share\snmp\mibs" -v2c -c public 192.168.178.94  1.3.6.1.2.1 | wc -l
5345

And it is now using the MS SNMP MIB:
SNMPv2-MIB::sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 122 Stepping 8 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 19043 Multiprocessor Free)

I do get an error if I perform a walk for the whole tree. But I suspect I have seen that error before.
Edit (2021-12-17): Installed the released 5.9.1 (without patch), but wasn't able to see the error below. A grep on enterprises doesn't return any hits either. /Edit

"C:\Program Files (x86)\IP-Tools\Net-SNMP\bin\snmpwalk" -M "C:\Program Files (x86)\IP-Tools\Net-SNMP\share\snmp\mibs" -v2c -c public 192.168.178.94  1 | wc -l
Error in packet.
Reason: (genError) A general failure occured
Failed object: SNMPv2-SMI::enterprises.77.1.1.3.0

5385

@bvanassche
Copy link
Contributor

Multiple fixes have been checked in on the v5.9 and master branches. Please help with testing these fixes.

@rhermsen
Copy link
Author

@bvanassche
Just looked at the changes in the master branch for winExtDLL.c at line 409, and "s_versioninfo.dwMajorVersion == 6" is also true for Windows 10
(Windows 10 > Software: Windows Version 6.3).
I will look into the other fixes.

@bvanassche
Copy link
Contributor

Hmm ... in the document https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa I found that dwMajorVersion == 10 for Windows 10. Anyway, the s_versioninfo.dwMajorVersion == 6 check has been removed from winExtDLL.c by commit bd7394d. Further feedback is welcome.

@rhermsen
Copy link
Author

Just checked to be sure, I compiled on Windows 10 Pro version 1909 build 18363.1556
and used it on Windows 10 Home version 21H1 build 19043.1348

@janclod
Copy link

janclod commented Dec 13, 2021

Nice to see the effort and progress :)

I built the latest V5-9-patches and it does not work any longer on my machine to query the sysDescr.0 OID.

@bvanassche I took some time to review your commits (also related to the documentation) and everything now works (important to exclude the system_mib if you wanna get MS SNMP output) 😅 no idea what I did before 😆

snmpd.exe -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,snmp_mib,system_mib,sysORTable -DwinExtDLL output

...
loading DLL C:\Windows\System32\inetmib1.dll.
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll initialization result 1
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 7
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 8
init_winExtDLL: DLL C:\Windows\System32\inetmib1.dll view length 8
...
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.1 (.1.3.6.1.2.1.1).
...

snmpget.exe -v 2c -c public localhost sysDescr.0 output

SNMPv2-MIB::sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 63 Stepping 2 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 19041 Multiprocessor Free)

Tested on
Information coming from the System -> About app
Win 10
Build 19041.1052
Information coming from the WinAPI (GetVersionEx)
dwMajor version: 6
dwMinor version: 2
dwBuild: 9200

The NetSNMP was built from branch V5-9-patches at this commit

.\snmpd.exe -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,sysORTable,system_mib output

...
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.1 (.1.3.6.1.2.1.1).
...
extension DLL C:\Windows\System32\inetmib1.dll: SNMP query function returned error code 5 (Windows) / 5 (Net-SNMP) for request type 160, OID .1.3.6.1.2.1.1.1.0, ASN type 0 and value 0.
...

When I have time I will have look what the differences are between my PR and the V5-9-patches branch.

@bvanassche @rhermsen yes Win10 major version can be 6, it also gave me some trouble 😒

@rhermsen
Copy link
Author

Also confirm that with commit 17759ba I can query the system mib.

C:\WINDOWS\system32>"C:\Program Files (x86)\IP-Tools\Net-SNMP\bin\snmpwalk" -M "C:\Program Files (x86)\IP-Tools\Net-SNMP\share\snmp\mibs" -v2c -c public 192.168.178.94  sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 122 Stepping 8 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 19043 Multiprocessor Free)

I don't see an error, and get more results back.
(did also verify with 5.9.1, but didn't see the earlier mentioned error, so edited my earlier statement from 12-Dec)

C:\WINDOWS\system32>"C:\Program Files (x86)\IP-Tools\Net-SNMP\bin\snmpwalk" -M "C:\Program Files (x86)\IP-Tools\Net-SNMP\share\snmp\mibs" -v2c -c public 192.168.178.94  1 | wc -l
7530

Thanks both @bvanassche and @janclod

@bvanassche
Copy link
Contributor

I can reproduce the sysDescr error on Windows 10:

$ /c/usr/bin/snmpwalk -v2c -cpublic localhost sysDescr.0
Error in packet.
Reason: (genError) A general failure occured
Failed object: SNMPv2-MIB::sysDescr.0

This is what appears in the snmpd log if I run the above command:

extension DLL C:\Windows\System32\inetmib1.dll: SNMP query function returned error code 5 (Windows) / 5 (Net-SNMP) for request type 161, OID .1.3.6.1.2.1.1.1.0, ASN type 0 and value 0.
extension DLL C:\Windows\System32\inetmib1.dll: SNMP query function returned error code 5 (Windows) / 5 (Net-SNMP) for request type 160, OID .1.3.6.1.2.1.1.1.0, ASN type 0 and value 0.

I think the above indicates a bug in the Microsoft DLL inetmib1.

@janclod
Copy link

janclod commented Dec 21, 2021

Glad to see that the issue is resolved :)

@bvanassche I got the same error on Win 10

extension DLL C:\Windows\System32\inetmib1.dll: SNMP query function returned error code 5 (Windows) / 5 (Net-SNMP) for request type 160, OID .1.3.6.1.2.1.1.1.0, ASN type 0 and value 0.

This error disappeared when I tested a second time, is it possible that the error is not always happening? Would it be possible to isolate the instances when the error occurs?

@bvanassche bvanassche reopened this Dec 23, 2021
@bvanassche
Copy link
Contributor

Hmm ... on my setup the error does not disappear if I repeatedly access sysDescr.0 (using a MinGW shell):

$ /c/usr/bin/snmpget -v2c -cpublic localhost sysDescr.0
Error in packet
Reason: (genError) A general failure occured
Failed object: SNMPv2-MIB::sysDescr.0

$ /c/usr/bin/snmpget -v2c -cpublic localhost sysDescr.0
Error in packet
Reason: (genError) A general failure occured
Failed object: SNMPv2-MIB::sysDescr.0

$ /c/usr/bin/snmpget -v2c -cpublic localhost sysDescr.0
Error in packet
Reason: (genError) A general failure occured
Failed object: SNMPv2-MIB::sysDescr.0

@rhermsen
Copy link
Author

rhermsen commented Dec 24, 2021

If I run snmpd from cmd prompt a query of the system description works for me:

Server:

C:\WINDOWS\system32>c:\usr\bin\snmpd -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,system_mib,sysORTable
duplicate registration: MIB modules mibII/snmp and C:\WINDOWS\System32\snmpmib.dll (oid .1.3.6.1.2.1.11).
winExtDLL: handler registration failed for C:\WINDOWS\System32\snmpmib.dll.
c:/usr/snmp/persist/snmpd.conf: line 46: Warning: Unknown token: ifXTable.
<snip>
c:/usr/snmp/persist/snmpd.conf: line 76: Warning: Unknown token: ifXTable.
c:/usr/snmp/persist/snmpd.conf: line 77: Warning: Unknown token: ifXTable.
NET-SNMP version 5.10

Client:

 MINGW64 ~
$ /c/usr/bin/snmpget -v2c -cpublic localhost sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 37 Stepping 5 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 18363 Multiprocessor Free)

But indeed if I run snmpd from within a msys shell it also gives this error.

 MINGW64 ~
$ /c/usr/bin/snmpd -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,system_mib,sysORTable
duplicate registration: MIB modules mibII/snmp and C:\WINDOWS\System32\snmpmib.dll (oid .1.3.6.1.2.1.11).
winExtDLL: handler registration failed for C:\WINDOWS\System32\snmpmib.dll.
c:/usr/snmp/persist/snmpd.conf: line 46: Warning: Unknown token: ifXTable.
c:/usr/snmp/persist/snmpd.conf: line 47: Warning: Unknown token: ifXTable.
<snip>
c:/usr/snmp/persist/snmpd.conf: line 76: Warning: Unknown token: ifXTable.
c:/usr/snmp/persist/snmpd.conf: line 77: Warning: Unknown token: ifXTable.
NET-SNMP version 5.10

client:

 MINGW64 ~
$ /c/usr/bin/snmpget -v2c -cpublic localhost sysDescr.0
Error in packet
Reason: (genError) A general failure occured
Failed object: SNMPv2-MIB::sysDescr.0

This is on the Win10 PC where I compiled this on. (Last compile step was dynamic):
C:\msys64\home\rhermsen\workdir\net-snmp\net-snmp-17759ba\win32>perl Configure --with-sdk --with-winextdll --with-ssl --with-ipv6 --config=release --linktype=dynamic --prefix="c:/usr"

@janclod
Copy link

janclod commented Dec 27, 2021

Just to be extra sure I did also re-test on Win 10 and it works fine on my machine.

NetSNMP build using commit bd7394d (V5-9-patches branch) with the following options

  1. OpenSSL support: enabled
  2. OpenSSL include directory: C:\OpenSSL-Win64\include
  3. OpenSSL library director: C:\OpenSSL-Win64\lib\VC
  4. Install path: c:/net-snmp
  5. Install after build: enabled
  6. Perl modules: disabled
  7. Install perl modules: disabled
  8. Quiet build (logged): enabled
  9. Debug mode: disabled
  10. IPv6 transports: disabled
  11. winExtDLL agent: enabled
  12. Link type: static
  13. Install development files disabled

Testing from the prompt command

snmpd output

snmpd.exe -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,system_mib,sysORTable -DwinExtDLL
...
registering handler for DLL C:\Windows\System32\inetmib1.dll and OID prefix iso.3.6.1.2.1.1 (.1.3.6.1.2.1.1).

snmpget output

snmpget.exe -v 2c -c public localhost sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: Hardware: Intel64 Family 6 Model 63 Stepping 2 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 19041 Multiprocessor Free)

@bvanassche let us know if any info from out side can help you troubleshoot :)

@mj84
Copy link

mj84 commented Oct 19, 2022

Hi there,

is this issue still unresolved?
I believe I'm experiencing the same issue while using SNMPv3 on net-snmp 5.10 and Windows Server 2016.

I start SNMPd using this commandline:
snmpd.exe -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,system_mib,sysORTable,snmp_mib -DwinExtDLL

And then I try to snmpget sysDescr.0:

C:\usr\bin>snmpget -v 3 -a SHA -A authpass -x AES -X privpass -u username -l authPriv 127.0.0.1 sysDescr.0
Error in packet
Reason: (genError) A general failure occured
Failed object: SNMPv2-MIB::sysDescr.0

SNMPd then writes the following to the log:

extension DLL C:\Windows\System32\inetmib1.dll: SNMP query function returned error code 5 (Windows) / 5 (Net-SNMP) for request type 160, OID .1.3.6.1.2.1.1.1.0, ASN type 0 and value 0.

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

No branches or pull requests

4 participants