summaryrefslogtreecommitdiffstats
-rw-r--r--keepalived/core/snmp.c20
-rw-r--r--keepalived/include/snmp.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/keepalived/core/snmp.c b/keepalived/core/snmp.c
index 5c83007..d9122bb 100644
--- a/keepalived/core/snmp.c
+++ b/keepalived/core/snmp.c
@@ -176,6 +176,21 @@ static struct variable8 global_vars[] = {
{SNMP_LINKBEAT, ASN_INTEGER, RONLY, snmp_scalar, 1, {5}},
};
+static int
+snmp_setup_session_cb(int majorID, int minorID,
+ void *serverarg, void *clientarg)
+{
+ netsnmp_session *sess = serverarg;
+ if (serverarg == NULL)
+ return;
+ /* Because ping are done synchronously, we do everything to
+ avoid to block too long. Better disconnect from the master
+ agent than waiting for him... */
+ sess->timeout = ONE_SEC / 5;
+ sess->retries = 0;
+ return 0;
+}
+
void
snmp_agent_init(oid *myoid, int len, char *name, struct variable *variables,
int varsize, int varlen)
@@ -198,6 +213,11 @@ snmp_agent_init(oid *myoid, int len, char *name, struct variable *variables,
block keepalived. We check every 2 minutes. */
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_AGENTX_PING_INTERVAL, 120);
+ /* We also register a callback to modify default timeout and
+ retries value. */
+ snmp_register_callback(SNMP_CALLBACK_LIBRARY,
+ SNMP_CALLBACK_SESSION_INIT,
+ snmp_setup_session_cb, NULL);
init_agent(name);
if (register_mib(name, (struct variable *) variables, varsize,
diff --git a/keepalived/include/snmp.h b/keepalived/include/snmp.h
index 18313c7..0da8e40 100644
--- a/keepalived/include/snmp.h
+++ b/keepalived/include/snmp.h
@@ -32,6 +32,7 @@
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/agent/snmp_vars.h>
#include <net-snmp/agent/util_funcs.h>
+#include <net-snmp/agent/agent_callbacks.h>
#undef FREE
#include "list.h"