31 Commits

Author SHA1 Message Date
Eric McDonald
93983e5b2a net-snmp: fix literal string test in snmpd_sink_add
The function snmpd_sink_add() has a guard clause that tests the literal
string "section", not the variable value "$section".

The test `[ -n "section" ]` always evaluates to true because the string
literal "section" is non-empty, making the check useless.

This function is only called internally with hardcoded arguments, so the
bug has no actual impact currently. For the same reason, this change
should not break existing configurations. However, I think it should be
fixed so future callers do not have a false sense of security.

Signed-off-by: Eric McDonald <librick-openwrt@proton.me>
2025-12-14 23:52:39 +02:00
Christian Korber
035c279d56 net-snmp: save pid to file
This commit saves the pid to a file in '/var/run'.

Signed-off-by: Christian Korber <ck@dev.tdt.de>
2025-08-11 08:13:44 +02:00
Christian Korber
7b616873d6 net-snmp: add logging to init script
To support logging in net-snmp this commit introduces this feature. There is
a new uci config section 'logging'.

The following new parameters are used:

config logging
	option log_file '/var/log/snmpd.log'
	option log_file_priority 'i'
	option log_syslog '0'
	option log_syslog_facility 'd'

Signed-off-by: Christian Korber <ck@dev.tdt.de>
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-08-11 08:13:44 +02:00
Christian Korber
2fc221699d net-snmp: modify init script for SNMPv3
This commit adds function 'snmpd_snmpv3_add' to the init script
to support SNMPv3 config parsing.

The new uci config section has the following configuration parameters:

config v3
	option username 'John'
	option allow_write '0'
	option auth_type 'SHA|MD5'
	option auth_pass 'passphrase'
	option privacy_type 'AES|DES'
	option privacy_pass 'passphrase'
	option RestrictOID 'yes|no'
	option RestrictedOID '1.3.6.1.2.1.1.1'

This new section is only relevant if the snmp_version 'v1/v2c/v3' or 'v3'
is set in the uci section 'general'.

Signed-off-by: Christian Korber <ck@dev.tdt.de>
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-08-11 08:13:44 +02:00
Christian Korber
dcad31d88c net-snmp: add system to trigger
In a previous commit (0b12bee) hostname was added to
snmpd.init. To track changes in system, the init file
needs to add 'system' to the trigger.
Therefore it is added in this commit.

Fixes: 0b12bee66a ("net-snmp: set hostname as sysname")

Signed-off-by: Christian Korber <ck@dev.tdt.de>
2025-04-30 13:20:23 +03:00
Christian Korber
0b12bee66a net-snmp: set hostname as sysname
This commit writes the option hostname obtained via uci_get
system.@system[0].hostname to the snmpd.conf file if sysName
is not defined in /etc/config/snmpd.

Signed-off-by: Christian Korber <ckorber@tdt.de>
2024-07-26 13:07:50 +02:00
Florian Eckert
9b67f7d134 net-snmp: rename stop_service to service_stopped
The commands in the function 'stop_service' do not stop the service.
Rather, they are commands that are to be executed when the service has
already been stopped. By renaming the function, the commands are now
executed after the service has been stopped.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-03-30 10:23:41 +03:00
Florian Eckert
d6edd837f5 net-snmp: fix whitespaces
Replace spaces with tabs

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-03-30 10:16:00 +03:00
Seth Kingry
7b1bfb181a net-snmp: move start order from 50 to 99
Signed-off-by: Seth Kingry <sjkingry@gmail.com>
2022-02-08 00:36:36 -05:00
Stijn Tintel
6df49a634a net-snmp: do not exit if files cannot be opened
If snmpd fails to open files, like /dev/kmem or /dev/mem, it exits.
Avoid this by adding the -r argument.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2019-12-19 20:04:38 +02:00
Alin Nastac
2168930089 net-snmp: reload firewall only when needed
Firewall needs to be reloaded in the following cases:
 - on service start when snmpd.general.enabled=1
 - when snmpd daemon is stopped

Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
2019-08-12 10:27:22 +02:00
Stijn Tintel
1709b83091 Merge pull request #5069 from dedeckeh/pr-netsnmp-fw
net-snmp: fix inbound firewall rule support
2018-08-02 19:41:08 +03:00
Xavier Franquet
a565ef8eaa SNMPD: Add snmp_extend config option
Signed-off-by: Xavier Franquet <xavier@franquet.es>
2018-05-23 16:04:13 +02:00
Hans Dedecker
0bd19db049 net-snmp: fix inbound firewall rule support
Commit ae5ee6ba6c added support for inbound
firewall rule support but some corner cases were not covered.

In case net-snmp is started and the network interface is already up
the procd firewall rule is created but not applied by fw3 as
service_started calling procd_set_config_changed firewall was missing.

When stopping net-snmp clean up the net-snmp inbound firewall rules in
iptables by calling procd_set_config_changed firewall in stop_service
which will trigger fw3 to remove the inbound firewall rules.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-11-11 18:06:03 +01:00
Stijn Tintel
e4165b4452 net-snmp: avoid duplicate section names
It seems that UCI can't handle duplicate section names in a single
config file, even if they use different types. After the previous
commit, running `uci export` results in the following error:

uci: Parse error (section of different type overwrites prior section with same name) at line 17, byte 23

Append a 6 to the com2sec6 section names to solve this.

Fixes: 0e1c8b4ccc ("net-snmp: snmpd: listen on IPv6 by default")
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-09-29 04:36:47 +03:00
Stijn Tintel
0e1c8b4ccc net-snmp: snmpd: listen on IPv6 by default
Closes #4758.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-09-29 02:45:25 +03:00
Stijn Tintel
8079f86caa net-snmp: add snmptrapd packages
Closes #4724.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-09-29 02:40:49 +03:00
Hans Dedecker
5878373882 netsnmp: add global enabled config option
Add enabled config option in the global uci section; it allows to put into
place the snmpd config but not yet start the netsnmp daemon.
If config option is unset; netsnmp daemon will be started as before.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-07-10 21:45:37 +02:00
Hans Dedecker
bb0dfbe6cc net-snmp: add notification config options
Add config support which allow snmpd to take a more active role by sending
traps.

Following config options are supported which map directly on snmpd directives:
-trapcommunity
-trapsink
-trap2sink
-informsink
-authtrapenable
-v1trapaddress
-trapsess

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-06-19 09:00:27 +02:00
Hans Dedecker
ae5ee6ba6c net-snmp: add inbound firewall rule support
Add UCI section general which holds the uci parameter network defining on
which interface(s) the snmp agent is reachable for inbound snmp requests
in case the firewall zone does not allow INPUT traffic by default.

For the different zones to which the different interfaces belong firewall
procd input rules are created making the snmp agent reachable on udp port
161.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-05-24 15:03:23 +02:00
Stijn Tintel
5081551ae8 net-snmp: add engineID config options
According to the snmpd.conf man page, the engineID of an snmp agent
should be consistent through time. However, it seems that the engineID
changes every reboot. Add options to configure how the engineID is
generated. The default setting generates it based on the MAC address of
the eth0 interface.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-02-14 15:17:07 +01:00
Stijn Tintel
0368739eac net-snmp: enable AgentX support
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-01-05 14:44:45 +01:00
Stijn Tintel
5b1e9eefd0 net-snmp: reload snmpd on interface events
When applying wireless configuration changes, the ifindex of the
wireless interface(s) change. While snmpd picks up the new interfaces
with the correct index, it does not remove the old ones:

IF-MIB::ifName.23 = STRING: wlan0
IF-MIB::ifName.24 = STRING: wlan1
IF-MIB::ifName.25 = STRING: wlan0
IF-MIB::ifName.26 = STRING: wlan1

This causes problems for monitoring tools that use ifName (or ifDesc) as
interface reference. Add a trigger that reloads snmpd on interface
up/down events so that it will no longer have the old interfaces.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2016-02-20 16:46:17 +01:00
feckert
0c0722926d net-snmp: add service_triggers callback
Signed-off-by: Florian Eckert <Eckert.Florian@googlemail.com>
Signed-off-by: Helge Mader <hmader@tdt.de>
2015-08-06 12:09:15 +02:00
feckert
8ca22a2a63 net-snmp: add config options
- trap_hostname
- trap_ip
- access_default
- access_HostName
- access_HostIP

Signed-off-by: Florian Eckert <Eckert.Florian@googlemail.com>
Signed-off-by: Helge Mader <hmader@tdt.de>
2015-08-06 12:01:02 +02:00
Stijn Tintel
bee2865492 net-snmp: monitor ifindex changes
When an ifindex for an interface changes, some monitoring tools can no
longer find the interface and send alerts. Monitor all network
interfaces via the procd netdev parameter, so that
/etc/init.d/snmpd reload will restart snmpd if any ifindex changed.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2015-02-18 06:19:59 +01:00
Stijn Tintel
53fc8d3191 net-snmp: cosmetic changes in snmpd init script
- Refactor RUN_C into CONFIGFILE, as used in dnsmasq and igmpproxy init
  scripts.
- Add a newline after each function definition.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2015-02-18 06:01:19 +01:00
Stijn Tintel
8faff3334f net-snmp: convert snmpd to procd
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2015-02-18 05:05:27 +01:00
Stijn Tintel
e2b43afc85 net-snmp: remove /etc/default/snmpd Debianism
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2015-02-18 04:46:05 +01:00
rcmcronny
29ca0b42b2 Update snmpd.init
add support for "disk <partition> <size>" option

example for /etc/config/snmpd
===========
config disk
	option partition	'/'
	option size		'500'
===========
2014-10-13 10:30:43 +02:00
Jo-Philipp Wich
7c00700f58 net-snmp: import from oldpackages, add myself as maintainer, add license information, update to v5.4.4, refresh patches
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-07-02 14:25:45 +02:00