Translated message

A translation of this page exists in English.

ブロードキャストアドレスで要求された場合に snmpd が "Failure in sendto" を表示する理由

Solution In Progress - Updated -

Issue

  • ブロードキャストソース IP アドレス '10.xx255' を使用して SNMP を要求すると、何も返されず、snmpd サーバーの /var/log/messages に次のエラーメッセージが表示されました。
snmpd[xxxx]: send response: Failure in sendto

snmpd サービスの strace では、メッセージが出力される前に sendmsgENETUNREACH を返しました。

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("0.0.0.0")}}], 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>

net-snmp のソースコードによると、ブロードキャストアドレスを使用して要求した場合、sendmsgEINVAL を返すはずです。sendmsgEINVAL ではなく ENETUNREACH を返すため、エラーメッセージが表示されると考えられます。

net-snmp-5.8-14.el8.x86_64/snmplib/transports/snmpUDPBaseDomain.c

         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);

sendmsgEINVAL ではなく ENETUNREACH を返し、エラーメッセージが表示されたのはなぜですか?

Environment

  • Red Hat Enterprise Linux (RHEL) 7、8、9
  • Simple Network Management Protocol (SNMP)
  • IP_PKTINFO 補助データ制御メッセージ (cmsg) を含む sendmsg
  • net-snmp と 影響を受けるバージョン:
    • RHEL9.3GA: net-snmp-5.9.1-11.el9 より前のバージョン
    • RHEL9.2: net-snmp-5.9.1-11.el9_2 より前のバージョン
    • RHEL9.0: net-snmp-5.9.1-7.el9_0.2 より前のバージョン
    • RHEL8.9GA: net-snmp-5.8-28.el8 より前のバージョン
    • RHEL8.8: net-snmp-5.8-27.el8_8.1 より前のバージョン
    • RHEL8.6: net-snmp-5.8-25.el8_6.2 より前のバージョン
    • RHEL8.4: net-snmp-5.8-20.el8_4.2 より前のバージョン
    • RHEL8.2: net-snmp-5.8-14.el8_2.5 より前のバージョン
    • RHEL7.9: kernel-3.10.0-1111.el7 以降を搭載したシステム上の net-snmp-5.7.2-49.el7_9.3 より前のバージョン

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