Re: snmptrap under IPv6 after setting clientaddr

2014-11-28 Thread Wes Hardaker
Rizwan Ansari rans...@mvista.com writes:

 I looked into IPv4 code and feel like same code is missing under IPv6
 section.

Thanks for the patch!  Can you submit it to our patch database to make
sure it doesn't get lost?

  http://www.net-snmp.org/patches/

-- 
Wes Hardaker
Parsons

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration  more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


snmptrap under IPv6 after setting clientaddr

2014-11-20 Thread Rizwan Ansari
Hi all,

Under IPv6 environment, sent snmptrap after setting clientaddr in
snmp.conf, It is sent from another interface.

Test Details..

[root@cghvhp1 ~]# cat /etc/snmp/snmp.conf
clientaddr 2001:ccc1::2
[root@cghvhp1 ~]#

[root@cghvhp1 snmp]# ifconfig eth3
eth3  Link encap:Ethernet  HWaddr 2C:44:FD:7D:D8:F1
  inet addr:192.168.110.1  Bcast:192.168.255.255  Mask:255.255.0.0
  inet6 addr: 2001:ccc1::1/0 Scope:Global
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  RX packets:5342 errors:0 dropped:13 overruns:0 frame:0
  TX packets:130 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:693454 (677.2 KiB)  TX bytes:15878 (15.5 KiB)
  Interrupt:36

[root@cghvhp1 snmp]# ifconfig eth4
eth4  Link encap:Ethernet  HWaddr 2C:44:FD:7D:D8:F2
  inet addr:192.168.110.2  Bcast:192.168.255.255  Mask:255.255.0.0
  inet6 addr: 2001:ccc1::2/0 Scope:Global
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  RX packets:21 errors:0 dropped:0 overruns:0 frame:0
  TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:2874 (2.8 KiB)  TX bytes:5946 (5.8 KiB)
  Interrupt:32

[root@cghvhp1 snmp]#


snmptrap is sent from eth3 while clientaddr is set to eth4.


I looked into IPv4 code and feel like same code is missing under IPv6
section.

Sending missing code section from IPv6 in
*snmplib/transports/snmpUDPIPv6Domain.c*

diff --git a/snmplib/transports/snmpUDPIPv6Domain.c
b/snmplib/transports/snmpUDPIPv6Domain.c
index b3eaae4..85a2f7a 100644
--- a/snmplib/transports/snmpUDPIPv6Domain.c
+++ b/snmplib/transports/snmpUDPIPv6Domain.c
@@ -190,6 +190,7 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int
local)
 {
 netsnmp_transport *t = NULL;
 int rc = 0;
+char   *client_socket = NULL;

 #ifdef NETSNMP_NO_LISTEN_SUPPORT
 if (local)
@@ -267,10 +268,29 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int
local)
 #endif /* NETSNMP_NO_LISTEN_SUPPORT */
 } else {
 /*
+ * This is a client session.  If we've been given a
+ * client address to send from, then bind to that.
+ * Otherwise the send will use something sensible.
+ */
+client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
+  NETSNMP_DS_LIB_CLIENT_ADDR);
+if (client_socket) {
+struct sockaddr_in6 client_addr;
+netsnmp_sockaddr_in6_2(client_addr, client_socket, NULL);
+rc = bind(t-sock, (struct sockaddr *)client_addr,
+  sizeof(struct sockaddr_in6));
+if ( rc != 0 ) {
+DEBUGMSGTL((netsnmp_udp6, failed to bind for
clientaddr: %d %s\n,
+errno, strerror(errno)));
+netsnmp_socketbase_close(t);
+netsnmp_transport_free(t);
+}
+}
+/*
  * This is a client session.  Save the address in the
  * transport-specific data pointer for later use by
netsnmp_udp6_send.
  */
-
 t-data = malloc(sizeof(netsnmp_indexed_addr_pair));
 if (t-data == NULL) {
 netsnmp_socketbase_close(t);



I need to confirm the changes, This is required to send snmptrap after
setting clientaddr in snmp.conf.

Please provide your  feedback regarding this change.


Thanks,
Rizwan
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration  more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users