summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-11-26 23:18:24 +0100
committerChristian Breunig <christian@breunig.cc>2025-11-27 08:12:03 +0100
commitd5f096a578f8146f18a3f718dc0c8a9b40d65400 (patch)
treec74c6539daa1d42dd3ddcc686f31084ad1f7ac0a /data
parentba1b8f6359adfaba3b4289afaffe997c16d6fed6 (diff)
downloadvyos-1x-d5f096a578f8146f18a3f718dc0c8a9b40d65400.tar.gz
vyos-1x-d5f096a578f8146f18a3f718dc0c8a9b40d65400.zip
snmp: T8039: fix v3 trap targets
The generated Net-SNMP configuration for SNMPv3 trap-targets was fundamentally broken. Not only was the auth/priv type not written in uppercase letters, but also the ordering of transport protocol, IP(v6) address and port was wrong. To complete the issues above - IPv6 addresses did not get wrapped into mandatory [] brackets.
Diffstat (limited to 'data')
-rw-r--r--data/templates/snmp/etc.snmpd.conf.j210
1 files changed, 7 insertions, 3 deletions
diff --git a/data/templates/snmp/etc.snmpd.conf.j2 b/data/templates/snmp/etc.snmpd.conf.j2
index 9d91192fc..978ea9b7e 100644
--- a/data/templates/snmp/etc.snmpd.conf.j2
+++ b/data/templates/snmp/etc.snmpd.conf.j2
@@ -164,6 +164,10 @@ access {{ group }} "" usm {{ group_config.seclevel }} exact {{ group_config.view
# trap-target
{% if v3.trap_target is vyos_defined %}
{% for trap, trap_config in v3.trap_target.items() %}
+{% set protocol = trap_config.protocol %}
+{% if trap | is_ipv6 %}
+{% set protocol = protocol ~ '6' %}
+{% endif %}
{% set options = '' %}
{% if trap_config.type == 'inform' %}
{% set options = options ~ ' -Ci' %}
@@ -175,14 +179,14 @@ access {{ group }} "" usm {{ group_config.seclevel }} exact {{ group_config.view
{% set options = options ~ ' -u ' ~ trap_config.user %}
{% endif %}
{% if trap_config.auth.plaintext_password is vyos_defined or trap_config.auth.encrypted_password is vyos_defined %}
-{% set options = options ~ ' -a ' ~ trap_config.auth.type %}
+{% set options = options ~ ' -a ' ~ trap_config.auth.type | upper %}
{% if trap_config.auth.plaintext_password is vyos_defined %}
{% set options = options ~ ' -A ' ~ trap_config.auth.plaintext_password %}
{% elif trap_config.auth.encrypted_password is vyos_defined %}
{% set options = options ~ ' -3m ' ~ trap_config.auth.encrypted_password %}
{% endif %}
{% if trap_config.privacy.plaintext_password is vyos_defined or trap_config.privacy.encrypted_password is vyos_defined %}
-{% set options = options ~ ' -x ' ~ trap_config.privacy.type %}
+{% set options = options ~ ' -x ' ~ trap_config.privacy.type | upper %}
{% if trap_config.privacy.plaintext_password is vyos_defined %}
{% set options = options ~ ' -X ' ~ trap_config.privacy.plaintext_password %}
{% elif trap_config.privacy.encrypted_password is vyos_defined %}
@@ -195,7 +199,7 @@ access {{ group }} "" usm {{ group_config.seclevel }} exact {{ group_config.view
{% else %}
{% set options = options ~ ' -l noAuthNoPriv' %}
{% endif %}
-trapsess -v 3 {{ options }} {{ trap }}:{{ trap_config.protocol }}:{{ trap_config.port }}
+trapsess -v 3 {{ options }} {{ protocol }}:{{ trap | bracketize_ipv6 }}:{{ trap_config.port }}
{% endfor %}
{% endif %}