On Thu, Dec 16, 2010 at 4:26 AM, Jan Safranek <[email protected]> wrote:
> On 12/15/2010 05:26 PM, Robert Story wrote:
>>
>> JS> The problem is not to get this information, the real
>> JS> challenge is to do it effectively, i.e. cache them somewhere, refresh
>> JS> the cache sometimes, look up in the cache effectively, ... Or do we
>> want
>> JS> to run netlink query on every outgoing UDP message?
>>
>> The ifTable code is already caching information about interfaces, so
>> that's a
>> good candidate for where to do it. If the 15 second refresh window is too
>> long, then netlink might be an option. hopefully we could register to find
>> out
>> when the interface address details have changed, instead of having to do
>> something for every packet.
>
> ifTable is not always available, e.g. in snmptrapd or tiny (sub)agents.
I have a straightforward suggestion, which involves no decisions about
whether or not an address is broadcast.
There's already a series of two attempts to send a response to a
broadcast request: the first gets EINVAL, and the second sets
ipi_spec_dst to INADDR_ANY. If the ifindex case is actually needed, I
propose setting ipi_ifindex to zero in the general case, and to the
passed if_index in the special broadcast response case:
--- snmpUDPBaseDomain.c (revision 19734)
+++ snmpUDPBaseDomain.c (working copy)
@@ -258,7 +258,7 @@
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,8 @@
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 which 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);
(Although, fundamentally, I don't know why the interface index is
needed at all here: as far as I can tell it will only hurt (e.g., will
cause the same mistreatment of a response to a directed broadcast as I
had for unicasts) and can't help (i.e., the routing table will already
have the right route to the directly-connected destination)).
What is the scenario in which the routing table has the wrong route to
the source of the broadcast?
Thanks,
Bill
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders