SNMP Trap send to non existent IP address hangs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SNMP Trap send to non existent IP address hangs

Jump to solution
1,450 Views
sw_bob
Contributor I

Hello all,

 

I have an applicaiton that sends  a few SNMP traps right at power up.

After initializing web server and telnet server, I initialize SNMP by calling this:

 

error = SNMP_init_with_traps("SNMP", 7, 2500, my_trap_list);

 

Then I make a few calls to send some traps out (just like SNMP demo provided with MQX 3.8).

What I found is that if trap destination IP address diesn't exist on the network (or if ethernet cable is unplugged), the trap sending function never returns.  I happens for all generic trap functions: SNMP_trap_coldStart(), SNMP_trap_linkUp(), etc.

I traced it down to this call inside these functions (highlighted in red):

 

   for (i = 0; i < SNMPCFG_MAX_TRAP_RECEIVERS; i++) {      if (snmpcfg->trap_receiver_list[i] != 0) {         ipaddr = snmpcfg->trap_receiver_list[i];         ipsrc=IP_route_find(ipaddr, 0);         htonl(ipsrcp, ipsrc);         addr.sin_addr.s_addr = ipaddr;         sendto(snmpcfg->trapsock, snmp.outbuf, traplen, 0, &addr, sizeof(addr));      } /* Endif */   } /* Endfor */

This function never returns and it looks like it keeps sending ARP queries without ever timing out.

 

Has anyone encountered this issue or maybe even found a solution?

 

Thanks,
Boris 

 

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,147 Views
Mohsin455
Contributor IV

Hi,

 

    Try using the socket option send_nowait on the tx socket.

 

Regards,

Mohsin455

View solution in original post

0 Kudos
Reply
2 Replies
1,148 Views
Mohsin455
Contributor IV

Hi,

 

    Try using the socket option send_nowait on the tx socket.

 

Regards,

Mohsin455

0 Kudos
Reply
1,147 Views
sw_bob
Contributor I

This seems to resolve the problem.

Thank you!

0 Kudos
Reply