On a 12-RELEASE (same problem on 12-stable and -head), tc.def is not installed. How to reproduce: Just generate an snmp request (no need to have a server running) dev:~ % uname -a FreeBSD dev.bsdrp.net 12.0-RELEASE-p3 FreeBSD 12.0-RELEASE-p3 GENERIC amd64 dev:~ % bsnmpget -s 127.0.0.1 sysName.0 bsnmpget: cannot open 'tc.def' bsnmpget: Snmp dialog: Operation timed out Quick & Dirty fix: cp /usr/src/contrib/bsnmp/lib/tc.def /usr/share/snmp/defs/ I didn't understand how the Makefile/install file process works to wrote a patch myself.
tc.def arrived in r216594 "Bring in a SNMP module that allows configuration of SNMPv3 Notification targets." which added in lib/libbsnmp/libbsnmp/Makefile: +FILESGROUPS+= DEFS +DEFSDIR?= ${SHAREDIR}/snmp/defs +DEFS= tc.def and reverted in r216605 "Unbreak the build by temprorarily not using include directives" -FILESGROUPS+= DEFS -DEFSDIR?= ${SHAREDIR}/snmp/defs -DEFS= tc.def r335885 "Update bsnmp to version 1.13" restored +include "tc.def" statements without addressing the build infrastructure
It seems I applied the similar patch in r345797.
(In reply to Andrey V. Elsukov from comment #2) I've just tried your commit: Do you know if the new error message ("Bad file descriptor") in place of "operation timed out" is a normal one ? Because the previous message seems more useful. Previous: olivier@srv:~ % uname -a FreeBSD netboot-f.oca.netflix.net 13.0-CURRENT FreeBSD 13.0-CURRENT r345549 GENERIC-NODEBUG amd64 olivier@srv:~ % bsnmpget -s 127.0.0.1 sysName.0 bsnmpget: cannot open 'tc.def' bsnmpget: Snmp dialog: Operation timed out New: olivier@srv:~ % uname -a FreeBSD netboot-f.oca.netflix.net 13.0-CURRENT FreeBSD 13.0-CURRENT r345805 GENERIC-NODEBUG amd64 olivier@srv:~ % bsnmpget -s 127.0.0.1 sysName.0 bsnmpget: Failed to open snmp session: Bad file descriptor
(In reply to Olivier Cochard from comment #3) > New: > olivier@srv:~ % uname -a > FreeBSD netboot-f.oca.netflix.net 13.0-CURRENT FreeBSD 13.0-CURRENT r345805 > GENERIC-NODEBUG amd64 > olivier@srv:~ % bsnmpget -s 127.0.0.1 sysName.0 > bsnmpget: Failed to open snmp session: Bad file descriptor It seems now all parts of server specification string become required. I'll take a look at this.
Created attachment 203341 [details] Proposed patch Hi Olivier, can you try this patch? I modified the parser code to be more smart and be able automatically fill needed fields if they were omitted. Hari, can you take a look at this too?
With this patch you can able do: # make -C lib/libbsnmp/ # make -C lib/libbsnmp/ install # bsnmpget -s 127.1 sysName.0 sysName.0 = test15.yandex.net # bsnmpget -s "udp::127.1" sysName.0 sysName.0 = test15.yandex.net # bsnmpget -s "udp::public@127.1" sysName.0 sysName.0 = test15.yandex.net # bsnmpget -s "udp::public@127.1:161" sysName.0 sysName.0 = test15.yandex.net # bsnmpget -s "udp::[::1]" sysName.0 sysName.0 = test15.yandex.net # bsnmpget -s "udp6::[::1]" sysName.0 sysName.0 = test15.yandex.net # bsnmpget -s "[fe80::1%lo0]" sysName.0 sysName.0 = test15.yandex.net ...
Patch tested and working great!
A commit references this bug: Author: ae Date: Wed Apr 3 12:47:49 UTC 2019 New revision: 345843 URL: https://svnweb.freebsd.org/changeset/base/345843 Log: Follow the declared behaviour that specifies server string format in bsnmpclient(3). snmp_parse_server() function accepts string where some fields can be omitted: [trans::][community@][server][:port] "trans" field can be "udp", "udp6", "dgram" and "stream". "community" can be empty string, if it is omitted, the default value will be used. For read_community it is "public", for write_comminity it is "private". "server" field can be hostname, IPv4 address or IPv6 address. IPv6 address should be specified in brackets "[]". If port is omitted, the default value "snmp" will be used for "udp" and "udp6" transports. So, now for bsnmpget(1) and bsnmwalk(1) it is not required to specify all fields in argument of '-s' option. E.g. # bsnmpget -s 127.1 sysName.0 # bsnmpget -s "udp::127.1" sysName.0 # bsnmpget -s "udp::public@127.1" sysName.0 # bsnmpget -s "udp::public@127.1:161" sysName.0 # bsnmpget -s "udp::[::1]" sysName.0 # bsnmpget -s "udp6::[::1]" sysName.0 # bsnmpget -s "[fe80::1%lo0]" sysName.0 PR: 236664 Reported by: olivier MFC after: 1 month Changes: head/contrib/bsnmp/lib/snmpclient.c
A commit references this bug: Author: ae Date: Wed May 1 09:05:49 UTC 2019 New revision: 346988 URL: https://svnweb.freebsd.org/changeset/base/346988 Log: MFC r345843: Follow the declared behaviour that specifies server string format in bsnmpclient(3). snmp_parse_server() function accepts string where some fields can be omitted: [trans::][community@][server][:port] "trans" field can be "udp", "udp6", "dgram" and "stream". "community" can be empty string, if it is omitted, the default value will be used. For read_community it is "public", for write_comminity it is "private". "server" field can be hostname, IPv4 address or IPv6 address. IPv6 address should be specified in brackets "[]". If port is omitted, the default value "snmp" will be used for "udp" and "udp6" transports. So, now for bsnmpget(1) and bsnmwalk(1) it is not required to specify all fields in argument of '-s' option. E.g. # bsnmpget -s 127.1 sysName.0 # bsnmpget -s "udp::127.1" sysName.0 # bsnmpget -s "udp::public@127.1" sysName.0 # bsnmpget -s "udp::public@127.1:161" sysName.0 # bsnmpget -s "udp::[::1]" sysName.0 # bsnmpget -s "udp6::[::1]" sysName.0 # bsnmpget -s "[fe80::1%lo0]" sysName.0 PR: 236664 Reported by: olivier Changes: _U stable/12/ stable/12/contrib/bsnmp/lib/snmpclient.c
Fixed and merged over a year ago.