blob: b14b76128aaf765db5ce30ea59181051c31a39e3 [file] [log] [blame]
Brad Bishop7f28bc52017-12-03 23:42:40 -05001From a92628a163ebf1ea62220684736300461c003875 Mon Sep 17 00:00:00 2001
2From: Niels Baggesen <nba@users.sourceforge.net>
3Date: Mon, 26 Jan 2015 20:26:06 +0100
4Subject: [PATCH] BUG#a2584: Fix snmptrap to use clientaddr from snmp.conf.
5 Thanks to rizwan
6
7Upstream-Status: backport
8
9Signed-off-by: Li Zhou <li.zhou@windriver.com>
10---
11 snmplib/transports/snmpUDPIPv6Domain.c | 21 +++++++++++++++++++++
12 1 file changed, 21 insertions(+)
13
Brad Bishop316dfdd2018-06-25 12:45:53 -040014Index: net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
15===================================================================
16--- net-snmp-5.7.3.orig/snmplib/transports/snmpUDPIPv6Domain.c
17+++ net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
18@@ -286,6 +286,27 @@ netsnmp_udp6_transport(struct sockaddr_i
19 return NULL;
20 #endif /* NETSNMP_NO_LISTEN_SUPPORT */
Brad Bishop7f28bc52017-12-03 23:42:40 -050021 } else {
22+ char *client_socket = NULL;
23+ /*
24+ * This is a client session. If we've been given a
25+ * client address to send from, then bind to that.
26+ * Otherwise the send will use "something sensible".
27+ */
28+
29+ client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
30+ NETSNMP_DS_LIB_CLIENT_ADDR);
31+ if (client_socket) {
32+ struct sockaddr_in6 client_addr;
33+ netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);
34+ rc = bind(t->sock, (struct sockaddr *)&client_addr,
35+ sizeof(struct sockaddr_in6));
36+ if ( rc != 0 ) {
37+ DEBUGMSGTL(("netsnmp_udp6", "failed to bind for clientaddr: %d %s\n",
38+ errno, strerror(errno)));
39+ netsnmp_socketbase_close(t);
40+ netsnmp_transport_free(t);
41+ }
42+ }
43 /*
44 * This is a client session. Save the address in the
45 * transport-specific data pointer for later use by netsnmp_udp6_send.