You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.7 KiB

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