| author | Vincent Bernat <bernat@luffy.cx> | 2012-01-28 09:17:47 (GMT) |
|---|---|---|
| committer | Vincent Bernat <bernat@luffy.cx> | 2012-01-28 09:19:10 (GMT) |
| commit | a39a7536c41dac7e23c6907706690fb1bc71019f (patch) | |
| tree | 4197636f82bb07c281e3f3d03a45b9c7ad537689 | |
| parent | 03ae184d5591f8f34b7da290421e99a1644cb7a4 (diff) | |
| download | keepalived-snmp.zip keepalived-snmp.tar.gz | |
snmp: workaround for AgentX ping blocking keepalivedsnmp
When establishing AgentX session with the master agent, we setup low
timeout and retries values. If the master agent is blocked, we will
wait for less than 1 second for them and therefore, there will be no
disruption for VRRP.
| -rw-r--r-- | keepalived/core/snmp.c | 20 | ||||
| -rw-r--r-- | keepalived/include/snmp.h | 1 |
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" |
