Found the issue. The reason is SNMP agent source addres is IPv4 and target address is IPv6. Due to this mismatch, it’s failing to send v6 trap.
But want to know how to solve this issue.
we call confd_notification_set_snmp_src_addr api to bind to either IPv4 or IPv6 address as source address. And this is done only once.
So if multiple snmp target addresses are configured with a mix of IPv4 and IPv6, and since the source address can be either of them, how does the confd snmpagent send traps to all the IPv4 and IPv6 hosts?
You can call confd_notification_set_snmp_src_addr() as many times as you want. So you can change the source address at any time.
Or you can create two notification contexts (e.g. nctx_ipv4 and nctx_ipv6) using the confd_register_snmp_notification() function. One for IPv4 and the other for IPv6. Then call confd_notification_send_snmp() using either of the two notification contexts.
I hope calling confd_notification_set_snmp_src_addr API as many time as we want shouldn’t cause any performance effect. If we want to use this approach, before calling confd_notification_send_snmp API, we need to call confd_notification_set_snmp_src_addr for both IPv4 and IPv6 to change the source address, right?
else we want to follow the 2nd approach
“Or you can create two notification contexts (e.g. nctx_ipv4 and nctx_ipv6) using the confd_register_snmp_notification() function. One for IPv4 and the other for IPv6. Then call confd_notification_send_snmp() using either of the two notification contexts.”
With this we will not be calling “confd_notification_set_snmp_src_addr” API right? If we don’t call this API, then while sending the trap, source port always shows as ‘161’ which is reserved for SNMP requests. While sending traps, we want the source port to be transient port not fixed port.
By defining these 2 contexts nctx_ipv4 and nctx_ipv6, how does confd_notification_send_snmp API would know source address type? Can you provide more info on this.
You will need to call confd_notification_set_snmp_src_addr() to set the IP address for each of the two contexts.
I believe that the benefit of the latter approach is that you only need to set the source address once for the two contexts. With the first approach, I believe you will have to set the source address at least each time you change between sending with an IPv4 and IPv6 source address. Not an issue, so it is up to you.
You cannot configure the source port to something other than the port that the ConfD SNMP agent listens to.
The SNMP agent in ConfD uses the same socket to send traps. This is probably an optimization, to avoid open a new UDP socket each time a trap is sent.