|
|
9a6c41 |
1190679 - In IPv6, snmp packet does not send from specified interface assigned by clientaddr option in snmpd.conf
|
|
|
9a6c41 |
|
|
|
9a6c41 |
commit a92628a163ebf1ea62220684736300461c003875
|
|
|
9a6c41 |
Author: Niels Baggesen <nba@users.sourceforge.net>
|
|
|
9a6c41 |
Date: Mon Jan 26 20:26:06 2015 +0100
|
|
|
9a6c41 |
|
|
|
9a6c41 |
BUG#a2584: Fix snmptrap to use clientaddr from snmp.conf. Thanks to rizwan
|
|
|
9a6c41 |
|
|
|
9a6c41 |
+ restore clientaddrUsesPort functionality for UDPv6
|
|
|
9a6c41 |
|
|
|
9a6c41 |
diff -up net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.udp6-clientaddr net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c
|
|
|
9a6c41 |
--- net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.udp6-clientaddr 2015-06-17 15:00:50.178122151 +0200
|
|
|
9a6c41 |
+++ net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c 2015-06-17 15:01:09.203194870 +0200
|
|
|
9a6c41 |
@@ -284,6 +284,27 @@ netsnmp_udp6_transport(struct sockaddr_i
|
|
|
9a6c41 |
return NULL;
|
|
|
9a6c41 |
#endif /* NETSNMP_NO_LISTEN_SUPPORT */
|
|
|
9a6c41 |
} else {
|
|
|
9a6c41 |
+ char *client_socket = NULL;
|
|
|
9a6c41 |
+ /*
|
|
|
9a6c41 |
+ * This is a client session. If we've been given a
|
|
|
9a6c41 |
+ * client address to send from, then bind to that.
|
|
|
9a6c41 |
+ * Otherwise the send will use "something sensible".
|
|
|
9a6c41 |
+ */
|
|
|
9a6c41 |
+
|
|
|
9a6c41 |
+ client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
|
|
|
9a6c41 |
+ NETSNMP_DS_LIB_CLIENT_ADDR);
|
|
|
9a6c41 |
+ if (client_socket) {
|
|
|
9a6c41 |
+ struct sockaddr_in6 client_addr;
|
|
|
9a6c41 |
+ netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);
|
|
|
9a6c41 |
+ rc = bind(t->sock, (struct sockaddr *)&client_addr,
|
|
|
9a6c41 |
+ sizeof(struct sockaddr_in6));
|
|
|
9a6c41 |
+ if ( rc != 0 ) {
|
|
|
9a6c41 |
+ DEBUGMSGTL(("netsnmp_udp6", "failed to bind for clientaddr: %d %s\n",
|
|
|
9a6c41 |
+ errno, strerror(errno)));
|
|
|
9a6c41 |
+ netsnmp_socketbase_close(t);
|
|
|
9a6c41 |
+ netsnmp_transport_free(t);
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
/*
|
|
|
9a6c41 |
* This is a client session. Save the address in the
|
|
|
9a6c41 |
* transport-specific data pointer for later use by netsnmp_udp6_send.
|
|
|
9a6c41 |
diff -up net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.old net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c
|
|
|
9a6c41 |
--- net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.old 2015-06-17 16:34:09.120181912 +0200
|
|
|
9a6c41 |
+++ net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c 2015-06-17 16:35:29.803192111 +0200
|
|
|
9a6c41 |
@@ -294,8 +294,13 @@ netsnmp_udp6_transport(struct sockaddr_i
|
|
|
9a6c41 |
client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
|
|
|
9a6c41 |
NETSNMP_DS_LIB_CLIENT_ADDR);
|
|
|
9a6c41 |
if (client_socket) {
|
|
|
9a6c41 |
+ int uses_port = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
|
|
|
9a6c41 |
+ NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
|
|
|
9a6c41 |
struct sockaddr_in6 client_addr;
|
|
|
9a6c41 |
netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);
|
|
|
9a6c41 |
+ if (uses_port == 0) {
|
|
|
9a6c41 |
+ client_addr.sin6_port = 0;
|
|
|
9a6c41 |
+ }
|
|
|
9a6c41 |
rc = bind(t->sock, (struct sockaddr *)&client_addr,
|
|
|
9a6c41 |
sizeof(struct sockaddr_in6));
|
|
|
9a6c41 |
if ( rc != 0 ) {
|
|
|
9a6c41 |
commit 1ee72102fbe722d232d74abc4660a8b134cec8d6
|
|
|
9a6c41 |
Author: Bart Van Assche <bvanassche@acm.org>
|
|
|
9a6c41 |
Date: Sat May 23 07:32:53 2015 +0200
|
|
|
9a6c41 |
|
|
|
9a6c41 |
snmplib, UDPIPv6 transport: Add a missing return statement
|
|
|
9a6c41 |
|
|
|
9a6c41 |
Detected by Coverity.
|
|
|
9a6c41 |
|
|
|
9a6c41 |
diff --git a/snmplib/transports/snmpUDPIPv6Domain.c b/snmplib/transports/snmpUDPIPv6Domain.c
|
|
|
9a6c41 |
index 029b164..11c39bb 100644
|
|
|
9a6c41 |
--- a/snmplib/transports/snmpUDPIPv6Domain.c
|
|
|
9a6c41 |
+++ b/snmplib/transports/snmpUDPIPv6Domain.c
|
|
|
9a6c41 |
@@ -285,6 +285,7 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
|
|
|
9a6c41 |
errno, strerror(errno)));
|
|
|
9a6c41 |
netsnmp_socketbase_close(t);
|
|
|
9a6c41 |
netsnmp_transport_free(t);
|
|
|
9a6c41 |
+ return NULL;
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
}
|
|
|
9a6c41 |
/*
|