Skip to content

Commit 48e4cf6

Browse files
sudhanshukumar22pavel-shirshov
authored andcommitted
commit 4ea6cafbcad4c72186587b45fa5e2f6c6dbec893 (HEAD -> bgp-snmp-socket-issue, origin/bgp-snmp-socket-issue) (#3604)
Author: sudhanshukumar22 <[email protected]> Date: Tue Oct 15 02:31:20 2019 -0700 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() FRR Pull request: FRRouting/frr#5134 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/
1 parent 249e858 commit 48e4cf6

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
From 6d43b90540c6aeda0fff001de93c88e01aacadab Mon Sep 17 00:00:00 2001
2+
From: sudhanshukumar22 <[email protected]>
3+
Date: Tue, 15 Oct 2019 02:11:01 -0700
4+
Subject: [PATCH] lib: changes for making snmp socket non-blocking
5+
6+
Description: The changes have been done to make the snmp socket
7+
non-blocking before calling snmp_read()
8+
FRR Pull request: https://github.com/FRRouting/frr/pull/5134
9+
10+
Problem Description/Summary :
11+
vtysh hangs on first try to enter after a reboot with BGP dynamic peers
12+
13+
Expected Behavior :
14+
VTYSH should not hang.
15+
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.
16+
Thread 1 (Thread 0x7f1e1ec46d40 (LWP 47)):
17+
18+
0x00007f1e1d762593 in recvfrom () from /lib/x86_64-linux-gnu/libpthread.so.0
19+
0x00007f1e1aadd09b in netsnmp_tcpbase_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
20+
0x00007f1e1aad9617 in netsnmp_transport_recv () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
21+
0x00007f1e1aab2c07 in _sess_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
22+
0x00007f1e1aab3a29 in snmp_sess_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
23+
0x00007f1e1aab3a7b in snmp_read2 () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
24+
0x00007f1e1aab3acf in snmp_read () from /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30
25+
0x00007f1e1b44d7ec in agentx_read (t=0x7fffa75f0080) at lib/agentx.c:63
26+
0x00007f1e1e7d6451 in thread_call (thread=0x7fffa75f0080) at lib/thread.c:1620
27+
0x00007f1e1e770699 in frr_run (master=0x559396ea60f0) at lib/libfrr.c:1011
28+
0x0000559395b4d953 in main (argc=5, argv=0x7fffa75f02b8) at bgpd/bgp_main.c:492
29+
30+
(gdb) bt
31+
32+
0x00007f830c89d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0
33+
0x000056450e1e8238 in vtysh_client_run (vclient=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable, callback=0x0, cbarg=0x0) at vtysh/vtysh.c:216
34+
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
35+
0x000056450e1e8ddb in vtysh_client_execute (head_client=0x56450e4a8b40 <vtysh_client+24768>, line=0x56450e21add0 enable) at vtysh/vtysh.c:393
36+
0x000056450e1e9c82 in vtysh_execute_func (line=0x56450e21add0 enable, pager=0) at vtysh/vtysh.c:598
37+
0x000056450e1e9dee in vtysh_execute_no_pager (line=0x56450e21add0 enable) at vtysh/vtysh.c:619
38+
0x000056450e1f7d48 in vtysh_read_file (confp=0x56451000a9d0, top_cfg=1) at vtysh/vtysh_config.c:494
39+
0x000056450e1f7ef2 in vtysh_read_config (config_default_dir=0x56450e4edc20 <frr_config> /etc/frr/frr.conf, top_cfg=1) at vtysh/vtysh_config.c:522
40+
0x000056450e1e5de4 in vtysh_apply_top_level_config () at vtysh/vtysh_main.c:301
41+
0x000056450e1e7842 in main (argc=2, argv=0x7ffc81e6f598, env=0x7ffc81e6f5b0) at vtysh/vtysh_main.c:692
42+
43+
The fix has been taken from the following link.
44+
https://sourceforge.net/p/net-snmp/patches/1348/
45+
---
46+
lib/agentx.c | 16 ++++++++++++++++
47+
1 file changed, 16 insertions(+)
48+
49+
diff --git a/lib/agentx.c b/lib/agentx.c
50+
index 40cac722a..2c6a43d1a 100644
51+
--- a/lib/agentx.c
52+
+++ b/lib/agentx.c
53+
@@ -55,13 +55,29 @@ static int agentx_timeout(struct thread *t)
54+
static int agentx_read(struct thread *t)
55+
{
56+
fd_set fds;
57+
+ int flags;
58+
+ int nonblock = false;
59+
struct listnode *ln = THREAD_ARG(t);
60+
list_delete_node(events, ln);
61+
62+
+ /* fix for non blocking socket */
63+
+ flags = fcntl(THREAD_FD(t), F_GETFL, 0);
64+
+ if (-1 == flags)
65+
+ return -1;
66+
+
67+
+ if (flags & O_NONBLOCK)
68+
+ nonblock = true;
69+
+ else
70+
+ fcntl(THREAD_FD(t), F_SETFL, flags | O_NONBLOCK);
71+
+
72+
FD_ZERO(&fds);
73+
FD_SET(THREAD_FD(t), &fds);
74+
snmp_read(&fds);
75+
76+
+ /* Reset the flag */
77+
+ if (!nonblock)
78+
+ fcntl(THREAD_FD(t), F_SETFL, flags);
79+
+
80+
netsnmp_check_outstanding_agent_requests();
81+
agentx_events_update();
82+
return 0;
83+
--
84+
2.18.0
85+

src/sonic-frr/patch/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
0002-Reduce-severity-of-Vty-connected-from-message.patch
33
0004-Allow-BGP-attr-NEXT_HOP-to-be-0.0.0.0-due-to-allevia.patch
44
0005-Support-VRF.patch
5+
0006-changes-for-making-snmp-socket-non-blocking.patch

0 commit comments

Comments
 (0)