Why did snmpd show "Failure in sendto" when requested with a broadcast address?

Solution Verified - Updated -


  • When we requested SNMP with a broadcast source IP address '10.x.x.255', nothing is returned and following error message was shown in /var/log/messages at the snmpd server:
snmpd[xxxx]: send response: Failure in sendto

In the strace of snmpd service, sendmsg returned ENETUNREACH before the message was output.

887241 11:20:29.860297 sendmsg(11, {msg_name={sa_family=AF_INET, sin_port=htons(36750), sin_addr=inet_addr("10.x.x.yyy")}, msg_namelen=16, msg_iov=[{iov_base="...", iov_len=53}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=IP_PKTINFO, cmsg_data={ipi_ifindex=0, ipi_spec_dst=inet_addr("10.x.x.255"), ipi_addr=inet_addr("")}}], msg_controllen=32, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = -1 ENETUNREACH (Network is unreachable) <0.000011>
887241 11:20:29.860389 getpid()         = 887241 <0.000005>
887241 11:20:29.860410 sendto(8, "<27>Mar 15 11:20:29 snmpd[887241]: send response: Failure in sendto\n", 68, MSG_NOSIGNAL, NULL, 0) = 68 <0.002007>
887241 11:20:29.862764 getpid()         = 887241 <0.000006>
887241 11:20:29.862798 sendto(8, "<27>Mar 15 11:20:29 snmpd[887241]:     -- IP-MIB::ipAdEntAddr.10.x.x.yyy\n", 74, MSG_NOSIGNAL, NULL, 0) = 74 <0.001213>

According to the source code of net-snmp, sendmsg is supposed to return EINVAL when it requested with a broadcast address. We think that sendmsg returning ENETUNREACH instead of EINVAL was the reason why the error message was shown.


         rc = sendmsg(fd, &m, MSG_NOSIGNAL|MSG_DONTWAIT);
        if (rc >= 0 || errno != EINVAL)
            return rc;

         * The error might be caused by broadcast srcip (i.e. we're responding
         * to a broadcast request) - sendmsg does not like it. Try to resend it
         * using the interface on which it was received


        rc = sendmsg(fd, &m, MSG_NOSIGNAL|MSG_DONTWAIT);

Could you please tell us why sendmsg returned ENETUNREACH instead of EINVAL and the error message was shown?


  • Red Hat Enterprise Linux (RHEL) 8
  • net-snmp
  • SNMP
  • sendmsg with IP_PKTINFO ancillary data control message (cmsg)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content