aboutsummaryrefslogtreecommitdiff
path: root/contrib/bsnmp
Commit message (Collapse)AuthorAgeFilesLines
* Merge release 1.14 of bsnmp.Hartmut Brandt2020-04-0115-89/+19719
|\ | | | | | | Notes: svn path=/head/; revision=359512
| * Flatten bsnmp vendor area.Hartmut Brandt2008-12-2085-65540/+0
| | | | | | | | Notes: svn path=/vendor/bsnmp/dist/; revision=186357
* | bsnmpd(1): Replace dubious srandomdev+random(3) with arc4random(3)Conrad Meyer2019-12-131-3/+1
| | | | | | | | Notes: svn path=/head/; revision=355697
* | Fix the byte order of IPv4 address parsed from begemotSnmpdTransInetStatusAndrey V. Elsukov2019-11-191-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | config option. An address is already in network byte order, there is no need to do htonl(). PR: 242056 MFC after: 1 week Notes: svn path=/head/; revision=354858
* | bsnmp: Fix operator precedence in error check in table_check_responseJustin Hibbits2019-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The ?: operator has a lower precedence than == and &&, so the result will always be recorded as true. Found by gcc8. Reviewed by: ngie, ae Differential Revision: https://reviews.freebsd.org/D22427 Notes: svn path=/head/; revision=354834
* | bsnmp: add asn1 message length validationEd Maste2019-08-061-0/+5
| | | | | | | | | | | | | | | | | | | | admbugs: 780 Submitted by: Guido Vranken, bz Reported by: Guido Vranken Security: CVE-2019-5610 Notes: svn path=/head/; revision=350635
* | Follow the declared behaviour that specifies server string format inAndrey V. Elsukov2019-04-031-63/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=345843
* | Create 64bit mibII counters for all interfaces.Andrey V. Elsukov2019-04-021-21/+0
| | | | | | | | | | | | | | | | | | PR: 157015 Obtained from: Yandex LLC MFC after: 1 month Notes: svn path=/head/; revision=345798
* | Add IPv6 transport for bsnmp.Andrey V. Elsukov2019-04-0215-288/+2252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a new table begemotSnmpdTransInetTable that uses the InetAddressType textual convention and can be used to create listening ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports future extension beyond UDP by adding a protocol identifier to the table index. In order to support this gensnmptree had to be modified. Submitted by: harti MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D16654 Notes: svn path=/head/; revision=345797
* | Correct a port number assignment.Andrey V. Elsukov2019-04-011-2/+1
| | | | | | | | | | | | | | | | PR: 236930 MFC after: 1 week Notes: svn path=/head/; revision=345763
* | Timer interval is correctly counted in ticks (1/100 s) inGleb Smirnoff2019-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | mibif_reset_hc_timer(). Multiplication by 10 is erroneous and is probably a blind copy and paste from next function. PR: 132993 Submitted by: Vitezslav Novy <vnovy vnovy.net> Notes: svn path=/head/; revision=342877
* | Make libbsnmp buildable.Jung-uk Kim2018-09-191-48/+81
| | | | | | | | Notes: svn path=/projects/openssl111/; revision=338769
* | bsnmpd(8): fix and optimize interface description processingEugene Grosbein2018-08-184-8/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * correctly prepare a buffer to obtain interface description from a kernel and truncate long description instead of dropping it altogether and spamming logs; * skip calling strlen() for each description and each SNMP request for MIB-II/ifXTable's ifAlias. * teach bsnmpd to allocate memory dynamically for interface descriptions to decrease memory usage for common case and not to break if long description occurs; PR: 217763 Reviewed by: harti and others MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D16459 Notes: svn path=/head/; revision=338013
* | Update bsnmp to version 1.13. This does not bring user-visible changes.Hartmut Brandt2018-07-0318-102/+300
| | | | | | | | | | | | | | | | | | | | For developers gensnmptree can now generate functions for enums to convert between enums and strings and to check the validity of a value. The sources in FreeBSD are now in sync with the upstream which allows to bring in IPv6 modifications. Notes: svn path=/head/; revision=335885
* | Don't put multiple names on a single .Nm line. This fixes apropos(1)Edward Tomasz Napierala2018-04-171-29/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | output, from this: strnlen, strlen, strlen,(3) - find length of string │······· ... to this: strlen, strnlen(3) - find length of string PR: 223525 MFC after: 2 weeks Notes: svn path=/head/; revision=332642
* | Remove support for the Arcnet protocol.Brooks Davis2018-04-131-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While Arcnet has some continued deployment in industrial controls, the lack of drivers for any of the PCI, USB, or PCIe NICs on the market suggests such users aren't running FreeBSD. Evidence in the PR database suggests that the cm(4) driver (our sole Arcnet NIC) was broken in 5.0 and has not worked since. PR: 182297 Reviewed by: jhibbits, vangyzen Relnotes: yes Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D15057 Notes: svn path=/head/; revision=332490
* | Rename "index" variable to "idx" since gcc complains that it shadowsAndrey V. Elsukov2018-01-192-11/+11
| | | | | | | | | | | | | | | | | | | | index(3) function declaration. Reported by: lwhsu MFC after: 2 weeks Notes: svn path=/head/; revision=328171
* | Add to bsnmpd(1) ability to specify multiple community strings withAndrey V. Elsukov2018-01-196-36/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | different access rights. By default there are two community strings with index 1 and 2, one for read-only access and second for read-write access: begemotSnmpdCommunityString.0.1 = $(read) begemotSnmpdCommunityString.0.2 = $(write) Now it is possible to define additional community strings using different indexes: begemotSnmpdCommunityString.0.3 = "SomeString1" begemotSnmpdCommunityPermission.0.3 = 1 begemotSnmpdCommunityString.0.4 = "SomeString2" begemotSnmpdCommunityPermission.0.4 = 2 begemotSnmpdCommunityString.0.5 = "SomeString3" begemotSnmpdCommunityString.0.6 = "SomeString4" New attribute begemotSnmpdCommunityPermission can be used to specify access rights: 1 means "read-only" access, 2 means "read-write" access. If attribute is not specified for some index this means "read-only" rights. Community strings must be unique, i.e. must not be the same for different indexes. Obtained from: Yandex LLC MFC after: 2 weeks Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D13785 Notes: svn path=/head/; revision=328160
* | Fix format string warning with enabled DEBUGGING.Andrey V. Elsukov2017-12-041-1/+1
| | | | | | | | | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=326510
* | Hide struct inpcb, struct tcpcb from the userland.Gleb Smirnoff2017-03-212-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a painful change, but it is needed. On the one hand, we avoid modifying them, and this slows down some ideas, on the other hand we still eventually modify them and tools like netstat(1) never work on next version of FreeBSD. We maintain a ton of spares in them, and we already got some ifdef hell at the end of tcpcb. Details: - Hide struct inpcb, struct tcpcb under _KERNEL || _WANT_FOO. - Make struct xinpcb, struct xtcpcb pure API structures, not including kernel structures inpcb and tcpcb inside. Export into these structures the fields from inpcb and tcpcb that are known to be used, and put there a ton of spare space. - Make kernel and userland utilities compilable after these changes. - Bump __FreeBSD_version. Reviewed by: rrs, gnn Differential Revision: D10018 Notes: svn path=/head/; revision=315662
* | bsnmp: explicitly test the return value for open_client_{local,udp} in ↵Enji Cooper2017-03-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | snmp_open(..) open_client_* returns -1 on failure; 0 on success. Ensure that the return value is 0 -- otherwise exit snmp_open(..). MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315642
* | bsnmp: don't leak snmp_client.fd in open_client_udp(..) on connect(2) failureEnji Cooper2017-03-201-0/+2
| | | | | | | | | | | | | | | | MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315641
* | bsnmpd: fix segfault when trans_insert_port(..) is called with multipleEnji Cooper2017-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | out of order addresses Move `port->transport` initialization before the TAILQ_FOREACH(..) loop to ensure that the value is properly initialized before it's inserted into the TAILQ. MFC after: 1 week PR: 217760 Submitted by: eugen Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315206
* | Fix regression from r310655, which broke operation of bsnmpd if it is boundGleb Smirnoff2017-01-172-55/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to a non-wildcard address. As documented in ip(4), doing sendmsg(2) with IP_SENDSRCADDR on a socket that is bound to non-wildcard address is completely different to using this control message on a wildcard one. A fix is to add a bool to mark whether we did setsockopt(IP_RECVDSTADDR) on the socket, and use IP_SENDSRCADDR control message only if we did. While here, garbage collect absolutely useless udp_recv() function that establishes some structures on stack to never use them later. Notes: svn path=/head/; revision=312331
* | Add a REVISION section to track changes for the BEGEMOT-MIB MIB fileEnji Cooper2017-01-091-0/+3
| | | | | | | | | | | | | | | | | | | | There haven't been any changes to the MIB definition, so the REVISION remains static at the version it was imported at MFC after: 1 week Notes: svn path=/head/; revision=311760
* | Add a REVISION section to track changes for the FOKUS-MIB MIB fileEnji Cooper2017-01-091-0/+3
| | | | | | | | | | | | | | | | | | | | There haven't been any changes to the MIB definition, so the REVISION remains static at the version it was imported at MFC after: 1 week Notes: svn path=/head/; revision=311759
* | Similar to r311750, check for the result from smiGetModule to avoid a segfaultEnji Cooper2017-01-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | when dereferencing a NULL pointer later on. Choose to just check for the NULL pointer in the next for-loop for now to fix the issue with a minimal amount of code churn sys/queue.h use here would make more sense than using a static table MFC after: 5 days Notes: svn path=/head/; revision=311757
* | Use calloc instead of malloc + memset(.., 0, ..)Enji Cooper2017-01-091-2/+1
| | | | | | | | | | | | | | MFC after: 5 days Notes: svn path=/head/; revision=311754
* | Check result from smiGetFirstNode and smiGetNodeByOIDEnji Cooper2017-01-091-1/+5
| | | | | | | | | | | | | | | | | | | | | | This avoids a segfault with malformed or unanticipated files, like IPV6-TC.txt (a file containing just TEXTUAL-CONVENTIONS). MFC after: 5 days Found with: gensnmpdef /usr/local/share/snmp/mibs/IPV6-TC.txt Notes: svn path=/head/; revision=311750
* | Add a REVISION section to track changes for the BEGEMOT-IP-MIB MIB fileEnji Cooper2017-01-091-0/+3
| | | | | | | | | | | | | | | | | | | | There haven't been any changes to the MIB definition, so the REVISION remains static at the version it was imported at MFC after: 1 week Notes: svn path=/head/; revision=311742
* | Use nitems(mib) instead of hardcoding mib's length when calling sysctl(3)Enji Cooper2017-01-091-6/+6
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=311733
* | Remove unnecessary __unused attribute attached to `ctx` in op_begemot_mibII(..)Enji Cooper2017-01-061-1/+1
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=311505
* | op_usm_users: don't deref uusers if it's NULL when SETting the valueEnji Cooper2017-01-051-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Add an XXX comment to note that the conditional seems suspect given how it's handled elsewhere in the SNMP_OP_SET case. MFC after: 2 weeks Reported by: Coverity CID: 1008573 Notes: svn path=/head/; revision=311394
* | snmp_table_fetch_async: don't leak `work` if snmp_pdu_send(..) failsEnji Cooper2017-01-051-1/+4
| | | | | | | | | | | | | | | | | | MFC after: 1 week Reported by: Coverity CID: 1017276 Notes: svn path=/head/; revision=311390
* | op_usm_users: fix indentation in SNMP_OP_SET blockEnji Cooper2017-01-051-1/+1
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=311384
* | Use calloc instead of malloc + memset(.., 0, ..)Enji Cooper2017-01-051-6/+3
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=311382
* | lsock_init_port: address issues with initializing sockaddr_un objectEnji Cooper2017-01-051-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Use strlcpy to ensure p->name doesn't overflow sa.sun_path [*]. - Use SUN_LEN(..) instead of spelling out calculation longhand (inspired by comment by jmallett). Tested with: dgram and stream support with both bsnmpwalk and snmpwalk MFC after: 1 week Reported by: Coverity CID: 1006825 Notes: svn path=/head/; revision=311381
* | lm_load: fix string copying issuesEnji Cooper2017-01-051-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Ensure `section` doesn't overrun section by using strlcpy instead of strcpy [*]. - Use strdup instead of malloc + strcpy (this wasn't flagged by Coverity, but is an opportunistic change). MFC after: 1 week Reported by: Coverity CID: 1006826 [*] Notes: svn path=/head/; revision=311378
* | snmp_mibII(3) requires net/if.h and net/if_mib.hEnji Cooper2017-01-041-1/+3
| | | | | | | | | | | | | | | | | | Document that requirement MFC after: 1 week Notes: svn path=/head/; revision=311282
* | Use calloc instead of malloc with buffers in snmp_{recv,send}_packetEnji Cooper2017-01-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This doesn't fix the issue noted in the PR, but at the very least it cleans up the error so it looks a bit more sane, and in the event that bsnmp did wander off into the weeds, the likelihood of it crashing with more sensible output is greater, in my opinion MFC counter set high so I have enough time to resolve the real underlying bug in bsnmpwalk MFC after: 1 month PR: 215721 Notes: svn path=/head/; revision=311263
* | Initialize msg.msg_flags to 0Enji Cooper2017-01-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This mutes a valid coverity warning about it being uninitialized when passed in to sendmsg(2). MFC after: 2 weeks Reported by: Coverity CID: 1368202 Notes: svn path=/head/; revision=311221
* | Fix spelling errors; bump .Dd for the changeEnji Cooper2017-01-011-3/+3
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=311003
* | Bump .Dd for the spelling and .Nm updatesEnji Cooper2017-01-011-1/+1
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=311001
* | Fix spelling errorsEnji Cooper2017-01-011-6/+6
| | | | | | | | | | | | | | | | MFC after: 3 days Reported by: igor Notes: svn path=/head/; revision=311000
* | bsnmpclient(3) also documents snmp_client_init, snmp_client_set_host,Enji Cooper2017-01-011-0/+3
| | | | | | | | | | | | | | | | | | and snmp_client_set_port. Add them to the NAME section MFC after: 3 days Notes: svn path=/head/; revision=310999
* | snmp_discover_engine: fix up req/resp (PDU object) handling a bitEnji Cooper2016-12-311-1/+6
| | | | | | | | | | | | | | | | | | | | | | - Call snmp_pdu_free on req and resp when done with the objects - Call snmp_pdu_free on req before calling snmp_pdu_create on it again MFC after: 1 week Notes: svn path=/head/; revision=310988
* | Similar to r310954, set .len to 0 on malloc failure and to `len` onlyEnji Cooper2016-12-311-4/+8
| | | | | | | | | | | | | | | | | | on success MFC after: 1 week Notes: svn path=/head/; revision=310960
* | Initialize ret to SNMPD_INPUT_OK at the top of snmp_input_start(..) toEnji Cooper2016-12-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | avoid returning an uninitialized value There are some really complicated, snakey if-statements combined with switch statements that could result in an invalid value being returned as `ret` MFC after: 1 week Reported by: Coverity CID: 1006551 Notes: svn path=/head/; revision=310958
* | Use strlcpy when copying `com` to pdu->community to avoid potentialEnji Cooper2016-12-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | buffer overruns MFC after: 1 week Reported by: Coverity CID: 1006823, 1006824 Notes: svn path=/head/; revision=310957
* | MIB-II: use strlcpy instead of strcpy when copying {descr,name}Enji Cooper2016-12-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is of course to avoid buffer overruns The remaining strcpy instance in the module needs to be audited for correctness MFC after: 1 week Reported by: Coverity CID: 1006827, 1006828 Notes: svn path=/head/; revision=310952