ConfD User Community

Not able to send IPv6 SNMP trap

Hi,
On my device, I have configured the SNMP trap receiving host as IPv6. But not able to receive any traps on the IPv6 host. IPv4 works fine.

developer logs shows the following error
28-Jun-2021::22:20:32.038 confd[549]: devel-snmpa cannot send message to FD49:B785:906:FAB0:9999::9A5:162: address family not supported by protocol family

Our OS supports ipv6 no issue with that. strace shows entries for IPv4 but not for IPv6.

snmp.log, has an entry for IPv6
29-Jun-2021::23:24:37.939confd[392]: snmp snmpv2-trap reqid=2021799458 FD49:B785:906:FAB0:9999::9A4:162 (TimeTicks sysUpTime=1842217)(OBJECT IDENTIFIER s…

Please let me know what is the reason for confd not able to send IPv6 traps.

Thanks,
Padma

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.

Thanks for your reply.

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.

confd_register_snmp_notification(dctx, workersock,
notify_name, “nctx_ipv4”, &nctx);
confd_register_snmp_notification(dctx, workersock,
notify_name, “nctx_ipv6”, &nctx)

confd_notification_send_snmp(nctx, “linkDown”, &vb[0], 3);

Right.

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.

Regarding having 2 context, would the following code work?

if (confd_register_snmp_notification(dctx, workersock,
notify_name, “nctx_ipv4”, &nctx) == CONFD_ERR)
confd_fatal(“Failed to register snmp notification \n”);
if (confd_register_snmp_notification(dctx, workersock,
notify_name, “nctx_ipv6”, &nctx) == CONFD_ERR)
confd_fatal(“Failed to register snmp notification \n”);

for IPv4 address
confd_notification_set_snmp_src_addr(nctx, &src);
for IPv6 address
confd_notification_set_snmp_src_addr(nctx, &src);

confd_notification_send_snmp(nctx, “linkUp”, &vb[0], 3);