aboutsummaryrefslogtreecommitdiff
path: root/contrib/bsnmp/snmpd
Commit message (Collapse)AuthorAgeFilesLines
* bsnmpd: fix unix/stream socket operationGleb Smirnoff2025-07-251-21/+2
| | | | | | | | | | | With new send method, that gives us directly port_input pointer, we know the correct file descriptor right away, no matter are we in SOCK_DGRAM or in SOCK_STREAM mode. Previously, the function tried to search for the socket, and that was totally wrong. With several simultaneous connections this end up with sending a reply to incorrect socket. Reviewed by: harti Differential Revision: https://reviews.freebsd.org/D51361
* bsnmpd: merge send and send2 methods for transportsGleb Smirnoff2025-07-254-26/+19
| | | | | | | | | | | | | | Shall be no functional change for normal SNMP sends, e.g. replies and traps. NB: for the inet_send() called from snmp_send_port() we now actually use supplied address, but we could do a better job at finding matching socket. However, it could be that snmp_send_port() is not used by any external module, and in that case it is easier to just deprecate it as poorly fitting design of the server. This will be checked with exp-run. Reviewed by: harti Differential Revision: https://reviews.freebsd.org/D51360
* bsnmpd: deprecate legacy UDP transport trans_udp.cGleb Smirnoff2025-07-253-450/+0
| | | | | | | | | | | | Since 04d1781439aa we have a more generic trans_inet.c, that supports IPv6 and can be extended further. The default config file we ship was switched to the new transport since 12.1-RELEASE, so for most people deprecation would go unnoticed. Others [who never run etcupdate(8)] would need to merge a couple lines into their snmpd.config. This will be reflected in RELNOTES file. Reviewed by: harti Differential Revision: https://reviews.freebsd.org/D51359
* bsnmpd: use C99 initializers for transport definitionsGleb Smirnoff2025-07-253-27/+24
| | | | | | | No functional change, just makes reading easier. Reviewed by: harti Differential Revision: https://reviews.freebsd.org/D51358
* bsnmpd: in debugging mode (-d) use default library print/error functionsGleb Smirnoff2025-07-171-7/+10
| | | | | | | | We want to see debugging on stderr in non-daemon mode, otherwise this mode has little value. Reviewed by: harti Differential Revision: https://reviews.freebsd.org/D51356
* bsnmpd: use MSG_NOSIGNAL when doing send(2) on a local socketGleb Smirnoff2025-07-171-1/+1
| | | | | | | | Otherwise in unix/stream mode a disconnected client will crash the server. Reviewed by: harti Differential Revision: https://reviews.freebsd.org/D51355
* bsnmp: make single bit bitfields unsigned to avoid clang 16 warningDimitry Andric2023-04-171-3/+3
| | | | | | | | | | | | | | Clang 16 introduced a warning about single bit bitfields in structs, which is triggered by a declaration in bsnmp's snmpd.h: contrib/bsnmp/snmpd/trans_lsock.c:271:21: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] peer->input.stream = 1; ^ ~ Signed one-bit bitfields can only have values -1 and 0, but the intent here is to use the field as a boolean, so make it unsigned. MFC after: 3 days
* SNMP: Update the fokus MIB with a new contact info.Hartmut Brandt2023-04-141-9/+12
| | | | Bring the contact info in sync with the contact info at IANA.
* Follow the standard object definition from RFC2578Shteryana Shopova2022-12-291-1/+1
| | | | | | | | Use mib-2 throughout the files where applicable PR: 254231 Reported by: Michael Proto Reviewed by: bz (at) FreeBSD (dot) org
* Fix bsnmpd(1) crash with ill-formed Discovery messageShteryana Shopova2021-10-011-1/+1
| | | | | | | | | RFC 3414 Section 4. Discovery specifies that a discovery request message has a varBindList left empty. Nonetheless, bsnmpd(1) should not crash when receiving a non-zero var-bindings list in a Discovery Request message. PR: 255214 MFC after: 2 weeks
* snmpmod(3): fix typo under the COMMUNITIES sectionEnji Cooper2020-11-051-1/+1
| | | | | | | | | | | | "recipte" should be spelled like "receipt". .Dd is intentionally not being bumped for the change. MFC after: 1 week Sponsored by: DellEMC Notes: svn path=/head/; revision=367399
* Fix immediate crash when snmpd is bound to a specific IP address.Gleb Smirnoff2020-04-201-14/+17
| | | | | | | | | | The code that sets up msghdr must first fully fill in the msghdr itself, and only then use CMSG_xxx() macros. Silence from: harti, one week Notes: svn path=/head/; revision=360138
* Merge release 1.14 of bsnmp.Hartmut Brandt2020-04-012-27/+97
|\ | | | | | | Notes: svn path=/head/; revision=359512
| * Flatten bsnmp vendor area.Hartmut Brandt2008-12-2021-9748/+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
* | Add IPv6 transport for bsnmp.Andrey V. Elsukov2019-04-0210-29/+1631
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Update bsnmp to version 1.13. This does not bring user-visible changes.Hartmut Brandt2018-07-034-12/+5
| | | | | | | | | | | | | | | | | | | | 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
* | 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
* | 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
* | 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
* | 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
* | 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
* | Use uint32_t instead of u_int32_t for or_last_change and services in "struct ↵Enji Cooper2016-12-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | systemg" This is being done to match "struct systemg" in snmpmod(3) No functional change MFC after: 3 days Notes: svn path=/head/; revision=310763
* | style(9): ip_get(..): clean up whitespaceEnji Cooper2016-12-281-0/+1
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=310663
* | style(9): sort alignment in udp_recv(..)Enji Cooper2016-12-281-1/+1
| | | | | | | | | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=310656
* | Fix bsnmpd sending/receiving with multi-homed configurations or INADDR_ANY usedEnji Cooper2016-12-285-21/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as the listening address in snmpd_input(..) Stash the IPv4 address of the receiver via the recv(..) callback and use it in the send(..) callback for the transport by specifying IP_SENDSRCADDR for the control message type. Add sendmsg logic to the UDP transport's send(..) callback and use the respective send(..) callback for the transport instead of calling sendto in snmpd_input(..). MFC after: 3 weeks Obtained from: Isilon OneFS (^/onefs/branches/BR_8_0_0_DEV@r507595) Submitted by: Thor Steingrimsson <thor.steingrimsson@isilon.com> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310655
* | style(9): clean up trailing whitespaceEnji Cooper2016-12-2718-39/+39
| | | | | | | | | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=310648
* | style(9): fix trailing whitespaceEnji Cooper2016-12-261-2/+2
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=310592
* | Update engine time using update_snmpd_engine_time(..)Enji Cooper2016-12-261-9/+1
| | | | | | | | | | | | | | | | | | MFC after: 6 days X-MFC with: r310498 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310591
* | Fix return type for `ret` (recv callback) and sort variables by alignmentEnji Cooper2016-12-261-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Again, for reasons I don't yet understand, this is not being flagged by the compiler. Unlike the issue addressed in r310587, this problem existed prior to r310586 MFC after: 2 weeks X-MFC with: r310586, r310587 Notes: svn path=/head/; revision=310588
* | Fix definition for recv_dgram(..); it should be "ssize_t", not "int"Enji Cooper2016-12-261-1/+1
| | | | | | | | | | | | | | | | | | | | I'm not sure why this wasn't flagged as an issue by the compiler, yet MFC after: 3 weeks X-MFC with: r310586 Notes: svn path=/head/; revision=310587
* | Refactor transport sources a bit to facilitate changes coming down pipelineEnji Cooper2016-12-264-178/+194
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add recv callback to transport layer to better facilitate code reuse and readability and for symmetry with send callback. Move recv_dgram and recv_stream to udp_recv and lsock_recv, respectively, and make the beforementioned functions recv callbacks for the udp and lsock transports, respectively. Consolidate the check_priv* functions in their relevant trans*.c source to limit scope/use. Note: this code is roughly based content from the submitter, although this was modified to be more of a direct move from snmpd/main.c to the trans_*.c sources, and to reduce unnecessary static function declarations. MFC after: 2 weeks Submitted by: Thor Steingrimsson <thor.steingrimsson@isilon.com> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310586
* | Fix style(9)Enji Cooper2016-12-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | - Sort #includes - Delete trailing whitespace No functional change MFC after: 3 days Notes: svn path=/head/; revision=310574
* | Allow SNMPv3 authNoPriv and noAuthNoPriv protocols to discover snmpEngineTimeEnji Cooper2016-12-243-12/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as discussed in RFC-5343 This fixes interoperability with net-snmp. Tested with the following invocations of snmpwalk (from net-snmp): - noAuthNoPriv: % snmpwalk -v 3 -n '' -u public localhost snmpEngineTime - authNoPriv: % snmpwalk -v 3 -n '' -u bsnmp -A bsnmptest -l authNoPriv -a sha localhost \ localhost snmpEngineTime - authPriv: % snmpwalk -v 3 -n '' -u bsnmp -A bsnmptest -l authPriv -a sha -x des \ -X bsnmptest localhost snmpEngineTime MFC after: 1 week Obtained from: Isilon OneFS (5ec6d772cacbc, with minor tweaks) Submitted by: Austin Voecks <austin.voecks@isilon.com> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310498
* | Sort #includes per style(9)Enji Cooper2016-12-231-3/+3
| | | | | | | | | | | | | | | | | | No functional change MFC after: 3 days Notes: svn path=/head/; revision=310459
* | Clarify failure in snmp_output(..) with call to snmp_pdu_decodeEnji Cooper2016-12-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | - Explicitly test snmp_pdu_encode against SNMP_CODE_OK instead of assuming any non-zero value is bad. - Print out the code before calling abort() to give the end-user something actionable to debug without having to recompile the binary, since the core might not have these details. MFC after: 1 week Notes: svn path=/head/; revision=310455
* | Revert r299830, it has couple of fatal errors.Gleb Smirnoff2016-05-181-5/+5
| | | | | | | | | | | | | | | | | | | | The CMSG_ family of macros take care of alignment, so we don't need r299830 at all, even if it was correct. Put NO_WCAST_ALIGN into Makefile. Together with: peter Notes: svn path=/head/; revision=300167
* | Fix .DdEnji Cooper2016-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | Today is the 14th, not the 10th of May Reported by: igor (derp) Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=299834