2012-05-24 09:44:43 +02:00
|
|
|
/* SNMP support
|
|
|
|
* Copyright (C) 2012 Vincent Bernat <bernat@luffy.cx>
|
|
|
|
*
|
|
|
|
* This file is part of GNU Zebra.
|
|
|
|
*
|
|
|
|
* GNU Zebra is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
2017-05-13 10:25:29 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2012-05-24 09:44:43 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
2016-06-12 17:52:50 +02:00
|
|
|
#ifdef SNMP_AGENTX
|
2012-05-24 09:44:43 +02:00
|
|
|
#include <net-snmp/net-snmp-config.h>
|
|
|
|
#include <net-snmp/net-snmp-includes.h>
|
2016-07-28 17:23:43 +02:00
|
|
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
|
|
#include <net-snmp/agent/snmp_vars.h>
|
2012-05-24 09:44:43 +02:00
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
#include "smux.h"
|
2016-07-27 19:39:44 +02:00
|
|
|
#include "memory.h"
|
2016-07-28 17:23:43 +02:00
|
|
|
#include "linklist.h"
|
2021-04-21 11:19:39 +02:00
|
|
|
#include "lib/version.h"
|
2018-06-14 15:35:09 +02:00
|
|
|
#include "lib_errors.h"
|
2020-04-30 21:33:11 +02:00
|
|
|
#include "xref.h"
|
|
|
|
|
|
|
|
XREF_SETUP();
|
2012-05-24 09:44:43 +02:00
|
|
|
|
2021-02-05 22:05:36 +01:00
|
|
|
DEFINE_HOOK(agentx_enabled, (), ());
|
|
|
|
|
2016-07-28 17:23:43 +02:00
|
|
|
static int agentx_enabled = 0;
|
|
|
|
|
|
|
|
static struct thread_master *agentx_tm;
|
|
|
|
static struct thread *timeout_thr = NULL;
|
|
|
|
static struct list *events = NULL;
|
|
|
|
|
|
|
|
static void agentx_events_update(void);
|
|
|
|
|
|
|
|
static int agentx_timeout(struct thread *t)
|
|
|
|
{
|
|
|
|
timeout_thr = NULL;
|
|
|
|
|
|
|
|
snmp_timeout();
|
|
|
|
run_alarms();
|
|
|
|
netsnmp_check_outstanding_agent_requests();
|
|
|
|
agentx_events_update();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int agentx_read(struct thread *t)
|
|
|
|
{
|
|
|
|
fd_set fds;
|
2020-01-31 16:44:23 +01:00
|
|
|
int flags, new_flags = 0;
|
lib: changes for making snmp socket non-blocking
Description: The changes have been done to make the snmp socket
non-blocking before calling snmp_read()
Problem Description/Summary :
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
Expected Behavior :
VTYSH should not hang.
When we debug more into bgpd docker by doing gdb on its threads, we find the below thread of bgpd, which is causing the issue.
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
(gdb) bt
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
0x000056450e1e8c6b in vtysh_client_run_all (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, continue_on_err=0, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:356
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
The fix has been taken from the following link.
https://sourceforge.net/p/net-snmp/patches/1348/
Signed-off-by: Preetham Singh <preetham.singh@broadcom.com>
2019-10-10 08:13:09 +02:00
|
|
|
int nonblock = false;
|
2016-07-28 17:23:43 +02:00
|
|
|
struct listnode *ln = THREAD_ARG(t);
|
2021-10-07 14:53:10 +02:00
|
|
|
struct thread **thr = listgetdata(ln);
|
|
|
|
XFREE(MTYPE_TMP, thr);
|
2016-07-28 17:23:43 +02:00
|
|
|
list_delete_node(events, ln);
|
|
|
|
|
lib: changes for making snmp socket non-blocking
Description: The changes have been done to make the snmp socket
non-blocking before calling snmp_read()
Problem Description/Summary :
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
Expected Behavior :
VTYSH should not hang.
When we debug more into bgpd docker by doing gdb on its threads, we find the below thread of bgpd, which is causing the issue.
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
(gdb) bt
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
0x000056450e1e8c6b in vtysh_client_run_all (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, continue_on_err=0, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:356
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
The fix has been taken from the following link.
https://sourceforge.net/p/net-snmp/patches/1348/
Signed-off-by: Preetham Singh <preetham.singh@broadcom.com>
2019-10-10 08:13:09 +02:00
|
|
|
/* fix for non blocking socket */
|
|
|
|
flags = fcntl(THREAD_FD(t), F_GETFL, 0);
|
2020-01-31 16:44:23 +01:00
|
|
|
if (-1 == flags) {
|
|
|
|
flog_err(EC_LIB_SYSTEM_CALL, "Failed to get FD settings fcntl: %s(%d)",
|
|
|
|
strerror(errno), errno);
|
lib: changes for making snmp socket non-blocking
Description: The changes have been done to make the snmp socket
non-blocking before calling snmp_read()
Problem Description/Summary :
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
Expected Behavior :
VTYSH should not hang.
When we debug more into bgpd docker by doing gdb on its threads, we find the below thread of bgpd, which is causing the issue.
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
(gdb) bt
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
0x000056450e1e8c6b in vtysh_client_run_all (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, continue_on_err=0, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:356
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
The fix has been taken from the following link.
https://sourceforge.net/p/net-snmp/patches/1348/
Signed-off-by: Preetham Singh <preetham.singh@broadcom.com>
2019-10-10 08:13:09 +02:00
|
|
|
return -1;
|
2020-01-31 16:44:23 +01:00
|
|
|
}
|
lib: changes for making snmp socket non-blocking
Description: The changes have been done to make the snmp socket
non-blocking before calling snmp_read()
Problem Description/Summary :
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
Expected Behavior :
VTYSH should not hang.
When we debug more into bgpd docker by doing gdb on its threads, we find the below thread of bgpd, which is causing the issue.
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
(gdb) bt
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
0x000056450e1e8c6b in vtysh_client_run_all (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, continue_on_err=0, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:356
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
The fix has been taken from the following link.
https://sourceforge.net/p/net-snmp/patches/1348/
Signed-off-by: Preetham Singh <preetham.singh@broadcom.com>
2019-10-10 08:13:09 +02:00
|
|
|
|
|
|
|
if (flags & O_NONBLOCK)
|
|
|
|
nonblock = true;
|
|
|
|
else
|
2020-01-31 16:44:23 +01:00
|
|
|
new_flags = fcntl(THREAD_FD(t), F_SETFL, flags | O_NONBLOCK);
|
|
|
|
|
|
|
|
if (new_flags == -1)
|
|
|
|
flog_err(EC_LIB_SYSTEM_CALL, "Failed to set snmp fd non blocking: %s(%d)",
|
|
|
|
strerror(errno), errno);
|
lib: changes for making snmp socket non-blocking
Description: The changes have been done to make the snmp socket
non-blocking before calling snmp_read()
Problem Description/Summary :
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
Expected Behavior :
VTYSH should not hang.
When we debug more into bgpd docker by doing gdb on its threads, we find the below thread of bgpd, which is causing the issue.
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
(gdb) bt
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
0x000056450e1e8c6b in vtysh_client_run_all (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, continue_on_err=0, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:356
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
The fix has been taken from the following link.
https://sourceforge.net/p/net-snmp/patches/1348/
Signed-off-by: Preetham Singh <preetham.singh@broadcom.com>
2019-10-10 08:13:09 +02:00
|
|
|
|
2016-07-28 17:23:43 +02:00
|
|
|
FD_ZERO(&fds);
|
|
|
|
FD_SET(THREAD_FD(t), &fds);
|
|
|
|
snmp_read(&fds);
|
|
|
|
|
lib: changes for making snmp socket non-blocking
Description: The changes have been done to make the snmp socket
non-blocking before calling snmp_read()
Problem Description/Summary :
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
Expected Behavior :
VTYSH should not hang.
When we debug more into bgpd docker by doing gdb on its threads, we find the below thread of bgpd, which is causing the issue.
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
(gdb) bt
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
0x000056450e1e8c6b in vtysh_client_run_all (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, continue_on_err=0, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:356
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
The fix has been taken from the following link.
https://sourceforge.net/p/net-snmp/patches/1348/
Signed-off-by: Preetham Singh <preetham.singh@broadcom.com>
2019-10-10 08:13:09 +02:00
|
|
|
/* Reset the flag */
|
2020-01-31 16:44:23 +01:00
|
|
|
if (!nonblock) {
|
|
|
|
new_flags = fcntl(THREAD_FD(t), F_SETFL, flags);
|
|
|
|
|
|
|
|
if (new_flags == -1)
|
|
|
|
flog_err(
|
|
|
|
EC_LIB_SYSTEM_CALL,
|
|
|
|
"Failed to set snmp fd back to original settings: %s(%d)",
|
|
|
|
strerror(errno), errno);
|
|
|
|
}
|
lib: changes for making snmp socket non-blocking
Description: The changes have been done to make the snmp socket
non-blocking before calling snmp_read()
Problem Description/Summary :
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
Expected Behavior :
VTYSH should not hang.
When we debug more into bgpd docker by doing gdb on its threads, we find the below thread of bgpd, which is causing the issue.
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
(gdb) bt
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
0x000056450e1e8c6b in vtysh_client_run_all (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, continue_on_err=0, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:356
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
The fix has been taken from the following link.
https://sourceforge.net/p/net-snmp/patches/1348/
Signed-off-by: Preetham Singh <preetham.singh@broadcom.com>
2019-10-10 08:13:09 +02:00
|
|
|
|
2016-07-28 17:23:43 +02:00
|
|
|
netsnmp_check_outstanding_agent_requests();
|
|
|
|
agentx_events_update();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void agentx_events_update(void)
|
|
|
|
{
|
|
|
|
int maxfd = 0;
|
|
|
|
int block = 1;
|
|
|
|
struct timeval timeout = {.tv_sec = 0, .tv_usec = 0};
|
|
|
|
fd_set fds;
|
|
|
|
struct listnode *ln;
|
2021-10-07 14:53:10 +02:00
|
|
|
struct thread **thr;
|
2016-07-28 17:23:43 +02:00
|
|
|
int fd, thr_fd;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-07-17 23:09:51 +02:00
|
|
|
thread_cancel(&timeout_thr);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-28 17:23:43 +02:00
|
|
|
FD_ZERO(&fds);
|
|
|
|
snmp_select_info(&maxfd, &fds, &timeout, &block);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-05 23:22:25 +02:00
|
|
|
if (!block) {
|
|
|
|
timeout_thr = NULL;
|
|
|
|
thread_add_timer_tv(agentx_tm, agentx_timeout, NULL, &timeout,
|
|
|
|
&timeout_thr);
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-28 17:23:43 +02:00
|
|
|
ln = listhead(events);
|
|
|
|
thr = ln ? listgetdata(ln) : NULL;
|
2021-10-07 14:53:10 +02:00
|
|
|
thr_fd = thr ? THREAD_FD(*thr) : -1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-28 17:23:43 +02:00
|
|
|
/* "two-pointer" / two-list simultaneous iteration
|
|
|
|
* ln/thr/thr_fd point to the next existing event listener to hit while
|
|
|
|
* fd counts to catch up */
|
|
|
|
for (fd = 0; fd < maxfd; fd++) {
|
|
|
|
/* caught up */
|
|
|
|
if (thr_fd == fd) {
|
|
|
|
struct listnode *nextln = listnextnode(ln);
|
|
|
|
if (!FD_ISSET(fd, &fds)) {
|
2021-10-07 14:53:10 +02:00
|
|
|
thread_cancel(thr);
|
|
|
|
XFREE(MTYPE_TMP, thr);
|
2016-07-28 17:23:43 +02:00
|
|
|
list_delete_node(events, ln);
|
|
|
|
}
|
|
|
|
ln = nextln;
|
|
|
|
thr = ln ? listgetdata(ln) : NULL;
|
2021-10-07 14:53:10 +02:00
|
|
|
thr_fd = thr ? THREAD_FD(*thr) : -1;
|
2016-07-28 17:23:43 +02:00
|
|
|
}
|
|
|
|
/* need listener, but haven't hit one where it would be */
|
|
|
|
else if (FD_ISSET(fd, &fds)) {
|
|
|
|
struct listnode *newln;
|
2021-10-07 14:53:10 +02:00
|
|
|
thr = XCALLOC(MTYPE_TMP, sizeof(struct thread *));
|
|
|
|
thread_add_read(agentx_tm, agentx_read, NULL, fd, thr);
|
2016-07-28 17:23:43 +02:00
|
|
|
newln = listnode_add_before(events, ln, thr);
|
2021-10-07 14:53:10 +02:00
|
|
|
(*thr)->arg = newln;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2016-07-28 17:23:43 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-28 17:23:43 +02:00
|
|
|
/* leftover event listeners at this point have fd > maxfd, delete them
|
|
|
|
*/
|
|
|
|
while (ln) {
|
|
|
|
struct listnode *nextln = listnextnode(ln);
|
2020-07-06 18:55:03 +02:00
|
|
|
thr = listgetdata(ln);
|
2021-10-07 14:53:10 +02:00
|
|
|
thread_cancel(thr);
|
|
|
|
XFREE(MTYPE_TMP, thr);
|
2016-07-28 17:23:43 +02:00
|
|
|
list_delete_node(events, ln);
|
|
|
|
ln = nextln;
|
|
|
|
}
|
|
|
|
}
|
2012-05-24 09:44:43 +02:00
|
|
|
|
|
|
|
/* AgentX node. */
|
2018-09-08 22:31:43 +02:00
|
|
|
static int config_write_agentx(struct vty *vty);
|
2018-09-08 21:46:23 +02:00
|
|
|
static struct cmd_node agentx_node = {
|
2018-09-09 00:15:50 +02:00
|
|
|
.name = "smux",
|
2018-09-08 21:46:23 +02:00
|
|
|
.node = SMUX_NODE,
|
|
|
|
.prompt = "",
|
2018-09-08 22:31:43 +02:00
|
|
|
.config_write = config_write_agentx,
|
2018-09-08 21:46:23 +02:00
|
|
|
};
|
2012-05-24 09:44:43 +02:00
|
|
|
|
|
|
|
/* Logging NetSNMP messages */
|
|
|
|
static int agentx_log_callback(int major, int minor, void *serverarg,
|
|
|
|
void *clientarg)
|
|
|
|
{
|
|
|
|
struct snmp_log_message *slm = (struct snmp_log_message *)serverarg;
|
2015-08-26 16:44:57 +02:00
|
|
|
char *msg = XSTRDUP(MTYPE_TMP, slm->msg);
|
2012-05-24 09:44:43 +02:00
|
|
|
if (msg)
|
|
|
|
msg[strlen(msg) - 1] = '\0';
|
|
|
|
switch (slm->priority) {
|
|
|
|
case LOG_EMERG:
|
2018-09-13 21:38:57 +02:00
|
|
|
flog_err(EC_LIB_SNMP, "snmp[emerg]: %s", msg ? msg : slm->msg);
|
2012-05-24 09:44:43 +02:00
|
|
|
break;
|
|
|
|
case LOG_ALERT:
|
2018-09-13 21:38:57 +02:00
|
|
|
flog_err(EC_LIB_SNMP, "snmp[alert]: %s", msg ? msg : slm->msg);
|
2012-05-24 09:44:43 +02:00
|
|
|
break;
|
|
|
|
case LOG_CRIT:
|
2018-09-13 21:38:57 +02:00
|
|
|
flog_err(EC_LIB_SNMP, "snmp[crit]: %s", msg ? msg : slm->msg);
|
2012-05-24 09:44:43 +02:00
|
|
|
break;
|
|
|
|
case LOG_ERR:
|
2018-09-13 21:38:57 +02:00
|
|
|
flog_err(EC_LIB_SNMP, "snmp[err]: %s", msg ? msg : slm->msg);
|
2012-05-24 09:44:43 +02:00
|
|
|
break;
|
|
|
|
case LOG_WARNING:
|
2018-09-13 21:34:28 +02:00
|
|
|
flog_warn(EC_LIB_SNMP, "snmp[warning]: %s",
|
2018-08-24 18:26:43 +02:00
|
|
|
msg ? msg : slm->msg);
|
2012-05-24 09:44:43 +02:00
|
|
|
break;
|
|
|
|
case LOG_NOTICE:
|
|
|
|
zlog_notice("snmp[notice]: %s", msg ? msg : slm->msg);
|
|
|
|
break;
|
|
|
|
case LOG_INFO:
|
|
|
|
zlog_info("snmp[info]: %s", msg ? msg : slm->msg);
|
|
|
|
break;
|
|
|
|
case LOG_DEBUG:
|
|
|
|
zlog_debug("snmp[debug]: %s", msg ? msg : slm->msg);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
2012-05-24 09:44:43 +02:00
|
|
|
}
|
2015-08-26 16:44:57 +02:00
|
|
|
XFREE(MTYPE_TMP, msg);
|
2012-05-24 09:44:43 +02:00
|
|
|
return SNMP_ERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_write_agentx(struct vty *vty)
|
|
|
|
{
|
|
|
|
if (agentx_enabled)
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "agentx\n");
|
2017-05-05 21:28:38 +02:00
|
|
|
return 1;
|
2012-05-24 09:44:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (agentx_enable,
|
|
|
|
agentx_enable_cmd,
|
|
|
|
"agentx",
|
2017-07-06 22:27:48 +02:00
|
|
|
"SNMP AgentX protocol settings\n")
|
2012-05-24 09:44:43 +02:00
|
|
|
{
|
|
|
|
if (!agentx_enabled) {
|
2016-12-20 18:10:30 +01:00
|
|
|
init_snmp(FRR_SMUX_NAME);
|
2016-07-28 17:23:43 +02:00
|
|
|
events = list_new();
|
|
|
|
agentx_events_update();
|
2012-05-24 09:44:43 +02:00
|
|
|
agentx_enabled = 1;
|
2021-02-05 22:05:36 +01:00
|
|
|
hook_call(agentx_enabled);
|
2012-05-24 09:44:43 +02:00
|
|
|
}
|
2018-10-28 03:50:47 +01:00
|
|
|
|
2017-05-05 21:28:38 +02:00
|
|
|
return CMD_SUCCESS;
|
2012-05-24 09:44:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_agentx,
|
|
|
|
no_agentx_cmd,
|
|
|
|
"no agentx",
|
|
|
|
NO_STR
|
2017-07-06 22:27:48 +02:00
|
|
|
"SNMP AgentX protocol settings\n")
|
2012-05-24 09:44:43 +02:00
|
|
|
{
|
|
|
|
if (!agentx_enabled)
|
|
|
|
return CMD_SUCCESS;
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "SNMP AgentX support cannot be disabled once enabled\n");
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2012-05-24 09:44:43 +02:00
|
|
|
}
|
|
|
|
|
2020-09-15 22:46:15 +02:00
|
|
|
int smux_enabled(void)
|
|
|
|
{
|
|
|
|
return agentx_enabled;
|
|
|
|
}
|
|
|
|
|
2012-05-24 09:44:43 +02:00
|
|
|
void smux_init(struct thread_master *tm)
|
|
|
|
{
|
2016-07-28 17:23:43 +02:00
|
|
|
agentx_tm = tm;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-24 09:44:43 +02:00
|
|
|
netsnmp_enable_subagent();
|
|
|
|
snmp_disable_log();
|
|
|
|
snmp_enable_calllog();
|
|
|
|
snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_LOGGING,
|
|
|
|
agentx_log_callback, NULL);
|
2016-12-20 18:10:30 +01:00
|
|
|
init_agent(FRR_SMUX_NAME);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-09-08 22:31:43 +02:00
|
|
|
install_node(&agentx_node);
|
2012-05-24 09:44:43 +02:00
|
|
|
install_element(CONFIG_NODE, &agentx_enable_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_agentx_cmd);
|
|
|
|
}
|
|
|
|
|
2021-02-05 22:05:36 +01:00
|
|
|
void smux_agentx_enable(void)
|
|
|
|
{
|
|
|
|
if (!agentx_enabled) {
|
|
|
|
init_snmp(FRR_SMUX_NAME);
|
|
|
|
events = list_new();
|
|
|
|
agentx_events_update();
|
|
|
|
agentx_enabled = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-24 09:44:43 +02:00
|
|
|
void smux_register_mib(const char *descr, struct variable *var, size_t width,
|
|
|
|
int num, oid name[], size_t namelen)
|
|
|
|
{
|
|
|
|
register_mib(descr, var, width, num, name, namelen);
|
|
|
|
}
|
|
|
|
|
2021-02-14 22:18:39 +01:00
|
|
|
void smux_trap(struct variable *vp, size_t vp_len, const oid *ename,
|
|
|
|
size_t enamelen, const oid *name, size_t namelen,
|
|
|
|
const oid *iname, size_t inamelen,
|
|
|
|
const struct trap_object *trapobj, size_t trapobjlen,
|
|
|
|
uint8_t sptrap)
|
2020-10-21 19:22:06 +02:00
|
|
|
{
|
|
|
|
struct index_oid trap_index[1];
|
|
|
|
|
|
|
|
/* copy the single index into the multi-index format */
|
|
|
|
oid_copy(trap_index[0].indexname, iname, inamelen);
|
|
|
|
trap_index[0].indexlen = inamelen;
|
|
|
|
|
2021-02-14 22:18:39 +01:00
|
|
|
smux_trap_multi_index(vp, vp_len, ename, enamelen, name, namelen,
|
|
|
|
trap_index, array_size(trap_index), trapobj,
|
|
|
|
trapobjlen, sptrap);
|
2020-10-21 19:22:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int smux_trap_multi_index(struct variable *vp, size_t vp_len, const oid *ename,
|
|
|
|
size_t enamelen, const oid *name, size_t namelen,
|
|
|
|
struct index_oid *iname, size_t index_len,
|
|
|
|
const struct trap_object *trapobj, size_t trapobjlen,
|
|
|
|
uint8_t sptrap)
|
2012-05-24 09:44:43 +02:00
|
|
|
{
|
2012-05-25 11:17:01 +02:00
|
|
|
oid objid_snmptrap[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
|
2020-03-08 20:43:26 +01:00
|
|
|
size_t objid_snmptrap_len = sizeof(objid_snmptrap) / sizeof(oid);
|
2012-05-25 11:17:01 +02:00
|
|
|
oid notification_oid[MAX_OID_LEN];
|
|
|
|
size_t notification_oid_len;
|
|
|
|
unsigned int i;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-25 11:17:01 +02:00
|
|
|
netsnmp_variable_list *notification_vars = NULL;
|
|
|
|
if (!agentx_enabled)
|
|
|
|
return 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-25 11:17:01 +02:00
|
|
|
/* snmpTrapOID */
|
|
|
|
oid_copy(notification_oid, ename, enamelen);
|
|
|
|
notification_oid[enamelen] = sptrap;
|
|
|
|
notification_oid_len = enamelen + 1;
|
|
|
|
snmp_varlist_add_variable(¬ification_vars, objid_snmptrap,
|
|
|
|
objid_snmptrap_len, ASN_OBJECT_ID,
|
2018-03-27 21:13:34 +02:00
|
|
|
(uint8_t *)notification_oid,
|
2012-05-25 11:17:01 +02:00
|
|
|
notification_oid_len * sizeof(oid));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-25 11:17:01 +02:00
|
|
|
/* Provided bindings */
|
|
|
|
for (i = 0; i < trapobjlen; i++) {
|
|
|
|
unsigned int j;
|
|
|
|
oid oid[MAX_OID_LEN];
|
|
|
|
size_t oid_len, onamelen;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t *val;
|
2012-05-25 11:17:01 +02:00
|
|
|
size_t val_len;
|
|
|
|
WriteMethod *wm = NULL;
|
|
|
|
struct variable cvp;
|
2020-10-21 19:22:06 +02:00
|
|
|
unsigned int iindex;
|
|
|
|
/*
|
|
|
|
* this allows the behaviour of smux_trap with a singe index
|
|
|
|
* for all objects to be maintained whilst allowing traps which
|
|
|
|
* have different indices per object to be supported
|
|
|
|
*/
|
|
|
|
iindex = (index_len == 1) ? 0 : i;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-25 11:17:01 +02:00
|
|
|
/* Make OID. */
|
|
|
|
if (trapobj[i].namelen > 0) {
|
|
|
|
/* Columnar object */
|
|
|
|
onamelen = trapobj[i].namelen;
|
|
|
|
oid_copy(oid, name, namelen);
|
|
|
|
oid_copy(oid + namelen, trapobj[i].name, onamelen);
|
2020-10-21 19:22:06 +02:00
|
|
|
oid_copy(oid + namelen + onamelen,
|
|
|
|
iname[iindex].indexname,
|
|
|
|
iname[iindex].indexlen);
|
|
|
|
oid_len = namelen + onamelen + iname[iindex].indexlen;
|
2012-05-25 11:17:01 +02:00
|
|
|
} else {
|
|
|
|
/* Scalar object */
|
|
|
|
onamelen = trapobj[i].namelen * (-1);
|
|
|
|
oid_copy(oid, name, namelen);
|
|
|
|
oid_copy(oid + namelen, trapobj[i].name, onamelen);
|
|
|
|
oid[onamelen + namelen] = 0;
|
|
|
|
oid_len = namelen + onamelen + 1;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-25 11:17:01 +02:00
|
|
|
/* Locate the appropriate function and type in the MIB registry.
|
|
|
|
*/
|
|
|
|
for (j = 0; j < vp_len; j++) {
|
|
|
|
if (oid_compare(trapobj[i].name, onamelen, vp[j].name,
|
|
|
|
vp[j].namelen)
|
|
|
|
!= 0)
|
|
|
|
continue;
|
|
|
|
/* We found the appropriate variable in the MIB
|
|
|
|
* registry. */
|
|
|
|
oid_copy(cvp.name, name, namelen);
|
|
|
|
oid_copy(cvp.name + namelen, vp[j].name, vp[j].namelen);
|
|
|
|
cvp.namelen = namelen + vp[j].namelen;
|
|
|
|
cvp.type = vp[j].type;
|
|
|
|
cvp.magic = vp[j].magic;
|
|
|
|
cvp.acl = vp[j].acl;
|
|
|
|
cvp.findVar = vp[j].findVar;
|
2020-10-21 19:22:06 +02:00
|
|
|
|
2012-05-25 11:17:01 +02:00
|
|
|
/* Grab the result. */
|
|
|
|
val = cvp.findVar(&cvp, oid, &oid_len, 1, &val_len,
|
|
|
|
&wm);
|
|
|
|
if (!val)
|
|
|
|
break;
|
|
|
|
snmp_varlist_add_variable(¬ification_vars, oid,
|
|
|
|
oid_len, vp[j].type, val,
|
|
|
|
val_len);
|
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2012-05-25 11:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
send_v2trap(notification_vars);
|
|
|
|
snmp_free_varbind(notification_vars);
|
2016-07-28 17:23:43 +02:00
|
|
|
agentx_events_update();
|
2012-05-24 09:44:43 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-09-15 22:46:15 +02:00
|
|
|
void smux_events_update(void)
|
|
|
|
{
|
|
|
|
agentx_events_update();
|
|
|
|
}
|
|
|
|
|
2016-06-12 17:52:50 +02:00
|
|
|
#endif /* SNMP_AGENTX */
|