Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 20db51d70e6b59a061db97ce9b89c771 > files > 45

net-snmp-5.3.2.2-14.el5.src.rpm

600319 - net-snmp-5.3.2.2-broadcast-response.patch broke answering to non local host on some interfaces

commit 7a3bf006936988553c5a70dba38b38415acde3d2
Author: jsafranek <jsafranek@06827809-a52a-0410-b366-d66718629ded>
Date:   Tue Jan 11 13:34:22 2011 +0000

    CHANGES: snmplib: from Bill Fenner: fix sending of UDP responses from multihomed agents.
    
    Try to send the response as it was before Net-SNMP 5.6 (assuming the appropriate request was unicast) and only if it fails try to set if_index (the request must be broadcast).
    
    git-svn-id: https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk@19846 06827809-a52a-0410-b366-d66718629ded

diff --git a/net-snmp/snmplib/transports/snmpUDPBaseDomain.c b/net-snmp/snmplib/transports/snmpUDPBaseDomain.c
index c53298f..5f1b763 100644
--- a/net-snmp/snmplib/snmpUDPDomain.c
+++ b/net-snmp/snmplib/snmpUDPDomain.c
@@ -258,7 +258,7 @@ int netsnmp_udpbase_sendto(int fd, struct in_addr *srcip, int if_index,
     cmsg.cm.cmsg_len = sizeof(struct cmsghdr) + sizeof(struct in_pktinfo);
     cmsg.cm.cmsg_level = SOL_IP;
     cmsg.cm.cmsg_type = IP_PKTINFO;
-    cmsg.ipi.ipi_ifindex = if_index;
+    cmsg.ipi.ipi_ifindex = 0;
     cmsg.ipi.ipi_spec_dst.s_addr = (srcip ? srcip->s_addr : INADDR_ANY);
 
     m.msg_name		= remote;
@@ -276,7 +276,9 @@ int netsnmp_udpbase_sendto(int fd, struct in_addr *srcip, int if_index,
     if (ret < 0 && errno == EINVAL && srcip) {
         /* The error might be caused by broadcast srcip (i.e. we're responding
          * to broadcast request) - sendmsg does not like it. Try to resend it
-         * with global address. */
+         * with global address and using the interface on whicg it was
+         * received */
+        cmsg.ipi.ipi_ifindex = if_index;
         cmsg.ipi.ipi_spec_dst.s_addr = INADDR_ANY;
         DEBUGMSGTL(("udpbase:sendto", "re-sending the message\n"));
         ret = sendmsg(fd, &m, MSG_NOSIGNAL|MSG_DONTWAIT);